diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index c9b8d9af0..c9cccdd5b 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,32 +1,17 @@ name: Build on: push: - branches: [ master ] + branches: [ master_java_2.0 ] pull_request: - branches: [ master ] + branches: [ master_java_2.0 ] jobs: build: - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v2 - - name: JDK - uses: actions/setup-java@v1 - with: - java-version: 1.8 - - name: Maven - run: mvn --batch-mode -Pci clean package - - name: CodeCov - uses: codecov/codecov-action@v1 - integration: - needs: build runs-on: ubuntu-latest env: - IM_REALM: ${{ secrets.IM_REALM }} - IM_BASE_URI: ${{ secrets.IM_BASE_URI }} - IM_APPKEY: ${{ secrets.IM_APPKEY }} - IM_CLIENT_ID: ${{ secrets.IM_CLIENT_ID }} - IM_CLIENT_SECRET: ${{ secrets.IM_CLIENT_SECRET }} + IM_BASE_URI: ${{ env.IM_BASE_URI }} + IM_APPKEY: ${{ env.IM_APPKEY }} + IM_CLIENT_ID: ${{ env.IM_CLIENT_ID }} + IM_CLIENT_SECRET: ${{ env.IM_CLIENT_SECRET }} steps: - name: Checkout uses: actions/checkout@v2 @@ -35,6 +20,7 @@ jobs: with: java-version: 1.8 - name: Maven - run: mvn -pl im-sdk-core --batch-mode -Pci clean test -D test="*IT" -D failIfNoTests=false -# run: mvn --batch-mode -Pci clean verify + run: mvn --batch-mode -Pci clean package + - name: Maven Test + run: mvn test diff --git a/.openapi-generator/FILES b/.openapi-generator/FILES new file mode 100644 index 000000000..704e5d949 --- /dev/null +++ b/.openapi-generator/FILES @@ -0,0 +1,767 @@ +.github/workflows/maven.yml +.gitignore +.openapi-generator-ignore +.travis.yml +README.md +api/openapi.yaml +build.gradle +build.sbt +docs/BlockApi.md +docs/ChatFileApi.md +docs/ContactApi.md +docs/EMAddContactResult.md +docs/EMAddGroupAdmin.md +docs/EMAddGroupAdminResource.md +docs/EMAddGroupAdminResult.md +docs/EMAddMultipleUserToGroup.md +docs/EMAddMultipleUserToGroupBlockList.md +docs/EMAddMultipleUserToGroupBlockListResult.md +docs/EMAddMultipleUserToGroupResource.md +docs/EMAddMultipleUserToGroupResult.md +docs/EMAddMultipleUserToGroupWhiteList.md +docs/EMAddMultipleUserToGroupWhiteListResult.md +docs/EMAddMultipleUserToRoom.md +docs/EMAddMultipleUserToRoomBlockList.md +docs/EMAddMultipleUserToRoomBlockListResult.md +docs/EMAddMultipleUserToRoomWhiteList.md +docs/EMAddMultipleUserToRoomWhiteListResult.md +docs/EMAddMultipleUsersToThread.md +docs/EMAddMultipleUsersToThreadResource.md +docs/EMAddMultipleUsersToThreadResult.md +docs/EMAddRoomAdmin.md +docs/EMAddRoomAdminResource.md +docs/EMAddRoomAdminResult.md +docs/EMAddRoomSuperAdmin.md +docs/EMAddRoomSuperAdminResource.md +docs/EMAddRoomSuperAdminResult.md +docs/EMAddUserToBlockList.md +docs/EMAddUserToBlockListResult.md +docs/EMAddUserToGroupBlockListResource.md +docs/EMAddUserToGroupBlockListResult.md +docs/EMAddUserToGroupResource.md +docs/EMAddUserToGroupResult.md +docs/EMAddUserToGroupWhiteListResource.md +docs/EMAddUserToGroupWhiteListResult.md +docs/EMAddUserToRoomBlockListResource.md +docs/EMAddUserToRoomBlockListResult.md +docs/EMAddUserToRoomResource.md +docs/EMAddUserToRoomResult.md +docs/EMAddUserToRoomWhiteListResource.md +docs/EMAddUserToRoomWhiteListResult.md +docs/EMAllGloballyMutedUsersResource.md +docs/EMCheckUserJoinedGroupResult.md +docs/EMContactRemarkResource.md +docs/EMCreateGroup.md +docs/EMCreateGroupResource.md +docs/EMCreateGroupResult.md +docs/EMCreateMessage.md +docs/EMCreateRoom.md +docs/EMCreateRoomResource.md +docs/EMCreateRoomResult.md +docs/EMCreateThread.md +docs/EMCreateThreadResource.md +docs/EMCreateThreadResult.md +docs/EMCreateToken.md +docs/EMCreateUser.md +docs/EMCreateUserFailResource.md +docs/EMCreateUserResource.md +docs/EMCreateUsersResult.md +docs/EMCustomGroupMemberAttribute.md +docs/EMCustomGroupMemberAttributeResult.md +docs/EMDeleteGroupResource.md +docs/EMDeleteGroupResult.md +docs/EMDeleteGroupShareFileResource.md +docs/EMDeleteGroupShareFileResult.md +docs/EMDeleteRoomCustomAttributes.md +docs/EMDeleteRoomCustomAttributesResource.md +docs/EMDeleteRoomCustomAttributesResult.md +docs/EMDeleteRoomResource.md +docs/EMDeleteRoomResult.md +docs/EMDeleteThreadResource.md +docs/EMDeleteThreadResult.md +docs/EMDeleteUserMetadataResult.md +docs/EMDeleteUserResult.md +docs/EMDeleteUsersResult.md +docs/EMDeviceResource.md +docs/EMDisableGroupResource.md +docs/EMDisableGroupResult.md +docs/EMEnableGroupResource.md +docs/EMEnableGroupResult.md +docs/EMForceDeleteRoomCustomAttributes.md +docs/EMForceDeleteRoomCustomAttributesResource.md +docs/EMForceDeleteRoomCustomAttributesResult.md +docs/EMForceSetRoomCustomAttributes.md +docs/EMForceSetRoomCustomAttributesResource.md +docs/EMForceSetRoomCustomAttributesResult.md +docs/EMForceUserLogoutResource.md +docs/EMForceUserLogoutResult.md +docs/EMGetAllGloballyMutedUsersResult.md +docs/EMGetAppGroupResource.md +docs/EMGetAppGroupsResult.md +docs/EMGetBlockListResult.md +docs/EMGetContactListResource.md +docs/EMGetContactListResult.md +docs/EMGetGroupAdminListResult.md +docs/EMGetGroupAnnouncementResource.md +docs/EMGetGroupAnnouncementResult.md +docs/EMGetGroupBlockListResult.md +docs/EMGetGroupInfoResult.md +docs/EMGetGroupMemberAllCustomAttributeResult.md +docs/EMGetGroupMemberListResult.md +docs/EMGetGroupMuteListResult.md +docs/EMGetGroupShareFileResult.md +docs/EMGetGroupWhiteListResult.md +docs/EMGetHistoryMessageResource.md +docs/EMGetHistoryMessageResult.md +docs/EMGetMultipleGroupMembersAttributes.md +docs/EMGetMultipleGroupMembersAttributesResult.md +docs/EMGetMultipleUserMetadata.md +docs/EMGetMultipleUserMetadataResult.md +docs/EMGetMuteRoomMemberListResult.md +docs/EMGetOfflineMessageStatusResult.md +docs/EMGetRoomAdminListResult.md +docs/EMGetRoomAnnouncementResult.md +docs/EMGetRoomBlockListResult.md +docs/EMGetRoomCustomAttributes.md +docs/EMGetRoomCustomAttributesResult.md +docs/EMGetRoomInfoResource.md +docs/EMGetRoomInfoResult.md +docs/EMGetRoomListResource.md +docs/EMGetRoomListResult.md +docs/EMGetRoomMemberListResult.md +docs/EMGetRoomSuperAdminListResult.md +docs/EMGetRoomWhiteListResult.md +docs/EMGetThreadMemberListResult.md +docs/EMGetThreadMemberListResultData.md +docs/EMGetThreadsUnderAppResource.md +docs/EMGetThreadsUnderAppResult.md +docs/EMGetThreadsUnderAppResultProperties.md +docs/EMGetToken.md +docs/EMGetUserGlobalMuteResult.md +docs/EMGetUserJoinedGroupsResult.md +docs/EMGetUserJoinedRoomListResource.md +docs/EMGetUserJoinedRoomListResult.md +docs/EMGetUserJoinedThreadsResult.md +docs/EMGetUserJoinedThreadsUnderGroupResult.md +docs/EMGetUserMetadataCapacityResult.md +docs/EMGetUserMetadataResult.md +docs/EMGetUserOfflineMessageCountResult.md +docs/EMGetUserOnlineLoginDeviceListResult.md +docs/EMGetUserOnlineStateResult.md +docs/EMGetUserResult.md +docs/EMGetUsersOnlineState.md +docs/EMGetUsersOnlineStateResult.md +docs/EMGetUsersResult.md +docs/EMGroupInfoResource.md +docs/EMGroupMuteResource.md +docs/EMGroupShareFileResource.md +docs/EMImageSize.md +docs/EMImportChatGroupMessage.md +docs/EMImportChatGroupMessageResource.md +docs/EMImportChatGroupMessageResult.md +docs/EMImportChatUserMessage.md +docs/EMImportChatUserMessageResource.md +docs/EMImportChatUserMessageResult.md +docs/EMMessageContent.md +docs/EMModifyGroup.md +docs/EMModifyGroupAnnouncement.md +docs/EMModifyGroupAnnouncementResource.md +docs/EMModifyGroupAnnouncementResult.md +docs/EMModifyGroupResult.md +docs/EMModifyRoom.md +docs/EMModifyRoomAnnouncement.md +docs/EMModifyRoomAnnouncementResource.md +docs/EMModifyRoomAnnouncementResult.md +docs/EMModifyRoomResource.md +docs/EMModifyRoomResult.md +docs/EMModifyThread.md +docs/EMModifyThreadResource.md +docs/EMModifyThreadResult.md +docs/EMModifyUserPassword.md +docs/EMMuteAllGroupMembersResource.md +docs/EMMuteAllGroupMembersResult.md +docs/EMMuteAllRoomMemberResource.md +docs/EMMuteAllRoomMemberResult.md +docs/EMMuteGroupMember.md +docs/EMMuteGroupMemberResource.md +docs/EMMuteGroupMemberResult.md +docs/EMMuteRoomMember.md +docs/EMMuteRoomMemberResource.md +docs/EMMuteRoomMemberResult.md +docs/EMOneWayDeleteConversation.md +docs/EMOneWayDeleteConversationResource.md +docs/EMOneWayDeleteConversationResult.md +docs/EMRecallMessage.md +docs/EMRecallMessageResource.md +docs/EMRecallMessageResult.md +docs/EMRemoveContactResult.md +docs/EMRemoveGroupAdminResource.md +docs/EMRemoveGroupAdminResult.md +docs/EMRemoveMultipleUsersFromThread.md +docs/EMRemoveMultipleUsersFromThreadResult.md +docs/EMRemoveRoomAdminResource.md +docs/EMRemoveRoomAdminResult.md +docs/EMRemoveRoomSuperAdminResource.md +docs/EMRemoveRoomSuperAdminResult.md +docs/EMRemoveThreadUsersResource.md +docs/EMRemoveUserFromBlockListResult.md +docs/EMRemoveUserFromGroupBlockListResource.md +docs/EMRemoveUserFromGroupBlockListResult.md +docs/EMRemoveUserFromGroupWhiteListResult.md +docs/EMRemoveUserFromRoomBlockListResource.md +docs/EMRemoveUserFromRoomBlockListResult.md +docs/EMRemoveUserFromRoomResource.md +docs/EMRemoveUserFromRoomResult.md +docs/EMRemoveUserFromRoomWhiteListResult.md +docs/EMRemoveUserToGroupResource.md +docs/EMRemoveUserToGroupResult.md +docs/EMRoomBlockListResource.md +docs/EMRoomMuteMemberResource.md +docs/EMRoomWhiteListResource.md +docs/EMSendMessageResult.md +docs/EMSetContactNote.md +docs/EMSetContactNoteResult.md +docs/EMSetRoomCustomAttributes.md +docs/EMSetRoomCustomAttributesResource.md +docs/EMSetRoomCustomAttributesResult.md +docs/EMSetUserGlobalMute.md +docs/EMSetUserGlobalMuteResource.md +docs/EMSetUserGlobalMuteResult.md +docs/EMSetUserMetadataResult.md +docs/EMThreadResource.md +docs/EMUnmuteAllGroupMembersResource.md +docs/EMUnmuteAllGroupMembersResult.md +docs/EMUnmuteAllRoomMemberResource.md +docs/EMUnmuteAllRoomMemberResult.md +docs/EMUnmuteRoomMemberResource.md +docs/EMUnmuteRoomMemberResult.md +docs/EMUploadChatFileResource.md +docs/EMUploadChatFileResult.md +docs/EMUploadGroupShareFileResult.md +docs/EMUserDeactivateResult.md +docs/EMUserGlobalMuteResource.md +docs/EMUserJoinedGroupResource.md +docs/EMUserResource.md +docs/GroupApi.md +docs/HistoryMessageApi.md +docs/MessageApi.md +docs/MetadataApi.md +docs/RoomApi.md +docs/ThreadApi.md +docs/TokenApi.md +docs/UserApi.md +git_push.sh +gradle.properties +gradle/wrapper/gradle-wrapper.jar +gradle/wrapper/gradle-wrapper.properties +gradlew +gradlew.bat +pom.xml +settings.gradle +src/main/AndroidManifest.xml +src/main/java/com/easemob/im/ApiCallback.java +src/main/java/com/easemob/im/ApiClient.java +src/main/java/com/easemob/im/ApiException.java +src/main/java/com/easemob/im/ApiResponse.java +src/main/java/com/easemob/im/Configuration.java +src/main/java/com/easemob/im/GzipRequestInterceptor.java +src/main/java/com/easemob/im/JSON.java +src/main/java/com/easemob/im/Pair.java +src/main/java/com/easemob/im/ProgressRequestBody.java +src/main/java/com/easemob/im/ProgressResponseBody.java +src/main/java/com/easemob/im/ServerConfiguration.java +src/main/java/com/easemob/im/ServerVariable.java +src/main/java/com/easemob/im/StringUtil.java +src/main/java/com/easemob/im/api/BlockApi.java +src/main/java/com/easemob/im/api/ChatFileApi.java +src/main/java/com/easemob/im/api/ContactApi.java +src/main/java/com/easemob/im/api/GroupApi.java +src/main/java/com/easemob/im/api/HistoryMessageApi.java +src/main/java/com/easemob/im/api/MessageApi.java +src/main/java/com/easemob/im/api/MetadataApi.java +src/main/java/com/easemob/im/api/RoomApi.java +src/main/java/com/easemob/im/api/ThreadApi.java +src/main/java/com/easemob/im/api/TokenApi.java +src/main/java/com/easemob/im/api/UserApi.java +src/main/java/com/easemob/im/api/model/AbstractOpenApiSchema.java +src/main/java/com/easemob/im/api/model/EMAddContactResult.java +src/main/java/com/easemob/im/api/model/EMAddGroupAdmin.java +src/main/java/com/easemob/im/api/model/EMAddGroupAdminResource.java +src/main/java/com/easemob/im/api/model/EMAddGroupAdminResult.java +src/main/java/com/easemob/im/api/model/EMAddMultipleUserToGroup.java +src/main/java/com/easemob/im/api/model/EMAddMultipleUserToGroupBlockList.java +src/main/java/com/easemob/im/api/model/EMAddMultipleUserToGroupBlockListResult.java +src/main/java/com/easemob/im/api/model/EMAddMultipleUserToGroupResource.java +src/main/java/com/easemob/im/api/model/EMAddMultipleUserToGroupResult.java +src/main/java/com/easemob/im/api/model/EMAddMultipleUserToGroupWhiteList.java +src/main/java/com/easemob/im/api/model/EMAddMultipleUserToGroupWhiteListResult.java +src/main/java/com/easemob/im/api/model/EMAddMultipleUserToRoom.java +src/main/java/com/easemob/im/api/model/EMAddMultipleUserToRoomBlockList.java +src/main/java/com/easemob/im/api/model/EMAddMultipleUserToRoomBlockListResult.java +src/main/java/com/easemob/im/api/model/EMAddMultipleUserToRoomWhiteList.java +src/main/java/com/easemob/im/api/model/EMAddMultipleUserToRoomWhiteListResult.java +src/main/java/com/easemob/im/api/model/EMAddMultipleUsersToThread.java +src/main/java/com/easemob/im/api/model/EMAddMultipleUsersToThreadResource.java +src/main/java/com/easemob/im/api/model/EMAddMultipleUsersToThreadResult.java +src/main/java/com/easemob/im/api/model/EMAddRoomAdmin.java +src/main/java/com/easemob/im/api/model/EMAddRoomAdminResource.java +src/main/java/com/easemob/im/api/model/EMAddRoomAdminResult.java +src/main/java/com/easemob/im/api/model/EMAddRoomSuperAdmin.java +src/main/java/com/easemob/im/api/model/EMAddRoomSuperAdminResource.java +src/main/java/com/easemob/im/api/model/EMAddRoomSuperAdminResult.java +src/main/java/com/easemob/im/api/model/EMAddUserToBlockList.java +src/main/java/com/easemob/im/api/model/EMAddUserToBlockListResult.java +src/main/java/com/easemob/im/api/model/EMAddUserToGroupBlockListResource.java +src/main/java/com/easemob/im/api/model/EMAddUserToGroupBlockListResult.java +src/main/java/com/easemob/im/api/model/EMAddUserToGroupResource.java +src/main/java/com/easemob/im/api/model/EMAddUserToGroupResult.java +src/main/java/com/easemob/im/api/model/EMAddUserToGroupWhiteListResource.java +src/main/java/com/easemob/im/api/model/EMAddUserToGroupWhiteListResult.java +src/main/java/com/easemob/im/api/model/EMAddUserToRoomBlockListResource.java +src/main/java/com/easemob/im/api/model/EMAddUserToRoomBlockListResult.java +src/main/java/com/easemob/im/api/model/EMAddUserToRoomResource.java +src/main/java/com/easemob/im/api/model/EMAddUserToRoomResult.java +src/main/java/com/easemob/im/api/model/EMAddUserToRoomWhiteListResource.java +src/main/java/com/easemob/im/api/model/EMAddUserToRoomWhiteListResult.java +src/main/java/com/easemob/im/api/model/EMAllGloballyMutedUsersResource.java +src/main/java/com/easemob/im/api/model/EMCheckUserJoinedGroupResult.java +src/main/java/com/easemob/im/api/model/EMContactRemarkResource.java +src/main/java/com/easemob/im/api/model/EMCreateGroup.java +src/main/java/com/easemob/im/api/model/EMCreateGroupResource.java +src/main/java/com/easemob/im/api/model/EMCreateGroupResult.java +src/main/java/com/easemob/im/api/model/EMCreateMessage.java +src/main/java/com/easemob/im/api/model/EMCreateRoom.java +src/main/java/com/easemob/im/api/model/EMCreateRoomResource.java +src/main/java/com/easemob/im/api/model/EMCreateRoomResult.java +src/main/java/com/easemob/im/api/model/EMCreateThread.java +src/main/java/com/easemob/im/api/model/EMCreateThreadResource.java +src/main/java/com/easemob/im/api/model/EMCreateThreadResult.java +src/main/java/com/easemob/im/api/model/EMCreateToken.java +src/main/java/com/easemob/im/api/model/EMCreateUser.java +src/main/java/com/easemob/im/api/model/EMCreateUserFailResource.java +src/main/java/com/easemob/im/api/model/EMCreateUserResource.java +src/main/java/com/easemob/im/api/model/EMCreateUsersResult.java +src/main/java/com/easemob/im/api/model/EMCustomGroupMemberAttribute.java +src/main/java/com/easemob/im/api/model/EMCustomGroupMemberAttributeResult.java +src/main/java/com/easemob/im/api/model/EMDeleteGroupResource.java +src/main/java/com/easemob/im/api/model/EMDeleteGroupResult.java +src/main/java/com/easemob/im/api/model/EMDeleteGroupShareFileResource.java +src/main/java/com/easemob/im/api/model/EMDeleteGroupShareFileResult.java +src/main/java/com/easemob/im/api/model/EMDeleteRoomCustomAttributes.java +src/main/java/com/easemob/im/api/model/EMDeleteRoomCustomAttributesResource.java +src/main/java/com/easemob/im/api/model/EMDeleteRoomCustomAttributesResult.java +src/main/java/com/easemob/im/api/model/EMDeleteRoomResource.java +src/main/java/com/easemob/im/api/model/EMDeleteRoomResult.java +src/main/java/com/easemob/im/api/model/EMDeleteThreadResource.java +src/main/java/com/easemob/im/api/model/EMDeleteThreadResult.java +src/main/java/com/easemob/im/api/model/EMDeleteUserMetadataResult.java +src/main/java/com/easemob/im/api/model/EMDeleteUserResult.java +src/main/java/com/easemob/im/api/model/EMDeleteUsersResult.java +src/main/java/com/easemob/im/api/model/EMDeviceResource.java +src/main/java/com/easemob/im/api/model/EMDisableGroupResource.java +src/main/java/com/easemob/im/api/model/EMDisableGroupResult.java +src/main/java/com/easemob/im/api/model/EMEnableGroupResource.java +src/main/java/com/easemob/im/api/model/EMEnableGroupResult.java +src/main/java/com/easemob/im/api/model/EMForceDeleteRoomCustomAttributes.java +src/main/java/com/easemob/im/api/model/EMForceDeleteRoomCustomAttributesResource.java +src/main/java/com/easemob/im/api/model/EMForceDeleteRoomCustomAttributesResult.java +src/main/java/com/easemob/im/api/model/EMForceSetRoomCustomAttributes.java +src/main/java/com/easemob/im/api/model/EMForceSetRoomCustomAttributesResource.java +src/main/java/com/easemob/im/api/model/EMForceSetRoomCustomAttributesResult.java +src/main/java/com/easemob/im/api/model/EMForceUserLogoutResource.java +src/main/java/com/easemob/im/api/model/EMForceUserLogoutResult.java +src/main/java/com/easemob/im/api/model/EMGetAllGloballyMutedUsersResult.java +src/main/java/com/easemob/im/api/model/EMGetAppGroupResource.java +src/main/java/com/easemob/im/api/model/EMGetAppGroupsResult.java +src/main/java/com/easemob/im/api/model/EMGetBlockListResult.java +src/main/java/com/easemob/im/api/model/EMGetContactListResource.java +src/main/java/com/easemob/im/api/model/EMGetContactListResult.java +src/main/java/com/easemob/im/api/model/EMGetGroupAdminListResult.java +src/main/java/com/easemob/im/api/model/EMGetGroupAnnouncementResource.java +src/main/java/com/easemob/im/api/model/EMGetGroupAnnouncementResult.java +src/main/java/com/easemob/im/api/model/EMGetGroupBlockListResult.java +src/main/java/com/easemob/im/api/model/EMGetGroupInfoResult.java +src/main/java/com/easemob/im/api/model/EMGetGroupMemberAllCustomAttributeResult.java +src/main/java/com/easemob/im/api/model/EMGetGroupMemberListResult.java +src/main/java/com/easemob/im/api/model/EMGetGroupMuteListResult.java +src/main/java/com/easemob/im/api/model/EMGetGroupShareFileResult.java +src/main/java/com/easemob/im/api/model/EMGetGroupWhiteListResult.java +src/main/java/com/easemob/im/api/model/EMGetHistoryMessageResource.java +src/main/java/com/easemob/im/api/model/EMGetHistoryMessageResult.java +src/main/java/com/easemob/im/api/model/EMGetMultipleGroupMembersAttributes.java +src/main/java/com/easemob/im/api/model/EMGetMultipleGroupMembersAttributesResult.java +src/main/java/com/easemob/im/api/model/EMGetMultipleUserMetadata.java +src/main/java/com/easemob/im/api/model/EMGetMultipleUserMetadataResult.java +src/main/java/com/easemob/im/api/model/EMGetMuteRoomMemberListResult.java +src/main/java/com/easemob/im/api/model/EMGetOfflineMessageStatusResult.java +src/main/java/com/easemob/im/api/model/EMGetRoomAdminListResult.java +src/main/java/com/easemob/im/api/model/EMGetRoomAnnouncementResult.java +src/main/java/com/easemob/im/api/model/EMGetRoomBlockListResult.java +src/main/java/com/easemob/im/api/model/EMGetRoomCustomAttributes.java +src/main/java/com/easemob/im/api/model/EMGetRoomCustomAttributesResult.java +src/main/java/com/easemob/im/api/model/EMGetRoomInfoResource.java +src/main/java/com/easemob/im/api/model/EMGetRoomInfoResult.java +src/main/java/com/easemob/im/api/model/EMGetRoomListResource.java +src/main/java/com/easemob/im/api/model/EMGetRoomListResult.java +src/main/java/com/easemob/im/api/model/EMGetRoomMemberListResult.java +src/main/java/com/easemob/im/api/model/EMGetRoomSuperAdminListResult.java +src/main/java/com/easemob/im/api/model/EMGetRoomWhiteListResult.java +src/main/java/com/easemob/im/api/model/EMGetThreadMemberListResult.java +src/main/java/com/easemob/im/api/model/EMGetThreadMemberListResultData.java +src/main/java/com/easemob/im/api/model/EMGetThreadsUnderAppResource.java +src/main/java/com/easemob/im/api/model/EMGetThreadsUnderAppResult.java +src/main/java/com/easemob/im/api/model/EMGetThreadsUnderAppResultProperties.java +src/main/java/com/easemob/im/api/model/EMGetToken.java +src/main/java/com/easemob/im/api/model/EMGetUserGlobalMuteResult.java +src/main/java/com/easemob/im/api/model/EMGetUserJoinedGroupsResult.java +src/main/java/com/easemob/im/api/model/EMGetUserJoinedRoomListResource.java +src/main/java/com/easemob/im/api/model/EMGetUserJoinedRoomListResult.java +src/main/java/com/easemob/im/api/model/EMGetUserJoinedThreadsResult.java +src/main/java/com/easemob/im/api/model/EMGetUserJoinedThreadsUnderGroupResult.java +src/main/java/com/easemob/im/api/model/EMGetUserMetadataCapacityResult.java +src/main/java/com/easemob/im/api/model/EMGetUserMetadataResult.java +src/main/java/com/easemob/im/api/model/EMGetUserOfflineMessageCountResult.java +src/main/java/com/easemob/im/api/model/EMGetUserOnlineLoginDeviceListResult.java +src/main/java/com/easemob/im/api/model/EMGetUserOnlineStateResult.java +src/main/java/com/easemob/im/api/model/EMGetUserResult.java +src/main/java/com/easemob/im/api/model/EMGetUsersOnlineState.java +src/main/java/com/easemob/im/api/model/EMGetUsersOnlineStateResult.java +src/main/java/com/easemob/im/api/model/EMGetUsersResult.java +src/main/java/com/easemob/im/api/model/EMGroupInfoResource.java +src/main/java/com/easemob/im/api/model/EMGroupMuteResource.java +src/main/java/com/easemob/im/api/model/EMGroupShareFileResource.java +src/main/java/com/easemob/im/api/model/EMImageSize.java +src/main/java/com/easemob/im/api/model/EMImportChatGroupMessage.java +src/main/java/com/easemob/im/api/model/EMImportChatGroupMessageResource.java +src/main/java/com/easemob/im/api/model/EMImportChatGroupMessageResult.java +src/main/java/com/easemob/im/api/model/EMImportChatUserMessage.java +src/main/java/com/easemob/im/api/model/EMImportChatUserMessageResource.java +src/main/java/com/easemob/im/api/model/EMImportChatUserMessageResult.java +src/main/java/com/easemob/im/api/model/EMMessageContent.java +src/main/java/com/easemob/im/api/model/EMModifyGroup.java +src/main/java/com/easemob/im/api/model/EMModifyGroupAnnouncement.java +src/main/java/com/easemob/im/api/model/EMModifyGroupAnnouncementResource.java +src/main/java/com/easemob/im/api/model/EMModifyGroupAnnouncementResult.java +src/main/java/com/easemob/im/api/model/EMModifyGroupResult.java +src/main/java/com/easemob/im/api/model/EMModifyRoom.java +src/main/java/com/easemob/im/api/model/EMModifyRoomAnnouncement.java +src/main/java/com/easemob/im/api/model/EMModifyRoomAnnouncementResource.java +src/main/java/com/easemob/im/api/model/EMModifyRoomAnnouncementResult.java +src/main/java/com/easemob/im/api/model/EMModifyRoomResource.java +src/main/java/com/easemob/im/api/model/EMModifyRoomResult.java +src/main/java/com/easemob/im/api/model/EMModifyThread.java +src/main/java/com/easemob/im/api/model/EMModifyThreadResource.java +src/main/java/com/easemob/im/api/model/EMModifyThreadResult.java +src/main/java/com/easemob/im/api/model/EMModifyUserPassword.java +src/main/java/com/easemob/im/api/model/EMMuteAllGroupMembersResource.java +src/main/java/com/easemob/im/api/model/EMMuteAllGroupMembersResult.java +src/main/java/com/easemob/im/api/model/EMMuteAllRoomMemberResource.java +src/main/java/com/easemob/im/api/model/EMMuteAllRoomMemberResult.java +src/main/java/com/easemob/im/api/model/EMMuteGroupMember.java +src/main/java/com/easemob/im/api/model/EMMuteGroupMemberResource.java +src/main/java/com/easemob/im/api/model/EMMuteGroupMemberResult.java +src/main/java/com/easemob/im/api/model/EMMuteRoomMember.java +src/main/java/com/easemob/im/api/model/EMMuteRoomMemberResource.java +src/main/java/com/easemob/im/api/model/EMMuteRoomMemberResult.java +src/main/java/com/easemob/im/api/model/EMOneWayDeleteConversation.java +src/main/java/com/easemob/im/api/model/EMOneWayDeleteConversationResource.java +src/main/java/com/easemob/im/api/model/EMOneWayDeleteConversationResult.java +src/main/java/com/easemob/im/api/model/EMRecallMessage.java +src/main/java/com/easemob/im/api/model/EMRecallMessageResource.java +src/main/java/com/easemob/im/api/model/EMRecallMessageResult.java +src/main/java/com/easemob/im/api/model/EMRemoveContactResult.java +src/main/java/com/easemob/im/api/model/EMRemoveGroupAdminResource.java +src/main/java/com/easemob/im/api/model/EMRemoveGroupAdminResult.java +src/main/java/com/easemob/im/api/model/EMRemoveMultipleUsersFromThread.java +src/main/java/com/easemob/im/api/model/EMRemoveMultipleUsersFromThreadResult.java +src/main/java/com/easemob/im/api/model/EMRemoveRoomAdminResource.java +src/main/java/com/easemob/im/api/model/EMRemoveRoomAdminResult.java +src/main/java/com/easemob/im/api/model/EMRemoveRoomSuperAdminResource.java +src/main/java/com/easemob/im/api/model/EMRemoveRoomSuperAdminResult.java +src/main/java/com/easemob/im/api/model/EMRemoveThreadUsersResource.java +src/main/java/com/easemob/im/api/model/EMRemoveUserFromBlockListResult.java +src/main/java/com/easemob/im/api/model/EMRemoveUserFromGroupBlockListResource.java +src/main/java/com/easemob/im/api/model/EMRemoveUserFromGroupBlockListResult.java +src/main/java/com/easemob/im/api/model/EMRemoveUserFromGroupWhiteListResult.java +src/main/java/com/easemob/im/api/model/EMRemoveUserFromRoomBlockListResource.java +src/main/java/com/easemob/im/api/model/EMRemoveUserFromRoomBlockListResult.java +src/main/java/com/easemob/im/api/model/EMRemoveUserFromRoomResource.java +src/main/java/com/easemob/im/api/model/EMRemoveUserFromRoomResult.java +src/main/java/com/easemob/im/api/model/EMRemoveUserFromRoomWhiteListResult.java +src/main/java/com/easemob/im/api/model/EMRemoveUserToGroupResource.java +src/main/java/com/easemob/im/api/model/EMRemoveUserToGroupResult.java +src/main/java/com/easemob/im/api/model/EMRoomBlockListResource.java +src/main/java/com/easemob/im/api/model/EMRoomMuteMemberResource.java +src/main/java/com/easemob/im/api/model/EMRoomWhiteListResource.java +src/main/java/com/easemob/im/api/model/EMSendMessageResult.java +src/main/java/com/easemob/im/api/model/EMSetContactNote.java +src/main/java/com/easemob/im/api/model/EMSetContactNoteResult.java +src/main/java/com/easemob/im/api/model/EMSetRoomCustomAttributes.java +src/main/java/com/easemob/im/api/model/EMSetRoomCustomAttributesResource.java +src/main/java/com/easemob/im/api/model/EMSetRoomCustomAttributesResult.java +src/main/java/com/easemob/im/api/model/EMSetUserGlobalMute.java +src/main/java/com/easemob/im/api/model/EMSetUserGlobalMuteResource.java +src/main/java/com/easemob/im/api/model/EMSetUserGlobalMuteResult.java +src/main/java/com/easemob/im/api/model/EMSetUserMetadataResult.java +src/main/java/com/easemob/im/api/model/EMThreadResource.java +src/main/java/com/easemob/im/api/model/EMUnmuteAllGroupMembersResource.java +src/main/java/com/easemob/im/api/model/EMUnmuteAllGroupMembersResult.java +src/main/java/com/easemob/im/api/model/EMUnmuteAllRoomMemberResource.java +src/main/java/com/easemob/im/api/model/EMUnmuteAllRoomMemberResult.java +src/main/java/com/easemob/im/api/model/EMUnmuteRoomMemberResource.java +src/main/java/com/easemob/im/api/model/EMUnmuteRoomMemberResult.java +src/main/java/com/easemob/im/api/model/EMUploadChatFileResource.java +src/main/java/com/easemob/im/api/model/EMUploadChatFileResult.java +src/main/java/com/easemob/im/api/model/EMUploadGroupShareFileResult.java +src/main/java/com/easemob/im/api/model/EMUserDeactivateResult.java +src/main/java/com/easemob/im/api/model/EMUserGlobalMuteResource.java +src/main/java/com/easemob/im/api/model/EMUserJoinedGroupResource.java +src/main/java/com/easemob/im/api/model/EMUserResource.java +src/main/java/com/easemob/im/auth/ApiKeyAuth.java +src/main/java/com/easemob/im/auth/Authentication.java +src/main/java/com/easemob/im/auth/HttpBasicAuth.java +src/main/java/com/easemob/im/auth/HttpBearerAuth.java +src/test/java/com/easemob/im/api/BlockApiTest.java +src/test/java/com/easemob/im/api/ChatFileApiTest.java +src/test/java/com/easemob/im/api/ContactApiTest.java +src/test/java/com/easemob/im/api/GroupApiTest.java +src/test/java/com/easemob/im/api/HistoryMessageApiTest.java +src/test/java/com/easemob/im/api/MessageApiTest.java +src/test/java/com/easemob/im/api/MetadataApiTest.java +src/test/java/com/easemob/im/api/RoomApiTest.java +src/test/java/com/easemob/im/api/ThreadApiTest.java +src/test/java/com/easemob/im/api/TokenApiTest.java +src/test/java/com/easemob/im/api/UserApiTest.java +src/test/java/com/easemob/im/api/model/EMAddContactResultTest.java +src/test/java/com/easemob/im/api/model/EMAddGroupAdminResourceTest.java +src/test/java/com/easemob/im/api/model/EMAddGroupAdminResultTest.java +src/test/java/com/easemob/im/api/model/EMAddGroupAdminTest.java +src/test/java/com/easemob/im/api/model/EMAddMultipleUserToGroupBlockListResultTest.java +src/test/java/com/easemob/im/api/model/EMAddMultipleUserToGroupBlockListTest.java +src/test/java/com/easemob/im/api/model/EMAddMultipleUserToGroupResourceTest.java +src/test/java/com/easemob/im/api/model/EMAddMultipleUserToGroupResultTest.java +src/test/java/com/easemob/im/api/model/EMAddMultipleUserToGroupTest.java +src/test/java/com/easemob/im/api/model/EMAddMultipleUserToGroupWhiteListResultTest.java +src/test/java/com/easemob/im/api/model/EMAddMultipleUserToGroupWhiteListTest.java +src/test/java/com/easemob/im/api/model/EMAddMultipleUserToRoomBlockListResultTest.java +src/test/java/com/easemob/im/api/model/EMAddMultipleUserToRoomBlockListTest.java +src/test/java/com/easemob/im/api/model/EMAddMultipleUserToRoomTest.java +src/test/java/com/easemob/im/api/model/EMAddMultipleUserToRoomWhiteListResultTest.java +src/test/java/com/easemob/im/api/model/EMAddMultipleUserToRoomWhiteListTest.java +src/test/java/com/easemob/im/api/model/EMAddMultipleUsersToThreadResourceTest.java +src/test/java/com/easemob/im/api/model/EMAddMultipleUsersToThreadResultTest.java +src/test/java/com/easemob/im/api/model/EMAddMultipleUsersToThreadTest.java +src/test/java/com/easemob/im/api/model/EMAddRoomAdminResourceTest.java +src/test/java/com/easemob/im/api/model/EMAddRoomAdminResultTest.java +src/test/java/com/easemob/im/api/model/EMAddRoomAdminTest.java +src/test/java/com/easemob/im/api/model/EMAddRoomSuperAdminResourceTest.java +src/test/java/com/easemob/im/api/model/EMAddRoomSuperAdminResultTest.java +src/test/java/com/easemob/im/api/model/EMAddRoomSuperAdminTest.java +src/test/java/com/easemob/im/api/model/EMAddUserToBlockListResultTest.java +src/test/java/com/easemob/im/api/model/EMAddUserToBlockListTest.java +src/test/java/com/easemob/im/api/model/EMAddUserToGroupBlockListResourceTest.java +src/test/java/com/easemob/im/api/model/EMAddUserToGroupBlockListResultTest.java +src/test/java/com/easemob/im/api/model/EMAddUserToGroupResourceTest.java +src/test/java/com/easemob/im/api/model/EMAddUserToGroupResultTest.java +src/test/java/com/easemob/im/api/model/EMAddUserToGroupWhiteListResourceTest.java +src/test/java/com/easemob/im/api/model/EMAddUserToGroupWhiteListResultTest.java +src/test/java/com/easemob/im/api/model/EMAddUserToRoomBlockListResourceTest.java +src/test/java/com/easemob/im/api/model/EMAddUserToRoomBlockListResultTest.java +src/test/java/com/easemob/im/api/model/EMAddUserToRoomResourceTest.java +src/test/java/com/easemob/im/api/model/EMAddUserToRoomResultTest.java +src/test/java/com/easemob/im/api/model/EMAddUserToRoomWhiteListResourceTest.java +src/test/java/com/easemob/im/api/model/EMAddUserToRoomWhiteListResultTest.java +src/test/java/com/easemob/im/api/model/EMAllGloballyMutedUsersResourceTest.java +src/test/java/com/easemob/im/api/model/EMCheckUserJoinedGroupResultTest.java +src/test/java/com/easemob/im/api/model/EMContactRemarkResourceTest.java +src/test/java/com/easemob/im/api/model/EMCreateGroupResourceTest.java +src/test/java/com/easemob/im/api/model/EMCreateGroupResultTest.java +src/test/java/com/easemob/im/api/model/EMCreateGroupTest.java +src/test/java/com/easemob/im/api/model/EMCreateMessageTest.java +src/test/java/com/easemob/im/api/model/EMCreateRoomResourceTest.java +src/test/java/com/easemob/im/api/model/EMCreateRoomResultTest.java +src/test/java/com/easemob/im/api/model/EMCreateRoomTest.java +src/test/java/com/easemob/im/api/model/EMCreateThreadResourceTest.java +src/test/java/com/easemob/im/api/model/EMCreateThreadResultTest.java +src/test/java/com/easemob/im/api/model/EMCreateThreadTest.java +src/test/java/com/easemob/im/api/model/EMCreateTokenTest.java +src/test/java/com/easemob/im/api/model/EMCreateUserFailResourceTest.java +src/test/java/com/easemob/im/api/model/EMCreateUserResourceTest.java +src/test/java/com/easemob/im/api/model/EMCreateUserTest.java +src/test/java/com/easemob/im/api/model/EMCreateUsersResultTest.java +src/test/java/com/easemob/im/api/model/EMCustomGroupMemberAttributeResultTest.java +src/test/java/com/easemob/im/api/model/EMCustomGroupMemberAttributeTest.java +src/test/java/com/easemob/im/api/model/EMDeleteGroupResourceTest.java +src/test/java/com/easemob/im/api/model/EMDeleteGroupResultTest.java +src/test/java/com/easemob/im/api/model/EMDeleteGroupShareFileResourceTest.java +src/test/java/com/easemob/im/api/model/EMDeleteGroupShareFileResultTest.java +src/test/java/com/easemob/im/api/model/EMDeleteRoomCustomAttributesResourceTest.java +src/test/java/com/easemob/im/api/model/EMDeleteRoomCustomAttributesResultTest.java +src/test/java/com/easemob/im/api/model/EMDeleteRoomCustomAttributesTest.java +src/test/java/com/easemob/im/api/model/EMDeleteRoomResourceTest.java +src/test/java/com/easemob/im/api/model/EMDeleteRoomResultTest.java +src/test/java/com/easemob/im/api/model/EMDeleteThreadResourceTest.java +src/test/java/com/easemob/im/api/model/EMDeleteThreadResultTest.java +src/test/java/com/easemob/im/api/model/EMDeleteUserMetadataResultTest.java +src/test/java/com/easemob/im/api/model/EMDeleteUserResultTest.java +src/test/java/com/easemob/im/api/model/EMDeleteUsersResultTest.java +src/test/java/com/easemob/im/api/model/EMDeviceResourceTest.java +src/test/java/com/easemob/im/api/model/EMDisableGroupResourceTest.java +src/test/java/com/easemob/im/api/model/EMDisableGroupResultTest.java +src/test/java/com/easemob/im/api/model/EMEnableGroupResourceTest.java +src/test/java/com/easemob/im/api/model/EMEnableGroupResultTest.java +src/test/java/com/easemob/im/api/model/EMForceDeleteRoomCustomAttributesResourceTest.java +src/test/java/com/easemob/im/api/model/EMForceDeleteRoomCustomAttributesResultTest.java +src/test/java/com/easemob/im/api/model/EMForceDeleteRoomCustomAttributesTest.java +src/test/java/com/easemob/im/api/model/EMForceSetRoomCustomAttributesResourceTest.java +src/test/java/com/easemob/im/api/model/EMForceSetRoomCustomAttributesResultTest.java +src/test/java/com/easemob/im/api/model/EMForceSetRoomCustomAttributesTest.java +src/test/java/com/easemob/im/api/model/EMForceUserLogoutResourceTest.java +src/test/java/com/easemob/im/api/model/EMForceUserLogoutResultTest.java +src/test/java/com/easemob/im/api/model/EMGetAllGloballyMutedUsersResultTest.java +src/test/java/com/easemob/im/api/model/EMGetAppGroupResourceTest.java +src/test/java/com/easemob/im/api/model/EMGetAppGroupsResultTest.java +src/test/java/com/easemob/im/api/model/EMGetBlockListResultTest.java +src/test/java/com/easemob/im/api/model/EMGetContactListResourceTest.java +src/test/java/com/easemob/im/api/model/EMGetContactListResultTest.java +src/test/java/com/easemob/im/api/model/EMGetGroupAdminListResultTest.java +src/test/java/com/easemob/im/api/model/EMGetGroupAnnouncementResourceTest.java +src/test/java/com/easemob/im/api/model/EMGetGroupAnnouncementResultTest.java +src/test/java/com/easemob/im/api/model/EMGetGroupBlockListResultTest.java +src/test/java/com/easemob/im/api/model/EMGetGroupInfoResultTest.java +src/test/java/com/easemob/im/api/model/EMGetGroupMemberAllCustomAttributeResultTest.java +src/test/java/com/easemob/im/api/model/EMGetGroupMemberListResultTest.java +src/test/java/com/easemob/im/api/model/EMGetGroupMuteListResultTest.java +src/test/java/com/easemob/im/api/model/EMGetGroupShareFileResultTest.java +src/test/java/com/easemob/im/api/model/EMGetGroupWhiteListResultTest.java +src/test/java/com/easemob/im/api/model/EMGetHistoryMessageResourceTest.java +src/test/java/com/easemob/im/api/model/EMGetHistoryMessageResultTest.java +src/test/java/com/easemob/im/api/model/EMGetMultipleGroupMembersAttributesResultTest.java +src/test/java/com/easemob/im/api/model/EMGetMultipleGroupMembersAttributesTest.java +src/test/java/com/easemob/im/api/model/EMGetMultipleUserMetadataResultTest.java +src/test/java/com/easemob/im/api/model/EMGetMultipleUserMetadataTest.java +src/test/java/com/easemob/im/api/model/EMGetMuteRoomMemberListResultTest.java +src/test/java/com/easemob/im/api/model/EMGetOfflineMessageStatusResultTest.java +src/test/java/com/easemob/im/api/model/EMGetRoomAdminListResultTest.java +src/test/java/com/easemob/im/api/model/EMGetRoomAnnouncementResultTest.java +src/test/java/com/easemob/im/api/model/EMGetRoomBlockListResultTest.java +src/test/java/com/easemob/im/api/model/EMGetRoomCustomAttributesResultTest.java +src/test/java/com/easemob/im/api/model/EMGetRoomCustomAttributesTest.java +src/test/java/com/easemob/im/api/model/EMGetRoomInfoResourceTest.java +src/test/java/com/easemob/im/api/model/EMGetRoomInfoResultTest.java +src/test/java/com/easemob/im/api/model/EMGetRoomListResourceTest.java +src/test/java/com/easemob/im/api/model/EMGetRoomListResultTest.java +src/test/java/com/easemob/im/api/model/EMGetRoomMemberListResultTest.java +src/test/java/com/easemob/im/api/model/EMGetRoomSuperAdminListResultTest.java +src/test/java/com/easemob/im/api/model/EMGetRoomWhiteListResultTest.java +src/test/java/com/easemob/im/api/model/EMGetThreadMemberListResultDataTest.java +src/test/java/com/easemob/im/api/model/EMGetThreadMemberListResultTest.java +src/test/java/com/easemob/im/api/model/EMGetThreadsUnderAppResourceTest.java +src/test/java/com/easemob/im/api/model/EMGetThreadsUnderAppResultPropertiesTest.java +src/test/java/com/easemob/im/api/model/EMGetThreadsUnderAppResultTest.java +src/test/java/com/easemob/im/api/model/EMGetTokenTest.java +src/test/java/com/easemob/im/api/model/EMGetUserGlobalMuteResultTest.java +src/test/java/com/easemob/im/api/model/EMGetUserJoinedGroupsResultTest.java +src/test/java/com/easemob/im/api/model/EMGetUserJoinedRoomListResourceTest.java +src/test/java/com/easemob/im/api/model/EMGetUserJoinedRoomListResultTest.java +src/test/java/com/easemob/im/api/model/EMGetUserJoinedThreadsResultTest.java +src/test/java/com/easemob/im/api/model/EMGetUserJoinedThreadsUnderGroupResultTest.java +src/test/java/com/easemob/im/api/model/EMGetUserMetadataCapacityResultTest.java +src/test/java/com/easemob/im/api/model/EMGetUserMetadataResultTest.java +src/test/java/com/easemob/im/api/model/EMGetUserOfflineMessageCountResultTest.java +src/test/java/com/easemob/im/api/model/EMGetUserOnlineLoginDeviceListResultTest.java +src/test/java/com/easemob/im/api/model/EMGetUserOnlineStateResultTest.java +src/test/java/com/easemob/im/api/model/EMGetUserResultTest.java +src/test/java/com/easemob/im/api/model/EMGetUsersOnlineStateResultTest.java +src/test/java/com/easemob/im/api/model/EMGetUsersOnlineStateTest.java +src/test/java/com/easemob/im/api/model/EMGetUsersResultTest.java +src/test/java/com/easemob/im/api/model/EMGroupInfoResourceTest.java +src/test/java/com/easemob/im/api/model/EMGroupMuteResourceTest.java +src/test/java/com/easemob/im/api/model/EMGroupShareFileResourceTest.java +src/test/java/com/easemob/im/api/model/EMImageSizeTest.java +src/test/java/com/easemob/im/api/model/EMImportChatGroupMessageResourceTest.java +src/test/java/com/easemob/im/api/model/EMImportChatGroupMessageResultTest.java +src/test/java/com/easemob/im/api/model/EMImportChatGroupMessageTest.java +src/test/java/com/easemob/im/api/model/EMImportChatUserMessageResourceTest.java +src/test/java/com/easemob/im/api/model/EMImportChatUserMessageResultTest.java +src/test/java/com/easemob/im/api/model/EMImportChatUserMessageTest.java +src/test/java/com/easemob/im/api/model/EMMessageContentTest.java +src/test/java/com/easemob/im/api/model/EMModifyGroupAnnouncementResourceTest.java +src/test/java/com/easemob/im/api/model/EMModifyGroupAnnouncementResultTest.java +src/test/java/com/easemob/im/api/model/EMModifyGroupAnnouncementTest.java +src/test/java/com/easemob/im/api/model/EMModifyGroupResultTest.java +src/test/java/com/easemob/im/api/model/EMModifyGroupTest.java +src/test/java/com/easemob/im/api/model/EMModifyRoomAnnouncementResourceTest.java +src/test/java/com/easemob/im/api/model/EMModifyRoomAnnouncementResultTest.java +src/test/java/com/easemob/im/api/model/EMModifyRoomAnnouncementTest.java +src/test/java/com/easemob/im/api/model/EMModifyRoomResourceTest.java +src/test/java/com/easemob/im/api/model/EMModifyRoomResultTest.java +src/test/java/com/easemob/im/api/model/EMModifyRoomTest.java +src/test/java/com/easemob/im/api/model/EMModifyThreadResourceTest.java +src/test/java/com/easemob/im/api/model/EMModifyThreadResultTest.java +src/test/java/com/easemob/im/api/model/EMModifyThreadTest.java +src/test/java/com/easemob/im/api/model/EMModifyUserPasswordTest.java +src/test/java/com/easemob/im/api/model/EMMuteAllGroupMembersResourceTest.java +src/test/java/com/easemob/im/api/model/EMMuteAllGroupMembersResultTest.java +src/test/java/com/easemob/im/api/model/EMMuteAllRoomMemberResourceTest.java +src/test/java/com/easemob/im/api/model/EMMuteAllRoomMemberResultTest.java +src/test/java/com/easemob/im/api/model/EMMuteGroupMemberResourceTest.java +src/test/java/com/easemob/im/api/model/EMMuteGroupMemberResultTest.java +src/test/java/com/easemob/im/api/model/EMMuteGroupMemberTest.java +src/test/java/com/easemob/im/api/model/EMMuteRoomMemberResourceTest.java +src/test/java/com/easemob/im/api/model/EMMuteRoomMemberResultTest.java +src/test/java/com/easemob/im/api/model/EMMuteRoomMemberTest.java +src/test/java/com/easemob/im/api/model/EMOneWayDeleteConversationResourceTest.java +src/test/java/com/easemob/im/api/model/EMOneWayDeleteConversationResultTest.java +src/test/java/com/easemob/im/api/model/EMOneWayDeleteConversationTest.java +src/test/java/com/easemob/im/api/model/EMRecallMessageResourceTest.java +src/test/java/com/easemob/im/api/model/EMRecallMessageResultTest.java +src/test/java/com/easemob/im/api/model/EMRecallMessageTest.java +src/test/java/com/easemob/im/api/model/EMRemoveContactResultTest.java +src/test/java/com/easemob/im/api/model/EMRemoveGroupAdminResourceTest.java +src/test/java/com/easemob/im/api/model/EMRemoveGroupAdminResultTest.java +src/test/java/com/easemob/im/api/model/EMRemoveMultipleUsersFromThreadResultTest.java +src/test/java/com/easemob/im/api/model/EMRemoveMultipleUsersFromThreadTest.java +src/test/java/com/easemob/im/api/model/EMRemoveRoomAdminResourceTest.java +src/test/java/com/easemob/im/api/model/EMRemoveRoomAdminResultTest.java +src/test/java/com/easemob/im/api/model/EMRemoveRoomSuperAdminResourceTest.java +src/test/java/com/easemob/im/api/model/EMRemoveRoomSuperAdminResultTest.java +src/test/java/com/easemob/im/api/model/EMRemoveThreadUsersResourceTest.java +src/test/java/com/easemob/im/api/model/EMRemoveUserFromBlockListResultTest.java +src/test/java/com/easemob/im/api/model/EMRemoveUserFromGroupBlockListResourceTest.java +src/test/java/com/easemob/im/api/model/EMRemoveUserFromGroupBlockListResultTest.java +src/test/java/com/easemob/im/api/model/EMRemoveUserFromGroupWhiteListResultTest.java +src/test/java/com/easemob/im/api/model/EMRemoveUserFromRoomBlockListResourceTest.java +src/test/java/com/easemob/im/api/model/EMRemoveUserFromRoomBlockListResultTest.java +src/test/java/com/easemob/im/api/model/EMRemoveUserFromRoomResourceTest.java +src/test/java/com/easemob/im/api/model/EMRemoveUserFromRoomResultTest.java +src/test/java/com/easemob/im/api/model/EMRemoveUserFromRoomWhiteListResultTest.java +src/test/java/com/easemob/im/api/model/EMRemoveUserToGroupResourceTest.java +src/test/java/com/easemob/im/api/model/EMRemoveUserToGroupResultTest.java +src/test/java/com/easemob/im/api/model/EMRoomBlockListResourceTest.java +src/test/java/com/easemob/im/api/model/EMRoomMuteMemberResourceTest.java +src/test/java/com/easemob/im/api/model/EMRoomWhiteListResourceTest.java +src/test/java/com/easemob/im/api/model/EMSendMessageResultTest.java +src/test/java/com/easemob/im/api/model/EMSetContactNoteResultTest.java +src/test/java/com/easemob/im/api/model/EMSetContactNoteTest.java +src/test/java/com/easemob/im/api/model/EMSetRoomCustomAttributesResourceTest.java +src/test/java/com/easemob/im/api/model/EMSetRoomCustomAttributesResultTest.java +src/test/java/com/easemob/im/api/model/EMSetRoomCustomAttributesTest.java +src/test/java/com/easemob/im/api/model/EMSetUserGlobalMuteResourceTest.java +src/test/java/com/easemob/im/api/model/EMSetUserGlobalMuteResultTest.java +src/test/java/com/easemob/im/api/model/EMSetUserGlobalMuteTest.java +src/test/java/com/easemob/im/api/model/EMSetUserMetadataResultTest.java +src/test/java/com/easemob/im/api/model/EMThreadResourceTest.java +src/test/java/com/easemob/im/api/model/EMUnmuteAllGroupMembersResourceTest.java +src/test/java/com/easemob/im/api/model/EMUnmuteAllGroupMembersResultTest.java +src/test/java/com/easemob/im/api/model/EMUnmuteAllRoomMemberResourceTest.java +src/test/java/com/easemob/im/api/model/EMUnmuteAllRoomMemberResultTest.java +src/test/java/com/easemob/im/api/model/EMUnmuteRoomMemberResourceTest.java +src/test/java/com/easemob/im/api/model/EMUnmuteRoomMemberResultTest.java +src/test/java/com/easemob/im/api/model/EMUploadChatFileResourceTest.java +src/test/java/com/easemob/im/api/model/EMUploadChatFileResultTest.java +src/test/java/com/easemob/im/api/model/EMUploadGroupShareFileResultTest.java +src/test/java/com/easemob/im/api/model/EMUserDeactivateResultTest.java +src/test/java/com/easemob/im/api/model/EMUserGlobalMuteResourceTest.java +src/test/java/com/easemob/im/api/model/EMUserJoinedGroupResourceTest.java +src/test/java/com/easemob/im/api/model/EMUserResourceTest.java diff --git a/.openapi-generator/VERSION b/.openapi-generator/VERSION new file mode 100644 index 000000000..3769235d3 --- /dev/null +++ b/.openapi-generator/VERSION @@ -0,0 +1 @@ +7.1.0 \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md deleted file mode 100644 index 45b5a720e..000000000 --- a/CHANGELOG.md +++ /dev/null @@ -1,26 +0,0 @@ -# Changelog - -All notable changes to this project will be documented in this file. - -The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), -and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). - -## [0.3.0] - 2021-07-12 - -### Added - -- 可自定义 baseURI -- 可设置 HTTP client proxy -- 可对用户属性 metadata 做增删改查 - -### Changed - -- Upgraded Reactor to 2020.0.4 -- Upgraded Netty to 4.1.59.Final - -## [0.2.5] - 2021-03-26 - -[unreleased]: https://github.com/easemob/easemob-im-server-sdk/compare/v0.3.0...HEAD -[0.3.0]: https://github.com/easemob/easemob-im-server-sdk/compare/v0.2.5...v0.3.0 -[0.2.5]: https://github.com/easemob/easemob-im-server-sdk/releases/tag/v0.2.5 - diff --git a/README.md b/README.md index b35885383..e69de29bb 100644 --- a/README.md +++ b/README.md @@ -1,160 +0,0 @@ -# Easemob IM Java SDK [![build](https://github.com/easemob/easemob-im-server-sdk/workflows/Build/badge.svg)](https://github.com/easemob/easemob-im-server-sdk/actions) [![codecov](https://codecov.io/gh/easemob/easemob-im-server-sdk/branch/master/graph/badge.svg)](https://codecov.io/gh/easemob/easemob-im-server-sdk) - -**Easemob IM Java SDK** 是对环信 IM [服务端 API](http://docs-im.easemob.com/im/server/ready/intro) 的封装。 - -提供用户、群组等资源的操作管理能力。 - -## 依赖 - -- Java 1.8 -- [Reactor](https://projectreactor.io)(io.projectreactor:reactor-bom:2020.0.4) - -## 安装 - -如果你的项目使用 Maven 构建,在 pom.xml 中添加下面代码即可: - -``` xml - - com.easemob.im - im-sdk-core - 0.5.4 - -``` - -如果你的项目使用 Gradle 构建,可以在 build.grade 中添加下面代码: - -``` gradle -implementation 'com.easemob.im:im-sdk-core:0.5.4' -``` - -## 准备 -使用 Server SDK 的前提需要您准备: -* 1. 环信 appKey -* 2. 两种 appCredentials 中的其中之一: - - 2.1 环信 clientId, clientSecret - - 2.2 声网 appId, appCert - -### 获取环信 appKey, clientId, clientSecret - -如果您有环信管理后台账号并创建过应用,请进入 [这里](https://console.easemob.com/user/login) 进行登录。 -![图片](https://user-images.githubusercontent.com/15087647/114996679-a34cb980-9ed1-11eb-89ae-a22c1af7d69d.png) - -如图点击查看后,可以看到自己的 appkey、Client ID、ClientSecret,用于 SDK 的初始化。 - -如果您没有环信管理后台账号,请进入 [这里](https://console.easemob.com/user/register) 进行注册账号,注册成功后请进行登录。 -![图片](https://user-images.githubusercontent.com/15087647/114997381-59180800-9ed2-11eb-968a-a29406c78021.png) - -如图先添加应用(也就是创建 appkey,自动生成 Client ID、ClientSecret),添加成功后在应用列表中可以看到应用信息,点击查看可以看到自己的 appkey、Client ID、ClientSecret,用于 SDK 的初始化。 - -### 获取声网 appId, appCert - -如果您有声网 Console 后台账号并创建过项目,请先登录声网 Console 后台,点击[这里](https://sso.agora.io/cn/login/),然后到"项目列表" -> 找到自己的项目点击"编辑"图标后,即可看到 App ID、APP 证书。 - -如果您没有声网Console后台账号,请先注册账号,点击[这里](https://sso.agora.io/cn/v4/signup),注册成功后按照步骤1操作。 - - -## 使用 - -[EMService](https://easemob.github.io/easemob-im-server-sdk/com/easemob/im/server/EMService.html) 是所有 API 的入口,可以这样初始化: - -### 1. 使用 Easemob App Credentials 的情况 -``` java -建议写到配置类中,示例如下: -@Configuration -public class Config { - - @Bean - public EMService service() { - - EMProperties properties = EMProperties.builder() - .setAppkey("Appkey") - .setClientId("Client ID") - .setClientSecret("ClientSecret") - .build(); - - return new EMService(properties); - } -} -``` - -根据业务资源,API 分为: - -- [Attachment](https://easemob.github.io/easemob-im-server-sdk/com/easemob/im/server/api/attachment/AttachmentApi.html) - 用于上传下载附件 -- [Block](https://easemob.github.io/easemob-im-server-sdk/com/easemob/im/server/api/block/BlockApi.html) - 用于限制访问(将用户加入黑名单、群组/聊天室禁言等) -- [Contact](https://easemob.github.io/easemob-im-server-sdk/com/easemob/im/server/api/contact/ContactApi.html) - 用于管理联系人(添加好友等) -- [Group](https://easemob.github.io/easemob-im-server-sdk/com/easemob/im/server/api/group/GroupApi.html) - 用于管理群组 -- [Message](https://easemob.github.io/easemob-im-server-sdk/com/easemob/im/server/api/message/MessageApi.html) - 用于发送消息 -- [User](https://easemob.github.io/easemob-im-server-sdk/com/easemob/im/server/api/user/UserApi.html) - 用于管理用户 -- [UserMetadata](https://easemob.github.io/easemob-im-server-sdk/com/easemob/im/server/api/metadata/MetadataApi.html) - 用于管理用户属性 -- [Push](https://easemob.github.io/easemob-im-server-sdk/com/easemob/im/server/api/push/PushApi.html) - 用于管理用户推送(设置推送免打扰等) -- [Token](https://easemob.github.io/easemob-im-server-sdk/com/easemob/im/server/api/token/TokenApi.html) - 用于获取用户Token -- [Room](https://easemob.github.io/easemob-im-server-sdk/com/easemob/im/server/api/room/RoomApi.html) - 用于管理聊天室 - -每个业务资源对应一个方法,例如,用户相关的 API,都可以在 `.user()` 找到。 - -举个例子,我们要注册一个用户,就可以这样写: - -``` java -@Service -public class UserService { - - @Autowired - private EMService service; - - private void createUser() { - try { - EMUser user = service.user().create("username", "password").block(); - } catch (EMException e) { - e.getErrorCode(); - e.getMessage(); - } - - } -} -``` - -API 的返回值是响应式的,如果希望阻塞,可以使用上面例子中的 `.block()`。 - -注意:如果你的项目不是响应式的编程,那么请在调用的 server sdk api 的结尾添加 `.block()`。 - -对使用的 API 添加 `try/catch` ,如果使用的 API 没有抛出异常,代表请求成功,反之则请求失败,通过 `EMException` 异常对象的 `getErrorCode()/getMessage()` 拿到错误码以及错误描述。 - -## 参考 - -SDK 的 api 文档在[这里](https://easemob.github.io/easemob-im-server-sdk/) 。 - -## 常见问题 -如果你想看 Server SDK 的请求与响应,可以在配置文件中添加: -``` java -logging.level.com.easemob.im.http=debug -``` - -## 注意事项 - -Server SDK 是对环信 IM [服务端 API](http://docs-im.easemob.com/im/server/ready/intro) 的封装,但并没有封装所有的 API,只封装了开发者常用的 API。 - -对于注册环信id的规则,Server SDK 有自己的限制, 正则为 `^[a-z][0-9a-z-]{1,32}$`,这点与 [官网文档](https://docs-im.easemob.com/im/server/ready/user#%E7%8E%AF%E4%BF%A1_id_%E4%BD%BF%E7%94%A8%E8%A7%84%E5%88%99) 中说明的环信id规则是有区别的,这样做是因为目前环信id注册的限制范围比较广,Server SDK 考虑缩小环信 id 注册的限制范围使其更加规范,在此说明一下。 - -如果不想使用 Server SDK 注册环信 id 的限制,可以在初始化配置时添加 `turnOffUserNameValidation()` (sdk 需要使用 0.3.5 以上的版本)。 - -强烈建议不要使用纯数字或者有规律的字符串来注册环信 id,否则自己的用户可能会遭受到攻击、垃圾消息等后果。 -``` java -EMProperties properties = EMProperties.builder() - .setAppkey("appkey") - .setClientId("Client ID") - .setClientSecret("ClientSecret") - .turnOffUserNameValidation() - .build(); -``` - - diff --git a/build.gradle b/build.gradle new file mode 100644 index 000000000..d02b3f72f --- /dev/null +++ b/build.gradle @@ -0,0 +1,168 @@ +apply plugin: 'idea' +apply plugin: 'eclipse' +apply plugin: 'java' +apply plugin: 'com.diffplug.spotless' + +group = 'com.easemob.im' +version = '1.0.0' + +buildscript { + repositories { + mavenCentral() + } + dependencies { + classpath 'com.android.tools.build:gradle:2.3.+' + classpath 'com.github.dcendents:android-maven-gradle-plugin:2.1' + classpath 'com.diffplug.spotless:spotless-plugin-gradle:6.11.0' + } +} + +repositories { + mavenCentral() +} +sourceSets { + main.java.srcDirs = ['src/main/java'] +} + +if(hasProperty('target') && target == 'android') { + + apply plugin: 'com.android.library' + apply plugin: 'com.github.dcendents.android-maven' + + android { + compileSdkVersion 25 + buildToolsVersion '25.0.2' + defaultConfig { + minSdkVersion 14 + targetSdkVersion 25 + } + compileOptions { + sourceCompatibility JavaVersion.VERSION_1_8 + targetCompatibility JavaVersion.VERSION_1_8 + } + + // Rename the aar correctly + libraryVariants.all { variant -> + variant.outputs.each { output -> + def outputFile = output.outputFile + if (outputFile != null && outputFile.name.endsWith('.aar')) { + def fileName = "${project.name}-${variant.baseName}-${version}.aar" + output.outputFile = new File(outputFile.parent, fileName) + } + } + } + + dependencies { + provided "jakarta.annotation:jakarta.annotation-api:$jakarta_annotation_version" + } + } + + afterEvaluate { + android.libraryVariants.all { variant -> + def task = project.tasks.create "jar${variant.name.capitalize()}", Jar + task.description = "Create jar artifact for ${variant.name}" + task.dependsOn variant.javaCompile + task.from variant.javaCompile.destinationDirectory + task.destinationDirectory = project.file("${project.buildDir}/outputs/jar") + task.archiveFileName = "${project.name}-${variant.baseName}-${version}.jar" + artifacts.add('archives', task) + } + } + + task sourcesJar(type: Jar) { + from android.sourceSets.main.java.srcDirs + classifier = 'sources' + } + + artifacts { + archives sourcesJar + } + +} else { + + apply plugin: 'java' + apply plugin: 'maven-publish' + + sourceCompatibility = JavaVersion.VERSION_1_8 + targetCompatibility = JavaVersion.VERSION_1_8 + + publishing { + publications { + maven(MavenPublication) { + artifactId = 'im-sdk-core' + from components.java + } + } + } + + task execute(type:JavaExec) { + main = System.getProperty('mainClass') + classpath = sourceSets.main.runtimeClasspath + } +} + +ext { + jakarta_annotation_version = "1.3.5" +} + +dependencies { + implementation 'io.swagger:swagger-annotations:1.6.8' + implementation "com.google.code.findbugs:jsr305:3.0.2" + implementation 'com.squareup.okhttp3:okhttp:4.10.0' + implementation 'com.squareup.okhttp3:logging-interceptor:4.10.0' + implementation 'com.google.code.gson:gson:2.9.1' + implementation 'io.gsonfire:gson-fire:1.9.0' + implementation 'javax.ws.rs:jsr311-api:1.1.1' + implementation 'javax.ws.rs:javax.ws.rs-api:2.1.1' + implementation 'org.openapitools:jackson-databind-nullable:0.2.6' + implementation group: 'org.apache.commons', name: 'commons-lang3', version: '3.12.0' + implementation "jakarta.annotation:jakarta.annotation-api:$jakarta_annotation_version" + testImplementation 'org.junit.jupiter:junit-jupiter-api:5.9.1' + testImplementation 'org.mockito:mockito-core:3.12.4' + testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.9.1' +} + +javadoc { + options.tags = [ "http.response.details:a:Http Response Details" ] +} + +// Use spotless plugin to automatically format code, remove unused import, etc +// To apply changes directly to the file, run `gradlew spotlessApply` +// Ref: https://github.com/diffplug/spotless/tree/main/plugin-gradle +spotless { + // comment out below to run spotless as part of the `check` task + enforceCheck false + + format 'misc', { + // define the files (e.g. '*.gradle', '*.md') to apply `misc` to + target '.gitignore' + + // define the steps to apply to those files + trimTrailingWhitespace() + indentWithSpaces() // Takes an integer argument if you don't like 4 + endWithNewline() + } + java { + // don't need to set target, it is inferred from java + + // apply a specific flavor of google-java-format + googleJavaFormat('1.8').aosp().reflowLongStrings() + + removeUnusedImports() + importOrder() + } +} + +test { + // Enable JUnit 5 (Gradle 4.6+). + useJUnitPlatform() + + // Always run tests, even when nothing changed. + dependsOn 'cleanTest' + + // Show test results. + testLogging { + events "passed", "skipped", "failed" + } + +} diff --git a/build.sbt b/build.sbt new file mode 100644 index 000000000..48e17171c --- /dev/null +++ b/build.sbt @@ -0,0 +1,28 @@ +lazy val root = (project in file(".")). + settings( + organization := "com.easemob.im", + name := "im-sdk-core", + version := "1.0.0", + scalaVersion := "2.11.4", + scalacOptions ++= Seq("-feature"), + javacOptions in compile ++= Seq("-Xlint:deprecation"), + publishArtifact in (Compile, packageDoc) := false, + resolvers += Resolver.mavenLocal, + libraryDependencies ++= Seq( + "io.swagger" % "swagger-annotations" % "1.6.5", + "com.squareup.okhttp3" % "okhttp" % "4.10.0", + "com.squareup.okhttp3" % "logging-interceptor" % "4.10.0", + "com.google.code.gson" % "gson" % "2.9.1", + "org.apache.commons" % "commons-lang3" % "3.12.0", + "javax.ws.rs" % "jsr311-api" % "1.1.1", + "javax.ws.rs" % "javax.ws.rs-api" % "2.1.1", + "org.openapitools" % "jackson-databind-nullable" % "0.2.6", + "io.gsonfire" % "gson-fire" % "1.9.0" % "compile", + "jakarta.annotation" % "jakarta.annotation-api" % "1.3.5" % "compile", + "com.google.code.findbugs" % "jsr305" % "3.0.2" % "compile", + "jakarta.annotation" % "jakarta.annotation-api" % "1.3.5" % "compile", + "org.junit.jupiter" % "junit-jupiter-api" % "5.9.1" % "test", + "com.novocode" % "junit-interface" % "0.10" % "test", + "org.mockito" % "mockito-core" % "3.12.4" % "test" + ) + ) diff --git a/git_push.sh b/git_push.sh new file mode 100644 index 000000000..f53a75d4f --- /dev/null +++ b/git_push.sh @@ -0,0 +1,57 @@ +#!/bin/sh +# ref: https://help.github.com/articles/adding-an-existing-project-to-github-using-the-command-line/ +# +# Usage example: /bin/sh ./git_push.sh wing328 openapi-petstore-perl "minor update" "gitlab.com" + +git_user_id=$1 +git_repo_id=$2 +release_note=$3 +git_host=$4 + +if [ "$git_host" = "" ]; then + git_host="github.com" + echo "[INFO] No command line input provided. Set \$git_host to $git_host" +fi + +if [ "$git_user_id" = "" ]; then + git_user_id="GIT_USER_ID" + echo "[INFO] No command line input provided. Set \$git_user_id to $git_user_id" +fi + +if [ "$git_repo_id" = "" ]; then + git_repo_id="GIT_REPO_ID" + echo "[INFO] No command line input provided. Set \$git_repo_id to $git_repo_id" +fi + +if [ "$release_note" = "" ]; then + release_note="Minor update" + echo "[INFO] No command line input provided. Set \$release_note to $release_note" +fi + +# Initialize the local directory as a Git repository +git init + +# Adds the files in the local repository and stages them for commit. +git add . + +# Commits the tracked changes and prepares them to be pushed to a remote repository. +git commit -m "$release_note" + +# Sets the new remote +git_remote=$(git remote) +if [ "$git_remote" = "" ]; then # git remote not defined + + if [ "$GIT_TOKEN" = "" ]; then + echo "[INFO] \$GIT_TOKEN (environment variable) is not set. Using the git credential in your environment." + git remote add origin https://${git_host}/${git_user_id}/${git_repo_id}.git + else + git remote add origin https://${git_user_id}:"${GIT_TOKEN}"@${git_host}/${git_user_id}/${git_repo_id}.git + fi + +fi + +git pull origin master + +# Pushes (Forces) the changes in the local repository up to the remote repository +echo "Git pushing to https://${git_host}/${git_user_id}/${git_repo_id}.git" +git push origin master 2>&1 | grep -v 'To https' diff --git a/gradle.properties b/gradle.properties new file mode 100644 index 000000000..a34085782 --- /dev/null +++ b/gradle.properties @@ -0,0 +1,6 @@ +# This file is automatically generated by OpenAPI Generator (https://github.com/openAPITools/openapi-generator). +# To include other gradle properties as part of the code generation process, please use the `gradleProperties` option. +# +# Gradle properties reference: https://docs.gradle.org/current/userguide/build_environment.html#sec:gradle_configuration_properties +# For example, uncomment below to build for Android +#target = android diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar new file mode 100644 index 000000000..7454180f2 Binary files /dev/null and b/gradle/wrapper/gradle-wrapper.jar differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties new file mode 100644 index 000000000..ffed3a254 --- /dev/null +++ b/gradle/wrapper/gradle-wrapper.properties @@ -0,0 +1,5 @@ +distributionBase=GRADLE_USER_HOME +distributionPath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-7.2-bin.zip +zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists diff --git a/gradlew b/gradlew new file mode 100644 index 000000000..005bcde04 --- /dev/null +++ b/gradlew @@ -0,0 +1,234 @@ +#!/bin/sh + +# +# Copyright © 2015-2021 the original authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +############################################################################## +# +# Gradle start up script for POSIX generated by Gradle. +# +# Important for running: +# +# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is +# noncompliant, but you have some other compliant shell such as ksh or +# bash, then to run this script, type that shell name before the whole +# command line, like: +# +# ksh Gradle +# +# Busybox and similar reduced shells will NOT work, because this script +# requires all of these POSIX shell features: +# * functions; +# * expansions «$var», «${var}», «${var:-default}», «${var+SET}», +# «${var#prefix}», «${var%suffix}», and «$( cmd )»; +# * compound commands having a testable exit status, especially «case»; +# * various built-in commands including «command», «set», and «ulimit». +# +# Important for patching: +# +# (2) This script targets any POSIX shell, so it avoids extensions provided +# by Bash, Ksh, etc; in particular arrays are avoided. +# +# The "traditional" practice of packing multiple parameters into a +# space-separated string is a well documented source of bugs and security +# problems, so this is (mostly) avoided, by progressively accumulating +# options in "$@", and eventually passing that to Java. +# +# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS, +# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly; +# see the in-line comments for details. +# +# There are tweaks for specific operating systems such as AIX, CygWin, +# Darwin, MinGW, and NonStop. +# +# (3) This script is generated from the Groovy template +# https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# within the Gradle project. +# +# You can find Gradle at https://github.com/gradle/gradle/. +# +############################################################################## + +# Attempt to set APP_HOME + +# Resolve links: $0 may be a link +app_path=$0 + +# Need this for daisy-chained symlinks. +while + APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path + [ -h "$app_path" ] +do + ls=$( ls -ld "$app_path" ) + link=${ls#*' -> '} + case $link in #( + /*) app_path=$link ;; #( + *) app_path=$APP_HOME$link ;; + esac +done + +APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit + +APP_NAME="Gradle" +APP_BASE_NAME=${0##*/} + +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +DEFAULT_JVM_OPTS='-Dfile.encoding=UTF-8 "-Xmx64m" "-Xms64m"' + +# Use the maximum available, or set MAX_FD != -1 to use that value. +MAX_FD=maximum + +warn () { + echo "$*" +} >&2 + +die () { + echo + echo "$*" + echo + exit 1 +} >&2 + +# OS specific support (must be 'true' or 'false'). +cygwin=false +msys=false +darwin=false +nonstop=false +case "$( uname )" in #( + CYGWIN* ) cygwin=true ;; #( + Darwin* ) darwin=true ;; #( + MSYS* | MINGW* ) msys=true ;; #( + NONSTOP* ) nonstop=true ;; +esac + +CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar + + +# Determine the Java command to use to start the JVM. +if [ -n "$JAVA_HOME" ] ; then + if [ -x "$JAVA_HOME/jre/sh/java" ] ; then + # IBM's JDK on AIX uses strange locations for the executables + JAVACMD=$JAVA_HOME/jre/sh/java + else + JAVACMD=$JAVA_HOME/bin/java + fi + if [ ! -x "$JAVACMD" ] ; then + die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." + fi +else + JAVACMD=java + which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." +fi + +# Increase the maximum file descriptors if we can. +if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then + case $MAX_FD in #( + max*) + MAX_FD=$( ulimit -H -n ) || + warn "Could not query maximum file descriptor limit" + esac + case $MAX_FD in #( + '' | soft) :;; #( + *) + ulimit -n "$MAX_FD" || + warn "Could not set maximum file descriptor limit to $MAX_FD" + esac +fi + +# Collect all arguments for the java command, stacking in reverse order: +# * args from the command line +# * the main class name +# * -classpath +# * -D...appname settings +# * --module-path (only if needed) +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables. + +# For Cygwin or MSYS, switch paths to Windows format before running java +if "$cygwin" || "$msys" ; then + APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) + CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) + + JAVACMD=$( cygpath --unix "$JAVACMD" ) + + # Now convert the arguments - kludge to limit ourselves to /bin/sh + for arg do + if + case $arg in #( + -*) false ;; # don't mess with options #( + /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath + [ -e "$t" ] ;; #( + *) false ;; + esac + then + arg=$( cygpath --path --ignore --mixed "$arg" ) + fi + # Roll the args list around exactly as many times as the number of + # args, so each arg winds up back in the position where it started, but + # possibly modified. + # + # NB: a `for` loop captures its iteration list before it begins, so + # changing the positional parameters here affects neither the number of + # iterations, nor the values presented in `arg`. + shift # remove old arg + set -- "$@" "$arg" # push replacement arg + done +fi + +# Collect all arguments for the java command; +# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of +# shell script including quotes and variable substitutions, so put them in +# double quotes to make sure that they get re-expanded; and +# * put everything else in single quotes, so that it's not re-expanded. + +set -- \ + "-Dorg.gradle.appname=$APP_BASE_NAME" \ + -classpath "$CLASSPATH" \ + org.gradle.wrapper.GradleWrapperMain \ + "$@" + +# Use "xargs" to parse quoted args. +# +# With -n1 it outputs one arg per line, with the quotes and backslashes removed. +# +# In Bash we could simply go: +# +# readarray ARGS < <( xargs -n1 <<<"$var" ) && +# set -- "${ARGS[@]}" "$@" +# +# but POSIX shell has neither arrays nor command substitution, so instead we +# post-process each arg (as a line of input to sed) to backslash-escape any +# character that might be a shell metacharacter, then use eval to reverse +# that process (while maintaining the separation between arguments), and wrap +# the whole thing up as a single "set" statement. +# +# This will of course break if any of these variables contains a newline or +# an unmatched quote. +# + +eval "set -- $( + printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" | + xargs -n1 | + sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' | + tr '\n' ' ' + )" '"$@"' + +exec "$JAVACMD" "$@" diff --git a/gradlew.bat b/gradlew.bat new file mode 100644 index 000000000..6a68175eb --- /dev/null +++ b/gradlew.bat @@ -0,0 +1,89 @@ +@rem +@rem Copyright 2015 the original author or authors. +@rem +@rem Licensed under the Apache License, Version 2.0 (the "License"); +@rem you may not use this file except in compliance with the License. +@rem You may obtain a copy of the License at +@rem +@rem https://www.apache.org/licenses/LICENSE-2.0 +@rem +@rem Unless required by applicable law or agreed to in writing, software +@rem distributed under the License is distributed on an "AS IS" BASIS, +@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +@rem See the License for the specific language governing permissions and +@rem limitations under the License. +@rem + +@if "%DEBUG%" == "" @echo off +@rem ########################################################################## +@rem +@rem Gradle startup script for Windows +@rem +@rem ########################################################################## + +@rem Set local scope for the variables with windows NT shell +if "%OS%"=="Windows_NT" setlocal + +set DIRNAME=%~dp0 +if "%DIRNAME%" == "" set DIRNAME=. +set APP_BASE_NAME=%~n0 +set APP_HOME=%DIRNAME% + +@rem Resolve any "." and ".." in APP_HOME to make it shorter. +for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi + +@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +set DEFAULT_JVM_OPTS=-Dfile.encoding=UTF-8 "-Xmx64m" "-Xms64m" + +@rem Find java.exe +if defined JAVA_HOME goto findJavaFromJavaHome + +set JAVA_EXE=java.exe +%JAVA_EXE% -version >NUL 2>&1 +if "%ERRORLEVEL%" == "0" goto execute + +echo. +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:findJavaFromJavaHome +set JAVA_HOME=%JAVA_HOME:"=% +set JAVA_EXE=%JAVA_HOME%/bin/java.exe + +if exist "%JAVA_EXE%" goto execute + +echo. +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:execute +@rem Setup the command line + +set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar + + +@rem Execute Gradle +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* + +:end +@rem End local scope for the variables with windows NT shell +if "%ERRORLEVEL%"=="0" goto mainEnd + +:fail +rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of +rem the _cmd.exe /c_ return code! +if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 +exit /b 1 + +:mainEnd +if "%OS%"=="Windows_NT" endlocal + +:omega diff --git a/im-sdk-cli/README.md b/im-sdk-cli/README.md deleted file mode 100644 index 10e1385c5..000000000 --- a/im-sdk-cli/README.md +++ /dev/null @@ -1,186 +0,0 @@ -# Easemob IM CLI - -**Easemob IM CLI**是基于**Easemob IM Java SDK**开发的控制台项目,旨在为开发者提供方便快捷的命令行界面来调用服务端API,同时也是**Easemob IM Java SDK**的使用示例。 - -## 快速开始 - -### 安装 - -#### 1. 自动安装 - -(1) 执行安装脚本 -```bash -sh -c "$(curl -fsSL https://raw.githubusercontent.com/easemob/easemob-im-server-sdk/master/im-sdk-cli/install.sh)" -``` - -或: - -```bash -sh -c "$(wget https://raw.githubusercontent.com/easemob/easemob-im-server-sdk/master/im-sdk-cli/install.sh -O -)" -``` - -(2) 添加alias - -向`~/.zshrc`或`~/.bashrc`中添加以下命令(取决于您使用的SHELL): - -```bash -alias im='java -jar ~/.easemob/im-sdk-cli.jar' -source ~/.easemob/completion.sh -``` - -(3) 刷新配置 - -```bash -source ~/.zshrc 或 ~/.bashrc -``` - -这将会将程序安装至`~/.easemob/`中,并将相关命令加入系统环境变量 - -#### 2. 手动安装 - -(1) 编译打包 -```bash -git clone https://github.com/easemob/easemob-im-server-sdk.git -cd /easemob-im-server-sdk -mvn package -Dmaven.test.skip=true -mkdir ~/.easemob -cp im-sdk-cli/target/im-sdk-cli-x.x.x.jar ~/.easemob/im-sdk-cli.jar -cp im-sdk-cli/target/completion.sh ~/.easemob/completion.sh -``` - -(2) 添加alias - -向`~/.zshrc`或`~/.bashrc`中添加以下命令(取决于您使用的SHELL): - -```bash -alias im='java -jar ~/.easemob/im-sdk-cli.jar' -source ~/.easemob/completion.sh -``` - -(3) 刷新配置 - -```bash -source ~/.zshrc 或 ~/.bashrc -``` - -### 配置 - -IM CLI 会从`~/.easemob/config.properties`中读取配置文件,您需要从[环信通讯云管理后台](https://console.easemob.com/)来获取您的应用开发者密钥并填写到此处。 - -```properties -vim ~/.easemob/config.properties - -im.appkey=your-appkey -im.client-id=your-app-client-id -im.client-secret=your-app-client-secret -``` - -### 体验 - -```bash -# 创建一个用户,用户名为test-user,密码为test-password -❯ im create user test-user test-password - -done -``` - -```bash -# 修改用户名为test-user的登录密码 -❯ im update user test-user --password=new-password - -done -``` - -```bash -# 获取用户名为test-user的用户信息 -❯ im get user test-user - -username: test-user -canLogin: true -``` - -```bash -# 删除用户名为test-user的用户 -❯ im delete user test-user - -done -``` - -## 使用方法 - -### 1. 入口命令 - -`im`是入口命令,输入`im -h `查看帮助文档 - -~~~bash -# 查看入口命令帮助 -❯ im -h - -Usage: im [-hvV] [COMMAND] - -h, --help Show this help message and exit. - -v, --verbose - -V, --version Print version information and exit. -Commands: - create Create a resource. - get Get a resource. - delete Delete a resource. - update Update a resource. -~~~ - -从提示中可知,`im`命令采用面向资源的操作方式,由`create`、`get`、`delete`、`update`四个子命令来表示对资源的`添加`、`查询`、`删除`和`更新`。 - -### 2. 操作 - -> 提示:您可在任意命令后输入`-h`或`--help`来查看详细使用帮助,如支持的操作、可操作的资源、命令参数等。 - -```bash -# 查看可查询的资源 -❯ im get -h - -Usage: im get [COMMAND] -Get a resource. -Commands: - admin List admin - attachment Download attachment by id. - block List blocked user. - contact List contacts of a user. - group Get a group's info or list groups - member List group or room members, not include the owner and admins. - message List or count messages. - room Get a room's info or list rooms - session Get specific user's online status. - user Get a user's info or list users. -``` - -### 3. 资源 - -```bash -# 查看创建用户所需的参数 -❯ im create user -h - -Usage: im create user [-hV] -Create a user. - the username - the password - -h, --help Show this help message and exit. - -V, --version Print version information and exit. -``` - -#### 资源解释 - -- user:用户 -- group:群组 -- room:聊天室 -- member:群组/聊天室成员 -- block:黑名单、禁言 -- message:消息 -- contact:好友 -- attachment:附件 -- admin:群组/聊天管理员、超级管理员 -- session:用户在线状态 - -## 完成度 - -目前CLI支持了常用的API,后续会持续完善。 - -如果您在使用时发生了错误,或者对此项目有一些建议,欢迎您在Issue中与我们讨论,您的反馈对我们至关重要。 \ No newline at end of file diff --git a/im-sdk-cli/completion.sh b/im-sdk-cli/completion.sh deleted file mode 100644 index 0a39ab616..000000000 --- a/im-sdk-cli/completion.sh +++ /dev/null @@ -1,1172 +0,0 @@ -#!/usr/bin/env bash -# -# im Bash Completion -# ======================= -# -# Bash completion support for the `im` command, -# generated by [picocli](http://picocli.info/) version 4.6.1. -# -# Installation -# ------------ -# -# 1. Source all completion scripts in your .bash_profile -# -# cd $YOUR_APP_HOME/bin -# for f in $(find . -name "*_completion"); do line=". $(pwd)/$f"; grep "$line" ~/.bash_profile || echo "$line" >> ~/.bash_profile; done -# -# 2. Open a new bash console, and type `im [TAB][TAB]` -# -# 1a. Alternatively, if you have [bash-completion](https://github.com/scop/bash-completion) installed: -# Place this file in a `bash-completion.d` folder: -# -# * /etc/bash-completion.d -# * /usr/local/etc/bash-completion.d -# * ~/bash-completion.d -# -# Documentation -# ------------- -# The script is called by bash whenever [TAB] or [TAB][TAB] is pressed after -# 'im (..)'. By reading entered command line parameters, -# it determines possible bash completions and writes them to the COMPREPLY variable. -# Bash then completes the user input if only one entry is listed in the variable or -# shows the options if more than one is listed in COMPREPLY. -# -# References -# ---------- -# [1] http://stackoverflow.com/a/12495480/1440785 -# [2] http://tiswww.case.edu/php/chet/bash/FAQ -# [3] https://www.gnu.org/software/bash/manual/html_node/The-Shopt-Builtin.html -# [4] http://zsh.sourceforge.net/Doc/Release/Options.html#index-COMPLETE_005fALIASES -# [5] https://stackoverflow.com/questions/17042057/bash-check-element-in-array-for-elements-in-another-array/17042655#17042655 -# [6] https://www.gnu.org/software/bash/manual/html_node/Programmable-Completion.html#Programmable-Completion -# [7] https://stackoverflow.com/questions/3249432/can-a-bash-tab-completion-script-be-used-in-zsh/27853970#27853970 -# - -if [ -n "$BASH_VERSION" ]; then - # Enable programmable completion facilities when using bash (see [3]) - shopt -s progcomp -elif [ -n "$ZSH_VERSION" ]; then - # Make alias a distinct command for completion purposes when using zsh (see [4]) - setopt COMPLETE_ALIASES - alias compopt=complete - - # Enable bash completion in zsh (see [7]) - autoload -U +X compinit && compinit - autoload -U +X bashcompinit && bashcompinit -fi - -# CompWordsContainsArray takes an array and then checks -# if all elements of this array are in the global COMP_WORDS array. -# -# Returns zero (no error) if all elements of the array are in the COMP_WORDS array, -# otherwise returns 1 (error). -function CompWordsContainsArray() { - declare -a localArray - localArray=("$@") - local findme - for findme in "${localArray[@]}"; do - if ElementNotInCompWords "$findme"; then return 1; fi - done - return 0 -} -function ElementNotInCompWords() { - local findme="$1" - local element - for element in "${COMP_WORDS[@]}"; do - if [[ "$findme" = "$element" ]]; then return 1; fi - done - return 0 -} - -# The `currentPositionalIndex` function calculates the index of the current positional parameter. -# -# currentPositionalIndex takes three parameters: -# the command name, -# a space-separated string with the names of options that take a parameter, and -# a space-separated string with the names of boolean options (that don't take any params). -# When done, this function echos the current positional index to std_out. -# -# Example usage: -# local currIndex=$(currentPositionalIndex "mysubcommand" "$ARG_OPTS" "$FLAG_OPTS") -function currentPositionalIndex() { - local commandName="$1" - local optionsWithArgs="$2" - local booleanOptions="$3" - local previousWord - local result=0 - - for i in $(seq $((COMP_CWORD - 1)) -1 0); do - previousWord=${COMP_WORDS[i]} - if [ "${previousWord}" = "$commandName" ]; then - break - fi - if [[ "${optionsWithArgs}" =~ ${previousWord} ]]; then - ((result-=2)) # Arg option and its value not counted as positional param - elif [[ "${booleanOptions}" =~ ${previousWord} ]]; then - ((result-=1)) # Flag option itself not counted as positional param - fi - ((result++)) - done - echo "$result" -} - -# Bash completion entry point function. -# _complete_im finds which commands and subcommands have been specified -# on the command line and delegates to the appropriate function -# to generate possible options and subcommands for the last specified subcommand. -function _complete_im() { - local cmds0=(create) - local cmds1=(get) - local cmds2=(delete) - local cmds3=(update) - local cmds4=(create admin) - local cmds5=(create attachment) - local cmds6=(create block) - local cmds7=(create contact) - local cmds8=(create group) - local cmds9=(create member) - local cmds10=(create message) - local cmds11=(create room) - local cmds12=(create user) - local cmds13=(get admin) - local cmds14=(get attachment) - local cmds15=(get block) - local cmds16=(get contact) - local cmds17=(get group) - local cmds18=(get member) - local cmds19=(get message) - local cmds20=(get room) - local cmds21=(get session) - local cmds22=(get user) - local cmds23=(delete admin) - local cmds24=(delete block) - local cmds25=(delete contact) - local cmds26=(delete group) - local cmds27=(delete member) - local cmds28=(delete room) - local cmds29=(delete session) - local cmds30=(delete user) - local cmds31=(update group) - local cmds32=(update user) - local cmds33=(update room) - - if CompWordsContainsArray "${cmds33[@]}"; then _picocli_im_update_room; return $?; fi - if CompWordsContainsArray "${cmds32[@]}"; then _picocli_im_update_user; return $?; fi - if CompWordsContainsArray "${cmds31[@]}"; then _picocli_im_update_group; return $?; fi - if CompWordsContainsArray "${cmds30[@]}"; then _picocli_im_delete_user; return $?; fi - if CompWordsContainsArray "${cmds29[@]}"; then _picocli_im_delete_session; return $?; fi - if CompWordsContainsArray "${cmds28[@]}"; then _picocli_im_delete_room; return $?; fi - if CompWordsContainsArray "${cmds27[@]}"; then _picocli_im_delete_member; return $?; fi - if CompWordsContainsArray "${cmds26[@]}"; then _picocli_im_delete_group; return $?; fi - if CompWordsContainsArray "${cmds25[@]}"; then _picocli_im_delete_contact; return $?; fi - if CompWordsContainsArray "${cmds24[@]}"; then _picocli_im_delete_block; return $?; fi - if CompWordsContainsArray "${cmds23[@]}"; then _picocli_im_delete_admin; return $?; fi - if CompWordsContainsArray "${cmds22[@]}"; then _picocli_im_get_user; return $?; fi - if CompWordsContainsArray "${cmds21[@]}"; then _picocli_im_get_session; return $?; fi - if CompWordsContainsArray "${cmds20[@]}"; then _picocli_im_get_room; return $?; fi - if CompWordsContainsArray "${cmds19[@]}"; then _picocli_im_get_message; return $?; fi - if CompWordsContainsArray "${cmds18[@]}"; then _picocli_im_get_member; return $?; fi - if CompWordsContainsArray "${cmds17[@]}"; then _picocli_im_get_group; return $?; fi - if CompWordsContainsArray "${cmds16[@]}"; then _picocli_im_get_contact; return $?; fi - if CompWordsContainsArray "${cmds15[@]}"; then _picocli_im_get_block; return $?; fi - if CompWordsContainsArray "${cmds14[@]}"; then _picocli_im_get_attachment; return $?; fi - if CompWordsContainsArray "${cmds13[@]}"; then _picocli_im_get_admin; return $?; fi - if CompWordsContainsArray "${cmds12[@]}"; then _picocli_im_create_user; return $?; fi - if CompWordsContainsArray "${cmds11[@]}"; then _picocli_im_create_room; return $?; fi - if CompWordsContainsArray "${cmds10[@]}"; then _picocli_im_create_message; return $?; fi - if CompWordsContainsArray "${cmds9[@]}"; then _picocli_im_create_member; return $?; fi - if CompWordsContainsArray "${cmds8[@]}"; then _picocli_im_create_group; return $?; fi - if CompWordsContainsArray "${cmds7[@]}"; then _picocli_im_create_contact; return $?; fi - if CompWordsContainsArray "${cmds6[@]}"; then _picocli_im_create_block; return $?; fi - if CompWordsContainsArray "${cmds5[@]}"; then _picocli_im_create_attachment; return $?; fi - if CompWordsContainsArray "${cmds4[@]}"; then _picocli_im_create_admin; return $?; fi - if CompWordsContainsArray "${cmds3[@]}"; then _picocli_im_update; return $?; fi - if CompWordsContainsArray "${cmds2[@]}"; then _picocli_im_delete; return $?; fi - if CompWordsContainsArray "${cmds1[@]}"; then _picocli_im_get; return $?; fi - if CompWordsContainsArray "${cmds0[@]}"; then _picocli_im_create; return $?; fi - - # No subcommands were specified; generate completions for the top-level command. - _picocli_im; return $?; -} - -# Generates completions for the options and subcommands of the `im` command. -function _picocli_im() { - # Get completion data - local curr_word=${COMP_WORDS[COMP_CWORD]} - - local commands="create get delete update" - local flag_opts="-v --verbose -h --help -V --version" - local arg_opts="" - - if [[ "${curr_word}" == -* ]]; then - COMPREPLY=( $(compgen -W "${flag_opts} ${arg_opts}" -- "${curr_word}") ) - else - local positionals="" - COMPREPLY=( $(compgen -W "${commands} ${positionals}" -- "${curr_word}") ) - fi -} - -# Generates completions for the options and subcommands of the `create` subcommand. -function _picocli_im_create() { - # Get completion data - local curr_word=${COMP_WORDS[COMP_CWORD]} - - local commands="admin attachment block contact group member message room user" - local flag_opts="-h --help -V --version" - local arg_opts="" - - if [[ "${curr_word}" == -* ]]; then - COMPREPLY=( $(compgen -W "${flag_opts} ${arg_opts}" -- "${curr_word}") ) - else - local positionals="" - COMPREPLY=( $(compgen -W "${commands} ${positionals}" -- "${curr_word}") ) - fi -} - -# Generates completions for the options and subcommands of the `get` subcommand. -function _picocli_im_get() { - # Get completion data - local curr_word=${COMP_WORDS[COMP_CWORD]} - - local commands="admin attachment block contact group member message room session user" - local flag_opts="-h --help -V --version" - local arg_opts="" - - if [[ "${curr_word}" == -* ]]; then - COMPREPLY=( $(compgen -W "${flag_opts} ${arg_opts}" -- "${curr_word}") ) - else - local positionals="" - COMPREPLY=( $(compgen -W "${commands} ${positionals}" -- "${curr_word}") ) - fi -} - -# Generates completions for the options and subcommands of the `delete` subcommand. -function _picocli_im_delete() { - # Get completion data - local curr_word=${COMP_WORDS[COMP_CWORD]} - - local commands="admin block contact group member room session user" - local flag_opts="-h --help -V --version" - local arg_opts="" - - if [[ "${curr_word}" == -* ]]; then - COMPREPLY=( $(compgen -W "${flag_opts} ${arg_opts}" -- "${curr_word}") ) - else - local positionals="" - COMPREPLY=( $(compgen -W "${commands} ${positionals}" -- "${curr_word}") ) - fi -} - -# Generates completions for the options and subcommands of the `update` subcommand. -function _picocli_im_update() { - # Get completion data - local curr_word=${COMP_WORDS[COMP_CWORD]} - - local commands="group user room" - local flag_opts="-h --help -V --version" - local arg_opts="" - - if [[ "${curr_word}" == -* ]]; then - COMPREPLY=( $(compgen -W "${flag_opts} ${arg_opts}" -- "${curr_word}") ) - else - local positionals="" - COMPREPLY=( $(compgen -W "${commands} ${positionals}" -- "${curr_word}") ) - fi -} - -# Generates completions for the options and subcommands of the `admin` subcommand. -function _picocli_im_create_admin() { - # Get completion data - local curr_word=${COMP_WORDS[COMP_CWORD]} - local prev_word=${COMP_WORDS[COMP_CWORD-1]} - - local commands="" - local flag_opts="-h --help -V --version --super" - local arg_opts="--group --room" - - compopt +o default - - case ${prev_word} in - --group) - return - ;; - --room) - return - ;; - esac - - if [[ "${curr_word}" == -* ]]; then - COMPREPLY=( $(compgen -W "${flag_opts} ${arg_opts}" -- "${curr_word}") ) - else - local positionals="" - COMPREPLY=( $(compgen -W "${commands} ${positionals}" -- "${curr_word}") ) - fi -} - -# Generates completions for the options and subcommands of the `attachment` subcommand. -function _picocli_im_create_attachment() { - # Get completion data - local curr_word=${COMP_WORDS[COMP_CWORD]} - local prev_word=${COMP_WORDS[COMP_CWORD-1]} - - local commands="" - local flag_opts="-h --help -V --version" - local arg_opts="-f" - - compopt +o default - - case ${prev_word} in - -f) - compopt -o filenames - COMPREPLY=( $( compgen -f -- "${curr_word}" ) ) # files - return $? - ;; - esac - - if [[ "${curr_word}" == -* ]]; then - COMPREPLY=( $(compgen -W "${flag_opts} ${arg_opts}" -- "${curr_word}") ) - else - local positionals="" - COMPREPLY=( $(compgen -W "${commands} ${positionals}" -- "${curr_word}") ) - fi -} - -# Generates completions for the options and subcommands of the `block` subcommand. -function _picocli_im_create_block() { - # Get completion data - local curr_word=${COMP_WORDS[COMP_CWORD]} - local prev_word=${COMP_WORDS[COMP_CWORD-1]} - - local commands="" - local flag_opts="-h --help -V --version --login" - local arg_opts="--msg-to-user --msg-to-group --msg-to-room --join-group --join-room --duration" - - compopt +o default - - case ${prev_word} in - --msg-to-user) - return - ;; - --msg-to-group) - return - ;; - --msg-to-room) - return - ;; - --join-group) - return - ;; - --join-room) - return - ;; - --duration) - return - ;; - esac - - if [[ "${curr_word}" == -* ]]; then - COMPREPLY=( $(compgen -W "${flag_opts} ${arg_opts}" -- "${curr_word}") ) - else - local positionals="" - COMPREPLY=( $(compgen -W "${commands} ${positionals}" -- "${curr_word}") ) - fi -} - -# Generates completions for the options and subcommands of the `contact` subcommand. -function _picocli_im_create_contact() { - # Get completion data - local curr_word=${COMP_WORDS[COMP_CWORD]} - - local commands="" - local flag_opts="-h --help -V --version" - local arg_opts="" - - if [[ "${curr_word}" == -* ]]; then - COMPREPLY=( $(compgen -W "${flag_opts} ${arg_opts}" -- "${curr_word}") ) - else - local positionals="" - COMPREPLY=( $(compgen -W "${commands} ${positionals}" -- "${curr_word}") ) - fi -} - -# Generates completions for the options and subcommands of the `group` subcommand. -function _picocli_im_create_group() { - # Get completion data - local curr_word=${COMP_WORDS[COMP_CWORD]} - local prev_word=${COMP_WORDS[COMP_CWORD-1]} - - local commands="" - local flag_opts="-h --help -V --version --private --can-member-invite" - local arg_opts="--owner --name --description --max-members" - - compopt +o default - - case ${prev_word} in - --owner) - return - ;; - --name) - return - ;; - --description) - return - ;; - --max-members) - return - ;; - esac - - if [[ "${curr_word}" == -* ]]; then - COMPREPLY=( $(compgen -W "${flag_opts} ${arg_opts}" -- "${curr_word}") ) - else - local positionals="" - COMPREPLY=( $(compgen -W "${commands} ${positionals}" -- "${curr_word}") ) - fi -} - -# Generates completions for the options and subcommands of the `member` subcommand. -function _picocli_im_create_member() { - # Get completion data - local curr_word=${COMP_WORDS[COMP_CWORD]} - local prev_word=${COMP_WORDS[COMP_CWORD-1]} - - local commands="" - local flag_opts="-h --help -V --version" - local arg_opts="--to-group --to-room" - - compopt +o default - - case ${prev_word} in - --to-group) - return - ;; - --to-room) - return - ;; - esac - - if [[ "${curr_word}" == -* ]]; then - COMPREPLY=( $(compgen -W "${flag_opts} ${arg_opts}" -- "${curr_word}") ) - else - local positionals="" - COMPREPLY=( $(compgen -W "${commands} ${positionals}" -- "${curr_word}") ) - fi -} - -# Generates completions for the options and subcommands of the `message` subcommand. -function _picocli_im_create_message() { - # Get completion data - local curr_word=${COMP_WORDS[COMP_CWORD]} - local prev_word=${COMP_WORDS[COMP_CWORD-1]} - - local commands="" - local flag_opts="-h --help -V --version" - local arg_opts="--from --to-user --to-group --to-room --text --img --audio --video --loc --file --cmd --custom --secret --filename --bytes --duration --ext --param" - - compopt +o default - - case ${prev_word} in - --from) - return - ;; - --to-user) - return - ;; - --to-group) - return - ;; - --to-room) - return - ;; - --text) - return - ;; - --img) - return - ;; - --audio) - return - ;; - --video) - return - ;; - --loc) - return - ;; - --file) - return - ;; - --cmd) - return - ;; - --custom) - return - ;; - --secret) - return - ;; - --filename) - return - ;; - --bytes) - return - ;; - --duration) - return - ;; - --ext) - return - ;; - --param) - return - ;; - esac - - if [[ "${curr_word}" == -* ]]; then - COMPREPLY=( $(compgen -W "${flag_opts} ${arg_opts}" -- "${curr_word}") ) - else - local positionals="" - COMPREPLY=( $(compgen -W "${commands} ${positionals}" -- "${curr_word}") ) - fi -} - -# Generates completions for the options and subcommands of the `room` subcommand. -function _picocli_im_create_room() { - # Get completion data - local curr_word=${COMP_WORDS[COMP_CWORD]} - local prev_word=${COMP_WORDS[COMP_CWORD-1]} - - local commands="" - local flag_opts="-h --help -V --version" - local arg_opts="--name --owner --description --max-members" - - compopt +o default - - case ${prev_word} in - --name) - return - ;; - --owner) - return - ;; - --description) - return - ;; - --max-members) - return - ;; - esac - - if [[ "${curr_word}" == -* ]]; then - COMPREPLY=( $(compgen -W "${flag_opts} ${arg_opts}" -- "${curr_word}") ) - else - local positionals="" - COMPREPLY=( $(compgen -W "${commands} ${positionals}" -- "${curr_word}") ) - fi -} - -# Generates completions for the options and subcommands of the `user` subcommand. -function _picocli_im_create_user() { - # Get completion data - local curr_word=${COMP_WORDS[COMP_CWORD]} - - local commands="" - local flag_opts="-h --help -V --version" - local arg_opts="" - - if [[ "${curr_word}" == -* ]]; then - COMPREPLY=( $(compgen -W "${flag_opts} ${arg_opts}" -- "${curr_word}") ) - else - local positionals="" - COMPREPLY=( $(compgen -W "${commands} ${positionals}" -- "${curr_word}") ) - fi -} - -# Generates completions for the options and subcommands of the `admin` subcommand. -function _picocli_im_get_admin() { - # Get completion data - local curr_word=${COMP_WORDS[COMP_CWORD]} - local prev_word=${COMP_WORDS[COMP_CWORD-1]} - - local commands="" - local flag_opts="-h --help -V --version --super" - local arg_opts="--group --room" - - compopt +o default - - case ${prev_word} in - --group) - return - ;; - --room) - return - ;; - esac - - if [[ "${curr_word}" == -* ]]; then - COMPREPLY=( $(compgen -W "${flag_opts} ${arg_opts}" -- "${curr_word}") ) - else - local positionals="" - COMPREPLY=( $(compgen -W "${commands} ${positionals}" -- "${curr_word}") ) - fi -} - -# Generates completions for the options and subcommands of the `attachment` subcommand. -function _picocli_im_get_attachment() { - # Get completion data - local curr_word=${COMP_WORDS[COMP_CWORD]} - local prev_word=${COMP_WORDS[COMP_CWORD-1]} - - local commands="" - local flag_opts="-h --help -V --version" - local arg_opts="-o" - - compopt +o default - - case ${prev_word} in - -o) - compopt -o filenames - COMPREPLY=( $( compgen -f -- "${curr_word}" ) ) # files - return $? - ;; - esac - - if [[ "${curr_word}" == -* ]]; then - COMPREPLY=( $(compgen -W "${flag_opts} ${arg_opts}" -- "${curr_word}") ) - else - local positionals="" - COMPREPLY=( $(compgen -W "${commands} ${positionals}" -- "${curr_word}") ) - fi -} - -# Generates completions for the options and subcommands of the `block` subcommand. -function _picocli_im_get_block() { - # Get completion data - local curr_word=${COMP_WORDS[COMP_CWORD]} - local prev_word=${COMP_WORDS[COMP_CWORD-1]} - - local commands="" - local flag_opts="-h --help -V --version --login" - local arg_opts="--msg-to-user --msg-to-group --msg-to-room --join-group --join-room" - - compopt +o default - - case ${prev_word} in - --msg-to-user) - return - ;; - --msg-to-group) - return - ;; - --msg-to-room) - return - ;; - --join-group) - return - ;; - --join-room) - return - ;; - esac - - if [[ "${curr_word}" == -* ]]; then - COMPREPLY=( $(compgen -W "${flag_opts} ${arg_opts}" -- "${curr_word}") ) - else - local positionals="" - COMPREPLY=( $(compgen -W "${commands} ${positionals}" -- "${curr_word}") ) - fi -} - -# Generates completions for the options and subcommands of the `contact` subcommand. -function _picocli_im_get_contact() { - # Get completion data - local curr_word=${COMP_WORDS[COMP_CWORD]} - - local commands="" - local flag_opts="-h --help -V --version" - local arg_opts="" - - if [[ "${curr_word}" == -* ]]; then - COMPREPLY=( $(compgen -W "${flag_opts} ${arg_opts}" -- "${curr_word}") ) - else - local positionals="" - COMPREPLY=( $(compgen -W "${commands} ${positionals}" -- "${curr_word}") ) - fi -} - -# Generates completions for the options and subcommands of the `group` subcommand. -function _picocli_im_get_group() { - # Get completion data - local curr_word=${COMP_WORDS[COMP_CWORD]} - local prev_word=${COMP_WORDS[COMP_CWORD-1]} - - local commands="" - local flag_opts="-h --help -V --version" - local arg_opts="--have-user --limit --cursor" - - compopt +o default - - case ${prev_word} in - --have-user) - return - ;; - --limit) - return - ;; - --cursor) - return - ;; - esac - - if [[ "${curr_word}" == -* ]]; then - COMPREPLY=( $(compgen -W "${flag_opts} ${arg_opts}" -- "${curr_word}") ) - else - local positionals="" - COMPREPLY=( $(compgen -W "${commands} ${positionals}" -- "${curr_word}") ) - fi -} - -# Generates completions for the options and subcommands of the `member` subcommand. -function _picocli_im_get_member() { - # Get completion data - local curr_word=${COMP_WORDS[COMP_CWORD]} - local prev_word=${COMP_WORDS[COMP_CWORD-1]} - - local commands="" - local flag_opts="-h --help -V --version" - local arg_opts="--group --room --limit --cursor" - - compopt +o default - - case ${prev_word} in - --group) - return - ;; - --room) - return - ;; - --limit) - return - ;; - --cursor) - return - ;; - esac - - if [[ "${curr_word}" == -* ]]; then - COMPREPLY=( $(compgen -W "${flag_opts} ${arg_opts}" -- "${curr_word}") ) - else - local positionals="" - COMPREPLY=( $(compgen -W "${commands} ${positionals}" -- "${curr_word}") ) - fi -} - -# Generates completions for the options and subcommands of the `message` subcommand. -function _picocli_im_get_message() { - # Get completion data - local curr_word=${COMP_WORDS[COMP_CWORD]} - local prev_word=${COMP_WORDS[COMP_CWORD-1]} - - local commands="" - local flag_opts="-h --help -V --version --history --count --missed" - local arg_opts="--status -o --user" - - compopt +o default - - case ${prev_word} in - --status) - return - ;; - -o) - compopt -o filenames - COMPREPLY=( $( compgen -f -- "${curr_word}" ) ) # files - return $? - ;; - --user) - return - ;; - esac - - if [[ "${curr_word}" == -* ]]; then - COMPREPLY=( $(compgen -W "${flag_opts} ${arg_opts}" -- "${curr_word}") ) - else - local positionals="" - COMPREPLY=( $(compgen -W "${commands} ${positionals}" -- "${curr_word}") ) - fi -} - -# Generates completions for the options and subcommands of the `room` subcommand. -function _picocli_im_get_room() { - # Get completion data - local curr_word=${COMP_WORDS[COMP_CWORD]} - local prev_word=${COMP_WORDS[COMP_CWORD-1]} - - local commands="" - local flag_opts="-h --help -V --version" - local arg_opts="--have-user --limit --cursor" - - compopt +o default - - case ${prev_word} in - --have-user) - return - ;; - --limit) - return - ;; - --cursor) - return - ;; - esac - - if [[ "${curr_word}" == -* ]]; then - COMPREPLY=( $(compgen -W "${flag_opts} ${arg_opts}" -- "${curr_word}") ) - else - local positionals="" - COMPREPLY=( $(compgen -W "${commands} ${positionals}" -- "${curr_word}") ) - fi -} - -# Generates completions for the options and subcommands of the `session` subcommand. -function _picocli_im_get_session() { - # Get completion data - local curr_word=${COMP_WORDS[COMP_CWORD]} - - local commands="" - local flag_opts="-h --help -V --version" - local arg_opts="" - - if [[ "${curr_word}" == -* ]]; then - COMPREPLY=( $(compgen -W "${flag_opts} ${arg_opts}" -- "${curr_word}") ) - else - local positionals="" - COMPREPLY=( $(compgen -W "${commands} ${positionals}" -- "${curr_word}") ) - fi -} - -# Generates completions for the options and subcommands of the `user` subcommand. -function _picocli_im_get_user() { - # Get completion data - local curr_word=${COMP_WORDS[COMP_CWORD]} - local prev_word=${COMP_WORDS[COMP_CWORD-1]} - - local commands="" - local flag_opts="-h --help -V --version" - local arg_opts="--limit --cursor" - - compopt +o default - - case ${prev_word} in - --limit) - return - ;; - --cursor) - return - ;; - esac - - if [[ "${curr_word}" == -* ]]; then - COMPREPLY=( $(compgen -W "${flag_opts} ${arg_opts}" -- "${curr_word}") ) - else - local positionals="" - COMPREPLY=( $(compgen -W "${commands} ${positionals}" -- "${curr_word}") ) - fi -} - -# Generates completions for the options and subcommands of the `admin` subcommand. -function _picocli_im_delete_admin() { - # Get completion data - local curr_word=${COMP_WORDS[COMP_CWORD]} - local prev_word=${COMP_WORDS[COMP_CWORD-1]} - - local commands="" - local flag_opts="-h --help -V --version" - local arg_opts="--group --room --super" - - compopt +o default - - case ${prev_word} in - --group) - return - ;; - --room) - return - ;; - --super) - return - ;; - esac - - if [[ "${curr_word}" == -* ]]; then - COMPREPLY=( $(compgen -W "${flag_opts} ${arg_opts}" -- "${curr_word}") ) - else - local positionals="" - COMPREPLY=( $(compgen -W "${commands} ${positionals}" -- "${curr_word}") ) - fi -} - -# Generates completions for the options and subcommands of the `block` subcommand. -function _picocli_im_delete_block() { - # Get completion data - local curr_word=${COMP_WORDS[COMP_CWORD]} - local prev_word=${COMP_WORDS[COMP_CWORD-1]} - - local commands="" - local flag_opts="-h --help -V --version --login" - local arg_opts="--msg-to-user --msg-to-group --msg-to-room --join-group --join-room" - - compopt +o default - - case ${prev_word} in - --msg-to-user) - return - ;; - --msg-to-group) - return - ;; - --msg-to-room) - return - ;; - --join-group) - return - ;; - --join-room) - return - ;; - esac - - if [[ "${curr_word}" == -* ]]; then - COMPREPLY=( $(compgen -W "${flag_opts} ${arg_opts}" -- "${curr_word}") ) - else - local positionals="" - COMPREPLY=( $(compgen -W "${commands} ${positionals}" -- "${curr_word}") ) - fi -} - -# Generates completions for the options and subcommands of the `contact` subcommand. -function _picocli_im_delete_contact() { - # Get completion data - local curr_word=${COMP_WORDS[COMP_CWORD]} - - local commands="" - local flag_opts="-h --help -V --version" - local arg_opts="" - - if [[ "${curr_word}" == -* ]]; then - COMPREPLY=( $(compgen -W "${flag_opts} ${arg_opts}" -- "${curr_word}") ) - else - local positionals="" - COMPREPLY=( $(compgen -W "${commands} ${positionals}" -- "${curr_word}") ) - fi -} - -# Generates completions for the options and subcommands of the `group` subcommand. -function _picocli_im_delete_group() { - # Get completion data - local curr_word=${COMP_WORDS[COMP_CWORD]} - - local commands="" - local flag_opts="-h --help -V --version" - local arg_opts="" - - if [[ "${curr_word}" == -* ]]; then - COMPREPLY=( $(compgen -W "${flag_opts} ${arg_opts}" -- "${curr_word}") ) - else - local positionals="" - COMPREPLY=( $(compgen -W "${commands} ${positionals}" -- "${curr_word}") ) - fi -} - -# Generates completions for the options and subcommands of the `member` subcommand. -function _picocli_im_delete_member() { - # Get completion data - local curr_word=${COMP_WORDS[COMP_CWORD]} - local prev_word=${COMP_WORDS[COMP_CWORD-1]} - - local commands="" - local flag_opts="-h --help -V --version" - local arg_opts="--from-group --from-room" - - compopt +o default - - case ${prev_word} in - --from-group) - return - ;; - --from-room) - return - ;; - esac - - if [[ "${curr_word}" == -* ]]; then - COMPREPLY=( $(compgen -W "${flag_opts} ${arg_opts}" -- "${curr_word}") ) - else - local positionals="" - COMPREPLY=( $(compgen -W "${commands} ${positionals}" -- "${curr_word}") ) - fi -} - -# Generates completions for the options and subcommands of the `room` subcommand. -function _picocli_im_delete_room() { - # Get completion data - local curr_word=${COMP_WORDS[COMP_CWORD]} - - local commands="" - local flag_opts="-h --help -V --version" - local arg_opts="" - - if [[ "${curr_word}" == -* ]]; then - COMPREPLY=( $(compgen -W "${flag_opts} ${arg_opts}" -- "${curr_word}") ) - else - local positionals="" - COMPREPLY=( $(compgen -W "${commands} ${positionals}" -- "${curr_word}") ) - fi -} - -# Generates completions for the options and subcommands of the `session` subcommand. -function _picocli_im_delete_session() { - # Get completion data - local curr_word=${COMP_WORDS[COMP_CWORD]} - local prev_word=${COMP_WORDS[COMP_CWORD-1]} - - local commands="" - local flag_opts="-h --help -V --version" - local arg_opts="--device" - - compopt +o default - - case ${prev_word} in - --device) - return - ;; - esac - - if [[ "${curr_word}" == -* ]]; then - COMPREPLY=( $(compgen -W "${flag_opts} ${arg_opts}" -- "${curr_word}") ) - else - local positionals="" - COMPREPLY=( $(compgen -W "${commands} ${positionals}" -- "${curr_word}") ) - fi -} - -# Generates completions for the options and subcommands of the `user` subcommand. -function _picocli_im_delete_user() { - # Get completion data - local curr_word=${COMP_WORDS[COMP_CWORD]} - - local commands="" - local flag_opts="-h --help -V --version --all" - local arg_opts="" - - if [[ "${curr_word}" == -* ]]; then - COMPREPLY=( $(compgen -W "${flag_opts} ${arg_opts}" -- "${curr_word}") ) - else - local positionals="" - COMPREPLY=( $(compgen -W "${commands} ${positionals}" -- "${curr_word}") ) - fi -} - -# Generates completions for the options and subcommands of the `group` subcommand. -function _picocli_im_update_group() { - # Get completion data - local curr_word=${COMP_WORDS[COMP_CWORD]} - local prev_word=${COMP_WORDS[COMP_CWORD-1]} - - local commands="" - local flag_opts="-h --help -V --version --can-member-invite" - local arg_opts="--owner --name --description --announcement --max-members" - - compopt +o default - - case ${prev_word} in - --owner) - return - ;; - --name) - return - ;; - --description) - return - ;; - --announcement) - return - ;; - --max-members) - return - ;; - esac - - if [[ "${curr_word}" == -* ]]; then - COMPREPLY=( $(compgen -W "${flag_opts} ${arg_opts}" -- "${curr_word}") ) - else - local positionals="" - COMPREPLY=( $(compgen -W "${commands} ${positionals}" -- "${curr_word}") ) - fi -} - -# Generates completions for the options and subcommands of the `user` subcommand. -function _picocli_im_update_user() { - # Get completion data - local curr_word=${COMP_WORDS[COMP_CWORD]} - local prev_word=${COMP_WORDS[COMP_CWORD-1]} - - local commands="" - local flag_opts="-h --help -V --version" - local arg_opts="--password" - - compopt +o default - - case ${prev_word} in - --password) - return - ;; - esac - - if [[ "${curr_word}" == -* ]]; then - COMPREPLY=( $(compgen -W "${flag_opts} ${arg_opts}" -- "${curr_word}") ) - else - local positionals="" - COMPREPLY=( $(compgen -W "${commands} ${positionals}" -- "${curr_word}") ) - fi -} - -# Generates completions for the options and subcommands of the `room` subcommand. -function _picocli_im_update_room() { - # Get completion data - local curr_word=${COMP_WORDS[COMP_CWORD]} - local prev_word=${COMP_WORDS[COMP_CWORD-1]} - - local commands="" - local flag_opts="-h --help -V --version" - local arg_opts="--name --description --max-members" - - compopt +o default - - case ${prev_word} in - --name) - return - ;; - --description) - return - ;; - --max-members) - return - ;; - esac - - if [[ "${curr_word}" == -* ]]; then - COMPREPLY=( $(compgen -W "${flag_opts} ${arg_opts}" -- "${curr_word}") ) - else - local positionals="" - COMPREPLY=( $(compgen -W "${commands} ${positionals}" -- "${curr_word}") ) - fi -} - -# Define a completion specification (a compspec) for the -# `im`, `im.sh`, and `im.bash` commands. -# Uses the bash `complete` builtin (see [6]) to specify that shell function -# `_complete_im` is responsible for generating possible completions for the -# current word on the command line. -# The `-o default` option means that if the function generated no matches, the -# default Bash completions and the Readline default filename completions are performed. -complete -F _complete_im -o default im im.sh im.bash diff --git a/im-sdk-cli/install.sh b/im-sdk-cli/install.sh deleted file mode 100755 index fb1244136..000000000 --- a/im-sdk-cli/install.sh +++ /dev/null @@ -1,44 +0,0 @@ -#!/usr/bin/env bash - -version=0.2.5 - -easemob_home="${HOME}/.easemob" -config_file=$easemob_home/"config.properties" -jar_name=im-sdk-cli.jar - -echo Begin installing Easemob SDK IM CLI v$version - -if [ ! -d $easemob_home ]; then - echo "Create dir $easemob_home." - mkdir $easemob_home -else - echo "$easemob_home exists, skip creating dir." -fi - -if [ ! -f $config_file ]; then - echo "Create file ${config_file}." - touch $config_file - echo -e "# You can get configs from https://console.easemob.com/\nim.appkey=\nim.client-id=\nim.client-secret=" >~/.easemob/config.properties -else - echo "$config_file exists, skip creating file." -fi - -echo "downloading $jar_name." -curl -fL -o $easemob_home/$jar_name https://repo1.maven.org/maven2/com/easemob/im/im-sdk-cli/$version/im-sdk-cli-$version.jar - -echo "downloading completion.sh." -curl -fL -o $easemob_home/completion.sh https://raw.githubusercontent.com/easemob/easemob-im-server-sdk/master/im-sdk-cli/completion.sh - -echo -e "\nAll done!\n" - -echo "Please add the following script in your ~/.bashrc or ~/.zshrc:" -echo "" -echo " alias im='java -jar ~/.easemob/im-sdk-cli.jar'" -echo " source ~/.easemob/completion.sh" -echo "" -echo "Then issue the following command:" -echo "" -echo " source ~/.bashrc or ~/.zshrc" -echo " im -h" -echo "" -echo "Enjoy!!!" diff --git a/im-sdk-cli/pom.xml b/im-sdk-cli/pom.xml deleted file mode 100644 index 49ff99bf3..000000000 --- a/im-sdk-cli/pom.xml +++ /dev/null @@ -1,230 +0,0 @@ - - - - 4.0.0 - - com.easemob.im - im-sdk-cli - 0.4.6-SNAPSHOT - Easemob IM cli utility - - - com.easemob.im - im-sdk-parent - 0.4.6-SNAPSHOT - - - - 1.8 - 4.6.1 - 2.4.3 - ${java.version} - ${java.version} - - - - - com.easemob.im - im-sdk-core - 0.4.6-SNAPSHOT - - - info.picocli - picocli - ${picocli.version} - - - info.picocli - picocli-spring-boot-starter - ${picocli.version} - - - org.springframework.boot - spring-boot-starter - - - org.springframework.boot - spring-boot-configuration-processor - - - - - - - org.springframework.boot - spring-boot-dependencies - ${spring-boot.version} - pom - import - - - - - - - - org.springframework.boot - spring-boot-maven-plugin - ${spring-boot.version} - - - repackage - - repackage - - - - - - org.apache.maven.plugins - maven-compiler-plugin - 3.8.1 - - - - info.picocli - picocli-codegen - 4.6.1 - - - - -Aproject=${project.groupId}/${project.artifactId} - - - - - org.codehaus.mojo - exec-maven-plugin - 3.0.0 - - - generate-autocompletion-script - package - - exec - - - - - java - - -Dpicocli.autocomplete.systemExitOnError - -cp - - picocli.AutoComplete - --force - --completionScript - ${project.build.directory}/completion.sh - com.easemob.im.cli.IMCliCmd - - - - - - - - - - spring-release - Spring release - https://repo.spring.io/release - - - - - - spring-release - Spring release - https://repo.spring.io/release - - - - - - native - - 21.0.0.2 - 0.9.0 - - - - org.springframework.experimental - spring-native - ${spring-native.version} - - - - - - org.springframework.boot - spring-boot-maven-plugin - ${spring-boot.version} - - - repackage - none - - - - - org.springframework.experimental - spring-aot-maven-plugin - ${spring-native.version} - - - test-generate - - test-generate - - - - generate - - generate - - - - - - org.graalvm.nativeimage - native-image-maven-plugin - ${graalvm.version} - - - - native-image - - package - - - - im - com.easemob.im.cli.IMCliApp - --verbose - - - - org.apache.maven.plugins - maven-compiler-plugin - 3.8.1 - - - - - -Xlint:all - -Xlint:-options - -Xlint:-processing - -Xlint:-serial - - true - ${java.version} - ${java.version} - - - - - - - diff --git a/im-sdk-cli/src/main/java/com/easemob/im/cli/IMCliApp.java b/im-sdk-cli/src/main/java/com/easemob/im/cli/IMCliApp.java deleted file mode 100644 index 3e0808a9f..000000000 --- a/im-sdk-cli/src/main/java/com/easemob/im/cli/IMCliApp.java +++ /dev/null @@ -1,37 +0,0 @@ -package com.easemob.im.cli; - -import com.easemob.im.server.EMService; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.CommandLineRunner; -import org.springframework.boot.ExitCodeGenerator; -import org.springframework.boot.SpringApplication; -import org.springframework.boot.autoconfigure.SpringBootApplication; -import picocli.CommandLine; - -@SpringBootApplication -public class IMCliApp implements CommandLineRunner, ExitCodeGenerator { - @Autowired - private CommandLine.IFactory factory; - - @Autowired - private IMCliCmd cmd; - - @Autowired - private EMService service; - - private int exitCode; - - public static void main(String[] args) { - SpringApplication.run(IMCliApp.class, args); - } - - @Override - public void run(String... args) throws Exception { - this.exitCode = new CommandLine(this.cmd, this.factory).execute(args); - } - - @Override - public int getExitCode() { - return this.exitCode; - } -} diff --git a/im-sdk-cli/src/main/java/com/easemob/im/cli/IMCliCmd.java b/im-sdk-cli/src/main/java/com/easemob/im/cli/IMCliCmd.java deleted file mode 100644 index 3e9070c62..000000000 --- a/im-sdk-cli/src/main/java/com/easemob/im/cli/IMCliCmd.java +++ /dev/null @@ -1,51 +0,0 @@ -package com.easemob.im.cli; - -import ch.qos.logback.classic.Level; -import ch.qos.logback.classic.Logger; -import com.easemob.im.cli.cmd.CreateCmd; -import com.easemob.im.cli.cmd.DeleteCmd; -import com.easemob.im.cli.cmd.GetCmd; -import com.easemob.im.cli.cmd.UpdateCmd; -import com.easemob.im.server.EMVersion; -import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.InitializingBean; -import org.springframework.stereotype.Component; -import picocli.CommandLine; -import picocli.CommandLine.Command; -import picocli.CommandLine.Option; - -import java.util.Arrays; - -@Component -@Command(name = "im", - mixinStandardHelpOptions = true, - versionProvider = Version.class, - subcommands = { - CreateCmd.class, - GetCmd.class, - DeleteCmd.class, - UpdateCmd.class - }) -public class IMCliCmd implements InitializingBean { - @Option(names = {"-v", "--verbose"}) - private boolean verbose; - - @Override - public void afterPropertiesSet() throws Exception { - if (this.verbose) { - Logger root = (Logger) LoggerFactory.getLogger(org.slf4j.Logger.ROOT_LOGGER_NAME); - root.setLevel(Level.DEBUG); - } - } -} - - -class Version implements CommandLine.IVersionProvider { - - @Override - public String[] getVersion() { - String[] versions = new String[1]; - versions[0] = EMVersion.getVersion(); - return versions; - } -} diff --git a/im-sdk-cli/src/main/java/com/easemob/im/cli/IMCliConfiguration.java b/im-sdk-cli/src/main/java/com/easemob/im/cli/IMCliConfiguration.java deleted file mode 100644 index da31ebd6c..000000000 --- a/im-sdk-cli/src/main/java/com/easemob/im/cli/IMCliConfiguration.java +++ /dev/null @@ -1,31 +0,0 @@ -package com.easemob.im.cli; - -import com.easemob.im.server.EMProperties; -import com.easemob.im.server.EMService; -import org.springframework.boot.context.properties.EnableConfigurationProperties; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.context.annotation.PropertySource; -import org.springframework.context.annotation.PropertySources; - -@Configuration -@PropertySources({ - @PropertySource(value = "file:${user.home}/.easemob/config.properties") -}) -@EnableConfigurationProperties({IMCliProperties.class}) -public class IMCliConfiguration { - - @Bean - public EMService service(IMCliProperties cliProperties) { - EMProperties properties = EMProperties.builder() - .setBaseUri(cliProperties.getBaseUri()) - .setAppkey(cliProperties.getAppkey()) - .setClientId(cliProperties.getClientId()) - .setClientSecret(cliProperties.getClientSecret()) - .build(); - - EMService service = new EMService(properties); - - return service; - } -} diff --git a/im-sdk-cli/src/main/java/com/easemob/im/cli/IMCliProperties.java b/im-sdk-cli/src/main/java/com/easemob/im/cli/IMCliProperties.java deleted file mode 100644 index 095b75787..000000000 --- a/im-sdk-cli/src/main/java/com/easemob/im/cli/IMCliProperties.java +++ /dev/null @@ -1,44 +0,0 @@ -package com.easemob.im.cli; - -import org.springframework.boot.context.properties.ConfigurationProperties; - -@ConfigurationProperties(prefix = "im") -public class IMCliProperties { - private String baseUri; - private String appkey; - private String clientId; - private String clientSecret; - - public String getBaseUri() { - return baseUri; - } - - public void setBaseUri(String baseUri) { - this.baseUri = baseUri; - } - - public String getAppkey() { - return appkey; - } - - public void setAppkey(String appkey) { - this.appkey = appkey; - } - - public String getClientId() { - return clientId; - } - - public void setClientId(String clientId) { - this.clientId = clientId; - } - - public String getClientSecret() { - return clientSecret; - } - - public void setClientSecret(String clientSecret) { - this.clientSecret = clientSecret; - } - -} diff --git a/im-sdk-cli/src/main/java/com/easemob/im/cli/cmd/CreateCmd.java b/im-sdk-cli/src/main/java/com/easemob/im/cli/cmd/CreateCmd.java deleted file mode 100644 index a838dea17..000000000 --- a/im-sdk-cli/src/main/java/com/easemob/im/cli/cmd/CreateCmd.java +++ /dev/null @@ -1,351 +0,0 @@ -package com.easemob.im.cli.cmd; - -import com.easemob.im.server.EMException; -import com.easemob.im.server.EMService; -import com.easemob.im.server.model.*; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Component; -import org.springframework.util.StringUtils; -import picocli.CommandLine.ArgGroup; -import picocli.CommandLine.Command; -import picocli.CommandLine.Option; -import picocli.CommandLine.Parameters; -import reactor.core.publisher.Mono; - -import java.net.URI; -import java.nio.file.Path; -import java.time.Duration; -import java.util.List; -import java.util.Map; -import java.util.Set; - -@Component -@Command(name = "create", description = "Create a resource.", mixinStandardHelpOptions = true) -public class CreateCmd { - - @Autowired - private EMService service; - - @Command(name = "attachment", description = "Create an attachment.", mixinStandardHelpOptions = true) - public void attachment(@Option(names = "-f", description = "from file") Path file) { - this.service.attachment().uploadFile(file) - .doOnNext(resp -> - System.out.printf("id = %s\nurl = %s\nsecret = %s\n", resp.getId(), - resp.getUrl(), resp.getSecret())) - .doOnError(err -> System.out.println(String.format("error: %s", err.getMessage()))) - .onErrorResume(EMException.class, err -> Mono.empty()) - .block(); - } - - @Command(name = "block", description = "Block user from resource.", mixinStandardHelpOptions = true) - public void block(@Parameters(description = "user to block") String username, - @ArgGroup(multiplicity = "1", exclusive = false) BlockArgGroup argGroup) { - if (StringUtils.hasText(argGroup.msgToUsername)) { - this.service.block().blockUserSendMsgToUser(username, argGroup.msgToUsername) - .doOnSuccess(ignore -> System.out.println("done")) - .doOnError(err -> System.out.println("error: " + err.getMessage())) - .onErrorResume(EMException.class, ignore -> Mono.empty()) - .block(); - } - if (StringUtils.hasText(argGroup.msgToGroupId)) { - this.service.block() - .blockUserSendMsgToGroup(username, argGroup.msgToGroupId, argGroup.duration) - .doOnSuccess(ignore -> System.out.println("done")) - .doOnError(err -> System.out.println("error: " + err.getMessage())) - .onErrorResume(EMException.class, ignore -> Mono.empty()) - .block(); - } - if (StringUtils.hasText(argGroup.msgToRoomId)) { - this.service.block() - .blockUserSendMsgToRoom(username, argGroup.msgToRoomId, argGroup.duration) - .doOnSuccess(ig -> System.out.println("done.")) - .doOnError(err -> System.out.println("error: " + err.getMessage())) - .onErrorResume(EMException.class, ignore -> Mono.empty()) - .block(); - } - if (StringUtils.hasText(argGroup.joinGroupId)) { - this.service.block().blockUserJoinGroup(username, argGroup.joinGroupId) - .doOnSuccess(ignored -> System.out.println("done")) - .doOnError(err -> System.out.println("error: " + err.getMessage())) - .onErrorResume(EMException.class, ignore -> Mono.empty()) - .block(); - } - if (argGroup.joinRoomId != null) { - this.service.block().blockUserJoinRoom(username, argGroup.joinRoomId) - .doOnSuccess(ignored -> System.out.println("done")) - .doOnError(err -> System.out.println("error: " + err.getMessage())) - .onErrorResume(EMException.class, ignore -> Mono.empty()) - .block(); - } - if (argGroup.login) { - this.service.block().blockUserLogin(username) - .doOnSuccess(ignored -> System.out.println("done")) - .doOnError(err -> System.out.println("error: " + err.getMessage())) - .onErrorResume(EMException.class, ignore -> Mono.empty()) - .block(); - } - } - - @Command(name = "user", description = "Create a user.", mixinStandardHelpOptions = true) - public void user(@Parameters(description = "the username") String username, - @Parameters(description = "the password") String password) { - service.user().create(username, password) - .doOnSuccess(ignore -> System.out.println("done")) - .doOnError(err -> System.out.println("error: " + err.getMessage())) - .onErrorResume(EMException.class, ignore -> Mono.empty()) - .block(); - } - - @Command(name = "contact", description = "Add a contact to the user.", mixinStandardHelpOptions = true) - public void contact(@Parameters(description = "the user's username") String user1, - @Parameters(description = "the contact's username") String contact) { - this.service.contact().add(user1, contact) - .doOnSuccess(ignored -> System.out.println("done")) - .doOnError(err -> System.out.println("error: " + err.getMessage())) - .onErrorResume(EMException.class, ignore -> Mono.empty()) - .block(); - } - - @Command(name = "group", description = "Create a group.\n" + - "Public(by default) groups can be listed using Android, iOS, Web SDKs. So that end user can discover and join public groups.\n" - + - "Private groups can NOT be listed using Android, iOS, Web SDKs.", mixinStandardHelpOptions = true) - public void group(@Parameters(arity = "1", description = "the member's username list") - List members, - @Option(names = "--owner", required = true, description = "the owner's username") - String owner, - @Option(names = "--name", required = true, description = "the group's name") - String name, - @Option(names = "--description", required = true, description = "the group's description") - String description, - @Option(names = "--private", description = "create a private group") boolean isPrivate, - @Option(names = "--max-members", defaultValue = "200", description = "max number of members") - int maxMembers, - @Option(names = "--can-member-invite", description = "can member invite others to join") - boolean canMemberInvite) { - if (isPrivate) { - this.service.group().createPrivateGroup(owner, name, description, members, maxMembers, - canMemberInvite) - .doOnSuccess(groupId -> System.out.println("group: " + groupId)) - .doOnError(err -> System.out.println("error: " + err.getMessage())) - .onErrorResume(EMException.class, ignore -> Mono.empty()) - .block(); - } else { - this.service.group().createPublicGroup(owner, name, description, members, maxMembers, - !canMemberInvite) - .doOnSuccess(groupId -> System.out.println("group: " + groupId)) - .doOnError(err -> System.out.println("error: " + err.getMessage())) - .onErrorResume(EMException.class, ignore -> Mono.empty()) - .block(); - } - } - - @Command(name = "room", description = "Create a room.", mixinStandardHelpOptions = true) - public void room(@Parameters(arity = "1", description = "the member's username list") - List members, - @Option(names = "--name", required = true, description = "the room name") String name, - @Option(names = "--owner", required = true, description = "the owner's username") - String owner, - @Option(names = "--description", description = "the room's description", defaultValue = "") - String description, - @Option(names = "--max-members", defaultValue = "200", description = "max number of members") - int maxMembers) { - this.service.room().createRoom(name, description, owner, members, maxMembers) - .doOnSuccess(roomId -> System.out.println("roomId: " + roomId)) - .doOnError(err -> System.out.println("error: " + err.getMessage())) - .onErrorResume(EMException.class, ignore -> Mono.empty()) - .block(); - } - - @Command(name = "member", description = "Add user to group or room.", mixinStandardHelpOptions = true) - public void member(@Parameters(description = "the user") String username, - @ArgGroup(multiplicity = "1") MemberArgGroup argGroup) { - if (StringUtils.hasText(argGroup.toGroup)) { - this.service.group().addGroupMember(argGroup.toGroup, username) - .doOnSuccess(ig -> System.out.println("done")) - .doOnError(err -> System.out.println("error: " + err.getMessage())) - .onErrorResume(EMException.class, ignore -> Mono.empty()) - .block(); - } else if (StringUtils.hasText(argGroup.toRoom)) { - this.service.room().addRoomMember(argGroup.toRoom, username) - .doOnSuccess(ig -> System.out.println("done")) - .doOnError(err -> System.out.println("error: " + err.getMessage())) - .onErrorResume(EMException.class, ignore -> Mono.empty()) - .block(); - } - } - - @Command(name = "message", description = "Send messages.", mixinStandardHelpOptions = true) - public void message( - @Option(names = "--from", description = "message sender username", required = true) - String from, - @ArgGroup(multiplicity = "1", heading = "To whom.\n") MessageToGroup to, - @ArgGroup(multiplicity = "1", heading = "Message type\n") MessageTypeArgGroup msg, - @Option(names = "--secret", description = "secret returned by attachment upload service") - String secret, - @Option(names = "--filename", description = "filename", defaultValue = "未命名") - String filename, - @Option(names = "--bytes", description = "file size, unit is B(byte)", defaultValue = "0") - Integer bytes, - @Option(names = "--duration", description = "video or audio duration, unit is s(second)", defaultValue = "0") - Integer duration, - @Option(names = "--ext", description = "message extension") - Map extensions, - @Option(names = "--param", description = "message extension") - Map params) { - EMMessage message; - - if (msg.text != null) { - message = new EMTextMessage().text(msg.text); - } else if (msg.img != null) { - message = new EMImageMessage().displayName(filename).uri(URI.create(msg.img)) - .secret(secret).bytes(bytes); - } else if (msg.audio != null) { - message = new EMVoiceMessage().displayName(filename).uri(URI.create(msg.audio)) - .secret(secret).duration(duration).bytes(bytes); - } else if (msg.video != null) { - message = new EMVideoMessage().displayName(filename).uri(URI.create(msg.video)) - .secret(secret).duration(duration).bytes(bytes); - } else if (msg.loc != null) { - message = new EMLocationMessage().longitude(Double.parseDouble(msg.loc[0])) - .latitude(Double.parseDouble(msg.loc[1])).address(msg.loc[2]); - } else if (msg.file != null) { - message = new EMFileMessage().displayName(filename).uri(URI.create(msg.file)) - .secret(secret).bytes(bytes); - } else if (msg.cmd != null) { - message = new EMCommandMessage().action(msg.cmd).params(EMKeyValue.of(params)); - } else { - message = new EMCustomMessage().customEvent(msg.custom) - .customExtensions(EMKeyValue.of(params)); - } - String toType = to.toUsernames != null ? - "users" : - to.toGroupIds != null ? "chatgroups" : "chatrooms"; - Set toIds = to.toUsernames != null ? - to.toUsernames : - to.toGroupIds != null ? to.toGroupIds : to.toRoomIds; - this.service.message() - .send(from, toType, toIds, message, EMKeyValue.of(extensions)) - .doOnSuccess(sentMessages -> { - sentMessages.getMessageIdsByEntityId().forEach((toId, messageId) -> { - System.out.printf("toId = %s : messageId = %s\n", toId, messageId); - }); - }) - .doOnError(err -> System.out.println("error: " + err.getMessage())) - .onErrorResume(EMException.class, ignore -> Mono.empty()) - .block(); - } - - @Command(name = "admin", description = "Promote a admin.", mixinStandardHelpOptions = true) - public void admin(@Parameters(description = "admin username") String username, - @ArgGroup(multiplicity = "1") AdminArgGroup argGroup) { - if (argGroup.groupId != null) { - this.service.group().addGroupAdmin(argGroup.groupId, username) - .doOnSuccess(ig -> System.out.println("done")) - .doOnError(err -> System.out.println("error: " + err.getMessage())) - .onErrorResume(EMException.class, ignore -> Mono.empty()) - .block(); - } else if (argGroup.roomId != null) { - this.service.room().promoteRoomAdmin(argGroup.roomId, username) - .doOnSuccess(ig -> System.out.println("done")) - .doOnError(err -> System.out.println("error: " + err.getMessage())) - .onErrorResume(EMException.class, ignore -> Mono.empty()) - .block(); - } else if (argGroup.superAdmin) { - this.service.room().promoteRoomSuperAdmin(username) - .doOnSuccess(ig -> System.out.println("done")) - .doOnError(err -> System.out.println("error: " + err.getMessage())) - .onErrorResume(EMException.class, ignore -> Mono.empty()) - .block(); - } - } - - private static class BlockArgGroup { - @Option(names = {"--msg-to-user"}, description = "block user send message to this user") - String msgToUsername; - - @Option(names = {"--msg-to-group"}, description = "block user send message to this group") - String msgToGroupId; - - @Option(names = {"--msg-to-room"}, description = "block user send message to this room") - String msgToRoomId; - - @Option(names = {"--join-group"}, description = "block user to join group") - String joinGroupId; - - @Option(names = {"--join-room"}, description = "block user to join room") - String joinRoomId; - - @Option(names = {"--login"}, description = "block user to login") - boolean login; - - @Option(names = "--duration", description = "block duration, block user forever if missing") - Duration duration; - } - - - private static class MemberArgGroup { - @Option(names = "--to-group", description = "add user to this group") - String toGroup; - - @Option(names = "--to-room", description = "add user to this room") - String toRoom; - } - - - private static class MessageToGroup { - @Option(names = "--to-user", split = ",", description = "send message to these user, split each username by `,`") - Set toUsernames; - - @Option(names = "--to-group", split = ",", description = "send message to these groups, split each groupId by `,`") - Set toGroupIds; - - @Option(names = "--to-room", split = ",", description = "send message to these rooms, split each roomId by `,`") - Set toRoomIds; - } - - - private static class MessageTypeArgGroup { - @Option(names = "--text", description = "text message, value is the ") - String text; - - @Option(names = "--img", description = "send image message, value is image url") - String img; - - @Option(names = "--audio", description = "send audio message, value is image url") - String audio; - - @Option(names = "--video", description = "video message, value is video url") - String video; - - @Option(names = "--loc", split = ":", description = "location message, value format is longitude:latitude:address") - String[] loc; - - @Option(names = "--file", description = "file message, value is file url") - String file; - - @Option(names = "--cmd", description = "command message, value format is key:value") - String cmd; - - @Option(names = "--custom", description = "custom message, value format is event:extensionKey:extensionValue") - String custom; - } - - - private static class AdminArgGroup { - @Option(names = "--group", description = - "promote the specified user to group admin, group admin is some user who can block user from joining or " - + - "sending messages in this group") - String groupId; - - @Option(names = "--room", description = - "promote the specified user to room admin, room admin is some user who can block user from joining or " - + - "sending message in this room") - String roomId; - - @Option(names = "--super", description = "promote the specified user to super admin, super admin is some user who can create room") - boolean superAdmin; - } -} diff --git a/im-sdk-cli/src/main/java/com/easemob/im/cli/cmd/DeleteCmd.java b/im-sdk-cli/src/main/java/com/easemob/im/cli/cmd/DeleteCmd.java deleted file mode 100644 index 097898c95..000000000 --- a/im-sdk-cli/src/main/java/com/easemob/im/cli/cmd/DeleteCmd.java +++ /dev/null @@ -1,234 +0,0 @@ -package com.easemob.im.cli.cmd; - -import com.easemob.im.server.EMException; -import com.easemob.im.server.EMService; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Component; -import org.springframework.util.StringUtils; -import picocli.CommandLine.ArgGroup; -import picocli.CommandLine.Command; -import reactor.core.publisher.Mono; - -import static picocli.CommandLine.Option; -import static picocli.CommandLine.Parameters; - -@Component -@Command(name = "delete", description = "Delete a resource.", mixinStandardHelpOptions = true) -public class DeleteCmd { - - @Autowired - private EMService service; - - @Command(name = "block", description = "Unblock user from resource.", mixinStandardHelpOptions = true) - public void block(@Parameters(description = "user to unblock") String username, - @ArgGroup(multiplicity = "1", exclusive = false) UnBlockArgGroup argGroup) { - if (StringUtils.hasText(argGroup.msgToUsername)) { - this.service.block().unblockUserSendMsgToUser(username, argGroup.msgToUsername) - .doOnSuccess(ignore -> System.out.println("done")) - .doOnError(err -> System.out.println("error: " + err.getMessage())) - .onErrorResume(EMException.class, ignore -> Mono.empty()) - .block(); - } - if (StringUtils.hasText(argGroup.msgToGroupId)) { - this.service.block().unblockUserSendMsgToGroup(username, argGroup.msgToGroupId) - .doOnSuccess(ignore -> System.out.println("done")) - .doOnError(err -> System.out.println("error: " + err.getMessage())) - .onErrorResume(EMException.class, ignore -> Mono.empty()) - .block(); - } - if (StringUtils.hasText(argGroup.msgToRoomId)) { - this.service.block().unblockUserSendMsgToRoom(username, argGroup.msgToRoomId) - .doOnSuccess(ignore -> System.out.println("done")) - .doOnError(err -> System.out.println("error: " + err.getMessage())) - .onErrorResume(EMException.class, ignore -> Mono.empty()) - .block(); - } - if (StringUtils.hasText(argGroup.joinGroupId)) { - this.service.block().unblockUserJoinGroup(username, argGroup.joinGroupId) - .doOnSuccess(ignore -> System.out.println("done")) - .doOnError(err -> System.out.println("error: " + err.getMessage())) - .onErrorResume(EMException.class, ignore -> Mono.empty()) - .block(); - } - if (argGroup.joinRoomId != null) { - this.service.block().unblockUserJoinRoom(username, argGroup.joinRoomId) - .doOnSuccess(ignore -> System.out.println("done")) - .doOnError(err -> System.out.println("error: " + err.getMessage())) - .onErrorResume(EMException.class, ignore -> Mono.empty()) - .block(); - } - if (argGroup.login) { - this.service.block().unblockUserLogin(username) - .doOnSuccess(ignore -> System.out.println("done")) - .doOnError(err -> System.out.println("error: " + err.getMessage())) - .onErrorResume(EMException.class, ignore -> Mono.empty()) - .block(); - } - } - - @Command(name = "user", description = "Delete a user.", mixinStandardHelpOptions = true) - public void user(@ArgGroup(multiplicity = "1") DeleteUserArgGroup argGroup) { - if (argGroup.all) { - this.service.user().deleteAll() - .doOnNext(user -> System.out.println("user " + user + " deleted")) - .doOnError(err -> System.out.println("error: " + err.getMessage())) - .onErrorResume(EMException.class, ignore -> Mono.empty()) - .blockLast(); - } else { - this.service.user().delete(argGroup.username) - .doOnSuccess(user -> System.out.println("done")) - .doOnError(err -> System.out.println("error: " + err.getMessage())) - .onErrorResume(EMException.class, ignore -> Mono.empty()) - .block(); - } - } - - @Command(name = "contact", description = "Remove a contact from the user.", mixinStandardHelpOptions = true) - public void contact(@Parameters(description = "the user's username") String user, - @Parameters(description = "the contact's username") String contact) { - this.service.contact().remove(user, contact) - .doOnSuccess(ignored -> System.out.println("done")) - .doOnError(err -> System.out.println("error: " + err.getMessage())) - .onErrorResume(EMException.class, ignore -> Mono.empty()) - .block(); - } - - @Command(name = "group", description = "Destroy a group.\n" + - "Messages will be destroyed with the group, while the chat history is reserved.", mixinStandardHelpOptions = true) - public void group(@Parameters(description = "the group id") String groupId) { - this.service.group().destroyGroup(groupId) - .doOnSuccess(ignored -> System.out.println("done")) - .doOnError(err -> System.out.println("error: " + err.getMessage())) - .onErrorResume(EMException.class, ignore -> Mono.empty()) - .block(); - } - - @Command(name = "room", description = "Destroy a room.\n" + - "Messages will be destroyed with the room, while the chat history is reserved.", mixinStandardHelpOptions = true) - public void room(@Parameters(description = "the room id") String roomId) { - this.service.room().destroyRoom(roomId) - .doOnSuccess(ignored -> System.out.println("done")) - .doOnError(err -> System.out.println("error: " + err.getMessage())) - .onErrorResume(EMException.class, ignore -> Mono.empty()) - .block(); - } - - @Command(name = "session", description = "Force user logout, default to logout all devices if missing --device", mixinStandardHelpOptions = true) - public void session(@Parameters(description = "the username") String username, - @Option(names = "--device", description = "logout specific device") String deviceName) { - if (StringUtils.hasText(deviceName)) { - this.service.user().forceLogoutOneDevice(username, deviceName) - .doOnSuccess(ignored -> System.out.println("done")) - .doOnError(err -> System.out.println("error: " + err.getMessage())) - .onErrorResume(EMException.class, ignore -> Mono.empty()) - .block(); - } else { - this.service.user().forceLogoutAllDevices(username) - .doOnSuccess(ignored -> System.out.println("done")) - .doOnError(err -> System.out.println("error: " + err.getMessage())) - .onErrorResume(EMException.class, ignore -> Mono.empty()) - .block(); - } - } - - @Command(name = "member", description = "Remove user from group or room.", mixinStandardHelpOptions = true) - public void member(@Parameters(description = "the user") String username, - @ArgGroup(multiplicity = "1") MemberArgGroup argGroup) { - if (StringUtils.hasText(argGroup.fromGroup)) { - this.service.group().removeGroupMember(argGroup.fromGroup, username) - .doOnSuccess(ig -> System.out.println("done")) - .doOnError(err -> System.out.println("error: " + err.getMessage())) - .onErrorResume(EMException.class, ignore -> Mono.empty()) - .block(); - } else if (StringUtils.hasText(argGroup.fromRoom)) { - this.service.room().removeRoomMember(argGroup.fromRoom, username) - .doOnSuccess(ig -> System.out.println("done")) - .doOnError(err -> System.out.println("error: " + err.getMessage())) - .onErrorResume(EMException.class, ignore -> Mono.empty()) - .block(); - } - } - - @Command(name = "admin", description = "Demote a admin", mixinStandardHelpOptions = true) - public void admin(@Parameters(description = "admin username") String username, - @ArgGroup(multiplicity = "1") AdminArgGroup argGroup) { - if (argGroup.groupId != null) { - this.service.group().removeGroupAdmin(argGroup.groupId, username) - .doOnSuccess(ig -> System.out.println("done")) - .doOnError(err -> System.out.println("error: " + err.getMessage())) - .onErrorResume(EMException.class, ignore -> Mono.empty()) - .block(); - } else if (argGroup.roomId != null) { - this.service.room().demoteRoomAdmin(argGroup.roomId, username) - .doOnSuccess(ig -> System.out.println("done")) - .doOnError(err -> System.out.println("error: " + err.getMessage())) - .onErrorResume(EMException.class, ignore -> Mono.empty()) - .block(); - } else { - this.service.room().demoteRoomSuperAdmin(argGroup.superAdminUsername) - .doOnSuccess(ig -> System.out.println("done")) - .doOnError(err -> System.out.println("error: " + err.getMessage())) - .onErrorResume(EMException.class, ignore -> Mono.empty()) - .block(); - } - } - - @Command(name = "metadata", description = "Delete user metadata.", mixinStandardHelpOptions = true) - public void metadata(@Parameters(description = "the username") String username) { - this.service.metadata().deleteMetadataFromUser(username) - .doOnSuccess(rsp -> System.out.println("deletionSuccess: " + rsp)) - .doOnError(err -> System.out.println("error: " + err.getMessage())) - .onErrorResume(EMException.class, error -> Mono.empty()) - .block(); - } - - private static class UnBlockArgGroup { - @Option(names = {"--msg-to-user"}, description = "unblock user send message to this user") - String msgToUsername; - - @Option(names = {"--msg-to-group"}, description = "unblock user send message to this group") - String msgToGroupId; - - @Option(names = {"--msg-to-room"}, description = "unblock user send message to this room") - String msgToRoomId; - - @Option(names = {"--join-group"}, description = "unblock user to join group") - String joinGroupId; - - @Option(names = {"--join-room"}, description = "unblock user to join room") - String joinRoomId; - - @Option(names = {"--login"}, description = "unblock user to login") - boolean login; - } - - - private static class DeleteUserArgGroup { - @Parameters(description = "delete one user") - String username; - - @Option(names = {"--all"}, description = "delete all users") - boolean all; - } - - - private static class MemberArgGroup { - @Option(names = "--from-group", description = "remove user from this group") - String fromGroup; - - @Option(names = "--from-room", description = "remove user from this room") - String fromRoom; - } - - - private static class AdminArgGroup { - @Option(names = "--group", description = "demote a group admin") - String groupId; - - @Option(names = "--room", description = "demote a room admin") - String roomId; - - @Option(names = "--super", description = "demote a super admin") - String superAdminUsername; - } -} diff --git a/im-sdk-cli/src/main/java/com/easemob/im/cli/cmd/GetCmd.java b/im-sdk-cli/src/main/java/com/easemob/im/cli/cmd/GetCmd.java deleted file mode 100644 index 5aff8437d..000000000 --- a/im-sdk-cli/src/main/java/com/easemob/im/cli/cmd/GetCmd.java +++ /dev/null @@ -1,454 +0,0 @@ -package com.easemob.im.cli.cmd; - -import com.easemob.im.server.EMException; -import com.easemob.im.server.EMService; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Component; -import org.springframework.util.StringUtils; -import picocli.CommandLine.ArgGroup; -import picocli.CommandLine.Command; -import picocli.CommandLine.Option; -import picocli.CommandLine.Parameters; -import reactor.core.publisher.Mono; - -import java.nio.file.Path; -import java.time.Instant; -import java.time.ZoneId; -import java.time.ZonedDateTime; -import java.time.format.DateTimeFormatter; - -@Component -@Command(name = "get", description = "Get a resource.", mixinStandardHelpOptions = true) -public class GetCmd { - - @Autowired - private EMService service; - - @Command(name = "attachment", description = "Download attachment by id.", mixinStandardHelpOptions = true) - public void attachment( - @Parameters(description = "attachment file id, returned by upload service.") String id, - @Option(names = "-o", defaultValue = "", description = "attachment download path, default is current dir") - Path path) { - this.service.attachment().downloadFile(id, path, id) - .doOnSuccess(downloaded -> System.out - .println(String.format("downloaded: %s", downloaded.toString()))) - .doOnError( - error -> System.out.println(String.format("error: %s", error.getMessage()))) - .onErrorResume(EMException.class, error -> Mono.empty()) - .block(); - } - - @Command(name = "user", description = "Get a user's info or list users.", mixinStandardHelpOptions = true) - public void user(@Parameters(arity = "0..1", description = "The username, if miss, list users") - String username, - @ArgGroup(exclusive = false) LimitArgGroup limitArgGroup) { - if (StringUtils.hasText(username)) { - this.service.user().get(username) - .doOnNext(user -> { - System.out.printf("username: %s\n", user.getUsername()); - System.out.printf("canLogin: %b \n", user.getCanLogin()); - }).doOnError(err -> System.out.println("error: " + err.getMessage())) - .onErrorResume(EMException.class, ignore -> Mono.empty()) - .block(); - } else if (limitArgGroup != null) { - service.user().listUsers(limitArgGroup.limit, limitArgGroup.cursor) - .doOnNext(emPage -> { - emPage.getValues().forEach(System.out::println); - System.out.println("cursor: " + emPage.getCursor()); - }).doOnError(err -> System.out.println("error: " + err.getMessage())) - .onErrorResume(EMException.class, ignore -> Mono.empty()) - .block(); - } else { - service.user().listAllUsers() - .doOnNext(System.out::println) - .doOnError(err -> System.out.println("error: " + err.getMessage())) - .onErrorResume(EMException.class, ignore -> Mono.empty()) - .blockLast(); - } - } - - @Command(name = "contact", description = "List contacts of a user.", mixinStandardHelpOptions = true) - public void contact(@Parameters(description = "the user") String username) { - this.service.contact().list(username) - .doOnNext(System.out::println) - .doOnError(err -> System.out.println("error: " + err.getMessage())) - .onErrorResume(EMException.class, ignore -> Mono.empty()) - .blockLast(); - } - - @Command(name = "group", description = "Get a group's info or list groups", mixinStandardHelpOptions = true) - public void group( - @Parameters(arity = "0..1", description = "the group's id, list all groups if missing") - String groupId, - @Option(names = "--have-user", description = "search groups have this user, not support limit and cursor") - String username, - @ArgGroup(exclusive = false, heading = "If missing, list all groups\n") - LimitArgGroup limitArgGroup) { - if (StringUtils.hasText(groupId)) { - this.service.group().getGroup(groupId) - .doOnSuccess(group -> { - System.out.println("groupId: " + group.getGroupId()); - System.out.println("name: " + group.getName()); - System.out.println("description: " + group.getDescription()); - System.out.println("\tisPublic: " + group.getIsPublic()); - System.out.println("\tmaxMembers: " + group.getMaxMembers()); - System.out.println( - "\tcanMemberInviteOthers: " + group.getCanMemberInviteOthers()); - System.out.println("\towner: " + group.getOwner()); - }) - .doOnError(err -> System.out.println("error: " + err.getMessage())) - .onErrorResume(EMException.class, ignore -> Mono.empty()) - .block(); - this.service.group().getGroupAnnouncement(groupId) - .doOnSuccess(msg -> System.out.println("announcement: " + msg)) - .doOnError(err -> System.out.println("error: " + err.getMessage())) - .onErrorResume(EMException.class, ignore -> Mono.empty()) - .block(); - } else if (StringUtils.hasText(username)) { - this.service.group().listGroupsUserJoined(username) - .doOnNext(gid -> System.out.println("groupId: " + gid)) - .doOnError(err -> System.out.println("error: " + err.getMessage())) - .onErrorResume(EMException.class, ignore -> Mono.empty()) - .blockLast(); - } else if (limitArgGroup != null) { - this.service.group().listGroups(limitArgGroup.limit, limitArgGroup.cursor) - .doOnNext(emPage -> { - emPage.getValues().forEach(System.out::println); - System.out.println("cursor: " + emPage.getCursor()); - }) - .doOnError(err -> System.out.println("error: " + err.getMessage())) - .onErrorResume(EMException.class, ignore -> Mono.empty()) - .block(); - } else { - this.service.group().listAllGroups() - .doOnNext(gid -> { - System.out.println("groupId: " + gid); - }) - .doOnError(err -> System.out.println("error: " + err.getMessage())) - .onErrorResume(EMException.class, ignore -> Mono.empty()) - .blockLast(); - } - } - - @Command(name = "room", description = "Get a room's info or list rooms", mixinStandardHelpOptions = true) - public void room(@Parameters(arity = "0..1", description = "the room's id, if miss, list rooms") - String roomId, - @Option(names = "--have-user", description = "search rooms have this user, not support limit and cursor") - String username, - @ArgGroup(exclusive = false, heading = "If missing, list all rooms\n") - LimitArgGroup limitArgGroup) { - if (StringUtils.hasText(roomId)) { - this.service.room().getRoom(roomId) - .doOnSuccess(room -> { - System.out.println("roomId: " + room.id()); - System.out.println("\tname: " + room.name()); - System.out.println("\tdescription: " + room.description()); - System.out.println("\tmaxMembers: " + room.maxMembers()); - System.out.println("\tcanMemberInviteOthers: " + !room.needApprove()); - System.out.println("\towner: " + room.owner()); - }) - .doOnError(err -> System.out.println("error: " + err.getMessage())) - .onErrorResume(EMException.class, ignore -> Mono.empty()) - .block(); - } else if (StringUtils.hasText(username)) { - this.service.room().listRoomsUserJoined(username) - .doOnNext(rid -> System.out.println("roomId: " + rid)) - .doOnError(err -> System.out.println("error: " + err.getMessage())) - .onErrorResume(EMException.class, ignore -> Mono.empty()) - .blockLast(); - } else if (limitArgGroup != null) { - this.service.room().listRooms(limitArgGroup.limit, limitArgGroup.cursor) - .doOnNext(emPage -> { - emPage.getValues().forEach(System.out::println); - System.out.println("cursor: " + emPage.getCursor()); - }) - .doOnError(err -> System.out.println("error: " + err.getMessage())) - .onErrorResume(EMException.class, ignore -> Mono.empty()) - .block(); - } else { - this.service.room().listRoomsAll() - .doOnNext(rid -> { - System.out.println("roomId: " + rid); - }) - .doOnError(err -> System.out.println("error: " + err.getMessage())) - .onErrorResume(EMException.class, ignore -> Mono.empty()) - .blockLast(); - } - } - - @Command(name = "block", description = "List blocked user.", mixinStandardHelpOptions = true) - public void block(@ArgGroup(multiplicity = "1", exclusive = false) BlockArgGroup argGroup) { - if (StringUtils.hasText(argGroup.msgToUsername)) { - this.service.block().getUsersBlockedFromSendMsgToUser(argGroup.msgToUsername) - .doOnNext(System.out::println) - .doOnError(err -> System.out.println("error: " + err.getMessage())) - .onErrorResume(EMException.class, ignore -> Mono.empty()) - .blockLast(); - } - if (StringUtils.hasText(argGroup.msgToGroupId)) { - this.service.block().getUsersBlockedSendMsgToGroup(argGroup.msgToGroupId) - .doOnNext(System.out::println) - .doOnError(err -> System.out.println("error: " + err.getMessage())) - .onErrorResume(EMException.class, ignore -> Mono.empty()) - .blockLast(); - } - if (StringUtils.hasText(argGroup.msgToRoomId)) { - this.service.block().listUsersBlockedSendMsgToRoom(argGroup.msgToRoomId) - .doOnNext(System.out::println) - .doOnError(err -> System.out.println("error: " + err.getMessage())) - .onErrorResume(EMException.class, ignore -> Mono.empty()) - .blockLast(); - } - if (StringUtils.hasText(argGroup.joinGroupId)) { - this.service.block().getUsersBlockedJoinGroup(argGroup.joinGroupId) - .doOnNext(System.out::println) - .doOnError(err -> System.out.println("error: " + err.getMessage())) - .onErrorResume(EMException.class, ignore -> Mono.empty()) - .blockLast(); - } - if (argGroup.joinRoomId != null) { - this.service.block().getUsersBlockedJoinRoom(argGroup.joinRoomId) - .doOnNext(System.out::println) - .doOnError(err -> System.out.println("error: " + err.getMessage())) - .onErrorResume(EMException.class, ignore -> Mono.empty()) - .blockLast(); - } - if (argGroup.login) { - System.out.println("Not implemented"); - } - } - - @Command(name = "member", description = "List group or room members, not include the owner and admins.", mixinStandardHelpOptions = true) - public void member(@ArgGroup(multiplicity = "1") MemberArgGroup memberArgGroup, - @ArgGroup(exclusive = false) LimitArgGroup limitArgGroup) { - if (memberArgGroup.roomId != null) { - if (limitArgGroup != null) { - this.service.room().listRoomMembers(memberArgGroup.roomId, limitArgGroup.limit, - limitArgGroup.cursor) - .doOnSuccess(emPage -> { - emPage.getValues().forEach(System.out::println); - System.out.println("cursor: " + emPage.getCursor()); - }) - .doOnError(err -> System.out.println("error: " + err.getMessage())) - .onErrorResume(EMException.class, ignore -> Mono.empty()) - .block(); - } else { - this.service.room().listRoomMembersAll(memberArgGroup.roomId) - .doOnNext(System.out::println) - .doOnError(err -> System.out.println("error: " + err.getMessage())) - .onErrorResume(EMException.class, ignore -> Mono.empty()) - .blockLast(); - } - } else { - if (limitArgGroup != null) { - this.service.group().listGroupMembers(memberArgGroup.groupId, limitArgGroup.limit, - limitArgGroup.cursor) - .doOnSuccess(emPage -> { - emPage.getValues().forEach(System.out::println); - System.out.println("cursor: " + emPage.getCursor()); - }) - .doOnError(err -> System.out.println("error: " + err.getMessage())) - .onErrorResume(EMException.class, ignore -> Mono.empty()) - .block(); - } else { - this.service.group().listAllGroupMembers(memberArgGroup.groupId) - .doOnNext(System.out::println) - .doOnError(err -> System.out.println("error: " + err.getMessage())) - .onErrorResume(EMException.class, ignore -> Mono.empty()) - .blockLast(); - } - } - } - - @Command(name = "message", description = "List or count messages.", mixinStandardHelpOptions = true) - public void message(@ArgGroup MessageArgGroup argGroup, - @Option(names = "--user", description = "the message receiver") String username) { - if (argGroup.history != null) { - ZonedDateTime localDatetime = ZonedDateTime.parse(argGroup.history.datetime, - DateTimeFormatter.ISO_LOCAL_DATE_TIME.withZone(ZoneId.systemDefault())); - Instant instant = localDatetime.toInstant(); - - if (argGroup.history.downloadPath == null) { - this.service.message().getHistoryAsUri(instant) - .doOnNext(uri -> System.out.println(String.format("uri: %s", uri))) - .doOnError(err -> System.out - .println(String.format("error: %s", err.getMessage()))) - .block(); - } else { - this.service.message().getHistoryAsLocalFile(instant, argGroup.history.downloadPath, - argGroup.history.datetime.replaceAll("[-T:]", "_") + ".gz") - .doOnNext(uri -> System.out.println(String.format("uri: %s", uri))) - .doOnError(err -> System.out - .println(String.format("error: %s", err.getMessage()))) - .block(); - } - } else if (argGroup.count != null) { - if (username == null || !argGroup.count.missed) { - System.out.println("Only support specify --user and --missed for now."); - return; - } - this.service.message().countMissedMessages(username) - .doOnNext(msg -> { - System.out.printf("count: %s\n", msg.getMessageCount()); - }) - .doOnError(err -> System.out.println("error: " + err.getMessage())) - .onErrorResume(EMException.class, ignore -> Mono.empty()) - .blockLast(); - } else if (argGroup.statusMessageId != null) { - if (username == null) { - System.out.println("Must specify --user"); - return; - } - this.service.message().isMessageDeliveredToUser(argGroup.statusMessageId, username) - .doOnSuccess(isDelivered -> System.out - .println(isDelivered ? "Delivered." : "UnDelivered.")) - .doOnError(err -> System.out.println("error: " + err.getMessage())) - .onErrorResume(EMException.class, ignore -> Mono.empty()) - .block(); - } - } - - @Command(name = "admin", description = "List admin", mixinStandardHelpOptions = true) - public void admin(@ArgGroup(multiplicity = "1") AdminArgGroup argGroup) { - if (argGroup.groupId != null) { - this.service.group().listGroupAdmins(argGroup.groupId) - .doOnNext(System.out::println) - .doOnError(err -> System.out.println("error: " + err.getMessage())) - .onErrorResume(EMException.class, ignore -> Mono.empty()) - .blockLast(); - } else if (argGroup.roomId != null) { - this.service.room().listRoomAdminsAll(argGroup.roomId) - .doOnNext(System.out::println) - .doOnError(err -> System.out.println("error: " + err.getMessage())) - .onErrorResume(EMException.class, ignore -> Mono.empty()) - .blockLast(); - } else if (argGroup.superAdmin) { - this.service.room().listRoomSuperAdminsAll() - .doOnNext(System.out::println) - .doOnError(err -> System.out.println("error: " + err.getMessage())) - .onErrorResume(EMException.class, ignore -> Mono.empty()) - .blockLast(); - } - } - - @Command(name = "session", description = "Get specific user's online status.", mixinStandardHelpOptions = true) - public void session(@Parameters(description = "the username") String username) { - this.service.user().isUserOnline(username) - .doOnSuccess(isOnlie -> System.out - .printf("%s : %s\n", username, isOnlie ? "online" : "offline")) - .doOnError(err -> System.out.println("error: " + err.getMessage())) - .onErrorResume(EMException.class, error -> Mono.empty()) - .block(); - } - - @Command(name = "metadata", description = "Get user metadata or get metadata usage.", mixinStandardHelpOptions = true) - public void metadata(@Option(names = "--user", description = "the username") String username, - @Option(names = "--usage", description = "the usage", defaultValue = "usage") - String usage) { - System.out.println("usage = " + usage); - if (username != null) { - this.service.metadata().getMetadataFromUser(username) - .doOnSuccess(rsp -> System.out.println("data: " + rsp)) - .doOnError(err -> System.out.println("error: " + err.getMessage())) - .onErrorResume(EMException.class, error -> Mono.empty()) - .block(); - } else if (usage != null) { - this.service.metadata().getUsage() - .doOnSuccess(emMetadataUsage -> System.out - .println("bytesUsed: " + emMetadataUsage.getBytesUsed())) - .doOnError(err -> System.out.println("error: " + err.getMessage())) - .onErrorResume(EMException.class, error -> Mono.empty()) - .block(); - } - } - - private static class BlockArgGroup { - @Option(names = { - "--msg-to-user"}, description = "list users who can not send message to this user") - String msgToUsername; - - @Option(names = { - "--msg-to-group"}, description = "list users who can not send message in this group") - String msgToGroupId; - - @Option(names = {"--msg-to-room"}, description = "list users who can not join this room") - String msgToRoomId; - - @Option(names = {"--join-group"}, description = "list users who can not join this group") - String joinGroupId; - - @Option(names = {"--join-room"}, description = "list users who can not join this room") - String joinRoomId; - - @Option(names = {"--login"}, description = "list users who can not login") - boolean login; - } - - - private static class MemberArgGroup { - @Option(names = "--group", description = "list this group members") - String groupId; - - @Option(names = "--room", description = "list this room members") - String roomId; - } - - - private static class MessageHistoryArgGroup { - - @Option(names = "--history", description = "get the history file uri by time", required = true) - boolean history; - - @Option(names = "-o", description = "download the history file, the file is compressed, use `zless` to read it") - Path downloadPath; - - @Parameters(description = "the ISO8601 date time. e.g. 2020-12-12T13:00") - String datetime; - } - - - private static class MessageCountArgGroup { - - @Option(names = "--count", description = "count messages", required = true) - boolean count; - - @Option(names = "--missed", description = "count missed messages.") - boolean missed; - } - - - private static class MessageArgGroup { - - @ArgGroup(exclusive = false, heading = "Message history args.\n") MessageHistoryArgGroup - history; - - @ArgGroup(exclusive = false, heading = "Message count args.\n") MessageCountArgGroup count; - - @Option(names = "--status", description = "get specific message status") - String statusMessageId; - } - - - private static class AdminArgGroup { - @Option(names = "--group", description = "list group's admin") - String groupId; - - @Option(names = "--room", description = "list room's admin") - String roomId; - - @Option(names = "--super", description = "list super admin") - boolean superAdmin; - } - - - private static class LimitArgGroup { - @Option(names = "--limit", description = "the limit", required = true) - Integer limit; - - /** - * 游标,第一次请求分页不需要指定,之后分页cursor用上一次请求返回的cursor - */ - @Option(names = "--cursor", description = "the cursor in latest response.") - String cursor; - } -} diff --git a/im-sdk-cli/src/main/java/com/easemob/im/cli/cmd/UpdateCmd.java b/im-sdk-cli/src/main/java/com/easemob/im/cli/cmd/UpdateCmd.java deleted file mode 100644 index e171155c3..000000000 --- a/im-sdk-cli/src/main/java/com/easemob/im/cli/cmd/UpdateCmd.java +++ /dev/null @@ -1,130 +0,0 @@ -package com.easemob.im.cli.cmd; - -import com.easemob.im.server.EMException; -import com.easemob.im.server.EMService; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Component; -import org.springframework.util.StringUtils; -import picocli.CommandLine.ArgGroup; -import picocli.CommandLine.Command; -import picocli.CommandLine.Option; -import picocli.CommandLine.Parameters; -import reactor.core.publisher.Mono; - -import java.util.Map; - -@Component -@Command(name = "update", description = "Update a resource.", mixinStandardHelpOptions = true) -public class UpdateCmd { - - @Autowired - private EMService service; - - @Command(name = "user", description = "Update user info.", mixinStandardHelpOptions = true) - public void user(@Parameters(description = "the username") String username, - @Option(names = "--password", description = "update user password") String password) { - if (password != null) { - this.service.user().updateUserPassword(username, password) - .doOnSuccess(ignore -> System.out.println("done")) - .doOnError(err -> System.out.println("error: " + err.getMessage())) - .onErrorResume(EMException.class, ignore -> Mono.empty()) - .block(); - } - } - - @Command(name = "group", description = "Update a group's settings.", mixinStandardHelpOptions = true) - public void group(@Parameters(description = "the group's id") String groupId, - @ArgGroup(multiplicity = "1", exclusive = false) GroupArgGroup argGroup) { - this.service.group().updateGroup(groupId, request -> { - request.setName(argGroup.name) - .setDescription(argGroup.description) - .setMaxMembers(argGroup.maxMembers) - .setCanMemberInviteOthers(argGroup.canMemberInvite) - .setNeedApproveToJoin( - argGroup.canMemberInvite == null ? null : !argGroup.canMemberInvite); - }).doOnSuccess(ignored -> System.out.println("done")) - .doOnError(err -> System.out.println("error: " + err.getMessage())) - .onErrorResume(EMException.class, ignore -> Mono.empty()) - .block(); - - if (StringUtils.hasText(argGroup.owner)) { - this.service.group().updateGroupOwner(groupId, argGroup.owner) - .doOnSuccess(ignored -> System.out.println("done")) - .doOnError(err -> System.out.println("error: " + err.getMessage())) - .onErrorResume(EMException.class, ignore -> Mono.empty()) - .block(); - } - - if (argGroup.announcement != null) { - this.service.group().updateGroupAnnouncement(groupId, argGroup.announcement) - .doOnSuccess(ignored -> System.out.println("done")) - .doOnError(err -> System.out.println("error: " + err.getMessage())) - .onErrorResume(EMException.class, ignore -> Mono.empty()) - .block(); - } - } - - @Command(name = "room", description = "Update a room's settings.", mixinStandardHelpOptions = true) - public void room(@Parameters(description = "the room's id") String roomId, - @ArgGroup(multiplicity = "1", exclusive = false) RoomArgGroup argGroup) { - this.service.room().updateRoom(roomId, request -> { - if (argGroup.name != null) { - request.withName(argGroup.name); - } - if (argGroup.description != null) { - request.withDescription(argGroup.description); - } - if (argGroup.maxMembers != null) { - request.withMaxMembers(argGroup.maxMembers); - } - }).doOnSuccess(ignored -> System.out.println("done")) - .doOnError(err -> System.out.println("error: " + err.getMessage())) - .onErrorResume(EMException.class, ignore -> Mono.empty()) - .block(); - } - - @Command(name = "metadata", description = "Update user metadata.", mixinStandardHelpOptions = true) - public void metadata(@Parameters(description = "the username") String username, - @Option(names = "--data", description = "set user metadata") - Map dataMap) { - this.service.metadata().setMetadataToUser(username, dataMap) - .doOnSuccess(ignored -> System.out.println("done")) - .doOnError(err -> System.out.println("error: " + err.getMessage())) - .onErrorResume(EMException.class, ignore -> Mono.empty()) - .block(); - } - - private static class GroupArgGroup { - @Option(names = { - "--owner"}, description = "the new owner's username, who must be member of this group") - String owner; - - @Option(names = "--name", description = "the group's name") - String name; - - @Option(names = "--description", description = "the group's description") - String description; - - @Option(names = {"--announcement"}, description = "the announcement") - String announcement; - - @Option(names = {"--max-members"}, description = "the max number of members") - Integer maxMembers; - - @Option(names = {"--can-member-invite"}, description = "can member invite others to join") - Boolean canMemberInvite; - } - - - private static class RoomArgGroup { - @Option(names = "--name", description = "new room name") - String name; - - @Option(names = {"--description"}, description = "the announcement") - String description; - - @Option(names = {"--max-members"}, description = "the max number of members") - Integer maxMembers; - } - -} diff --git a/im-sdk-cli/src/main/resources/application.properties b/im-sdk-cli/src/main/resources/application.properties deleted file mode 100644 index e3dfd0756..000000000 --- a/im-sdk-cli/src/main/resources/application.properties +++ /dev/null @@ -1,8 +0,0 @@ -spring.config.import=${user.home}/.easemob/config.properties -logging.level.root=error -spring.main.banner-mode=off -# uncomment to log http request/response -#logging.level.com.easemob.im.http=debug -#im.appkey= -#im.client-id= -#im.client-secret= diff --git a/im-sdk-core/pom.xml b/im-sdk-core/pom.xml deleted file mode 100644 index 419a53761..000000000 --- a/im-sdk-core/pom.xml +++ /dev/null @@ -1,69 +0,0 @@ - - - 4.0.0 - - com.easemob.im - im-sdk-core - 0.8.3-SNAPSHOT - Easemob IM SDK Core - - com.easemob.im - im-sdk-parent - 0.8.3-SNAPSHOT - - - - 1.18.6 - 1.7.30 - 1.4.4 - false - - - - - ch.qos.logback - logback-classic - ${logback.version} - test - - - ch.qos.logback - logback-core - ${logback.version} - test - - - io.github.resilience4j - resilience4j-circuitbreaker - - - io.github.resilience4j - resilience4j-reactor - - - - - - org.codehaus.mojo - templating-maven-plugin - 1.0.0 - - - filter-src - - filter-sources - - - ${basedir}/src/main/java-templates - - ${project.build.directory}/generated-sources/java-templates - - - - - - - - diff --git a/im-sdk-core/src/integration-test/java/com/easemob/im/server/api/AbstractIT.java b/im-sdk-core/src/integration-test/java/com/easemob/im/server/api/AbstractIT.java deleted file mode 100644 index a7d3d7ae1..000000000 --- a/im-sdk-core/src/integration-test/java/com/easemob/im/server/api/AbstractIT.java +++ /dev/null @@ -1,54 +0,0 @@ -package com.easemob.im.server.api; - -import com.easemob.im.server.EMProperties; -import com.easemob.im.server.EMService; - -public class AbstractIT { - - protected EMService service; - - public AbstractIT() { - String realm = System.getenv("IM_REALM"); -// String appkey = System.getenv("IM_APPKEY"); - String appkey = "62242102#90"; - String baseUri = System.getenv("IM_BASE_URI"); - - EMProperties properties = null; - - if (realm != null && realm.equals(EMProperties.Realm.AGORA_REALM.toString())) { - String appId = System.getenv("IM_APP_ID"); - String appCert = System.getenv("IM_APP_CERT"); - - properties = EMProperties.builder() - .setRealm(EMProperties.Realm.AGORA_REALM) - .setBaseUri(baseUri) - .setAppkey(appkey) - .setAppId(appId) - .setAppCert(appCert) - .build(); - - } else { -// String clientId = System.getenv("IM_CLIENT_ID"); -// String clientSecret = System.getenv("IM_CLIENT_SECRET"); - - String clientId = "YXA6a1jQXZnASMeiRB_z6Vo9wA"; - String clientSecret = "YXA6LDJ_YHmppwgccxHNEZmyMnjWy1E"; - - properties = EMProperties.builder() - .setRealm(EMProperties.Realm.EASEMOB_REALM) - .setBaseUri(baseUri) - .setAppkey(appkey) - .setClientId(clientId) - .setClientSecret(clientSecret) - .setHttpConnectionPoolSize(200) - .setHttpConnectionMaxIdleTime(20000) - .setHttpConnectionMaxLifeTime(60000) - .setHttpConnectionPendingAcquireMaxCount(1000) - .setHttpConnectionPendingAcquireTimeout(120000) - .setServerTimezone("+8") - .build(); - } - - this.service = new EMService(properties); - } -} diff --git a/im-sdk-core/src/integration-test/java/com/easemob/im/server/api/AgoraTokenIT.java b/im-sdk-core/src/integration-test/java/com/easemob/im/server/api/AgoraTokenIT.java deleted file mode 100644 index 79b8d245e..000000000 --- a/im-sdk-core/src/integration-test/java/com/easemob/im/server/api/AgoraTokenIT.java +++ /dev/null @@ -1,138 +0,0 @@ -package com.easemob.im.server.api; - -import com.easemob.im.server.EMProperties; -import com.easemob.im.server.EMService; -import com.easemob.im.server.api.token.agora.AccessToken2; -import com.easemob.im.server.api.token.allocate.AgoraTokenProvider; -import com.easemob.im.server.api.user.get.UserGetResponse; -import com.easemob.im.server.exception.EMUnauthorizedException; -import com.easemob.im.server.model.EMUser; -import org.junit.jupiter.api.Assumptions; -import org.junit.jupiter.api.BeforeAll; -import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.TestInstance; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import reactor.core.publisher.Mono; -import reactor.netty.http.client.HttpClient; -import com.easemob.im.server.api.util.Utilities; - -import static com.easemob.im.server.api.util.Utilities.IT_TIMEOUT; -import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; -import static org.junit.jupiter.api.Assertions.assertThrows; - -@TestInstance(TestInstance.Lifecycle.PER_CLASS) -public class AgoraTokenIT { - - private static final AccessToken2.PrivilegeRtc DUMMY_RTC_PRIVILEGE = - AccessToken2.PrivilegeRtc.PRIVILEGE_JOIN_CHANNEL; - private static final String DUMMY_CHANNEL_NAME = "dummyChannelName"; - private static final String DUMMY_UID = "dummyUID"; - - private static final int USER_TOKEN_EXPIRE_IN_SECONDS = 600; - private static final int APP_TOKEN_EXPIRE_IN_SECONDS = 10; - - protected EMService service; - - String realm = System.getenv("IM_REALM"); - String appkey = System.getenv("IM_APPKEY"); - String baseUri = System.getenv("IM_BASE_URI"); - String appId = System.getenv("IM_APP_ID"); - String appCert = System.getenv("IM_APP_CERT"); - - @BeforeAll - public void init() { - Assumptions.assumeTrue(EMProperties.Realm.AGORA_REALM.name().equals(realm)); - EMProperties properties = EMProperties.builder() - .setAgoraTokenExpireInSeconds(APP_TOKEN_EXPIRE_IN_SECONDS) - .setRealm(EMProperties.Realm.AGORA_REALM) - .setBaseUri(baseUri) - .setAppkey(appkey) - .setAppId(appId) - .setAppCert(appCert) - .build(); - this.service = new EMService(properties); - } - - // With an Easemob App Token you can GET all users - // The app token will renew upon expiration - @Test - public void appTokenTest() throws InterruptedException { - for (int i = 0; i < 20; i ++) { - assertDoesNotThrow(() -> this.service.user() - .listUsers(1, null).block(Utilities.IT_TIMEOUT)); - Thread.sleep(1000); - } - } - - @Test - public void userTokenTest() throws Exception { - - String aliceUserName = Utilities.randomUserName(); - String alicePassword = Utilities.randomPassword(); - String bobUserName = Utilities.randomUserName(); - String bobPassword = Utilities.randomPassword(); - service.user().create(aliceUserName, alicePassword).block(IT_TIMEOUT); - service.user().create(bobUserName, bobPassword).block(IT_TIMEOUT); - - EMUser aliceUser = service.user().get(aliceUserName).block(Utilities.IT_TIMEOUT); - String aliceAgoraToken = service.token().getUserToken(aliceUser, - USER_TOKEN_EXPIRE_IN_SECONDS, - token -> { - AccessToken2.ServiceRtc serviceRtc = - new AccessToken2.ServiceRtc(DUMMY_CHANNEL_NAME, DUMMY_UID); - serviceRtc.addPrivilegeRtc(DUMMY_RTC_PRIVILEGE, USER_TOKEN_EXPIRE_IN_SECONDS); - token.addService(serviceRtc); - }, - null - ); - - HttpClient clientWithAliceEasemobToken = getClientWithEasemobHeader(aliceAgoraToken); - - // With an Easemob User Token you are not authorized to GET another user - assertThrows(EMUnauthorizedException.class, () -> { - EMUser bobUser = clientWithAliceEasemobToken - .get().uri(String.format("/users/%s", bobUserName)) - .responseSingle((rsp, buf) -> { - service.getContext().getErrorMapper().statusCode(rsp); - return buf; - }) - .doOnNext(buf -> service.getContext().getErrorMapper().checkError(buf)) - .map(buf -> service.getContext().getCodec().decode(buf, UserGetResponse.class)) - .block(Utilities.IT_TIMEOUT) - .getEMUser(bobUserName); - }); - - // With an Easemob User Token you are able to GET the token owner - assertDoesNotThrow(() -> { - EMUser aliceUserFetchedWithHerToken = clientWithAliceEasemobToken - .get().uri(String.format("/users/%s", aliceUserName)) - .responseSingle((rsp, buf) -> { - service.getContext().getErrorMapper().statusCode(rsp); - return buf; - }) - .doOnNext(buf -> service.getContext().getErrorMapper().checkError(buf)) - .map(buf -> service.getContext().getCodec().decode(buf, UserGetResponse.class)) - .block(Utilities.IT_TIMEOUT) - .getEMUser(aliceUserName); - }); - - service.user().delete(aliceUserName).block(IT_TIMEOUT); - service.user().delete(bobUserName).block(IT_TIMEOUT); - } - - private HttpClient getClientWithEasemobHeader(String agoraToken) { - Context context = service.getContext(); - Codec codec = context.getCodec(); - ErrorMapper errorMapper = context.getErrorMapper(); - HttpClient httpClient = EMHttpClientFactory.create(context.getProperties()); - String baseUrl = - String.format("%s/%s", baseUri, context.getProperties().getAppkeySlashDelimited()); - String easemobToken = AgoraTokenProvider - .exchangeForEasemobToken(httpClient, baseUrl, Mono.just(agoraToken), codec, errorMapper) - .block(IT_TIMEOUT).getValue(); - return EMHttpClientFactory.create(context.getProperties()).baseUrl(baseUrl) - .headers(headers -> headers - .set("Authorization", String.format("Bearer %s", easemobToken))); - } -} diff --git a/im-sdk-core/src/integration-test/java/com/easemob/im/server/api/attachment/AttachmentIT.java b/im-sdk-core/src/integration-test/java/com/easemob/im/server/api/attachment/AttachmentIT.java deleted file mode 100644 index 820196080..000000000 --- a/im-sdk-core/src/integration-test/java/com/easemob/im/server/api/attachment/AttachmentIT.java +++ /dev/null @@ -1,49 +0,0 @@ -package com.easemob.im.server.api.attachment; - -import com.easemob.im.server.api.AbstractIT; -import com.easemob.im.server.api.util.Utilities; -import com.easemob.im.server.model.EMAttachment; -import org.junit.jupiter.api.Test; -import org.junit.platform.commons.util.ClassLoaderUtils; - -import java.nio.file.FileSystems; -import java.nio.file.Path; - -import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; - -import org.junit.jupiter.api.Disabled; - -public class AttachmentIT extends AbstractIT { - - AttachmentIT() { - super(); - } - - @Disabled - void testAttachmentUpload() { - String path = - ClassLoaderUtils.getDefaultClassLoader().getResource("upload/image.png").getPath(); - Path uploadPath = FileSystems.getDefault().getPath(path); - assertDoesNotThrow(() -> this.service.attachment().uploadFile(uploadPath) - .block(Utilities.IT_TIMEOUT)); - } - - // TODO: REST API has a bug --> disable this test for now - @Disabled - void testAttachmentDownload() { - Path uploadPath = FileSystems.getDefault().getPath( - ClassLoaderUtils.getDefaultClassLoader().getResource("upload/image.png").getPath()); - EMAttachment attachment = assertDoesNotThrow( - () -> this.service.attachment().uploadFile(uploadPath) - .block(Utilities.IT_TIMEOUT)); - - Path downloadPath = FileSystems.getDefault().getPath( - ClassLoaderUtils.getDefaultClassLoader().getResource("download/attachment/") - .getPath()); - assertDoesNotThrow(() -> this.service.attachment() - .downloadFile(attachment.getId(), downloadPath, "file.png") - .block(Utilities.IT_TIMEOUT)); - } - -} - diff --git a/im-sdk-core/src/integration-test/java/com/easemob/im/server/api/group/GroupIT.java b/im-sdk-core/src/integration-test/java/com/easemob/im/server/api/group/GroupIT.java deleted file mode 100644 index 1e92a49f6..000000000 --- a/im-sdk-core/src/integration-test/java/com/easemob/im/server/api/group/GroupIT.java +++ /dev/null @@ -1,1593 +0,0 @@ -package com.easemob.im.server.api.group; - -import com.easemob.im.server.api.AbstractIT; -import com.easemob.im.server.api.group.list.GroupResource; -import com.easemob.im.server.api.util.Utilities; -import com.easemob.im.server.exception.EMNotFoundException; -import com.easemob.im.server.model.EMBlock; -import com.easemob.im.server.model.EMGroup; -import com.easemob.im.server.model.EMPage; -import org.junit.jupiter.api.Test; - -import java.time.Duration; -import java.util.*; - -import static org.junit.jupiter.api.Assertions.*; - -public class GroupIT extends AbstractIT { - - GroupIT() { - super(); - } - - @Test - void testGroupCreatePublic() { - String randomOwnerUsername = Utilities.randomUserName(); - String randomPassword = Utilities.randomPassword(); - - String randomMemberUsername = Utilities.randomUserName(); - List members = new ArrayList<>(); - members.add(randomMemberUsername); - assertDoesNotThrow(() -> this.service.user().create(randomOwnerUsername, randomPassword) - .block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow(() -> this.service.user().create(randomMemberUsername, randomPassword) - .block(Utilities.IT_TIMEOUT)); - String groupId = assertDoesNotThrow(() -> this.service.group() - .createPublicGroup(randomOwnerUsername, "group", "group description", members, 200, - true).block(Utilities.IT_TIMEOUT)); - EMPage groupMemberPage = assertDoesNotThrow( - () -> this.service.group().listGroupMembers(groupId, 10, null) - .block(Utilities.IT_TIMEOUT)); - List groupMembers = groupMemberPage.getValues(); - if (groupMembers.size() != members.size()) { - throw new RuntimeException( - String.format("incorrect number of group %s members", groupId)); - } - assertDoesNotThrow( - () -> this.service.group().destroyGroup(groupId).block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow( - () -> this.service.user().delete(randomOwnerUsername).block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow(() -> this.service.user().delete(randomMemberUsername) - .block(Utilities.IT_TIMEOUT)); - } - - @Test - void testGroupCreatePublicWithCustom() { - String randomOwnerUsername = Utilities.randomUserName(); - String randomPassword = Utilities.randomPassword(); - - String randomMemberUsername = Utilities.randomUserName(); - List members = new ArrayList<>(); - members.add(randomMemberUsername); - assertDoesNotThrow(() -> this.service.user().create(randomOwnerUsername, randomPassword) - .block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow(() -> this.service.user().create(randomMemberUsername, randomPassword) - .block(Utilities.IT_TIMEOUT)); - String groupId = assertDoesNotThrow(() -> this.service.group() - .createPublicGroup(randomOwnerUsername, "group", "group description", members, 200, - true, "custom").block(Utilities.IT_TIMEOUT)); - EMPage groupMemberPage = assertDoesNotThrow( - () -> this.service.group().listGroupMembers(groupId, 10, null) - .block(Utilities.IT_TIMEOUT)); - List groupMembers = groupMemberPage.getValues(); - if (groupMembers.size() != members.size()) { - throw new RuntimeException( - String.format("incorrect number of group %s members", groupId)); - } - assertDoesNotThrow( - () -> this.service.group().destroyGroup(groupId).block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow( - () -> this.service.user().delete(randomOwnerUsername).block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow(() -> this.service.user().delete(randomMemberUsername) - .block(Utilities.IT_TIMEOUT)); - } - - @Test - void testGroupCreatePrivateWithNeedVerify() { - String randomOwnerUsername = Utilities.randomUserName(); - String randomPassword = Utilities.randomPassword(); - - String randomMemberUsername = Utilities.randomUserName(); - List members = new ArrayList<>(); - members.add(randomMemberUsername); - assertDoesNotThrow(() -> this.service.user().create(randomOwnerUsername, randomPassword) - .block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow(() -> this.service.user().create(randomMemberUsername, randomPassword) - .block(Utilities.IT_TIMEOUT)); - String groupId = assertDoesNotThrow(() -> this.service.group() - .createPrivateGroup(randomOwnerUsername, "group", "group description", members, 200, - true, true, true, "custom", false).block(Utilities.IT_TIMEOUT)); - EMPage groupMemberPage = assertDoesNotThrow( - () -> this.service.group().listGroupMembers(groupId, 100, null) - .block(Utilities.IT_TIMEOUT)); - - List groupMembers = groupMemberPage.getValues(); - if (groupMembers.size() != members.size()) { - throw new RuntimeException( - String.format("incorrect number of group %s members", groupId)); - } - assertDoesNotThrow( - () -> this.service.group().destroyGroup(groupId).block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow( - () -> this.service.user().delete(randomOwnerUsername).block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow(() -> this.service.user().delete(randomMemberUsername) - .block(Utilities.IT_TIMEOUT)); - } - - @Test - void testGroupCreatePrivate() { - String randomOwnerUsername = Utilities.randomUserName(); - String randomPassword = Utilities.randomPassword(); - - String randomMemberUsername = Utilities.randomUserName(); - List members = new ArrayList<>(); - members.add(randomMemberUsername); - assertDoesNotThrow(() -> this.service.user().create(randomOwnerUsername, randomPassword) - .block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow(() -> this.service.user().create(randomMemberUsername, randomPassword) - .block(Utilities.IT_TIMEOUT)); - String groupId = assertDoesNotThrow(() -> this.service.group() - .createPrivateGroup(randomOwnerUsername, "group", "group description", members, 200, - true, true, true, "custom").block(Utilities.IT_TIMEOUT)); - EMPage groupMemberPage = assertDoesNotThrow( - () -> this.service.group().listGroupMembers(groupId, 100, null) - .block(Utilities.IT_TIMEOUT)); - - List groupMembers = groupMemberPage.getValues(); - if (groupMembers.size() != members.size()) { - throw new RuntimeException( - String.format("incorrect number of group %s members", groupId)); - } - assertDoesNotThrow( - () -> this.service.group().destroyGroup(groupId).block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow( - () -> this.service.user().delete(randomOwnerUsername).block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow(() -> this.service.user().delete(randomMemberUsername) - .block(Utilities.IT_TIMEOUT)); - } - - @Test - void testGroupCreatePublicWithNeedVerify() { - String randomOwnerUsername = Utilities.randomUserName(); - String randomPassword = Utilities.randomPassword(); - - String randomMemberUsername = Utilities.randomUserName(); - List members = new ArrayList<>(); - members.add(randomMemberUsername); - assertDoesNotThrow(() -> this.service.user().create(randomOwnerUsername, randomPassword) - .block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow(() -> this.service.user().create(randomMemberUsername, randomPassword) - .block(Utilities.IT_TIMEOUT)); - String groupId = assertDoesNotThrow(() -> this.service.group() - .createPublicGroup(randomOwnerUsername, "politics", "group description", members, 200, - true, "custom", true).block(Utilities.IT_TIMEOUT)); - EMPage groupMemberPage = assertDoesNotThrow( - () -> this.service.group().listGroupMembers(groupId, 10, null) - .block(Utilities.IT_TIMEOUT)); - List groupMembers = groupMemberPage.getValues(); - if (groupMembers.size() != members.size()) { - throw new RuntimeException( - String.format("incorrect number of group %s members", groupId)); - } - assertDoesNotThrow( - () -> this.service.group().destroyGroup(groupId).block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow( - () -> this.service.user().delete(randomOwnerUsername).block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow(() -> this.service.user().delete(randomMemberUsername) - .block(Utilities.IT_TIMEOUT)); - } - - @Test - void testLargeGroupCreatePublic() { - String randomOwnerUsername = Utilities.randomUserName(); - String randomPassword = Utilities.randomPassword(); - - String randomMemberUsername = Utilities.randomUserName(); - List members = new ArrayList<>(); - members.add(randomMemberUsername); - assertDoesNotThrow(() -> this.service.user().create(randomOwnerUsername, randomPassword) - .block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow(() -> this.service.user().create(randomMemberUsername, randomPassword) - .block(Utilities.IT_TIMEOUT)); - String groupId = assertDoesNotThrow(() -> this.service.group() - .createLargePublicGroup(randomOwnerUsername, "politics", "group description", members, 5000, - true, "custom", true).block(Utilities.IT_TIMEOUT)); - EMGroup group = assertDoesNotThrow( - () -> this.service.group().getGroup(groupId) - .block(Utilities.IT_TIMEOUT)); - if (5000 != group.getMaxMembers()) { - throw new RuntimeException( - String.format("%s is not a large group", groupId)); - } - assertDoesNotThrow( - () -> this.service.group().destroyGroup(groupId).block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow( - () -> this.service.user().delete(randomOwnerUsername).block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow(() -> this.service.user().delete(randomMemberUsername) - .block(Utilities.IT_TIMEOUT)); - } - - @Test - void testLargeGroupCreatePublicWithCustomGroupId() { - String randomOwnerUsername = Utilities.randomUserName(); - String randomPassword = Utilities.randomPassword(); - - String randomMemberUsername = Utilities.randomUserName(); - List members = new ArrayList<>(); - members.add(randomMemberUsername); - assertDoesNotThrow(() -> this.service.user().create(randomOwnerUsername, randomPassword) - .block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow(() -> this.service.user().create(randomMemberUsername, randomPassword) - .block(Utilities.IT_TIMEOUT)); - - Random random = new Random(); - String customGroupId = String.valueOf(10000000 + random.nextInt(80000000)); - String groupId = assertDoesNotThrow(() -> this.service.group() - .createLargePublicGroup(customGroupId, randomOwnerUsername, "politics", "group description", members, 5000, - true, "custom", true).block(Utilities.IT_TIMEOUT)); - EMGroup group = assertDoesNotThrow( - () -> this.service.group().getGroup(groupId) - .block(Utilities.IT_TIMEOUT)); - if (!customGroupId.equals(groupId)) { - throw new RuntimeException( - String.format("%s and %s are different", customGroupId, groupId)); - } - if (5000 != group.getMaxMembers()) { - throw new RuntimeException( - String.format("%s is not a large group", groupId)); - } - assertDoesNotThrow( - () -> this.service.group().destroyGroup(groupId).block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow( - () -> this.service.user().delete(randomOwnerUsername).block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow(() -> this.service.user().delete(randomMemberUsername) - .block(Utilities.IT_TIMEOUT)); - } - - @Test - void testLargeGroupCreatePrivate() { - String randomOwnerUsername = Utilities.randomUserName(); - String randomPassword = Utilities.randomPassword(); - - String randomMemberUsername = Utilities.randomUserName(); - List members = new ArrayList<>(); - members.add(randomMemberUsername); - assertDoesNotThrow(() -> this.service.user().create(randomOwnerUsername, randomPassword) - .block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow(() -> this.service.user().create(randomMemberUsername, randomPassword) - .block(Utilities.IT_TIMEOUT)); - String groupId = assertDoesNotThrow(() -> this.service.group() - .createLargePrivateGroup(randomOwnerUsername, "group", "group description", members, 5000, - true, true, true, "custom", false).block(Utilities.IT_TIMEOUT)); - EMGroup group = assertDoesNotThrow( - () -> this.service.group().getGroup(groupId) - .block(Utilities.IT_TIMEOUT)); - if (5000 != group.getMaxMembers()) { - throw new RuntimeException( - String.format("%s is not a large group", groupId)); - } - assertDoesNotThrow( - () -> this.service.group().destroyGroup(groupId).block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow( - () -> this.service.user().delete(randomOwnerUsername).block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow(() -> this.service.user().delete(randomMemberUsername) - .block(Utilities.IT_TIMEOUT)); - } - - @Test - void testLargeGroupCreatePrivateWithCustomGroupId() { - String randomOwnerUsername = Utilities.randomUserName(); - String randomPassword = Utilities.randomPassword(); - - String randomMemberUsername = Utilities.randomUserName(); - List members = new ArrayList<>(); - members.add(randomMemberUsername); - assertDoesNotThrow(() -> this.service.user().create(randomOwnerUsername, randomPassword) - .block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow(() -> this.service.user().create(randomMemberUsername, randomPassword) - .block(Utilities.IT_TIMEOUT)); - - Random random = new Random(); - String customGroupId = String.valueOf(10000000 + random.nextInt(80000000)); - String groupId = assertDoesNotThrow(() -> this.service.group() - .createLargePrivateGroup(customGroupId, randomOwnerUsername, "group", "group description", members, 5000, - true, true, true, "custom", false).block(Utilities.IT_TIMEOUT)); - EMGroup group = assertDoesNotThrow( - () -> this.service.group().getGroup(groupId) - .block(Utilities.IT_TIMEOUT)); - if (!customGroupId.equals(groupId)) { - throw new RuntimeException( - String.format("%s and %s are different", customGroupId, groupId)); - } - if (5000 != group.getMaxMembers()) { - throw new RuntimeException( - String.format("%s is not a large group", groupId)); - } - assertDoesNotThrow( - () -> this.service.group().destroyGroup(groupId).block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow( - () -> this.service.user().delete(randomOwnerUsername).block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow(() -> this.service.user().delete(randomMemberUsername) - .block(Utilities.IT_TIMEOUT)); - } - - @Test - void testGroupDestroy() throws InterruptedException { - String randomOwnerUsername = Utilities.randomUserName(); - String randomPassword = Utilities.randomPassword(); - - String randomMemberUsername = Utilities.randomUserName(); - List members = new ArrayList<>(); - members.add(randomMemberUsername); - assertDoesNotThrow(() -> this.service.user().create(randomOwnerUsername, randomPassword) - .block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow(() -> this.service.user().create(randomMemberUsername, randomPassword) - .block(Utilities.IT_TIMEOUT)); - String groupId = assertDoesNotThrow(() -> this.service.group() - .createPrivateGroup(randomOwnerUsername, "group", "group description", members, 200, - true).block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow( - () -> this.service.group().destroyGroup(groupId).block(Utilities.IT_TIMEOUT)); - Thread.sleep(3000); - assertThrows(EMNotFoundException.class, - () -> this.service.group().getGroup(groupId).block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow( - () -> this.service.user().delete(randomOwnerUsername).block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow(() -> this.service.user().delete(randomMemberUsername) - .block(Utilities.IT_TIMEOUT)); - } - - @Test - void testGroupListAllGroups() { - String randomOwnerUsername = Utilities.randomUserName(); - String randomPassword = Utilities.randomPassword(); - - String randomMemberUsername = Utilities.randomUserName(); - List members = new ArrayList<>(); - members.add(randomMemberUsername); - assertDoesNotThrow(() -> this.service.user().create(randomOwnerUsername, randomPassword) - .block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow(() -> this.service.user().create(randomMemberUsername, randomPassword) - .block(Utilities.IT_TIMEOUT)); - String groupId = assertDoesNotThrow(() -> this.service.group() - .createPrivateGroup(randomOwnerUsername, "group", "group description", members, 200, - true).block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow( - () -> this.service.group().listAllGroups().blockFirst(Utilities.IT_TIMEOUT)); - assertDoesNotThrow( - () -> this.service.group().destroyGroup(groupId).block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow( - () -> this.service.user().delete(randomOwnerUsername).block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow(() -> this.service.user().delete(randomMemberUsername) - .block(Utilities.IT_TIMEOUT)); - } - - @Test - void testGroupListAllGroupsWithInfo() { - String randomOwnerUsername = Utilities.randomUserName(); - String randomPassword = Utilities.randomPassword(); - - String randomMemberUsername = Utilities.randomUserName(); - List members = new ArrayList<>(); - members.add(randomMemberUsername); - assertDoesNotThrow(() -> this.service.user().create(randomOwnerUsername, randomPassword) - .block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow(() -> this.service.user().create(randomMemberUsername, randomPassword) - .block(Utilities.IT_TIMEOUT)); - String groupId = assertDoesNotThrow(() -> this.service.group() - .createPrivateGroup(randomOwnerUsername, "group", "group description", members, 200, - true).block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow( - () -> this.service.group().listAllGroupsWithInfo().blockFirst(Utilities.IT_TIMEOUT)); - assertDoesNotThrow( - () -> this.service.group().destroyGroup(groupId).block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow( - () -> this.service.user().delete(randomOwnerUsername).block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow(() -> this.service.user().delete(randomMemberUsername) - .block(Utilities.IT_TIMEOUT)); - } - - @Test - void testGroupListGroups() { - String randomOwnerUsername = Utilities.randomUserName(); - String randomPassword = Utilities.randomPassword(); - - String randomMemberUsername = Utilities.randomUserName(); - List members = new ArrayList<>(); - members.add(randomMemberUsername); - assertDoesNotThrow(() -> this.service.user().create(randomOwnerUsername, randomPassword) - .block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow(() -> this.service.user().create(randomMemberUsername, randomPassword) - .block(Utilities.IT_TIMEOUT)); - String groupId = assertDoesNotThrow(() -> this.service.group() - .createPrivateGroup(randomOwnerUsername, "group", "group description", members, 200, - true).block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow( - () -> this.service.group().listGroups(1, null).block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow( - () -> this.service.group().destroyGroup(groupId).block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow( - () -> this.service.user().delete(randomOwnerUsername).block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow(() -> this.service.user().delete(randomMemberUsername) - .block(Utilities.IT_TIMEOUT)); - } - - @Test - void testGroupListGroupsWithInfo() { - String randomOwnerUsername = Utilities.randomUserName(); - String randomPassword = Utilities.randomPassword(); - - String randomMemberUsername = Utilities.randomUserName(); - List members = new ArrayList<>(); - members.add(randomMemberUsername); - assertDoesNotThrow(() -> this.service.user().create(randomOwnerUsername, randomPassword) - .block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow(() -> this.service.user().create(randomMemberUsername, randomPassword) - .block(Utilities.IT_TIMEOUT)); - String groupId = assertDoesNotThrow(() -> this.service.group() - .createPrivateGroup(randomOwnerUsername, "group", "group description", members, 200, - true).block(Utilities.IT_TIMEOUT)); - EMPage group = this.service.group().listGroupsWithInfo(1, null).block(Utilities.IT_TIMEOUT); - assertDoesNotThrow( - () -> this.service.group().listGroupsWithInfo(1, null).block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow( - () -> this.service.group().destroyGroup(groupId).block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow( - () -> this.service.user().delete(randomOwnerUsername).block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow(() -> this.service.user().delete(randomMemberUsername) - .block(Utilities.IT_TIMEOUT)); - } - - @Test - void testUserJoinGroupList() { - String randomOwnerUsername = Utilities.randomUserName(); - String randomPassword = Utilities.randomPassword(); - - String randomMemberUsername = Utilities.randomUserName(); - List members = new ArrayList<>(); - members.add(randomMemberUsername); - assertDoesNotThrow(() -> this.service.user().create(randomOwnerUsername, randomPassword) - .block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow(() -> this.service.user().create(randomMemberUsername, randomPassword) - .block(Utilities.IT_TIMEOUT)); - String groupId = assertDoesNotThrow(() -> this.service.group() - .createPrivateGroup(randomOwnerUsername, "group", "group description", members, 200, - true).block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow( - () -> this.service.group().listGroupsUserJoined(randomMemberUsername).blockFirst(Utilities.IT_TIMEOUT)); - assertDoesNotThrow( - () -> this.service.group().destroyGroup(groupId).block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow( - () -> this.service.user().delete(randomOwnerUsername).block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow(() -> this.service.user().delete(randomMemberUsername) - .block(Utilities.IT_TIMEOUT)); - } - - @Test - void testUserJoinGroupListWithInfo() { - String randomOwnerUsername = Utilities.randomUserName(); - String randomPassword = Utilities.randomPassword(); - - String randomMemberUsername = Utilities.randomUserName(); - List members = new ArrayList<>(); - members.add(randomMemberUsername); - assertDoesNotThrow(() -> this.service.user().create(randomOwnerUsername, randomPassword) - .block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow(() -> this.service.user().create(randomMemberUsername, randomPassword) - .block(Utilities.IT_TIMEOUT)); - String groupId = assertDoesNotThrow(() -> this.service.group() - .createPrivateGroup(randomOwnerUsername, "group", "group description", members, 200, - true).block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow( - () -> this.service.group().listGroupsUserJoinedWithInfo(randomMemberUsername).blockFirst(Utilities.IT_TIMEOUT)); - assertDoesNotThrow( - () -> this.service.group().listGroupsUserJoinedWithInfo(randomMemberUsername, 1, 1).block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow( - () -> this.service.group().destroyGroup(groupId).block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow( - () -> this.service.user().delete(randomOwnerUsername).block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow(() -> this.service.user().delete(randomMemberUsername) - .block(Utilities.IT_TIMEOUT)); - } - - @Test - void testGroupGet() { - String randomOwnerUsername = Utilities.randomUserName(); - String randomPassword = Utilities.randomPassword(); - - String randomMemberUsername = Utilities.randomUserName(); - String randomAdminUsername = Utilities.randomUserName(); - List members = new ArrayList<>(); - members.add(randomMemberUsername); - members.add(randomAdminUsername); - assertDoesNotThrow(() -> this.service.user().create(randomOwnerUsername, randomPassword) - .block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow(() -> this.service.user().create(randomMemberUsername, randomPassword) - .block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow(() -> this.service.user().create(randomAdminUsername, randomPassword) - .block(Utilities.IT_TIMEOUT)); - String groupId = assertDoesNotThrow(() -> this.service.group() - .createPrivateGroup(randomOwnerUsername, "group", "group description", members, 200, - true).block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow( - () -> this.service.group().addGroupAdmin(groupId, randomAdminUsername).block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow( - () -> { - EMGroup emGroup = this.service.group().getGroup(groupId).block(Utilities.IT_TIMEOUT); - assertEquals(emGroup.getAffiliationsCount(), 3); - assertNotNull(emGroup.getAffiliations()); - EMGroup.Affiliation affiliation = emGroup.getAffiliations(); - assertEquals(affiliation.getMembers().length, 2); - }); - assertDoesNotThrow( - () -> this.service.group().destroyGroup(groupId).block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow( - () -> this.service.user().delete(randomOwnerUsername).block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow(() -> this.service.user().delete(randomMemberUsername) - .block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow(() -> this.service.user().delete(randomAdminUsername) - .block(Utilities.IT_TIMEOUT)); - } - - @Test - void testGroupListGet() { - String randomOwnerUsername = Utilities.randomUserName(); - String randomPassword = Utilities.randomPassword(); - - String randomMemberUsername = Utilities.randomUserName(); - String randomAdminUsername = Utilities.randomUserName(); - List members = new ArrayList<>(); - members.add(randomMemberUsername); - members.add(randomAdminUsername); - assertDoesNotThrow(() -> this.service.user().create(randomOwnerUsername, randomPassword) - .block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow(() -> this.service.user().create(randomMemberUsername, randomPassword) - .block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow(() -> this.service.user().create(randomAdminUsername, randomPassword) - .block(Utilities.IT_TIMEOUT)); - String groupId1 = assertDoesNotThrow(() -> this.service.group() - .createPrivateGroup(randomOwnerUsername, "group", "group description", members, 200, - true).block(Utilities.IT_TIMEOUT)); - - String groupId2 = assertDoesNotThrow(() -> this.service.group() - .createPrivateGroup(randomOwnerUsername, "group", "group description", members, 200, - true).block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow( - () -> { - List groupIdList = new ArrayList<>(); - groupIdList.add(groupId1); - groupIdList.add(groupId2); - List emGroupList = this.service.group().getGroupList(groupIdList).block(Utilities.IT_TIMEOUT); - emGroupList.forEach(emGroup -> { - assertEquals(emGroup.getAffiliationsCount(), 3); - assertNotNull(emGroup.getAffiliations()); - EMGroup.Affiliation affiliation = emGroup.getAffiliations(); - assertEquals(affiliation.getMembers().length, 2); - }); - }); - assertDoesNotThrow( - () -> this.service.group().destroyGroup(groupId1).block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow( - () -> this.service.group().destroyGroup(groupId2).block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow( - () -> this.service.user().delete(randomOwnerUsername).block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow(() -> this.service.user().delete(randomMemberUsername) - .block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow(() -> this.service.user().delete(randomAdminUsername) - .block(Utilities.IT_TIMEOUT)); - } - - @Test - void testGroupGetWithCustom() { - String randomOwnerUsername = Utilities.randomUserName(); - String randomPassword = Utilities.randomPassword(); - - String randomMemberUsername = Utilities.randomUserName(); - String randomAdminUsername = Utilities.randomUserName(); - List members = new ArrayList<>(); - members.add(randomMemberUsername); - members.add(randomAdminUsername); - assertDoesNotThrow(() -> this.service.user().create(randomOwnerUsername, randomPassword) - .block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow(() -> this.service.user().create(randomMemberUsername, randomPassword) - .block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow(() -> this.service.user().create(randomAdminUsername, randomPassword) - .block(Utilities.IT_TIMEOUT)); - String groupId = assertDoesNotThrow(() -> this.service.group() - .createPrivateGroup(randomOwnerUsername, "group", "group description", members, 200, - true, "custom").block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow( - () -> this.service.group().addGroupAdmin(groupId, randomAdminUsername).block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow( - () -> { - EMGroup emGroup = this.service.group().getGroup(groupId).block(Utilities.IT_TIMEOUT); - assertEquals(emGroup.getAffiliationsCount(), 3); - assertNotNull(emGroup.getAffiliations()); - EMGroup.Affiliation affiliation = emGroup.getAffiliations(); - assertEquals(affiliation.getMembers().length, 2); - assertEquals(emGroup.getIsMute(), false); - assertEquals(emGroup.getCustom(), "custom"); - }); - assertDoesNotThrow( - () -> this.service.group().destroyGroup(groupId).block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow( - () -> this.service.user().delete(randomOwnerUsername).block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow(() -> this.service.user().delete(randomMemberUsername) - .block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow(() -> this.service.user().delete(randomAdminUsername) - .block(Utilities.IT_TIMEOUT)); - } - - @Test - void testGroupUpdate() { - String randomOwnerUsername = Utilities.randomUserName(); - String randomPassword = Utilities.randomPassword(); - - String randomMemberUsername = Utilities.randomUserName(); - List members = new ArrayList<>(); - members.add(randomMemberUsername); - assertDoesNotThrow(() -> this.service.user().create(randomOwnerUsername, randomPassword) - .block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow(() -> this.service.user().create(randomMemberUsername, randomPassword) - .block(Utilities.IT_TIMEOUT)); - int maxMembers = 100; - String groupId = assertDoesNotThrow(() -> this.service.group() - .createPrivateGroup(randomOwnerUsername, "group", "group description", members, 200, - true).block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow(() -> this.service.group() - .updateGroup(groupId, settings -> settings.setMaxMembers(maxMembers).setPublic(true).setCustom("group custom")) - .block(Utilities.IT_TIMEOUT)); - EMGroup group = assertDoesNotThrow( - () -> this.service.group().getGroup(groupId).block(Utilities.IT_TIMEOUT)); - if (group.getMaxMembers() != maxMembers) { - throw new RuntimeException(String.format("%s group max member update fail", groupId)); - } - if (!group.getIsPublic()) { - throw new RuntimeException(String.format("%s group public update fail", groupId)); - } - assertDoesNotThrow( - () -> this.service.group().destroyGroup(groupId).block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow( - () -> this.service.user().delete(randomOwnerUsername).block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow(() -> this.service.user().delete(randomMemberUsername) - .block(Utilities.IT_TIMEOUT)); - } - - @Test - void testGroupUpdateOwner() { - String randomOwnerUsername = Utilities.randomUserName(); - String randomPassword = Utilities.randomPassword(); - - String randomMemberUsername = Utilities.randomUserName(); - List members = new ArrayList<>(); - members.add(randomMemberUsername); - assertDoesNotThrow(() -> this.service.user().create(randomOwnerUsername, randomPassword) - .block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow(() -> this.service.user().create(randomMemberUsername, randomPassword) - .block(Utilities.IT_TIMEOUT)); - String groupId = assertDoesNotThrow(() -> this.service.group() - .createPrivateGroup(randomOwnerUsername, "group", "group description", members, 200, - true).block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow( - () -> this.service.group().updateGroupOwner(groupId, randomMemberUsername) - .block(Utilities.IT_TIMEOUT)); - EMGroup group = assertDoesNotThrow( - () -> this.service.group().getGroup(groupId).block(Utilities.IT_TIMEOUT)); - if (!group.getOwner().equals(randomMemberUsername)) { - throw new RuntimeException( - String.format("%s group update owner %s fail", groupId, randomMemberUsername)); - } - assertDoesNotThrow( - () -> this.service.group().destroyGroup(groupId).block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow( - () -> this.service.user().delete(randomOwnerUsername).block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow(() -> this.service.user().delete(randomMemberUsername) - .block(Utilities.IT_TIMEOUT)); - } - - @Test - void testGroupGetAnnouncement() { - String randomOwnerUsername = Utilities.randomUserName(); - String randomPassword = Utilities.randomPassword(); - - String randomMemberUsername = Utilities.randomUserName(); - List members = new ArrayList<>(); - members.add(randomMemberUsername); - assertDoesNotThrow(() -> this.service.user().create(randomOwnerUsername, randomPassword) - .block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow(() -> this.service.user().create(randomMemberUsername, randomPassword) - .block(Utilities.IT_TIMEOUT)); - String groupId = assertDoesNotThrow(() -> this.service.group() - .createPrivateGroup(randomOwnerUsername, "group", "group description", members, 200, - true).block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow(() -> this.service.group().getGroupAnnouncement(groupId) - .block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow( - () -> this.service.group().destroyGroup(groupId).block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow( - () -> this.service.user().delete(randomOwnerUsername).block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow(() -> this.service.user().delete(randomMemberUsername) - .block(Utilities.IT_TIMEOUT)); - } - - @Test - void testGroupUpdateAnnouncement() { - String randomOwnerUsername = Utilities.randomUserName(); - String randomPassword = Utilities.randomPassword(); - - String randomMemberUsername = Utilities.randomUserName(); - List members = new ArrayList<>(); - members.add(randomMemberUsername); - assertDoesNotThrow(() -> this.service.user().create(randomOwnerUsername, randomPassword) - .block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow(() -> this.service.user().create(randomMemberUsername, randomPassword) - .block(Utilities.IT_TIMEOUT)); - String updateAnnouncement = "update announcement"; - String groupId = assertDoesNotThrow(() -> this.service.group() - .createPrivateGroup(randomOwnerUsername, "group", "group description", members, 200, - true).block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow( - () -> this.service.group().updateGroupAnnouncement(groupId, updateAnnouncement) - .block(Utilities.IT_TIMEOUT)); - String newAnnouncement = assertDoesNotThrow( - () -> this.service.group().getGroupAnnouncement(groupId) - .block(Utilities.IT_TIMEOUT)); - if (!updateAnnouncement.equals(newAnnouncement)) { - throw new RuntimeException(String.format("update %s group announcement fail", groupId)); - } - assertDoesNotThrow( - () -> this.service.group().destroyGroup(groupId).block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow( - () -> this.service.user().delete(randomOwnerUsername).block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow(() -> this.service.user().delete(randomMemberUsername) - .block(Utilities.IT_TIMEOUT)); - } - - @Test - void testGroupListAllGroupMembers() { - String randomOwnerUsername = Utilities.randomUserName(); - String randomPassword = Utilities.randomPassword(); - - String randomMemberUsername = Utilities.randomUserName(); - List members = new ArrayList<>(); - members.add(randomMemberUsername); - assertDoesNotThrow(() -> this.service.user().create(randomOwnerUsername, randomPassword) - .block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow(() -> this.service.user().create(randomMemberUsername, randomPassword) - .block(Utilities.IT_TIMEOUT)); - String groupId = assertDoesNotThrow(() -> this.service.group() - .createPrivateGroup(randomOwnerUsername, "group", "group description", members, 200, - true).block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow(() -> this.service.group().listAllGroupMembers(groupId) - .blockFirst(Utilities.IT_TIMEOUT)); - assertDoesNotThrow( - () -> this.service.group().destroyGroup(groupId).block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow( - () -> this.service.user().delete(randomOwnerUsername).block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow(() -> this.service.user().delete(randomMemberUsername) - .block(Utilities.IT_TIMEOUT)); - } - - @Test - void testListAllGroupMembersIncludeOwner() { - String randomOwnerUsername = Utilities.randomUserName(); - String randomPassword = Utilities.randomPassword(); - - String randomMemberUsername = Utilities.randomUserName(); - List members = new ArrayList<>(); - members.add(randomMemberUsername); - assertDoesNotThrow(() -> this.service.user().create(randomOwnerUsername, randomPassword) - .block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow(() -> this.service.user().create(randomMemberUsername, randomPassword) - .block(Utilities.IT_TIMEOUT)); - String groupId = assertDoesNotThrow(() -> this.service.group() - .createPrivateGroup(randomOwnerUsername, "group", "group description", members, 200, - true).block(Utilities.IT_TIMEOUT)); - List> memberList = assertDoesNotThrow(() -> this.service.group().listAllGroupMembersIncludeOwner(groupId, "asc") - .collectList().block(Utilities.IT_TIMEOUT)); - assertEquals(memberList.size(), 2); - - assertDoesNotThrow( - () -> this.service.group().destroyGroup(groupId).block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow( - () -> this.service.user().delete(randomOwnerUsername).block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow(() -> this.service.user().delete(randomMemberUsername) - .block(Utilities.IT_TIMEOUT)); - } - - @Test - void testListGroupMembersIncludeOwner() { - String randomOwnerUsername = Utilities.randomUserName(); - String randomPassword = Utilities.randomPassword(); - - String randomMemberUsername = Utilities.randomUserName(); - List members = new ArrayList<>(); - members.add(randomMemberUsername); - assertDoesNotThrow(() -> this.service.user().create(randomOwnerUsername, randomPassword) - .block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow(() -> this.service.user().create(randomMemberUsername, randomPassword) - .block(Utilities.IT_TIMEOUT)); - String groupId = assertDoesNotThrow(() -> this.service.group() - .createPrivateGroup(randomOwnerUsername, "group", "group description", members, 200, - true).block(Utilities.IT_TIMEOUT)); - List> memberList = assertDoesNotThrow(() -> this.service.group().listGroupMembersIncludeOwner(groupId, 0, 1, "asc") - .block(Utilities.IT_TIMEOUT)); - assertEquals(memberList.size(), 1); - - assertDoesNotThrow( - () -> this.service.group().destroyGroup(groupId).block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow( - () -> this.service.user().delete(randomOwnerUsername).block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow(() -> this.service.user().delete(randomMemberUsername) - .block(Utilities.IT_TIMEOUT)); - } - - @Test - void testGroupListMembers() { - String randomOwnerUsername = Utilities.randomUserName(); - String randomPassword = Utilities.randomPassword(); - - String randomMemberUsername1 = Utilities.randomUserName(); - String randomMemberUsername2 = Utilities.randomUserName(); - List members = new ArrayList<>(); - members.add(randomMemberUsername1); - assertDoesNotThrow(() -> this.service.user().create(randomOwnerUsername, randomPassword) - .block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow(() -> this.service.user().create(randomMemberUsername1, randomPassword) - .block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow(() -> this.service.user().create(randomMemberUsername2, randomPassword) - .block(Utilities.IT_TIMEOUT)); - String groupId = assertDoesNotThrow(() -> this.service.group() - .createPrivateGroup(randomOwnerUsername, "group", "group description", members, 200, - true).block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow(() -> this.service.group().addGroupMember(groupId, randomMemberUsername2) - .block(Utilities.IT_TIMEOUT)); - EMPage groupMemberPage = assertDoesNotThrow( - () -> this.service.group().listGroupMembers(groupId, 2, null, "asc") - .block(Utilities.IT_TIMEOUT)); - List groupMembers = groupMemberPage.getValues(); - if (!groupMembers.isEmpty()) { - assertTrue(groupMembers.containsAll(Arrays.asList(randomMemberUsername1,randomMemberUsername2))); - assertTrue(randomMemberUsername1.equals(groupMembers.get(0))); - } - assertDoesNotThrow( - () -> this.service.group().destroyGroup(groupId).block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow( - () -> this.service.user().delete(randomOwnerUsername).block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow(() -> this.service.user().delete(randomMemberUsername1) - .block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow(() -> this.service.user().delete(randomMemberUsername2) - .block(Utilities.IT_TIMEOUT)); - } - - @Test - void testGroupAddMemberSingle() { - String randomOwnerUsername = Utilities.randomUserName(); - String randomPassword = Utilities.randomPassword(); - - String randomMemberUsername = Utilities.randomUserName(); - List members = new ArrayList<>(); - assertDoesNotThrow(() -> this.service.user().create(randomOwnerUsername, randomPassword) - .block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow(() -> this.service.user().create(randomMemberUsername, randomPassword) - .block(Utilities.IT_TIMEOUT)); - String groupId = assertDoesNotThrow(() -> this.service.group() - .createPrivateGroup(randomOwnerUsername, "group", "group description", members, 200, - true).block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow(() -> this.service.group().addGroupMember(groupId, randomMemberUsername) - .block(Utilities.IT_TIMEOUT)); - EMPage groupMemberPage = assertDoesNotThrow( - () -> this.service.group().listGroupMembers(groupId, 2, null) - .block(Utilities.IT_TIMEOUT)); - List groupMembers = groupMemberPage.getValues(); - if (!groupMembers.isEmpty()) { - groupMembers.forEach(member -> { - if (!member.equals(randomMemberUsername)) { - throw new RuntimeException( - String.format("%s does not exist in %s group member list", member, - groupId)); - } - }); - } - assertDoesNotThrow( - () -> this.service.group().destroyGroup(groupId).block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow( - () -> this.service.user().delete(randomOwnerUsername).block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow(() -> this.service.user().delete(randomMemberUsername) - .block(Utilities.IT_TIMEOUT)); - } - - @Test - void testGroupAddMemberBatch() { - String randomOwnerUsername = Utilities.randomUserName(); - String randomPassword = Utilities.randomPassword(); - - String randomMemberUsername = Utilities.randomUserName(); - String randomMemberUsername1 = Utilities.randomUserName(); - String randomMemberUsername2 = Utilities.randomUserName(); - - assertDoesNotThrow(() -> this.service.user().create(randomOwnerUsername, randomPassword) - .block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow(() -> this.service.user().create(randomMemberUsername, randomPassword) - .block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow(() -> this.service.user().create(randomMemberUsername1, randomPassword) - .block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow(() -> this.service.user().create(randomMemberUsername2, randomPassword) - .block(Utilities.IT_TIMEOUT)); - - List members = new ArrayList<>(); - members.add(randomMemberUsername); - - String groupId = assertDoesNotThrow(() -> this.service.group() - .createPrivateGroup(randomOwnerUsername, "group", "group description", members, 200, - true).block(Utilities.IT_TIMEOUT)); - - List addMembers = new ArrayList<>(); - addMembers.add(randomMemberUsername1); - addMembers.add(randomMemberUsername2); - - assertDoesNotThrow(() -> this.service.group().addGroupMembers(groupId, addMembers) - .block(Utilities.IT_TIMEOUT)); - - assertDoesNotThrow( - () -> this.service.group().destroyGroup(groupId).block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow( - () -> this.service.user().delete(randomOwnerUsername).block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow(() -> this.service.user().delete(randomMemberUsername) - .block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow(() -> this.service.user().delete(randomMemberUsername1) - .block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow(() -> this.service.user().delete(randomMemberUsername2) - .block(Utilities.IT_TIMEOUT)); - } - - @Test - void testGroupRemoveMemberSingle() { - String randomOwnerUsername = Utilities.randomUserName(); - String randomPassword = Utilities.randomPassword(); - - String randomMemberUsername = Utilities.randomUserName(); - List members = new ArrayList<>(); - members.add(randomMemberUsername); - assertDoesNotThrow(() -> this.service.user().create(randomOwnerUsername, randomPassword) - .block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow(() -> this.service.user().create(randomMemberUsername, randomPassword) - .block(Utilities.IT_TIMEOUT)); - String groupId = assertDoesNotThrow(() -> this.service.group() - .createPrivateGroup(randomOwnerUsername, "group", "group description", members, 200, - true).block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow( - () -> this.service.group().removeGroupMember(groupId, randomMemberUsername) - .block(Utilities.IT_TIMEOUT)); - EMPage groupMemberPage = assertDoesNotThrow( - () -> this.service.group().listGroupMembers(groupId, 2, null) - .block(Utilities.IT_TIMEOUT)); - List groupMembers = groupMemberPage.getValues(); - if (!groupMembers.isEmpty()) { - throw new RuntimeException( - String.format("%s exist in %s group member list", randomMemberUsername, - groupId)); - } - assertDoesNotThrow( - () -> this.service.group().destroyGroup(groupId).block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow( - () -> this.service.user().delete(randomOwnerUsername).block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow(() -> this.service.user().delete(randomMemberUsername) - .block(Utilities.IT_TIMEOUT)); - } - - @Test - void testGroupRemoveMemberBatch() { - String randomOwnerUsername = Utilities.randomUserName(); - String randomPassword = Utilities.randomPassword(); - - String randomMemberUsername = Utilities.randomUserName(); - String randomMemberUsername1 = Utilities.randomUserName(); - String randomMemberUsername2 = Utilities.randomUserName(); - - assertDoesNotThrow(() -> this.service.user().create(randomOwnerUsername, randomPassword) - .block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow(() -> this.service.user().create(randomMemberUsername, randomPassword) - .block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow(() -> this.service.user().create(randomMemberUsername1, randomPassword) - .block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow(() -> this.service.user().create(randomMemberUsername2, randomPassword) - .block(Utilities.IT_TIMEOUT)); - - List members = new ArrayList<>(); - members.add(randomMemberUsername); - members.add(randomMemberUsername1); - members.add(randomMemberUsername2); - - String groupId = assertDoesNotThrow(() -> this.service.group() - .createPrivateGroup(randomOwnerUsername, "group", "group description", members, 200, - true).block(Utilities.IT_TIMEOUT)); - - - List removeMembers = new ArrayList<>(); - removeMembers.add(randomMemberUsername1); - removeMembers.add(randomMemberUsername2); - removeMembers.add("randomMemberUsername3"); - - assertDoesNotThrow( - () -> this.service.group().removeGroupMembers(groupId, removeMembers) - .block(Utilities.IT_TIMEOUT)); - - assertDoesNotThrow( - () -> this.service.group().destroyGroup(groupId).block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow( - () -> this.service.user().delete(randomOwnerUsername).block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow(() -> this.service.user().delete(randomMemberUsername) - .block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow(() -> this.service.user().delete(randomMemberUsername1) - .block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow(() -> this.service.user().delete(randomMemberUsername2) - .block(Utilities.IT_TIMEOUT)); - } - - @Test - void testGroupAddAdmin() { - String randomOwnerUsername = Utilities.randomUserName(); - String randomPassword = Utilities.randomPassword(); - - String randomAdminUsername = Utilities.randomUserName(); - String randomMemberUsername = Utilities.randomUserName(); - List members = new ArrayList<>(); - members.add(randomMemberUsername); - members.add(randomAdminUsername); - assertDoesNotThrow(() -> this.service.user().create(randomOwnerUsername, randomPassword) - .block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow(() -> this.service.user().create(randomAdminUsername, randomPassword) - .block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow(() -> this.service.user().create(randomMemberUsername, randomPassword) - .block(Utilities.IT_TIMEOUT)); - String groupId = assertDoesNotThrow(() -> this.service.group() - .createPrivateGroup(randomOwnerUsername, "group", "group description", members, 200, - true).block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow(() -> this.service.group().addGroupAdmin(groupId, randomAdminUsername) - .block(Utilities.IT_TIMEOUT)); - String adminName = assertDoesNotThrow(() -> this.service.group().listGroupAdmins(groupId) - .blockFirst(Utilities.IT_TIMEOUT)); - if (!adminName.equals(randomAdminUsername)) { - throw new RuntimeException( - String.format("%s does not exist in %s group admin list", randomAdminUsername, - groupId)); - } - assertDoesNotThrow( - () -> this.service.group().destroyGroup(groupId).block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow( - () -> this.service.user().delete(randomOwnerUsername).block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow( - () -> this.service.user().delete(randomAdminUsername).block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow(() -> this.service.user().delete(randomMemberUsername) - .block(Utilities.IT_TIMEOUT)); - } - - @Test - void testGroupRemoveAdmin() { - String randomOwnerUsername = Utilities.randomUserName(); - String randomPassword = Utilities.randomPassword(); - - String randomAdminUsername = Utilities.randomUserName(); - String randomMemberUsername = Utilities.randomUserName(); - List members = new ArrayList<>(); - members.add(randomMemberUsername); - members.add(randomAdminUsername); - assertDoesNotThrow(() -> this.service.user().create(randomOwnerUsername, randomPassword) - .block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow(() -> this.service.user().create(randomAdminUsername, randomPassword) - .block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow(() -> this.service.user().create(randomMemberUsername, randomPassword) - .block(Utilities.IT_TIMEOUT)); - String groupId = assertDoesNotThrow(() -> this.service.group() - .createPrivateGroup(randomOwnerUsername, "group", "group description", members, 200, - true).block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow(() -> this.service.group().addGroupAdmin(groupId, randomAdminUsername) - .block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow(() -> this.service.group().removeGroupAdmin(groupId, randomAdminUsername) - .block(Utilities.IT_TIMEOUT)); - String adminName = assertDoesNotThrow(() -> this.service.group().listGroupAdmins(groupId) - .blockFirst(Utilities.IT_TIMEOUT)); - if (adminName != null) { - throw new RuntimeException( - String.format("%s exist in %s group admin list", randomAdminUsername, groupId)); - } - assertDoesNotThrow( - () -> this.service.group().destroyGroup(groupId).block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow( - () -> this.service.user().delete(randomOwnerUsername).block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow( - () -> this.service.user().delete(randomAdminUsername).block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow(() -> this.service.user().delete(randomMemberUsername) - .block(Utilities.IT_TIMEOUT)); - } - - @Test - void testGroupGetUsersBlockedJoin() { - String randomOwnerUsername = Utilities.randomUserName(); - String randomPassword = Utilities.randomPassword(); - - String randomMemberUsername = Utilities.randomUserName(); - List members = new ArrayList<>(); - members.add(randomMemberUsername); - assertDoesNotThrow(() -> this.service.user().create(randomOwnerUsername, randomPassword) - .block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow(() -> this.service.user().create(randomMemberUsername, randomPassword) - .block(Utilities.IT_TIMEOUT)); - String groupId = assertDoesNotThrow(() -> this.service.group() - .createPrivateGroup(randomOwnerUsername, "group", "group description", members, 200, - true).block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow( - () -> this.service.block().blockUserJoinGroup(randomMemberUsername, groupId) - .block(Utilities.IT_TIMEOUT)); - EMBlock block = assertDoesNotThrow( - () -> this.service.block().getUsersBlockedJoinGroup(groupId) - .blockFirst(Utilities.IT_TIMEOUT)); - if (block != null && !block.getUsername().equals(randomMemberUsername)) { - throw new RuntimeException( - String.format("%s does not exist in %s group block list", randomMemberUsername, - groupId)); - } - assertDoesNotThrow( - () -> this.service.group().destroyGroup(groupId).block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow( - () -> this.service.user().delete(randomOwnerUsername).block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow(() -> this.service.user().delete(randomMemberUsername) - .block(Utilities.IT_TIMEOUT)); - } - - @Test - void testGroupBlockUserJoin() { - String randomOwnerUsername = Utilities.randomUserName(); - String randomPassword = Utilities.randomPassword(); - - String randomMemberUsername = Utilities.randomUserName(); - List members = new ArrayList<>(); - members.add(randomMemberUsername); - assertDoesNotThrow(() -> this.service.user().create(randomOwnerUsername, randomPassword) - .block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow(() -> this.service.user().create(randomMemberUsername, randomPassword) - .block(Utilities.IT_TIMEOUT)); - String groupId = assertDoesNotThrow(() -> this.service.group() - .createPrivateGroup(randomOwnerUsername, "group", "group description", members, 200, - true).block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow( - () -> this.service.block().blockUserJoinGroup(randomMemberUsername, groupId) - .block(Utilities.IT_TIMEOUT)); - EMPage groupMemberPage = assertDoesNotThrow( - () -> this.service.group().listGroupMembers(groupId, 2, null) - .block(Utilities.IT_TIMEOUT)); - if (!groupMemberPage.getValues().isEmpty()) { - groupMemberPage.getValues().forEach(member -> { - if (member.equals(randomMemberUsername)) { - throw new RuntimeException( - String.format("%s exist in %s group member list", member, groupId)); - } - }); - } - EMBlock block = assertDoesNotThrow( - () -> this.service.block().getUsersBlockedJoinGroup(groupId) - .blockFirst(Utilities.IT_TIMEOUT)); - if (block != null && !block.getUsername().equals(randomMemberUsername)) { - throw new RuntimeException( - String.format("%s does not exist in %s group block list", randomMemberUsername, - groupId)); - } - - assertDoesNotThrow(() -> this.service.group().addGroupMember(groupId, randomMemberUsername) - .block(Utilities.IT_TIMEOUT)); - EMBlock block1 = assertDoesNotThrow( - () -> this.service.block().getUsersBlockedJoinGroup(groupId) - .blockFirst(Utilities.IT_TIMEOUT)); - if (block1 != null) { - throw new RuntimeException( - String.format("%s exist in %s group block list", randomMemberUsername, - groupId)); - } - assertDoesNotThrow( - () -> this.service.group().destroyGroup(groupId).block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow( - () -> this.service.user().delete(randomOwnerUsername).block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow(() -> this.service.user().delete(randomMemberUsername) - .block(Utilities.IT_TIMEOUT)); - } - - @Test - void testGroupUnblockUserJoin() { - String randomOwnerUsername = Utilities.randomUserName(); - String randomPassword = Utilities.randomPassword(); - - String randomMemberUsername = Utilities.randomUserName(); - List members = new ArrayList<>(); - members.add(randomMemberUsername); - assertDoesNotThrow(() -> this.service.user().create(randomOwnerUsername, randomPassword) - .block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow(() -> this.service.user().create(randomMemberUsername, randomPassword) - .block(Utilities.IT_TIMEOUT)); - String groupId = assertDoesNotThrow(() -> this.service.group() - .createPrivateGroup(randomOwnerUsername, "group", "group description", members, 200, - true).block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow( - () -> this.service.block().blockUserJoinGroup(randomMemberUsername, groupId) - .block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow( - () -> this.service.block().unblockUserJoinGroup(randomMemberUsername, groupId) - .block(Utilities.IT_TIMEOUT)); - EMBlock block = assertDoesNotThrow( - () -> this.service.block().getUsersBlockedJoinGroup(groupId) - .blockFirst(Utilities.IT_TIMEOUT)); - EMPage groupMemberPage = assertDoesNotThrow( - () -> this.service.group().listGroupMembers(groupId, 2, null) - .block(Utilities.IT_TIMEOUT)); - if (block != null) { - throw new RuntimeException( - String.format("%s exist in %s group block list", randomMemberUsername, - groupId)); - } - - List groupMembers = groupMemberPage.getValues(); - if (!groupMembers.isEmpty()) { - groupMembers.forEach(member -> { - if (member.equals(randomMemberUsername)) { - throw new RuntimeException( - String.format("%s exist in %s group member list", member, groupId)); - } - }); - } - assertDoesNotThrow( - () -> this.service.group().destroyGroup(groupId).block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow( - () -> this.service.user().delete(randomOwnerUsername).block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow(() -> this.service.user().delete(randomMemberUsername) - .block(Utilities.IT_TIMEOUT)); - } - - @Test - void testGroupGetUsersBlockedSendMsg() { - String randomOwnerUsername = Utilities.randomUserName(); - String randomPassword = Utilities.randomPassword(); - - String randomMemberUsername = Utilities.randomUserName(); - List members = new ArrayList<>(); - members.add(randomMemberUsername); - assertDoesNotThrow(() -> this.service.user().create(randomOwnerUsername, randomPassword) - .block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow(() -> this.service.user().create(randomMemberUsername, randomPassword) - .block(Utilities.IT_TIMEOUT)); - String groupId = assertDoesNotThrow(() -> this.service.group() - .createPrivateGroup(randomOwnerUsername, "group", "group description", members, 200, - true).block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow(() -> this.service.block() - .blockUserSendMsgToGroup(randomMemberUsername, groupId, Duration.ofMillis(6000)) - .block(Utilities.IT_TIMEOUT)); - EMBlock block = assertDoesNotThrow( - () -> this.service.block().getUsersBlockedSendMsgToGroup(groupId) - .blockFirst(Utilities.IT_TIMEOUT)); - if (block == null) { - throw new RuntimeException( - String.format("block %s send message to %s group fail", randomMemberUsername, - groupId)); - } - - if (block != null && !block.getUsername().equals(randomMemberUsername)) { - throw new RuntimeException( - String.format("%s does not exist in %s group mute list", randomMemberUsername, - groupId)); - } - assertDoesNotThrow( - () -> this.service.group().destroyGroup(groupId).block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow( - () -> this.service.user().delete(randomOwnerUsername).block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow(() -> this.service.user().delete(randomMemberUsername) - .block(Utilities.IT_TIMEOUT)); - } - - @Test - void testGroupBlockUserSendMsg() { - String randomOwnerUsername = Utilities.randomUserName(); - String randomPassword = Utilities.randomPassword(); - - String randomMemberUsername = Utilities.randomUserName(); - List members = new ArrayList<>(); - members.add(randomMemberUsername); - assertDoesNotThrow(() -> this.service.user().create(randomOwnerUsername, randomPassword) - .block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow(() -> this.service.user().create(randomMemberUsername, randomPassword) - .block(Utilities.IT_TIMEOUT)); - String groupId = assertDoesNotThrow(() -> this.service.group() - .createPrivateGroup(randomOwnerUsername, "group", "group description", members, 200, - true).block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow(() -> this.service.block() - .blockUserSendMsgToGroup(randomMemberUsername, groupId, Duration.ofMillis(3000)) - .block(Utilities.IT_TIMEOUT)); - EMBlock block = assertDoesNotThrow( - () -> this.service.block().getUsersBlockedSendMsgToGroup(groupId) - .blockFirst(Utilities.IT_TIMEOUT)); - if (block == null) { - throw new RuntimeException( - String.format("block %s send message to %s group fail", randomMemberUsername, - groupId)); - } - - if (block != null && !block.getUsername().equals(randomMemberUsername)) { - throw new RuntimeException( - String.format("%s does not exist in %s group mute list", randomMemberUsername, - groupId)); - } - assertDoesNotThrow( - () -> this.service.group().destroyGroup(groupId).block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow( - () -> this.service.user().delete(randomOwnerUsername).block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow(() -> this.service.user().delete(randomMemberUsername) - .block(Utilities.IT_TIMEOUT)); - } - - @Test - void testGroupBlockUsersSendMsg() { - String randomOwnerUsername = Utilities.randomUserName(); - String randomPassword = Utilities.randomPassword(); - - String randomMemberUsername = Utilities.randomUserName(); - String randomMemberUsername1 = Utilities.randomUserName(); - List members = new ArrayList<>(); - members.add(randomMemberUsername); - members.add(randomMemberUsername1); - - assertDoesNotThrow(() -> this.service.user().create(randomOwnerUsername, randomPassword) - .block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow(() -> this.service.user().create(randomMemberUsername, randomPassword) - .block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow(() -> this.service.user().create(randomMemberUsername1, randomPassword) - .block(Utilities.IT_TIMEOUT)); - String groupId = assertDoesNotThrow(() -> this.service.group() - .createPrivateGroup(randomOwnerUsername, "group", "group description", members, 200, - true).block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow(() -> this.service.block() - .blockUsersSendMsgToGroup(members, groupId, Duration.ofMillis(3000)) - .block(Utilities.IT_TIMEOUT)); - List blocks = assertDoesNotThrow( - () -> this.service.block().getUsersBlockedSendMsgToGroup(groupId).collectList().block() - ); - if (blocks == null) { - throw new RuntimeException( - String.format("block %s send message to %s group fail", randomMemberUsername, - groupId)); - } - - assertEquals(2, blocks.size()); - - assertDoesNotThrow( - () -> this.service.group().destroyGroup(groupId).block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow( - () -> this.service.user().delete(randomOwnerUsername).block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow(() -> this.service.user().delete(randomMemberUsername) - .block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow(() -> this.service.user().delete(randomMemberUsername1) - .block(Utilities.IT_TIMEOUT)); - } - - @Test - void testGroupUnblockUserSendMsg() { - String randomOwnerUsername = Utilities.randomUserName(); - String randomPassword = Utilities.randomPassword(); - - String randomMemberUsername = Utilities.randomUserName(); - List members = new ArrayList<>(); - members.add(randomMemberUsername); - assertDoesNotThrow(() -> this.service.user().create(randomOwnerUsername, randomPassword) - .block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow(() -> this.service.user().create(randomMemberUsername, randomPassword) - .block(Utilities.IT_TIMEOUT)); - String groupId = assertDoesNotThrow(() -> this.service.group() - .createPrivateGroup(randomOwnerUsername, "group", "group description", members, 200, - true).block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow(() -> this.service.block() - .blockUserSendMsgToGroup(randomMemberUsername, groupId, Duration.ofMillis(6000)) - .block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow( - () -> this.service.block().unblockUserSendMsgToGroup(randomMemberUsername, groupId) - .block(Utilities.IT_TIMEOUT)); - EMBlock block = assertDoesNotThrow( - () -> this.service.block().getUsersBlockedSendMsgToGroup(groupId) - .blockFirst(Utilities.IT_TIMEOUT)); - if (block != null) { - throw new RuntimeException( - String.format("%s exist in %s group mute list", randomMemberUsername, groupId)); - } - assertDoesNotThrow( - () -> this.service.group().destroyGroup(groupId).block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow( - () -> this.service.user().delete(randomOwnerUsername).block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow(() -> this.service.user().delete(randomMemberUsername) - .block(Utilities.IT_TIMEOUT)); - } - - @Test - void testGroupBlockAllUsersSendMsg() { - String randomOwnerUsername = Utilities.randomUserName(); - String randomPassword = Utilities.randomPassword(); - - String randomMemberUsername = Utilities.randomUserName(); - String randomMemberUsername1 = Utilities.randomUserName(); - List members = new ArrayList<>(); - members.add(randomMemberUsername); - members.add(randomMemberUsername1); - - assertDoesNotThrow(() -> this.service.user().create(randomOwnerUsername, randomPassword) - .block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow(() -> this.service.user().create(randomMemberUsername, randomPassword) - .block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow(() -> this.service.user().create(randomMemberUsername1, randomPassword) - .block(Utilities.IT_TIMEOUT)); - String groupId = assertDoesNotThrow(() -> this.service.group() - .createPrivateGroup(randomOwnerUsername, "group", "group description", members, 200, - true).block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow(() -> this.service.block() - .blockAllUserSendMsgToGroup(groupId) - .block(Utilities.IT_TIMEOUT)); - EMGroup group = assertDoesNotThrow( - () -> this.service.group().getGroup(groupId).block() - ); - - assertEquals(true, group.getIsMute()); - - assertDoesNotThrow( - () -> this.service.group().destroyGroup(groupId).block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow( - () -> this.service.user().delete(randomOwnerUsername).block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow(() -> this.service.user().delete(randomMemberUsername) - .block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow(() -> this.service.user().delete(randomMemberUsername1) - .block(Utilities.IT_TIMEOUT)); - } - - @Test - void testGroupUnblockAllUserSendMsg() { - String randomOwnerUsername = Utilities.randomUserName(); - String randomPassword = Utilities.randomPassword(); - - String randomMemberUsername = Utilities.randomUserName(); - List members = new ArrayList<>(); - members.add(randomMemberUsername); - assertDoesNotThrow(() -> this.service.user().create(randomOwnerUsername, randomPassword) - .block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow(() -> this.service.user().create(randomMemberUsername, randomPassword) - .block(Utilities.IT_TIMEOUT)); - String groupId = assertDoesNotThrow(() -> this.service.group() - .createPrivateGroup(randomOwnerUsername, "group", "group description", members, 200, - true).block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow(() -> this.service.block() - .blockAllUserSendMsgToGroup(groupId) - .block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow( - () -> this.service.block().unblockAllUserSendMsgToGroup(groupId) - .block(Utilities.IT_TIMEOUT)); - EMGroup group = assertDoesNotThrow( - () -> this.service.group().getGroup(groupId).block() - ); - - assertEquals(false, group.getIsMute()); - - assertDoesNotThrow( - () -> this.service.group().destroyGroup(groupId).block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow( - () -> this.service.user().delete(randomOwnerUsername).block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow(() -> this.service.user().delete(randomMemberUsername) - .block(Utilities.IT_TIMEOUT)); - } - - @Test - void testGroupAssign(){ - String randomOwnerUsername = Utilities.randomUserName(); - String randomPassword = Utilities.randomPassword(); - - String randomMemberUsername = Utilities.randomUserName(); - List members = new ArrayList<>(); - members.add(randomMemberUsername); - assertDoesNotThrow(() -> this.service.user().create(randomOwnerUsername, randomPassword) - .block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow(() -> this.service.user().create(randomMemberUsername, randomPassword) - .block(Utilities.IT_TIMEOUT)); - String groupId = assertDoesNotThrow(() -> this.service.group() - .createPublicGroup(randomOwnerUsername, "group", "group description", members, 200, - true).block(Utilities.IT_TIMEOUT)); - - assertDoesNotThrow(() -> this.service.group().assignGroup(groupId, randomMemberUsername).block(Utilities.IT_TIMEOUT)); - - assertDoesNotThrow( - () -> this.service.group().destroyGroup(groupId).block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow( - () -> this.service.user().delete(randomOwnerUsername).block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow(() -> this.service.user().delete(randomMemberUsername) - .block(Utilities.IT_TIMEOUT)); - } - - @Test - void testGroupUserIsJoined(){ - String randomOwnerUsername = Utilities.randomUserName(); - String randomPassword = Utilities.randomPassword(); - - String randomMemberUsername = Utilities.randomUserName(); - List members = new ArrayList<>(); - members.add(randomMemberUsername); - assertDoesNotThrow(() -> this.service.user().create(randomOwnerUsername, randomPassword) - .block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow(() -> this.service.user().create(randomMemberUsername, randomPassword) - .block(Utilities.IT_TIMEOUT)); - String groupId = assertDoesNotThrow(() -> this.service.group() - .createPublicGroup(randomOwnerUsername, "group", "group description", members, 200, - true).block(Utilities.IT_TIMEOUT)); - - Boolean result = assertDoesNotThrow(() -> this.service.group().userIsJoined(groupId, randomMemberUsername).block(Utilities.IT_TIMEOUT)); - assertEquals(true, result); - - assertDoesNotThrow( - () -> this.service.group().destroyGroup(groupId).block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow( - () -> this.service.user().delete(randomOwnerUsername).block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow(() -> this.service.user().delete(randomMemberUsername) - .block(Utilities.IT_TIMEOUT)); - } - - @Test - void testGroupDisable(){ - String randomOwnerUsername = Utilities.randomUserName(); - String randomPassword = Utilities.randomPassword(); - - String randomMemberUsername = Utilities.randomUserName(); - List members = new ArrayList<>(); - members.add(randomMemberUsername); - assertDoesNotThrow(() -> this.service.user().create(randomOwnerUsername, randomPassword) - .block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow(() -> this.service.user().create(randomMemberUsername, randomPassword) - .block(Utilities.IT_TIMEOUT)); - String groupId = assertDoesNotThrow(() -> this.service.group() - .createPublicGroup(randomOwnerUsername, "group", "group description", members, 200, - true).block(Utilities.IT_TIMEOUT)); - - assertDoesNotThrow( - () -> this.service.group().disableGroup(groupId).block(Utilities.IT_TIMEOUT)); - - EMGroup group = assertDoesNotThrow( - () -> this.service.group().getGroup(groupId).block(Utilities.IT_TIMEOUT)); - assertEquals(true, group.getIsDisabled()); - - assertDoesNotThrow( - () -> this.service.group().destroyGroup(groupId).block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow( - () -> this.service.user().delete(randomOwnerUsername).block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow(() -> this.service.user().delete(randomMemberUsername) - .block(Utilities.IT_TIMEOUT)); - } - - @Test - void testGroupEnable(){ - String randomOwnerUsername = Utilities.randomUserName(); - String randomPassword = Utilities.randomPassword(); - - String randomMemberUsername = Utilities.randomUserName(); - List members = new ArrayList<>(); - members.add(randomMemberUsername); - assertDoesNotThrow(() -> this.service.user().create(randomOwnerUsername, randomPassword) - .block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow(() -> this.service.user().create(randomMemberUsername, randomPassword) - .block(Utilities.IT_TIMEOUT)); - String groupId = assertDoesNotThrow(() -> this.service.group() - .createPublicGroup(randomOwnerUsername, "group", "group description", members, 200, - true).block(Utilities.IT_TIMEOUT)); - - assertDoesNotThrow( - () -> this.service.group().enableGroup(groupId).block(Utilities.IT_TIMEOUT)); - EMGroup group = assertDoesNotThrow( - () -> this.service.group().getGroup(groupId).block(Utilities.IT_TIMEOUT)); - assertEquals(false, group.getIsDisabled()); - - assertDoesNotThrow( - () -> this.service.group().destroyGroup(groupId).block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow( - () -> this.service.user().delete(randomOwnerUsername).block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow(() -> this.service.user().delete(randomMemberUsername) - .block(Utilities.IT_TIMEOUT)); - } - -} diff --git a/im-sdk-core/src/integration-test/java/com/easemob/im/server/api/historymsg/HistoryMsgIT.java b/im-sdk-core/src/integration-test/java/com/easemob/im/server/api/historymsg/HistoryMsgIT.java deleted file mode 100644 index 2109db51d..000000000 --- a/im-sdk-core/src/integration-test/java/com/easemob/im/server/api/historymsg/HistoryMsgIT.java +++ /dev/null @@ -1,36 +0,0 @@ -package com.easemob.im.server.api.historymsg; - -import com.easemob.im.server.api.AbstractIT; -import com.easemob.im.server.api.util.Utilities; -import org.junit.jupiter.api.Disabled; - -import java.nio.file.FileSystems; -import java.nio.file.Path; -import java.time.Duration; -import java.time.Instant; - -import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; - -public class HistoryMsgIT extends AbstractIT { - - HistoryMsgIT() { - super(); - } - - // TODO: disable them for now since msg history can be empty - @Disabled - void testHistoryMsgGetAsUri() { - // minus 2 hours since msg history has an at least one hour delay - this.service.message().getHistoryAsUri(Instant.now().minus(Duration.ofHours(2))) - .block(Utilities.IT_TIMEOUT); - } - - @Disabled - void testHistoryMsgGetAsLocalFile() { - Path path = FileSystems.getDefault().getPath("path"); - assertDoesNotThrow(() -> this.service.message() - .getHistoryAsLocalFile(Instant.now().minus(Duration.ofHours(2)), - path, "history.gz").block(Utilities.IT_TIMEOUT)); - } - -} diff --git a/im-sdk-core/src/integration-test/java/com/easemob/im/server/api/message/MessageIT.java b/im-sdk-core/src/integration-test/java/com/easemob/im/server/api/message/MessageIT.java deleted file mode 100644 index 8fc3946b2..000000000 --- a/im-sdk-core/src/integration-test/java/com/easemob/im/server/api/message/MessageIT.java +++ /dev/null @@ -1,1106 +0,0 @@ -package com.easemob.im.server.api.message; - -import com.easemob.im.server.EMException; -import com.easemob.im.server.api.AbstractIT; -import com.easemob.im.server.api.message.recall.RecallMessageSource; -import com.easemob.im.server.api.util.Utilities; -import com.easemob.im.server.model.*; -import org.junit.jupiter.api.Test; - -import java.net.URI; -import java.util.*; - -import static org.junit.jupiter.api.Assertions.*; - -public class MessageIT extends AbstractIT { - - MessageIT() { - super(); - } - - @Test - void testMessageSendText() { - String randomFromUsername = Utilities.randomUserName(); - String randomPassword = Utilities.randomPassword(); - - String randomToUsername = Utilities.randomUserName(); - assertDoesNotThrow(() -> this.service.user().create(randomFromUsername, randomPassword) - .block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow(() -> this.service.user().create(randomToUsername, randomPassword) - .block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow(() -> { - EMSentMessageIds messageIds = this.service.message().send() - .fromUser(randomFromUsername) - .toUser(randomToUsername) - .text(msg -> msg.text("hello")) - .extension(exts -> exts.add(EMKeyValue.of("timeout", 1))) - .send() - .block(Utilities.IT_TIMEOUT); - assertNotNull(messageIds.getMessageIdsByEntityId().get(randomToUsername)); - }); - assertDoesNotThrow(() -> { - Set tos = new HashSet<>(); - tos.add(randomToUsername); - - Set exts = new HashSet<>(); - exts.add(EMKeyValue.of("key", "value")); - - EMSentMessageIds messageIds = this.service.message().send(randomFromUsername, "users", tos, new EMTextMessage().text("你好"), exts).block(Utilities.IT_TIMEOUT); - assertNotNull(messageIds.getMessageIdsByEntityId().get(randomToUsername)); - }); - assertDoesNotThrow( - () -> this.service.user().delete(randomFromUsername).block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow( - () -> this.service.user().delete(randomToUsername).block(Utilities.IT_TIMEOUT)); - } - - @Test - void testMessageSendMsgText() { - String randomFromUsername = Utilities.randomUserName(); - String randomPassword = Utilities.randomPassword(); - - String randomToUsername = Utilities.randomUserName(); - assertDoesNotThrow(() -> this.service.user().create(randomFromUsername, randomPassword) - .block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow(() -> this.service.user().create(randomToUsername, randomPassword) - .block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow(() -> { - EMSentMessageIds messageIds = this.service.message().sendMsg() - .fromUser(randomFromUsername) - .toUser(randomToUsername) - .text(msg -> msg.text("hello")) - .extension(exts -> exts.add(EMKeyValue.of("timeout", 1))) - .send() - .block(Utilities.IT_TIMEOUT); - assertNotNull(messageIds.getMessageIdsByEntityId().get(randomToUsername)); - }); - assertDoesNotThrow(() -> { - Set tos = new HashSet<>(); - tos.add(randomToUsername); - - Set exts = new HashSet<>(); - exts.add(EMKeyValue.of("key", "value")); - - EMSentMessageIds messageIds = this.service.message().sendMsg(randomFromUsername, "users", tos, new EMTextMessage().text("你好"), exts).block(Utilities.IT_TIMEOUT); - assertNotNull(messageIds.getMessageIdsByEntityId().get(randomToUsername)); - }); - assertDoesNotThrow( - () -> this.service.user().delete(randomFromUsername).block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow( - () -> this.service.user().delete(randomToUsername).block(Utilities.IT_TIMEOUT)); - } - - @Test - void testMessageSendTextWithoutMsgId() { - String randomFromUsername = Utilities.randomUserName(); - String randomPassword = Utilities.randomPassword(); - - String randomToUsername = Utilities.randomUserName(); - assertDoesNotThrow(() -> this.service.user().create(randomFromUsername, randomPassword) - .block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow(() -> this.service.user().create(randomToUsername, randomPassword) - .block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow(() -> { - EMSentMessageResults messageResults = this.service.message().send() - .fromUser(randomFromUsername) - .toUser(randomToUsername) - .text(msg -> msg.text("hello")) - .extension(exts -> exts.add(EMKeyValue.of("timeout", 1))) - .sendWithoutMsgId() - .block(Utilities.IT_TIMEOUT); - assertEquals("success", messageResults.getMessageResultsByEntityId().get(randomToUsername)); - }); - assertDoesNotThrow(() -> { - Set tos = new HashSet<>(); - tos.add(randomToUsername); - - Set exts = new HashSet<>(); - exts.add(EMKeyValue.of("key", "value")); - - EMSentMessageResults messageResults = this.service.message().sendWithoutMsgId(randomFromUsername, "users", tos, new EMTextMessage().text("你好"), exts).block(Utilities.IT_TIMEOUT); - assertNotNull(messageResults.getMessageResultsByEntityId().get(randomToUsername)); - }); - assertDoesNotThrow( - () -> this.service.user().delete(randomFromUsername).block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow( - () -> this.service.user().delete(randomToUsername).block(Utilities.IT_TIMEOUT)); - } - - @Test - void testMessageSendTextDeliveryOnline() { - String randomFromUsername = Utilities.randomUserName(); - String randomPassword = Utilities.randomPassword(); - - String randomToUsername = Utilities.randomUserName(); - assertDoesNotThrow(() -> this.service.user().create(randomFromUsername, randomPassword) - .block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow(() -> this.service.user().create(randomToUsername, randomPassword) - .block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow(() -> { - EMSentMessageIds messageIds = this.service.message().send() - .fromUser(randomFromUsername) - .toUser(randomToUsername) - .text(msg -> msg.text("hello")) - .extension(exts -> exts.add(EMKeyValue.of("timeout", 1))) - .routeType("ROUTE_ONLINE") - .send() - .block(Utilities.IT_TIMEOUT); - assertNotNull(messageIds.getMessageIdsByEntityId().get(randomToUsername)); - }); - assertDoesNotThrow(() -> { - Set tos = new HashSet<>(); - tos.add(randomToUsername); - - Set exts = new HashSet<>(); - exts.add(EMKeyValue.of("key", "value")); - - EMSentMessageIds messageIds = this.service.message().send(randomFromUsername, "users", tos, new EMTextMessage().text("你好"), exts, "ROUTE_ONLINE").block(Utilities.IT_TIMEOUT); - assertNotNull(messageIds.getMessageIdsByEntityId().get(randomToUsername)); - }); - assertDoesNotThrow( - () -> this.service.user().delete(randomFromUsername).block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow( - () -> this.service.user().delete(randomToUsername).block(Utilities.IT_TIMEOUT)); - } - - @Test - void testMessageSendMsgTextDeliveryOnline() { - String randomFromUsername = Utilities.randomUserName(); - String randomPassword = Utilities.randomPassword(); - - String randomToUsername = Utilities.randomUserName(); - assertDoesNotThrow(() -> this.service.user().create(randomFromUsername, randomPassword) - .block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow(() -> this.service.user().create(randomToUsername, randomPassword) - .block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow(() -> { - EMSentMessageIds messageIds = this.service.message().sendMsg() - .fromUser(randomFromUsername) - .toUser(randomToUsername) - .text(msg -> msg.text("hello")) - .extension(exts -> exts.add(EMKeyValue.of("timeout", 1))) - .routeType("ROUTE_ONLINE") - .send() - .block(Utilities.IT_TIMEOUT); - assertNotNull(messageIds.getMessageIdsByEntityId().get(randomToUsername)); - }); - assertDoesNotThrow(() -> { - Set tos = new HashSet<>(); - tos.add(randomToUsername); - - Set exts = new HashSet<>(); - exts.add(EMKeyValue.of("key", "value")); - - EMSentMessageIds messageIds = this.service.message().sendMsg(randomFromUsername, "users", tos, new EMTextMessage().text("你好"), exts, "ROUTE_ONLINE").block(Utilities.IT_TIMEOUT); - assertNotNull(messageIds.getMessageIdsByEntityId().get(randomToUsername)); - }); - assertDoesNotThrow( - () -> this.service.user().delete(randomFromUsername).block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow( - () -> this.service.user().delete(randomToUsername).block(Utilities.IT_TIMEOUT)); - } - - @Test - void testMessageSendTextDeliveryOnlineWithoutMsgId() { - String randomFromUsername = Utilities.randomUserName(); - String randomPassword = Utilities.randomPassword(); - - String randomToUsername = Utilities.randomUserName(); - assertDoesNotThrow(() -> this.service.user().create(randomFromUsername, randomPassword) - .block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow(() -> this.service.user().create(randomToUsername, randomPassword) - .block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow(() -> { - EMSentMessageResults messageResults = this.service.message().send() - .fromUser(randomFromUsername) - .toUser(randomToUsername) - .text(msg -> msg.text("hello")) - .extension(exts -> exts.add(EMKeyValue.of("timeout", 1))) - .routeType("ROUTE_ONLINE") - .sendWithoutMsgId() - .block(Utilities.IT_TIMEOUT); - assertEquals("success", messageResults.getMessageResultsByEntityId().get(randomToUsername)); - }); - assertDoesNotThrow(() -> { - Set tos = new HashSet<>(); - tos.add(randomToUsername); - - Set exts = new HashSet<>(); - exts.add(EMKeyValue.of("key", "value")); - - EMSentMessageResults messageResults = this.service.message().sendWithoutMsgId(randomFromUsername, "users", tos, new EMTextMessage().text("你好"), exts, "ROUTE_ONLINE").block(Utilities.IT_TIMEOUT); - assertNotNull(messageResults.getMessageResultsByEntityId().get(randomToUsername)); - }); - assertDoesNotThrow( - () -> this.service.user().delete(randomFromUsername).block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow( - () -> this.service.user().delete(randomToUsername).block(Utilities.IT_TIMEOUT)); - } - - @Test - void testMessageSendTextSyncDevice() { - String randomFromUsername = Utilities.randomUserName(); - String randomPassword = Utilities.randomPassword(); - - String randomToUsername = Utilities.randomUserName(); - assertDoesNotThrow(() -> this.service.user().create(randomFromUsername, randomPassword) - .block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow(() -> this.service.user().create(randomToUsername, randomPassword) - .block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow(() -> { - EMSentMessageIds messageIds = this.service.message().send() - .fromUser(randomFromUsername) - .toUser(randomToUsername) - .text(msg -> msg.text("hello")) - .extension(exts -> exts.add(EMKeyValue.of("timeout", 1))) - .syncDevice(true) - .send() - .block(Utilities.IT_TIMEOUT); - assertNotNull(messageIds.getMessageIdsByEntityId().get(randomToUsername)); - }); - assertDoesNotThrow(() -> { - Set tos = new HashSet<>(); - tos.add(randomToUsername); - - Set exts = new HashSet<>(); - exts.add(EMKeyValue.of("key", "value")); - - EMSentMessageIds messageIds = this.service.message().send(randomFromUsername, "users", tos, new EMTextMessage().text("你好"), exts, true).block(Utilities.IT_TIMEOUT); - assertNotNull(messageIds.getMessageIdsByEntityId().get(randomToUsername)); - }); - assertDoesNotThrow( - () -> this.service.user().delete(randomFromUsername).block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow( - () -> this.service.user().delete(randomToUsername).block(Utilities.IT_TIMEOUT)); - } - - @Test - void testMessageSendMsgTextSyncDevice() { - String randomFromUsername = Utilities.randomUserName(); - String randomPassword = Utilities.randomPassword(); - - String randomToUsername = Utilities.randomUserName(); - assertDoesNotThrow(() -> this.service.user().create(randomFromUsername, randomPassword) - .block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow(() -> this.service.user().create(randomToUsername, randomPassword) - .block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow(() -> { - EMSentMessageIds messageIds = this.service.message().sendMsg() - .fromUser(randomFromUsername) - .toUser(randomToUsername) - .text(msg -> msg.text("hello")) - .extension(exts -> exts.add(EMKeyValue.of("timeout", 1))) - .syncDevice(true) - .send() - .block(Utilities.IT_TIMEOUT); - assertNotNull(messageIds.getMessageIdsByEntityId().get(randomToUsername)); - }); - assertDoesNotThrow(() -> { - Set tos = new HashSet<>(); - tos.add(randomToUsername); - - Set exts = new HashSet<>(); - exts.add(EMKeyValue.of("key", "value")); - - EMSentMessageIds messageIds = this.service.message().sendMsg(randomFromUsername, "users", tos, new EMTextMessage().text("你好"), exts, true).block(Utilities.IT_TIMEOUT); - assertNotNull(messageIds.getMessageIdsByEntityId().get(randomToUsername)); - }); - assertDoesNotThrow( - () -> this.service.user().delete(randomFromUsername).block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow( - () -> this.service.user().delete(randomToUsername).block(Utilities.IT_TIMEOUT)); - } - - @Test - void testMessageSendMsgTextWithDeliveryOnlineAndSyncDevice() { - String randomFromUsername = Utilities.randomUserName(); - String randomPassword = Utilities.randomPassword(); - - String randomToUsername = Utilities.randomUserName(); - assertDoesNotThrow(() -> this.service.user().create(randomFromUsername, randomPassword) - .block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow(() -> this.service.user().create(randomToUsername, randomPassword) - .block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow(() -> { - EMSentMessageIds messageIds = this.service.message().sendMsg() - .fromUser(randomFromUsername) - .toUser(randomToUsername) - .text(msg -> msg.text("hello")) - .extension(exts -> exts.add(EMKeyValue.of("timeout", 1))) - .routeType("ROUTE_ONLINE") - .syncDevice(true) - .send() - .block(Utilities.IT_TIMEOUT); - assertNotNull(messageIds.getMessageIdsByEntityId().get(randomToUsername)); - }); - assertDoesNotThrow(() -> { - Set tos = new HashSet<>(); - tos.add(randomToUsername); - - Set exts = new HashSet<>(); - exts.add(EMKeyValue.of("key", "value")); - - EMSentMessageIds messageIds = this.service.message().sendMsg(randomFromUsername, "users", tos, new EMTextMessage().text("你好"), exts, "ROUTE_ONLINE" ,true).block(Utilities.IT_TIMEOUT); - assertNotNull(messageIds.getMessageIdsByEntityId().get(randomToUsername)); - }); - assertDoesNotThrow( - () -> this.service.user().delete(randomFromUsername).block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow( - () -> this.service.user().delete(randomToUsername).block(Utilities.IT_TIMEOUT)); - } - - @Test - void testMessageSendTextSyncDeviceWithoutMsgId() { - String randomFromUsername = Utilities.randomUserName(); - String randomPassword = Utilities.randomPassword(); - - String randomToUsername = Utilities.randomUserName(); - assertDoesNotThrow(() -> this.service.user().create(randomFromUsername, randomPassword) - .block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow(() -> this.service.user().create(randomToUsername, randomPassword) - .block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow(() -> { - EMSentMessageResults messageResults = this.service.message().send() - .fromUser(randomFromUsername) - .toUser(randomToUsername) - .text(msg -> msg.text("hello")) - .extension(exts -> exts.add(EMKeyValue.of("timeout", 1))) - .syncDevice(true) - .sendWithoutMsgId() - .block(Utilities.IT_TIMEOUT); - assertEquals("success", messageResults.getMessageResultsByEntityId().get(randomToUsername)); - }); - assertDoesNotThrow(() -> { - Set tos = new HashSet<>(); - tos.add(randomToUsername); - - Set exts = new HashSet<>(); - exts.add(EMKeyValue.of("key", "value")); - - EMSentMessageResults messageResults = this.service.message().sendWithoutMsgId(randomFromUsername, "users", tos, new EMTextMessage().text("你好"), exts, false).block(Utilities.IT_TIMEOUT); - assertNotNull(messageResults.getMessageResultsByEntityId().get(randomToUsername)); - }); - assertDoesNotThrow( - () -> this.service.user().delete(randomFromUsername).block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow( - () -> this.service.user().delete(randomToUsername).block(Utilities.IT_TIMEOUT)); - } - - @Test - void testChatroomMessageSendTextSupportMsgLevel() { - String randomFromUsername = Utilities.randomUserName(); - String randomPassword = Utilities.randomPassword(); - - String randomToUsername = Utilities.randomUserName(); - assertDoesNotThrow(() -> this.service.user().create(randomFromUsername, randomPassword) - .block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow(() -> this.service.user().create(randomToUsername, randomPassword) - .block(Utilities.IT_TIMEOUT)); - - List members = new ArrayList<>(); - members.add(randomToUsername); - String roomId = assertDoesNotThrow(() -> this.service.room() - .createRoom("chat room", "room description", randomFromUsername, members, 200) - .block(Utilities.IT_TIMEOUT)); - - assertDoesNotThrow(() -> { - EMSentMessageIds sentMessageIds = this.service.message().sendMsg() - .fromUser(randomFromUsername) - .toRoom(roomId) - .text(msg -> msg.text("hello")) - .extension(exts -> exts.add(EMKeyValue.of("timeout", 1))) - .chatroomMsgLevel(ChatroomMsgLevel.NORMAL) - .send() - .block(Utilities.IT_TIMEOUT); - - assertEquals(roomId, sentMessageIds.getMessageIdsByEntityId().keySet().iterator().next()); - }); - - assertDoesNotThrow(() -> { - Set toChatRooms = new HashSet<>(); - toChatRooms.add(roomId); - - EMImageMessage imageMessage = - new EMImageMessage().uri(URI.create("http://example/image.png")) - .secret("secret") - .displayName("image.png"); - - Set exts = new HashSet<>(); - exts.add(EMKeyValue.of("key", "value")); - exts.add(EMKeyValue.of("key1", 10)); - exts.add(EMKeyValue.of("key2", new HashMap() { - { - put("mkey1", "mvalue1"); - put("mkey2", "mvalue2"); - } - })); - - EMSentMessageIds messageIds = service.message() - .sendMsg(randomFromUsername, "chatrooms", toChatRooms, imageMessage, exts, - "ROUTE_ONLINE", true, ChatroomMsgLevel.HIGH).block(); - assertEquals(roomId, messageIds.getMessageIdsByEntityId().keySet().iterator().next()); - }); - - assertDoesNotThrow( - () -> this.service.room().destroyRoom(roomId).block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow( - () -> this.service.user().delete(randomFromUsername).block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow( - () -> this.service.user().delete(randomToUsername).block(Utilities.IT_TIMEOUT)); - } - - @Test - void testMessageSendImage() { - String randomFromUsername = Utilities.randomUserName(); - String randomPassword = Utilities.randomPassword(); - - String randomToUsername = Utilities.randomUserName(); - assertDoesNotThrow(() -> this.service.user().create(randomFromUsername, randomPassword) - .block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow(() -> this.service.user().create(randomToUsername, randomPassword) - .block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow(() -> this.service.message().send() - .fromUser(randomFromUsername) - .toUser(randomToUsername) - .image(msg -> msg.uri(URI.create("http://example/image.png")) - .height(1709.000) - .width(2573.000) - .secret("secret") - .displayName("image.png") - ) - .extension(exts -> exts.add(EMKeyValue.of("timeout", 1))) - .send() - .block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow( - () -> this.service.user().delete(randomFromUsername).block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow( - () -> this.service.user().delete(randomToUsername).block(Utilities.IT_TIMEOUT)); - } - - @Test - void testMessageSendMsgImage() { - String randomFromUsername = Utilities.randomUserName(); - String randomPassword = Utilities.randomPassword(); - - String randomToUsername = Utilities.randomUserName(); - assertDoesNotThrow(() -> this.service.user().create(randomFromUsername, randomPassword) - .block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow(() -> this.service.user().create(randomToUsername, randomPassword) - .block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow(() -> this.service.message().sendMsg() - .fromUser(randomFromUsername) - .toUser(randomToUsername) - .image(msg -> msg.uri(URI.create("http://example/image.png")) - .height(1709.000) - .width(2573.000) - .secret("secret") - .displayName("image.png") - ) - .extension(exts -> exts.add(EMKeyValue.of("timeout", 1))) - .send() - .block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow(() -> { - Set tos = new HashSet<>(); - tos.add(randomToUsername); - - EMMessage emImageMessage = - new EMImageMessage().uri(URI.create("http://example/image.png")) - .height(1709.000) - .width(2573.000) - .secret("secret") - .displayName("image.png"); - - Set exts = new HashSet<>(); - exts.add(EMKeyValue.of("key", "value")); - - EMSentMessageIds messageIds = this.service.message() - .sendMsg(randomFromUsername, "users", tos, emImageMessage, exts) - .block(Utilities.IT_TIMEOUT); - assertNotNull(messageIds.getMessageIdsByEntityId().get(randomToUsername)); - }); - assertDoesNotThrow( - () -> this.service.user().delete(randomFromUsername).block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow( - () -> this.service.user().delete(randomToUsername).block(Utilities.IT_TIMEOUT)); - } - - @Test - void testMessageSendVoice() { - String randomFromUsername = Utilities.randomUserName(); - String randomPassword = Utilities.randomPassword(); - - String randomToUsername = Utilities.randomUserName(); - assertDoesNotThrow(() -> this.service.user().create(randomFromUsername, randomPassword) - .block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow(() -> this.service.user().create(randomToUsername, randomPassword) - .block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow(() -> this.service.message().send() - .fromUser(randomFromUsername) - .toUser(randomToUsername) - .voice(msg -> msg.uri(URI.create("http://example/voice.amr")) - .duration(3) - .secret("secret") - .displayName("voice.amr") - .bytes(5158) - ) - .extension(exts -> exts.add(EMKeyValue.of("timeout", 1))) - .send() - .block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow( - () -> this.service.user().delete(randomFromUsername).block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow( - () -> this.service.user().delete(randomToUsername).block(Utilities.IT_TIMEOUT)); - } - - @Test - void testMessageSendMsgVoice() { - String randomFromUsername = Utilities.randomUserName(); - String randomPassword = Utilities.randomPassword(); - - String randomToUsername = Utilities.randomUserName(); - assertDoesNotThrow(() -> this.service.user().create(randomFromUsername, randomPassword) - .block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow(() -> this.service.user().create(randomToUsername, randomPassword) - .block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow(() -> this.service.message().sendMsg() - .fromUser(randomFromUsername) - .toUser(randomToUsername) - .voice(msg -> msg.uri(URI.create("http://example/voice.amr")) - .duration(3) - .secret("secret") - .displayName("voice.amr") - .bytes(5158) - ) - .extension(exts -> exts.add(EMKeyValue.of("timeout", 1))) - .send() - .block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow( - () -> this.service.user().delete(randomFromUsername).block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow( - () -> this.service.user().delete(randomToUsername).block(Utilities.IT_TIMEOUT)); - } - - @Test - void testMessageSendVideo() { - String randomFromUsername = Utilities.randomUserName(); - String randomPassword = Utilities.randomPassword(); - - String randomToUsername = Utilities.randomUserName(); - assertDoesNotThrow(() -> this.service.user().create(randomFromUsername, randomPassword) - .block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow(() -> this.service.user().create(randomToUsername, randomPassword) - .block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow(() -> this.service.message().send() - .fromUser(randomFromUsername) - .toUser(randomToUsername) - .video(msg -> msg.uri(URI.create("http://example/video.mp4")) - .duration(3) - .secret("secret") - .displayName("video.mp4") - .thumb("http://example/videoThumbnail") - .thumbSecret("thumbSecret") - ) - .extension(exts -> exts.add(EMKeyValue.of("timeout", 1))) - .send() - .block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow( - () -> this.service.user().delete(randomFromUsername).block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow( - () -> this.service.user().delete(randomToUsername).block(Utilities.IT_TIMEOUT)); - } - - @Test - void testMessageSendMsgVideo() { - String randomFromUsername = Utilities.randomUserName(); - String randomPassword = Utilities.randomPassword(); - - String randomToUsername = Utilities.randomUserName(); - assertDoesNotThrow(() -> this.service.user().create(randomFromUsername, randomPassword) - .block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow(() -> this.service.user().create(randomToUsername, randomPassword) - .block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow(() -> this.service.message().sendMsg() - .fromUser(randomFromUsername) - .toUser(randomToUsername) - .video(msg -> msg.uri(URI.create("http://example/video.mp4")) - .duration(3) - .secret("secret") - .displayName("video.mp4") - .thumb("http://example/videoThumbnail") - .thumbSecret("thumbSecret") - ) - .extension(exts -> exts.add(EMKeyValue.of("timeout", 1))) - .send() - .block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow( - () -> this.service.user().delete(randomFromUsername).block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow( - () -> this.service.user().delete(randomToUsername).block(Utilities.IT_TIMEOUT)); - } - - @Test - void testMessageSendFile() { - String randomFromUsername = Utilities.randomUserName(); - String randomPassword = Utilities.randomPassword(); - - String randomToUsername = Utilities.randomUserName(); - assertDoesNotThrow(() -> this.service.user().create(randomFromUsername, randomPassword) - .block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow(() -> this.service.user().create(randomToUsername, randomPassword) - .block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow(() -> this.service.message().send() - .fromUser(randomFromUsername) - .toUser(randomToUsername) - .file(msg -> msg.uri(URI.create("http://example/file.txt")) - .secret("secret") - .displayName("file.txt") - ) - .extension(exts -> exts.add(EMKeyValue.of("timeout", 1))) - .send() - .block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow( - () -> this.service.user().delete(randomFromUsername).block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow( - () -> this.service.user().delete(randomToUsername).block(Utilities.IT_TIMEOUT)); - } - - @Test - void testMessageSendMsgFile() { - String randomFromUsername = Utilities.randomUserName(); - String randomPassword = Utilities.randomPassword(); - - String randomToUsername = Utilities.randomUserName(); - assertDoesNotThrow(() -> this.service.user().create(randomFromUsername, randomPassword) - .block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow(() -> this.service.user().create(randomToUsername, randomPassword) - .block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow(() -> this.service.message().sendMsg() - .fromUser(randomFromUsername) - .toUser(randomToUsername) - .file(msg -> msg.uri(URI.create("http://example/file.txt")) - .secret("secret") - .displayName("file.txt") - ) - .extension(exts -> exts.add(EMKeyValue.of("timeout", 1))) - .send() - .block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow( - () -> this.service.user().delete(randomFromUsername).block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow( - () -> this.service.user().delete(randomToUsername).block(Utilities.IT_TIMEOUT)); - } - - @Test - void testMessageSendLocation() { - String randomFromUsername = Utilities.randomUserName(); - String randomPassword = Utilities.randomPassword(); - - String randomToUsername = Utilities.randomUserName(); - assertDoesNotThrow(() -> this.service.user().create(randomFromUsername, randomPassword) - .block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow(() -> this.service.user().create(randomToUsername, randomPassword) - .block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow(() -> this.service.message().send() - .fromUser(randomFromUsername) - .toUser(randomToUsername) - .location(msg -> msg.latitude(1.234567).longitude(1.234567).address("some where")) - .extension(exts -> exts.add(EMKeyValue.of("timeout", 1))) - .send() - .block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow( - () -> this.service.user().delete(randomFromUsername).block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow( - () -> this.service.user().delete(randomToUsername).block(Utilities.IT_TIMEOUT)); - } - - @Test - void testMessageSendMsgLocation() { - String randomFromUsername = Utilities.randomUserName(); - String randomPassword = Utilities.randomPassword(); - - String randomToUsername = Utilities.randomUserName(); - assertDoesNotThrow(() -> this.service.user().create(randomFromUsername, randomPassword) - .block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow(() -> this.service.user().create(randomToUsername, randomPassword) - .block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow(() -> this.service.message().sendMsg() - .fromUser(randomFromUsername) - .toUser(randomToUsername) - .location(msg -> msg.latitude(1.234567).longitude(1.234567).address("some where")) - .extension(exts -> exts.add(EMKeyValue.of("timeout", 1))) - .send() - .block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow( - () -> this.service.user().delete(randomFromUsername).block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow( - () -> this.service.user().delete(randomToUsername).block(Utilities.IT_TIMEOUT)); - } - - @Test - void testMessageSendCommand() { - String randomFromUsername = Utilities.randomUserName(); - String randomPassword = Utilities.randomPassword(); - - String randomToUsername = Utilities.randomUserName(); - assertDoesNotThrow(() -> this.service.user().create(randomFromUsername, randomPassword) - .block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow(() -> this.service.user().create(randomToUsername, randomPassword) - .block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow(() -> this.service.message().send() - .fromUser(randomFromUsername) - .toUser(randomToUsername) - .command(msg -> msg.action("run").param("name", "rabbit")) - .extension(exts -> exts.add(EMKeyValue.of("timeout", 1))) - .send() - .block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow( - () -> this.service.user().delete(randomFromUsername).block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow( - () -> this.service.user().delete(randomToUsername).block(Utilities.IT_TIMEOUT)); - } - - @Test - void testMessageSendMsgCommand() { - String randomFromUsername = Utilities.randomUserName(); - String randomPassword = Utilities.randomPassword(); - - String randomToUsername = Utilities.randomUserName(); - assertDoesNotThrow(() -> this.service.user().create(randomFromUsername, randomPassword) - .block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow(() -> this.service.user().create(randomToUsername, randomPassword) - .block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow(() -> this.service.message().sendMsg() - .fromUser(randomFromUsername) - .toUser(randomToUsername) - .command(msg -> msg.action("run").param("name", "rabbit")) - .extension(exts -> exts.add(EMKeyValue.of("timeout", 1))) - .send() - .block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow( - () -> this.service.user().delete(randomFromUsername).block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow( - () -> this.service.user().delete(randomToUsername).block(Utilities.IT_TIMEOUT)); - } - - @Test - void testMessageSendCustom() { - String randomFromUsername = Utilities.randomUserName(); - String randomPassword = Utilities.randomPassword(); - - String randomToUsername = Utilities.randomUserName(); - assertDoesNotThrow(() -> this.service.user().create(randomFromUsername, randomPassword) - .block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow(() -> this.service.user().create(randomToUsername, randomPassword) - .block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow(() -> this.service.message().send() - .fromUser(randomFromUsername) - .toUser(randomToUsername) - .custom(msg -> msg.customEvent("liked").customExtension("name", "forest")) - .extension(exts -> exts.add(EMKeyValue.of("timeout", 1))) - .send() - .block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow( - () -> this.service.user().delete(randomFromUsername).block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow( - () -> this.service.user().delete(randomToUsername).block(Utilities.IT_TIMEOUT)); - } - - @Test - void testMessageSendMsgCustom() { - String randomFromUsername = Utilities.randomUserName(); - String randomPassword = Utilities.randomPassword(); - - String randomToUsername = Utilities.randomUserName(); - assertDoesNotThrow(() -> this.service.user().create(randomFromUsername, randomPassword) - .block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow(() -> this.service.user().create(randomToUsername, randomPassword) - .block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow(() -> this.service.message().sendMsg() - .fromUser(randomFromUsername) - .toUser(randomToUsername) - .custom(msg -> msg.customEvent("liked").customExtension("name", "forest")) - .extension(exts -> exts.add(EMKeyValue.of("timeout", 1))) - .send() - .block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow( - () -> this.service.user().delete(randomFromUsername).block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow( - () -> this.service.user().delete(randomToUsername).block(Utilities.IT_TIMEOUT)); - } - - /** - * 测试扩展字段ext支持Object类型 - */ - @Test - void testExtensionSupportObject() throws InterruptedException { - String randomFromUsername = Utilities.randomUserName(); - String randomPassword = Utilities.randomPassword(); - - String randomToUsername = Utilities.randomUserName(); - assertDoesNotThrow(() -> this.service.user().create(randomFromUsername, randomPassword) - .block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow(() -> this.service.user().create(randomToUsername, randomPassword) - .block(Utilities.IT_TIMEOUT)); - - Map hashMap = new HashMap<>(); - hashMap.put("name", "forest"); - Set kvSet = EMKeyValue.of(hashMap); - assertDoesNotThrow(() -> this.service.message().send() - .fromUser(randomFromUsername) - .toUser(randomToUsername) - .custom(msg -> msg.customEvent("liked").customExtensions(kvSet)) - .extension(exts -> exts.add(EMKeyValue.of("extension-object", new HashMap() { - { - put("em_push_content", "custom-content"); - put("extension_key", "extension-value"); - } - }))) - .send() - .block(Utilities.IT_TIMEOUT)); - - assertDoesNotThrow( - () -> this.service.user().delete(randomFromUsername).block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow( - () -> this.service.user().delete(randomToUsername).block(Utilities.IT_TIMEOUT)); - } - - @Test - void testRecallMessage() { - String randomFromUsername = Utilities.randomUserName(); - String randomPassword = Utilities.randomPassword(); - - String randomToUsername = Utilities.randomUserName(); - assertDoesNotThrow(() -> this.service.user().create(randomFromUsername, randomPassword) - .block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow(() -> this.service.user().create(randomToUsername, randomPassword) - .block(Utilities.IT_TIMEOUT)); - - List messageSourceList = new ArrayList<>(); - messageSourceList.add(new RecallMessageSource("13132131", "chat", randomFromUsername, randomToUsername, true)); - - assertDoesNotThrow(() -> this.service.message().recallMessage(messageSourceList).block()); - assertDoesNotThrow( - () -> this.service.user().delete(randomFromUsername).block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow( - () -> this.service.user().delete(randomToUsername).block(Utilities.IT_TIMEOUT)); - } - - @Test - void testMessageRecall() { - String randomFromUsername = Utilities.randomUserName(); - String randomPassword = Utilities.randomPassword(); - - String randomToUsername = Utilities.randomUserName(); - assertDoesNotThrow(() -> this.service.user().create(randomFromUsername, randomPassword) - .block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow(() -> this.service.user().create(randomToUsername, randomPassword) - .block(Utilities.IT_TIMEOUT)); - - RecallMessageSource recallMessage = new RecallMessageSource("13132131", "chat", randomFromUsername, randomToUsername, true); - - assertDoesNotThrow(() -> this.service.message().recallMsg(recallMessage).block()); - assertDoesNotThrow( - () -> this.service.user().delete(randomFromUsername).block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow( - () -> this.service.user().delete(randomToUsername).block(Utilities.IT_TIMEOUT)); - } - - @Test - void testDeleteMessageChannel() { - String randomFromUsername = Utilities.randomUserName(); - String randomPassword = Utilities.randomPassword(); - - String randomToUsername = Utilities.randomUserName(); - assertDoesNotThrow(() -> this.service.user().create(randomFromUsername, randomPassword) - .block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow(() -> this.service.user().create(randomToUsername, randomPassword) - .block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow(() -> this.service.message().deleteChannel(randomFromUsername, randomToUsername, "chat", true).block()); - assertDoesNotThrow( - () -> this.service.user().delete(randomFromUsername).block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow( - () -> this.service.user().delete(randomToUsername).block(Utilities.IT_TIMEOUT)); - } - - @Test - void testGroupMessageSendMsgTextSyncDevice() { - String randomOwnerUsername = Utilities.randomUserName(); - String randomFromUsername = Utilities.randomUserName(); - String randomPassword = Utilities.randomPassword(); - - String randomToUsername = Utilities.randomUserName(); - List members = new ArrayList<>(); - members.add(randomFromUsername); - members.add(randomToUsername); - assertDoesNotThrow(() -> this.service.user().create(randomOwnerUsername, randomPassword) - .block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow(() -> this.service.user().create(randomFromUsername, randomPassword) - .block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow(() -> this.service.user().create(randomToUsername, randomPassword) - .block(Utilities.IT_TIMEOUT)); - String groupId = assertDoesNotThrow(() -> this.service.group() - .createPublicGroup(randomOwnerUsername, "group", "group description", members, 200, - true).block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow(() -> { - EMSentMessageIds messageIds = this.service.message().sendMsg() - .fromUser(randomFromUsername) - .toGroup(groupId) - .text(msg -> msg.text("hello")) - .toGroupUsers(new HashSet() { - { - add(randomToUsername); - } - }) - .extension(exts -> exts.add(EMKeyValue.of("timeout", 1))) - .syncDevice(true) - .send() - .block(Utilities.IT_TIMEOUT); - - System.out.println("id :" + messageIds.getMessageIdsByEntityId().get(groupId)); - - assertNotNull(messageIds.getMessageIdsByEntityId().get(groupId)); - }); - assertDoesNotThrow(() -> { - Set tos = new HashSet<>(); - tos.add(groupId); - - Set toGroupUsers = new HashSet<>(); - toGroupUsers.add(randomToUsername); - - Set exts = new HashSet<>(); - exts.add(EMKeyValue.of("key", "value")); - - EMSentMessageIds messageIds = this.service.message() - .sendMsg(randomFromUsername, tos, new EMTextMessage().text("你好"), toGroupUsers, - exts, true).block(Utilities.IT_TIMEOUT); - assertNotNull(messageIds.getMessageIdsByEntityId().get(groupId)); - }); - assertDoesNotThrow( - () -> this.service.user().delete(randomOwnerUsername).block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow( - () -> this.service.user().delete(randomFromUsername).block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow( - () -> this.service.user().delete(randomToUsername).block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow( - () -> this.service.group().destroyGroup(groupId).block(Utilities.IT_TIMEOUT)); - } - - @Test - void testDirectionalChatroomMessageSendText() { - String randomFromUsername = Utilities.randomUserName(); - String randomPassword = Utilities.randomPassword(); - - String randomToUsername = Utilities.randomUserName(); - assertDoesNotThrow(() -> this.service.user().create(randomFromUsername, randomPassword) - .block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow(() -> this.service.user().create(randomToUsername, randomPassword) - .block(Utilities.IT_TIMEOUT)); - - List members = new ArrayList<>(); - members.add(randomToUsername); - String roomId = assertDoesNotThrow(() -> this.service.room() - .createRoom("chat room", "room description", randomFromUsername, members, 200) - .block(Utilities.IT_TIMEOUT)); - - Set roomIds = new HashSet<>(); - roomIds.add(roomId); - - assertDoesNotThrow(() -> { - EMSentMessageIds sentMessageIds = this.service.message().sendMsg() - .fromUser(randomFromUsername) - .toRooms(roomIds) - .text(msg -> msg.text("hello")) - .toRoomUsers(new HashSet() { - { - add(randomToUsername); - } - }) - .extension(exts -> exts.add(EMKeyValue.of("timeout", 1))) - .chatroomMsgLevel(ChatroomMsgLevel.NORMAL) - .syncDevice(true) - .send() - .block(Utilities.IT_TIMEOUT); - - assertEquals(roomId, sentMessageIds.getMessageIdsByEntityId().keySet().iterator().next()); - }); - - assertDoesNotThrow(() -> { - Set toChatRooms = new HashSet<>(); - toChatRooms.add(roomId); - - Set toRoomUsers = new HashSet<>(); - toRoomUsers.add(randomToUsername); - - EMImageMessage imageMessage = - new EMImageMessage().uri(URI.create("http://example/image.png")) - .secret("secret") - .displayName("image.png"); - - Set exts = new HashSet<>(); - exts.add(EMKeyValue.of("key", "value")); - exts.add(EMKeyValue.of("key1", 10)); - exts.add(EMKeyValue.of("key2", new HashMap() { - { - put("mkey1", "mvalue1"); - put("mkey2", "mvalue2"); - } - })); - - EMSentMessageIds messageIds = service.message() - .sendMsg(randomFromUsername, toChatRooms, imageMessage, toRoomUsers, exts, true, - ChatroomMsgLevel.HIGH).block(); - assertEquals(roomId, messageIds.getMessageIdsByEntityId().keySet().iterator().next()); - }); - - assertDoesNotThrow( - () -> this.service.room().destroyRoom(roomId).block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow( - () -> this.service.user().delete(randomFromUsername).block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow( - () -> this.service.user().delete(randomToUsername).block(Utilities.IT_TIMEOUT)); - } - - @Test - void testRoomBroadcastMessageSendText() { - String randomFromUsername = Utilities.randomUserName(); - String randomPassword = Utilities.randomPassword(); - - String randomToUsername = Utilities.randomUserName(); - assertDoesNotThrow(() -> this.service.user().create(randomFromUsername, randomPassword) - .block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow(() -> this.service.user().create(randomToUsername, randomPassword) - .block(Utilities.IT_TIMEOUT)); - - List members = new ArrayList<>(); - members.add(randomToUsername); - members.add("u1"); - String roomId = assertDoesNotThrow(() -> this.service.room() - .createRoom("chat room", "room description", randomFromUsername, members, 200) - .block(Utilities.IT_TIMEOUT)); - - assertDoesNotThrow(() -> { - Set exts = new HashSet<>(); - exts.add(EMKeyValue.of("key", "value")); - exts.add(EMKeyValue.of("key1", 10)); - exts.add(EMKeyValue.of("key2", new HashMap() { - { - put("mkey1", "mvalue1"); - put("mkey2", "mvalue2"); - } - })); - - EMSentMessageIds messageIds = service.message() - .sendRoomBroadcastMsg(randomFromUsername, new EMTextMessage().text("123456"), exts, true, - ChatroomMsgLevel.NORMAL).block(); - assertEquals("id", messageIds.getMessageIdsByEntityId().keySet().iterator().next()); - }); - - assertDoesNotThrow( - () -> this.service.room().destroyRoom(roomId).block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow( - () -> this.service.user().delete(randomFromUsername).block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow( - () -> this.service.user().delete(randomToUsername).block(Utilities.IT_TIMEOUT)); - } - -} diff --git a/im-sdk-core/src/integration-test/java/com/easemob/im/server/api/metadata/MetadataIT.java b/im-sdk-core/src/integration-test/java/com/easemob/im/server/api/metadata/MetadataIT.java deleted file mode 100644 index a2b31416e..000000000 --- a/im-sdk-core/src/integration-test/java/com/easemob/im/server/api/metadata/MetadataIT.java +++ /dev/null @@ -1,365 +0,0 @@ -package com.easemob.im.server.api.metadata; - -import com.easemob.im.server.api.AbstractIT; -import com.easemob.im.server.api.metadata.chatroom.AutoDelete; -import com.easemob.im.server.api.util.Utilities; -import com.easemob.im.server.model.EMMetadata; -import com.easemob.im.server.model.EMMetadataBatch; -import com.easemob.im.server.model.EMPage; -import org.junit.jupiter.api.Test; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; -import static org.junit.jupiter.api.Assertions.assertEquals; - -public class MetadataIT extends AbstractIT { - public MetadataIT() { - super(); - } - - @Test - public void testMetadataSet() { - - Map map = new HashMap<>(); - map.put("nickname", "昵称"); - map.put("avatar", "http://www.easemob.com/avatar.png"); - map.put("phone", "159"); - - String randomUsername = Utilities.randomUserName(); - String randomPassword = Utilities.randomPassword(); - assertDoesNotThrow(() -> this.service.user().create(randomUsername, randomPassword) - .block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow(() -> this.service.metadata().setMetadataToUser(randomUsername, map) - .block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow( - () -> this.service.user().delete(randomUsername).block(Utilities.IT_TIMEOUT)); - } - - @Test - public void testMetadataGet() { - Map map = new HashMap<>(); - map.put("nickname", "昵称"); - map.put("avatar", "http://www.easemob.com/avatar.png"); - map.put("phone", "159"); - - String randomUsername = Utilities.randomUserName(); - String randomPassword = Utilities.randomPassword(); - assertDoesNotThrow(() -> this.service.user().create(randomUsername, randomPassword) - .block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow(() -> this.service.metadata().setMetadataToUser(randomUsername, map) - .block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow(() -> this.service.metadata().getMetadataFromUser(randomUsername) - .block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow( - () -> this.service.user().delete(randomUsername).block(Utilities.IT_TIMEOUT)); - } - - @Test - public void testMetadataBatchGet() { - Map map = new HashMap<>(); - map.put("nickname", "昵称"); - map.put("avatar", "http://www.easemob.com/avatar.png"); - map.put("phone", "159"); - - String randomUsername = Utilities.randomUserName(); - String randomUsername1 = Utilities.randomUserName(); - String randomPassword = Utilities.randomPassword(); - assertDoesNotThrow(() -> this.service.user().create(randomUsername, randomPassword) - .block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow(() -> this.service.user().create(randomUsername1, randomPassword) - .block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow(() -> this.service.metadata().setMetadataToUser(randomUsername, map) - .block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow(() -> this.service.metadata().setMetadataToUser(randomUsername1, map) - .block(Utilities.IT_TIMEOUT)); - - List targets = new ArrayList<>(); - targets.add(randomUsername); - targets.add(randomUsername1); - - List properties = new ArrayList<>(); - properties.add("nickname"); - properties.add("avatar"); - properties.add("phone"); - - assertDoesNotThrow(() -> this.service.metadata().getMetadataFromUsers(targets, properties) - .block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow( - () -> this.service.user().delete(randomUsername).block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow( - () -> this.service.user().delete(randomUsername1).block(Utilities.IT_TIMEOUT)); - } - - @Test - public void testMetadataGetUsage() { - assertDoesNotThrow(() -> this.service.metadata().getUsage().block(Utilities.IT_TIMEOUT)); - } - - @Test - public void testMetadataDelete() { - Map map = new HashMap<>(); - map.put("nickname", "昵称"); - map.put("avatar", "http://www.easemob.com/avatar.png"); - map.put("phone", "159"); - - String randomUsername = Utilities.randomUserName(); - String randomPassword = Utilities.randomPassword(); - assertDoesNotThrow(() -> this.service.user().create(randomUsername, randomPassword) - .block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow(() -> this.service.metadata().setMetadataToUser(randomUsername, map) - .block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow(() -> this.service.metadata().getMetadataFromUser(randomUsername) - .block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow(() -> this.service.metadata().deleteMetadataFromUser(randomUsername) - .block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow( - () -> this.service.user().delete(randomUsername).block(Utilities.IT_TIMEOUT)); - } - - @Test - public void testChatRoomMetadataSet() { - - String randomOwnerUsername = Utilities.randomUserName(); - String randomPassword = Utilities.randomPassword(); - - String randomMemberUsername = Utilities.randomUserName(); - List members = new ArrayList<>(); - members.add(randomMemberUsername); - assertDoesNotThrow(() -> this.service.user().create(randomOwnerUsername, randomPassword) - .block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow(() -> this.service.user().create(randomMemberUsername, randomPassword) - .block(Utilities.IT_TIMEOUT)); - String roomId = assertDoesNotThrow(() -> this.service.room() - .createRoom("chat room", "room description", randomOwnerUsername, members, 200, - "custom") - .block(Utilities.IT_TIMEOUT)); - - Map map = new HashMap<>(); - map.put("nickname", "昵称"); - map.put("avatar", "http://www.easemob.com/avatar.png"); - map.put("phone", "159"); - - assertDoesNotThrow(() -> this.service.metadata() - .setChatRoomMetadata(randomMemberUsername, roomId, map, - AutoDelete.DELETE) - .block(Utilities.IT_TIMEOUT)); - - assertDoesNotThrow(() -> this.service.metadata() - .setChatRoomMetadataForced(randomOwnerUsername, roomId, map, - AutoDelete.DELETE) - .block(Utilities.IT_TIMEOUT)); - - assertDoesNotThrow(() -> this.service.metadata().listChatRoomMetadataAll(roomId) - .block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow( - () -> this.service.room().destroyRoom(roomId).block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow( - () -> this.service.user().delete(randomOwnerUsername).block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow( - () -> this.service.user().delete(randomMemberUsername).block(Utilities.IT_TIMEOUT)); - } - - @Test - public void testChatRoomMetadataGet() { - - String randomOwnerUsername = Utilities.randomUserName(); - String randomPassword = Utilities.randomPassword(); - - String randomMemberUsername = Utilities.randomUserName(); - List members = new ArrayList<>(); - members.add(randomMemberUsername); - assertDoesNotThrow(() -> this.service.user().create(randomOwnerUsername, randomPassword) - .block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow(() -> this.service.user().create(randomMemberUsername, randomPassword) - .block(Utilities.IT_TIMEOUT)); - String roomId = assertDoesNotThrow(() -> this.service.room() - .createRoom("chat room", "room description", randomOwnerUsername, members, 200, - "custom") - .block(Utilities.IT_TIMEOUT)); - - Map map = new HashMap<>(); - map.put("nickname", "昵称"); - map.put("avatar", "http://www.easemob.com/avatar.png"); - map.put("phone", "159"); - - assertDoesNotThrow(() -> this.service.metadata() - .setChatRoomMetadata(randomMemberUsername, roomId, map, - AutoDelete.DELETE) - .block(Utilities.IT_TIMEOUT)); - - List keys = new ArrayList<>(); - keys.add("nickname"); - - assertDoesNotThrow(() -> this.service.metadata().listChatRoomMetadata(roomId, keys) - .block(Utilities.IT_TIMEOUT)); - - assertDoesNotThrow(() -> this.service.metadata().listChatRoomMetadataAll(roomId) - .block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow( - () -> this.service.room().destroyRoom(roomId).block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow( - () -> this.service.user().delete(randomOwnerUsername).block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow( - () -> this.service.user().delete(randomMemberUsername).block(Utilities.IT_TIMEOUT)); - } - - @Test - public void testChatRoomMetadataDelete() { - - String randomOwnerUsername = Utilities.randomUserName(); - String randomPassword = Utilities.randomPassword(); - - String randomMemberUsername = Utilities.randomUserName(); - List members = new ArrayList<>(); - members.add(randomMemberUsername); - assertDoesNotThrow(() -> this.service.user().create(randomOwnerUsername, randomPassword) - .block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow(() -> this.service.user().create(randomMemberUsername, randomPassword) - .block(Utilities.IT_TIMEOUT)); - String roomId = assertDoesNotThrow(() -> this.service.room() - .createRoom("chat room", "room description", randomOwnerUsername, members, 200, - "custom") - .block(Utilities.IT_TIMEOUT)); - - Map map = new HashMap<>(); - map.put("nickname", "昵称"); - map.put("avatar", "http://www.easemob.com/avatar.png"); - map.put("phone", "159"); - - assertDoesNotThrow(() -> this.service.metadata() - .setChatRoomMetadata(randomMemberUsername, roomId, map, - AutoDelete.DELETE) - .block(Utilities.IT_TIMEOUT)); - - List keys = new ArrayList<>(); - keys.add("nickname"); - - assertDoesNotThrow(() -> this.service.metadata().listChatRoomMetadata(roomId, keys) - .block(Utilities.IT_TIMEOUT)); - - assertDoesNotThrow(() -> this.service.metadata() - .deleteChatRoomMetadata(randomMemberUsername, roomId, keys) - .block(Utilities.IT_TIMEOUT)); - - keys.clear(); - keys.add("avatar"); - - assertDoesNotThrow(() -> this.service.metadata().deleteChatRoomMetadataForced(roomId, keys) - .block(Utilities.IT_TIMEOUT)); - - assertDoesNotThrow(() -> this.service.metadata().listChatRoomMetadataAll(roomId) - .block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow( - () -> this.service.room().destroyRoom(roomId).block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow( - () -> this.service.user().delete(randomOwnerUsername).block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow( - () -> this.service.user().delete(randomMemberUsername).block(Utilities.IT_TIMEOUT)); - } - - @Test - public void testChatGroupMetadataUserSetAndGet() { - - String randomOwnerUsername = Utilities.randomUserName(); - String randomPassword = Utilities.randomPassword(); - - String randomMemberUsername = Utilities.randomUserName(); - List members = new ArrayList<>(); - members.add(randomMemberUsername); - assertDoesNotThrow(() -> this.service.user().create(randomOwnerUsername, randomPassword) - .block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow(() -> this.service.user().create(randomMemberUsername, randomPassword) - .block(Utilities.IT_TIMEOUT)); - String groupId = assertDoesNotThrow(() -> this.service.group() - .createPublicGroup(randomOwnerUsername, "group", "group description", members, 200, - true).block(Utilities.IT_TIMEOUT)); - - Map map = new HashMap<>(); - map.put("nickname", "昵称"); - map.put("avatar", "http://www.easemob.com/avatar.png"); - map.put("phone", "159"); - - assertDoesNotThrow(() -> this.service.metadata().setMetadataToChatGroupUser(randomMemberUsername, groupId, map) - .block(Utilities.IT_TIMEOUT)); - - EMMetadata metadata = assertDoesNotThrow(() -> this.service.metadata().getMetadataFromChatGroupUser(randomMemberUsername, groupId) - .block(Utilities.IT_TIMEOUT)); - - System.out.println("metadata : " + metadata); - - assertEquals("昵称", metadata.getData().get("nickname")); - assertEquals("http://www.easemob.com/avatar.png", metadata.getData().get("avatar")); - assertEquals("159", metadata.getData().get("phone")); - - assertDoesNotThrow( - () -> this.service.group().destroyGroup(groupId).block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow( - () -> this.service.user().delete(randomOwnerUsername).block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow(() -> this.service.user().delete(randomMemberUsername) - .block(Utilities.IT_TIMEOUT)); - } - - @Test - public void testChatGroupUsersMetadataBatchGet() { - - String randomOwnerUsername = Utilities.randomUserName(); - String randomPassword = Utilities.randomPassword(); - - String randomMemberUsername = Utilities.randomUserName(); - List members = new ArrayList<>(); - members.add(randomMemberUsername); - assertDoesNotThrow(() -> this.service.user().create(randomOwnerUsername, randomPassword) - .block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow(() -> this.service.user().create(randomMemberUsername, randomPassword) - .block(Utilities.IT_TIMEOUT)); - String groupId = assertDoesNotThrow(() -> this.service.group() - .createPublicGroup(randomOwnerUsername, "group", "group description", members, 200, - true).block(Utilities.IT_TIMEOUT)); - - Map map = new HashMap<>(); - map.put("nickname", "昵称"); - map.put("avatar", "http://www.easemob.com/avatar.png"); - map.put("phone", "159"); - - assertDoesNotThrow(() -> this.service.metadata().setMetadataToChatGroupUser(randomOwnerUsername, groupId, map) - .block(Utilities.IT_TIMEOUT)); - - assertDoesNotThrow(() -> this.service.metadata().setMetadataToChatGroupUser(randomMemberUsername, groupId, map) - .block(Utilities.IT_TIMEOUT)); - - List targets = new ArrayList<>(); - targets.add(randomOwnerUsername); - targets.add(randomMemberUsername); - - List properties = new ArrayList<>(); - properties.add("nickname"); - properties.add("avatar"); - properties.add("phone"); - - EMMetadataBatch metadataBatch = assertDoesNotThrow(() -> this.service.metadata().getMetadataFromChatGroupUsers(groupId, targets, properties) - .block(Utilities.IT_TIMEOUT)); - - System.out.println("metadataBatch : " + metadataBatch); - - assertEquals("昵称", metadataBatch.getData().get(randomOwnerUsername).get("nickname")); - assertEquals("http://www.easemob.com/avatar.png", metadataBatch.getData().get(randomOwnerUsername).get("avatar")); - assertEquals("159", metadataBatch.getData().get(randomOwnerUsername).get("phone")); - - assertEquals("昵称", metadataBatch.getData().get(randomMemberUsername).get("nickname")); - assertEquals("http://www.easemob.com/avatar.png", metadataBatch.getData().get(randomMemberUsername).get("avatar")); - assertEquals("159", metadataBatch.getData().get(randomMemberUsername).get("phone")); - - assertDoesNotThrow( - () -> this.service.group().destroyGroup(groupId).block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow( - () -> this.service.user().delete(randomOwnerUsername).block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow(() -> this.service.user().delete(randomMemberUsername) - .block(Utilities.IT_TIMEOUT)); - } - - -} diff --git a/im-sdk-core/src/integration-test/java/com/easemob/im/server/api/moderation/ModerationIT.java b/im-sdk-core/src/integration-test/java/com/easemob/im/server/api/moderation/ModerationIT.java deleted file mode 100644 index b79f305b4..000000000 --- a/im-sdk-core/src/integration-test/java/com/easemob/im/server/api/moderation/ModerationIT.java +++ /dev/null @@ -1,39 +0,0 @@ -package com.easemob.im.server.api.moderation; - -import com.easemob.im.server.EMException; -import com.easemob.im.server.api.AbstractIT; -import com.easemob.im.server.api.moderation.list.ExportDetailsListResponse; -import com.easemob.im.server.api.util.Utilities; -import org.junit.jupiter.api.Test; - -import java.nio.file.FileSystems; -import java.nio.file.Path; - -import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; -import static org.junit.jupiter.api.Assertions.assertThrows; - -public class ModerationIT extends AbstractIT { - - ModerationIT() { - super(); - } - - @Test - public void testExportMessageRecord() { - assertThrows(EMException.class, () -> this.service.moderation().export(1646602048000L, 1646666948000L, null, null, null, null).block(Utilities.IT_TIMEOUT)); - } - - @Test - public void testExportDetailsList() { - assertDoesNotThrow(() -> this.service.moderation().get(1, 10, "287c0730-9e97-11ec-ba62-139a925bb42e").block(Utilities.IT_TIMEOUT)); - } - - @Test - public void testRecordFileDownload() { - Path path = FileSystems.getDefault().getPath("/Users/xxx/xxx"); - - assertThrows(EMException.class, - () -> this.service.moderation().download("287c0730-9e97-11ec-ba62-139a925bb42e", path, "record.txt").block(Utilities.IT_TIMEOUT)); - } - -} diff --git a/im-sdk-core/src/integration-test/java/com/easemob/im/server/api/mute/MuteIT.java b/im-sdk-core/src/integration-test/java/com/easemob/im/server/api/mute/MuteIT.java deleted file mode 100644 index 1ba1e94b2..000000000 --- a/im-sdk-core/src/integration-test/java/com/easemob/im/server/api/mute/MuteIT.java +++ /dev/null @@ -1,62 +0,0 @@ -package com.easemob.im.server.api.mute; - -import com.easemob.im.server.api.AbstractIT; -import com.easemob.im.server.api.mute.mute.MuteUserRequest; -import com.easemob.im.server.api.util.Utilities; -import org.junit.jupiter.api.Test; - -import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; - -public class MuteIT extends AbstractIT { - - MuteIT() { - super(); - } - - @Test - void testMuteUser() { - String randomUsername = Utilities.randomUserName(); - String randomPassword = Utilities.randomPassword(); - - assertDoesNotThrow(() -> this.service.user().create(randomUsername, randomPassword) - .block(Utilities.IT_TIMEOUT)); - - assertDoesNotThrow(() -> this.service.mute() - .muteUser(MuteUserRequest.builder().username(randomUsername).chat(100).build()) - .block(Utilities.IT_TIMEOUT)); - - assertDoesNotThrow(() -> this.service.user().delete(randomUsername) - .block(Utilities.IT_TIMEOUT)); - } - - @Test - void testMuteDetail() { - String randomUsername = Utilities.randomUserName(); - String randomPassword = Utilities.randomPassword(); - - assertDoesNotThrow(() -> this.service.user().create(randomUsername, randomPassword) - .block(Utilities.IT_TIMEOUT)); - - assertDoesNotThrow(() -> this.service.mute().detail(randomUsername) - .block(Utilities.IT_TIMEOUT)); - - assertDoesNotThrow(() -> this.service.user().delete(randomUsername) - .block(Utilities.IT_TIMEOUT)); - } - - @Test - void testMuteList() { - String randomUsername = Utilities.randomUserName(); - String randomPassword = Utilities.randomPassword(); - - assertDoesNotThrow(() -> this.service.user().create(randomUsername, randomPassword) - .block(Utilities.IT_TIMEOUT)); - - assertDoesNotThrow(() -> this.service.mute() - .muteUser(MuteUserRequest.builder().username(randomUsername).chat(100).build()) - .block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow(() -> this.service.mute().muteList().block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow(() -> this.service.user().delete(randomUsername) - .block(Utilities.IT_TIMEOUT)); - } -} diff --git a/im-sdk-core/src/integration-test/java/com/easemob/im/server/api/push/PushIT.java b/im-sdk-core/src/integration-test/java/com/easemob/im/server/api/push/PushIT.java deleted file mode 100644 index e45f45a0b..000000000 --- a/im-sdk-core/src/integration-test/java/com/easemob/im/server/api/push/PushIT.java +++ /dev/null @@ -1,87 +0,0 @@ -package com.easemob.im.server.api.push; - -import com.easemob.im.server.api.AbstractIT; -import com.easemob.im.server.api.push.displaystyle.set.DisplayStyle; -import com.easemob.im.server.api.util.Utilities; -import com.easemob.im.server.model.EMConversationType; -import com.easemob.im.server.model.EMNotificationType; -import org.junit.jupiter.api.Test; - -import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; - -public class PushIT extends AbstractIT { - - PushIT() { - super(); - } - - @Test - void testUpdateUserNickname() { - String randomUsername = Utilities.randomUserName(); - String randomPassword = Utilities.randomPassword(); - assertDoesNotThrow(() -> this.service.user().create(randomUsername, randomPassword) - .block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow(() -> this.service.push() - .updateUserNickname(randomUsername, String.format("nickname-%s", randomUsername)) - .block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow( - () -> this.service.user().delete(randomUsername).block(Utilities.IT_TIMEOUT)); - } - - @Test - void testNotificationDisplayStyle() { - String randomUsername = Utilities.randomUserName(); - String randomPassword = Utilities.randomPassword(); - assertDoesNotThrow(() -> this.service.user().create(randomUsername, randomPassword) - .block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow(() -> this.service.push() - .setNotificationDisplayStyle(randomUsername, DisplayStyle.DETAILS) - .block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow( - () -> this.service.user().delete(randomUsername).block(Utilities.IT_TIMEOUT)); - } - - @Test - void testOpenNotificationNoDisturbing() { - String randomUsername = Utilities.randomUserName(); - String randomPassword = Utilities.randomPassword(); - assertDoesNotThrow(() -> this.service.user().create(randomUsername, randomPassword) - .block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow( - () -> this.service.push().openNotificationNoDisturbing(randomUsername, 10, 15) - .block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow( - () -> this.service.user().delete(randomUsername).block(Utilities.IT_TIMEOUT)); - } - - @Test - void testCloseNotificationNoDisturbing() { - String randomUsername = Utilities.randomUserName(); - String randomPassword = Utilities.randomPassword(); - assertDoesNotThrow(() -> this.service.user().create(randomUsername, randomPassword) - .block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow(() -> this.service.push().closeNotificationNoDisturbing(randomUsername) - .block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow( - () -> this.service.user().delete(randomUsername).block(Utilities.IT_TIMEOUT)); - } - - @Test - void testOfflinePushSetting() { - String randomUsername = Utilities.randomUserName(); - String randomUsername1 = Utilities.randomUserName(); - String randomPassword = Utilities.randomPassword(); - assertDoesNotThrow(() -> this.service.user().create(randomUsername, randomPassword) - .block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow(() -> this.service.user().create(randomUsername1, randomPassword) - .block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow(() -> this.service.push() - .offlineSetting(randomUsername, EMConversationType.USER, randomUsername1, - EMNotificationType.NONE, "08:30-10:00", 120000) - .block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow( - () -> this.service.user().delete(randomUsername).block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow( - () -> this.service.user().delete(randomUsername1).block(Utilities.IT_TIMEOUT)); - } -} diff --git a/im-sdk-core/src/integration-test/java/com/easemob/im/server/api/room/RoomIT.java b/im-sdk-core/src/integration-test/java/com/easemob/im/server/api/room/RoomIT.java deleted file mode 100644 index bb0215054..000000000 --- a/im-sdk-core/src/integration-test/java/com/easemob/im/server/api/room/RoomIT.java +++ /dev/null @@ -1,806 +0,0 @@ -package com.easemob.im.server.api.room; - -import com.easemob.im.server.api.AbstractIT; -import com.easemob.im.server.api.util.Utilities; -import com.easemob.im.server.model.EMBlock; -import com.easemob.im.server.model.EMRoom; -import org.junit.jupiter.api.Test; - -import java.time.Duration; -import java.util.ArrayList; -import java.util.List; -import java.util.Map; - -import static org.junit.jupiter.api.Assertions.*; - -public class RoomIT extends AbstractIT { - - RoomIT() { - super(); - } - - @Test - void testRoomCreate() { - String randomOwnerUsername = Utilities.randomUserName(); - String randomPassword = Utilities.randomPassword(); - - String randomMemberUsername = Utilities.randomUserName(); - List members = new ArrayList<>(); - members.add(randomMemberUsername); - assertDoesNotThrow(() -> this.service.user().create(randomOwnerUsername, randomPassword) - .block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow(() -> this.service.user().create(randomMemberUsername, randomPassword) - .block(Utilities.IT_TIMEOUT)); - String roomId = assertDoesNotThrow(() -> this.service.room() - .createRoom("chat room", "room description", randomOwnerUsername, members, 200) - .block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow( - () -> this.service.room().destroyRoom(roomId).block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow( - () -> this.service.user().delete(randomOwnerUsername).block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow(() -> this.service.user().delete(randomMemberUsername) - .block(Utilities.IT_TIMEOUT)); - } - - @Test - void testRoomCreateWithNeedVerify() { - String randomOwnerUsername = Utilities.randomUserName(); - String randomPassword = Utilities.randomPassword(); - - String randomMemberUsername = Utilities.randomUserName(); - List members = new ArrayList<>(); - members.add(randomMemberUsername); - assertDoesNotThrow(() -> this.service.user().create(randomOwnerUsername, randomPassword) - .block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow(() -> this.service.user().create(randomMemberUsername, randomPassword) - .block(Utilities.IT_TIMEOUT)); - String roomId = assertDoesNotThrow(() -> this.service.room() - .createRoom("chat room", "room description", randomOwnerUsername, members, 200, "custom", Boolean.TRUE) - .block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow( - () -> this.service.room().destroyRoom(roomId).block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow( - () -> this.service.user().delete(randomOwnerUsername).block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow(() -> this.service.user().delete(randomMemberUsername) - .block(Utilities.IT_TIMEOUT)); - } - - @Test - void testRoomGet() { - String randomOwnerUsername = Utilities.randomUserName(); - String randomPassword = Utilities.randomPassword(); - - String randomMemberUsername = Utilities.randomUserName(); - List members = new ArrayList<>(); - members.add(randomMemberUsername); - assertDoesNotThrow(() -> this.service.user().create(randomOwnerUsername, randomPassword) - .block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow(() -> this.service.user().create(randomMemberUsername, randomPassword) - .block(Utilities.IT_TIMEOUT)); - String roomId = assertDoesNotThrow(() -> this.service.room() - .createRoom("chat room", "room description", randomOwnerUsername, members, 200) - .block(Utilities.IT_TIMEOUT)); - EMRoom room = assertDoesNotThrow(() -> this.service.room().getRoom(roomId).block(Utilities.IT_TIMEOUT)); - assertNotNull(room); - assertEquals(2, room.members().size()); - assertDoesNotThrow( - () -> this.service.room().destroyRoom(roomId).block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow( - () -> this.service.user().delete(randomOwnerUsername).block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow(() -> this.service.user().delete(randomMemberUsername) - .block(Utilities.IT_TIMEOUT)); - } - - @Test - void testRoomUpdate() { - String randomOwnerUsername = Utilities.randomUserName(); - String randomPassword = Utilities.randomPassword(); - - String randomMemberUsername = Utilities.randomUserName(); - List members = new ArrayList<>(); - members.add(randomMemberUsername); - assertDoesNotThrow(() -> this.service.user().create(randomOwnerUsername, randomPassword) - .block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow(() -> this.service.user().create(randomMemberUsername, randomPassword) - .block(Utilities.IT_TIMEOUT)); - String roomId = assertDoesNotThrow(() -> this.service.room() - .createRoom("chat room", "room description", randomOwnerUsername, members, 200, "custom") - .block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow(() -> this.service.room() - .updateRoom(roomId, settings -> settings.withMaxMembers(100).withCustom("custom")) - .block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow( - () -> this.service.room().destroyRoom(roomId).block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow( - () -> this.service.user().delete(randomOwnerUsername).block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow(() -> this.service.user().delete(randomMemberUsername) - .block(Utilities.IT_TIMEOUT)); - } - - @Test - void testRoomListAll() { - String randomOwnerUsername = Utilities.randomUserName(); - String randomPassword = Utilities.randomPassword(); - - String randomMemberUsername = Utilities.randomUserName(); - List members = new ArrayList<>(); - members.add(randomMemberUsername); - assertDoesNotThrow(() -> this.service.user().create(randomOwnerUsername, randomPassword) - .block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow(() -> this.service.user().create(randomMemberUsername, randomPassword) - .block(Utilities.IT_TIMEOUT)); - String roomId = assertDoesNotThrow(() -> this.service.room() - .createRoom("chat room", "room description", randomOwnerUsername, members, 200) - .block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow( - () -> this.service.room().listRoomsAll().blockFirst(Utilities.IT_TIMEOUT)); - assertDoesNotThrow( - () -> this.service.room().destroyRoom(roomId).block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow( - () -> this.service.user().delete(randomOwnerUsername).block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow(() -> this.service.user().delete(randomMemberUsername) - .block(Utilities.IT_TIMEOUT)); - } - - @Test - void testRoomListRooms() { - String randomOwnerUsername = Utilities.randomUserName(); - String randomPassword = Utilities.randomPassword(); - - String randomMemberUsername = Utilities.randomUserName(); - List members = new ArrayList<>(); - members.add(randomMemberUsername); - assertDoesNotThrow(() -> this.service.user().create(randomOwnerUsername, randomPassword) - .block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow(() -> this.service.user().create(randomMemberUsername, randomPassword) - .block(Utilities.IT_TIMEOUT)); - String roomId = assertDoesNotThrow(() -> this.service.room() - .createRoom("chat room", "room description", randomOwnerUsername, members, 200) - .block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow( - () -> this.service.room().listRooms(1, null).block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow( - () -> this.service.room().destroyRoom(roomId).block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow( - () -> this.service.user().delete(randomOwnerUsername).block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow(() -> this.service.user().delete(randomMemberUsername) - .block(Utilities.IT_TIMEOUT)); - } - - @Test - void testRoomUserJoinedList() { - String randomOwnerUsername = Utilities.randomUserName(); - String randomPassword = Utilities.randomPassword(); - - String randomMemberUsername = Utilities.randomUserName(); - List members = new ArrayList<>(); - members.add(randomMemberUsername); - assertDoesNotThrow(() -> this.service.user().create(randomOwnerUsername, randomPassword) - .block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow(() -> this.service.user().create(randomMemberUsername, randomPassword) - .block(Utilities.IT_TIMEOUT)); - String roomId = assertDoesNotThrow(() -> this.service.room() - .createRoom("chat room", "room description", randomOwnerUsername, members, 200) - .block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow(() -> this.service.room().listRoomsUserJoined(randomOwnerUsername) - .blockFirst(Utilities.IT_TIMEOUT)); - assertDoesNotThrow( - () -> this.service.room().destroyRoom(roomId).block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow( - () -> this.service.user().delete(randomOwnerUsername).block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow(() -> this.service.user().delete(randomMemberUsername) - .block(Utilities.IT_TIMEOUT)); - } - - @Test - void testRoomMembersAll() { - String randomOwnerUsername = Utilities.randomUserName(); - String randomPassword = Utilities.randomPassword(); - - String randomMemberUsername1 = Utilities.randomUserName(); - String randomMemberUsername2 = Utilities.randomUserName(); - List members = new ArrayList<>(); - members.add(randomMemberUsername1); - assertDoesNotThrow(() -> this.service.user().create(randomOwnerUsername, randomPassword) - .block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow(() -> this.service.user().create(randomMemberUsername1, randomPassword) - .block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow(() -> this.service.user().create(randomMemberUsername2, randomPassword) - .block(Utilities.IT_TIMEOUT)); - String roomId = assertDoesNotThrow(() -> this.service.room() - .createRoom("chat room", "room description", randomOwnerUsername, members, 200) - .block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow(() -> this.service.room().addRoomMember(roomId,randomMemberUsername2) - .block(Utilities.IT_TIMEOUT)); - String firstJoinMember =assertDoesNotThrow(() -> this.service.room().listRoomMembersAll(roomId,"asc") - .blockFirst(Utilities.IT_TIMEOUT)); - assertEquals(randomMemberUsername1, firstJoinMember); - assertDoesNotThrow( - () -> this.service.room().destroyRoom(roomId).block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow( - () -> this.service.user().delete(randomOwnerUsername).block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow(() -> this.service.user().delete(randomMemberUsername1) - .block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow(() -> this.service.user().delete(randomMemberUsername2) - .block(Utilities.IT_TIMEOUT)); - } - - @Test - void testRoomMembersAllWithOwner() { - String randomOwnerUsername = Utilities.randomUserName(); - String randomPassword = Utilities.randomPassword(); - - String randomMemberUsername1 = Utilities.randomUserName(); - String randomMemberUsername2 = Utilities.randomUserName(); - List members = new ArrayList<>(); - members.add(randomMemberUsername1); - assertDoesNotThrow(() -> this.service.user().create(randomOwnerUsername, randomPassword) - .block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow(() -> this.service.user().create(randomMemberUsername1, randomPassword) - .block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow(() -> this.service.user().create(randomMemberUsername2, randomPassword) - .block(Utilities.IT_TIMEOUT)); - String roomId = assertDoesNotThrow(() -> this.service.room() - .createRoom("chat room", "room description", randomOwnerUsername, members, 200) - .block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow(() -> this.service.room().addRoomMember(roomId,randomMemberUsername2) - .block(Utilities.IT_TIMEOUT)); - List> roomMembers = assertDoesNotThrow(() -> this.service.room().listRoomMembersAllWithOwner(roomId).collectList() - .block(Utilities.IT_TIMEOUT)); - assertNotNull(roomMembers); - assertEquals(3, roomMembers.size()); - assertDoesNotThrow( - () -> this.service.room().destroyRoom(roomId).block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow( - () -> this.service.user().delete(randomOwnerUsername).block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow(() -> this.service.user().delete(randomMemberUsername1) - .block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow(() -> this.service.user().delete(randomMemberUsername2) - .block(Utilities.IT_TIMEOUT)); - } - - @Test - void testRoomMembers() { - String randomOwnerUsername = Utilities.randomUserName(); - String randomPassword = Utilities.randomPassword(); - - String randomMemberUsername = Utilities.randomUserName(); - List members = new ArrayList<>(); - members.add(randomMemberUsername); - assertDoesNotThrow(() -> this.service.user().create(randomOwnerUsername, randomPassword) - .block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow(() -> this.service.user().create(randomMemberUsername, randomPassword) - .block(Utilities.IT_TIMEOUT)); - String roomId = assertDoesNotThrow(() -> this.service.room() - .createRoom("chat room", "room description", randomOwnerUsername, members, 200) - .block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow(() -> this.service.room().listRoomMembers(roomId, 1, null) - .block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow( - () -> this.service.room().destroyRoom(roomId).block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow( - () -> this.service.user().delete(randomOwnerUsername).block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow(() -> this.service.user().delete(randomMemberUsername) - .block(Utilities.IT_TIMEOUT)); - } - - @Test - void testRoomMembersWithOwner() { - String randomOwnerUsername = Utilities.randomUserName(); - String randomPassword = Utilities.randomPassword(); - - String randomMemberUsername = Utilities.randomUserName(); - List members = new ArrayList<>(); - members.add(randomMemberUsername); - assertDoesNotThrow(() -> this.service.user().create(randomOwnerUsername, randomPassword) - .block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow(() -> this.service.user().create(randomMemberUsername, randomPassword) - .block(Utilities.IT_TIMEOUT)); - String roomId = assertDoesNotThrow(() -> this.service.room() - .createRoom("chat room", "room description", randomOwnerUsername, members, 200) - .block(Utilities.IT_TIMEOUT)); - List> roomMembers = assertDoesNotThrow(() -> this.service.room().listRoomMembersWithOwner(roomId, 1, 10) - .block(Utilities.IT_TIMEOUT)); - assertNotNull(roomMembers); - assertEquals(2, roomMembers.size()); - assertDoesNotThrow( - () -> this.service.room().destroyRoom(roomId).block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow( - () -> this.service.user().delete(randomOwnerUsername).block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow(() -> this.service.user().delete(randomMemberUsername) - .block(Utilities.IT_TIMEOUT)); - } - - @Test - void testRoomAddMember() { - String randomOwnerUsername = Utilities.randomUserName(); - String randomPassword = Utilities.randomPassword(); - - String randomMemberUsername = Utilities.randomUserName(); - List members = new ArrayList<>(); - assertDoesNotThrow(() -> this.service.user().create(randomOwnerUsername, randomPassword) - .block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow(() -> this.service.user().create(randomMemberUsername, randomPassword) - .block(Utilities.IT_TIMEOUT)); - String roomId = assertDoesNotThrow(() -> this.service.room() - .createRoom("chat room", "room description", randomOwnerUsername, members, 200) - .block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow(() -> this.service.room().addRoomMember(roomId, randomMemberUsername) - .block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow( - () -> this.service.room().destroyRoom(roomId).block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow( - () -> this.service.user().delete(randomOwnerUsername).block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow(() -> this.service.user().delete(randomMemberUsername) - .block(Utilities.IT_TIMEOUT)); - } - - @Test - void testRoomRemoveMember() { - String randomOwnerUsername = Utilities.randomUserName(); - String randomPassword = Utilities.randomPassword(); - - String randomMemberUsername = Utilities.randomUserName(); - List members = new ArrayList<>(); - members.add(randomMemberUsername); - assertDoesNotThrow(() -> this.service.user().create(randomOwnerUsername, randomPassword) - .block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow(() -> this.service.user().create(randomMemberUsername, randomPassword) - .block(Utilities.IT_TIMEOUT)); - String roomId = assertDoesNotThrow(() -> this.service.room() - .createRoom("chat room", "room description", randomOwnerUsername, members, 200) - .block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow(() -> this.service.room().removeRoomMember(roomId, randomMemberUsername) - .block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow( - () -> this.service.room().destroyRoom(roomId).block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow( - () -> this.service.user().delete(randomOwnerUsername).block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow(() -> this.service.user().delete(randomMemberUsername) - .block(Utilities.IT_TIMEOUT)); - } - - @Test - void testRoomAdminsAll() { - String randomOwnerUsername = Utilities.randomUserName(); - String randomPassword = Utilities.randomPassword(); - - String randomMemberUsername = Utilities.randomUserName(); - List members = new ArrayList<>(); - members.add(randomMemberUsername); - assertDoesNotThrow(() -> this.service.user().create(randomOwnerUsername, randomPassword) - .block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow(() -> this.service.user().create(randomMemberUsername, randomPassword) - .block(Utilities.IT_TIMEOUT)); - String roomId = assertDoesNotThrow(() -> this.service.room() - .createRoom("chat room", "room description", randomOwnerUsername, members, 200) - .block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow(() -> this.service.room().promoteRoomAdmin(roomId, randomMemberUsername) - .block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow(() -> this.service.room().listRoomAdminsAll(roomId) - .blockFirst(Utilities.IT_TIMEOUT)); - assertDoesNotThrow( - () -> this.service.room().destroyRoom(roomId).block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow( - () -> this.service.user().delete(randomOwnerUsername).block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow(() -> this.service.user().delete(randomMemberUsername) - .block(Utilities.IT_TIMEOUT)); - } - - @Test - void testRoomPromoteAdmin() { - String randomOwnerUsername = Utilities.randomUserName(); - String randomPassword = Utilities.randomPassword(); - - String randomMemberUsername = Utilities.randomUserName(); - List members = new ArrayList<>(); - members.add(randomMemberUsername); - assertDoesNotThrow(() -> this.service.user().create(randomOwnerUsername, randomPassword) - .block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow(() -> this.service.user().create(randomMemberUsername, randomPassword) - .block(Utilities.IT_TIMEOUT)); - String roomId = assertDoesNotThrow(() -> this.service.room() - .createRoom("chat room", "room description", randomOwnerUsername, members, 200) - .block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow(() -> this.service.room().promoteRoomAdmin(roomId, randomMemberUsername) - .block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow( - () -> this.service.room().destroyRoom(roomId).block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow( - () -> this.service.user().delete(randomOwnerUsername).block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow(() -> this.service.user().delete(randomMemberUsername) - .block(Utilities.IT_TIMEOUT)); - } - - @Test - void testRoomDemoteAdmin() { - String randomOwnerUsername = Utilities.randomUserName(); - String randomPassword = Utilities.randomPassword(); - - String randomMemberUsername = Utilities.randomUserName(); - List members = new ArrayList<>(); - members.add(randomMemberUsername); - assertDoesNotThrow(() -> this.service.user().create(randomOwnerUsername, randomPassword) - .block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow(() -> this.service.user().create(randomMemberUsername, randomPassword) - .block(Utilities.IT_TIMEOUT)); - String roomId = assertDoesNotThrow(() -> this.service.room() - .createRoom("chat room", "room description", randomOwnerUsername, members, 200) - .block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow(() -> this.service.room().promoteRoomAdmin(roomId, randomMemberUsername) - .block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow(() -> this.service.room().demoteRoomAdmin(roomId, randomMemberUsername) - .block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow( - () -> this.service.room().destroyRoom(roomId).block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow( - () -> this.service.user().delete(randomOwnerUsername).block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow(() -> this.service.user().delete(randomMemberUsername) - .block(Utilities.IT_TIMEOUT)); - } - - @Test - void testRoomSuperAdminsAll() { - String randomUsername = Utilities.randomUserName(); - String randomUsername1 = Utilities.randomUserName(); - String randomUsername2 = Utilities.randomUserName(); - String randomPassword = Utilities.randomPassword(); - assertDoesNotThrow(() -> this.service.user().create(randomUsername, randomPassword) - .block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow(() -> this.service.user().create(randomUsername1, randomPassword) - .block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow(() -> this.service.user().create(randomUsername2, randomPassword) - .block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow(() -> this.service.room().promoteRoomSuperAdmin(randomUsername) - .block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow(() -> this.service.room().promoteRoomSuperAdmin(randomUsername1) - .block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow(() -> this.service.room().promoteRoomSuperAdmin(randomUsername2) - .block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow(() -> this.service.room().listRoomSuperAdminsAll() - .blockFirst(Utilities.IT_TIMEOUT)); - assertDoesNotThrow( - () -> this.service.user().delete(randomUsername).block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow( - () -> this.service.user().delete(randomUsername1).block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow( - () -> this.service.user().delete(randomUsername2).block(Utilities.IT_TIMEOUT)); - } - - @Test - void testRoomPromoteSuperAdmin() { - String randomUsername = Utilities.randomUserName(); - String randomPassword = Utilities.randomPassword(); - assertDoesNotThrow(() -> this.service.user().create(randomUsername, randomPassword) - .block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow(() -> this.service.room().promoteRoomSuperAdmin(randomUsername) - .block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow( - () -> this.service.user().delete(randomUsername).block(Utilities.IT_TIMEOUT)); - } - - @Test - void testRoomDemoteSuperAdmin() { - String randomUsername = Utilities.randomUserName(); - String randomPassword = Utilities.randomPassword(); - assertDoesNotThrow(() -> this.service.user().create(randomUsername, randomPassword) - .block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow(() -> this.service.room().demoteRoomSuperAdmin(randomUsername) - .block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow( - () -> this.service.user().delete(randomUsername).block(Utilities.IT_TIMEOUT)); - } - - @Test - void testRoomDestroy() { - String randomOwnerUsername = Utilities.randomUserName(); - String randomPassword = Utilities.randomPassword(); - - String randomMemberUsername = Utilities.randomUserName(); - List members = new ArrayList<>(); - members.add(randomMemberUsername); - assertDoesNotThrow(() -> this.service.user().create(randomOwnerUsername, randomPassword) - .block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow(() -> this.service.user().create(randomMemberUsername, randomPassword) - .block(Utilities.IT_TIMEOUT)); - String roomId = assertDoesNotThrow(() -> this.service.room() - .createRoom("chat room", "room description", randomOwnerUsername, members, 200) - .block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow( - () -> this.service.room().destroyRoom(roomId).block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow( - () -> this.service.user().delete(randomOwnerUsername).block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow(() -> this.service.user().delete(randomMemberUsername) - .block(Utilities.IT_TIMEOUT)); - } - - @Test - void testRoomUsersBlockedSendMsg() { - String randomOwnerUsername = Utilities.randomUserName(); - String randomPassword = Utilities.randomPassword(); - - String randomMemberUsername1 = Utilities.randomUserName(); - String randomMemberUsername2 = Utilities.randomUserName(); - List members = new ArrayList<>(); - members.add(randomMemberUsername1); - members.add(randomMemberUsername2); - assertDoesNotThrow(() -> this.service.user().create(randomOwnerUsername, randomPassword) - .block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow(() -> this.service.user().create(randomMemberUsername1, randomPassword) - .block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow(() -> this.service.user().create(randomMemberUsername2, randomPassword) - .block(Utilities.IT_TIMEOUT)); - String roomId = assertDoesNotThrow(() -> this.service.room() - .createRoom("chat room", "room description", randomOwnerUsername, members, 200) - .block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow(() -> this.service.block() - .blockUserSendMsgToRoom(members, roomId, Duration.ofMillis(6000)) - .block(Utilities.IT_TIMEOUT)); - List blocks = assertDoesNotThrow(() -> this.service.block().listUsersBlockedSendMsgToRoom(roomId) - .collectList() - .block(Utilities.IT_TIMEOUT)); - assertEquals(blocks.size(), 2); - assertDoesNotThrow( - () -> this.service.room().destroyRoom(roomId).block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow( - () -> this.service.user().delete(randomOwnerUsername).block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow(() -> this.service.user().delete(randomMemberUsername1) - .block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow(() -> this.service.user().delete(randomMemberUsername2) - .block(Utilities.IT_TIMEOUT)); - } - - @Test - void testRoomBlockUserSendMsg() { - String randomOwnerUsername = Utilities.randomUserName(); - String randomPassword = Utilities.randomPassword(); - - String randomMemberUsername = Utilities.randomUserName(); - List members = new ArrayList<>(); - members.add(randomMemberUsername); - assertDoesNotThrow(() -> this.service.user().create(randomOwnerUsername, randomPassword) - .block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow(() -> this.service.user().create(randomMemberUsername, randomPassword) - .block(Utilities.IT_TIMEOUT)); - String roomId = assertDoesNotThrow(() -> this.service.room() - .createRoom("chat room", "room description", randomOwnerUsername, members, 200) - .block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow(() -> this.service.block() - .blockUserSendMsgToRoom(randomMemberUsername, roomId, Duration.ofMillis(30000)) - .block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow(() -> this.service.room().removeRoomMember(roomId, randomMemberUsername) - .block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow(() -> this.service.room().addRoomMember(roomId, randomMemberUsername) - .block(Utilities.IT_TIMEOUT)); - EMBlock block = assertDoesNotThrow( - () -> this.service.block().listUsersBlockedSendMsgToRoom(roomId) - .blockFirst(Utilities.IT_TIMEOUT)); - if (!block.getUsername().equals(randomMemberUsername)) { - throw new RuntimeException( - String.format("%s does not exist in %s room mute list", randomMemberUsername, - roomId)); - } - assertDoesNotThrow( - () -> this.service.room().destroyRoom(roomId).block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow( - () -> this.service.user().delete(randomOwnerUsername).block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow(() -> this.service.user().delete(randomMemberUsername) - .block(Utilities.IT_TIMEOUT)); - } - - @Test - void testRoomUnblockUserSendMsg() { - String randomOwnerUsername = Utilities.randomUserName(); - String randomPassword = Utilities.randomPassword(); - - String randomMemberUsername = Utilities.randomUserName(); - List members = new ArrayList<>(); - members.add(randomMemberUsername); - assertDoesNotThrow(() -> this.service.user().create(randomOwnerUsername, randomPassword) - .block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow(() -> this.service.user().create(randomMemberUsername, randomPassword) - .block(Utilities.IT_TIMEOUT)); - String roomId = assertDoesNotThrow(() -> this.service.room() - .createRoom("chat room", "room description", randomOwnerUsername, members, 200) - .block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow(() -> this.service.block() - .blockUserSendMsgToRoom(randomMemberUsername, roomId, Duration.ofMillis(6000)) - .block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow( - () -> this.service.block().unblockUserSendMsgToRoom(randomMemberUsername, roomId) - .block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow( - () -> this.service.room().destroyRoom(roomId).block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow( - () -> this.service.user().delete(randomOwnerUsername).block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow(() -> this.service.user().delete(randomMemberUsername) - .block(Utilities.IT_TIMEOUT)); - } - - @Test - void testRoomUnblockUsersSendMsg() { - String randomOwnerUsername = Utilities.randomUserName(); - String randomPassword = Utilities.randomPassword(); - - String randomMemberUsername1 = Utilities.randomUserName(); - String randomMemberUsername2 = Utilities.randomUserName(); - List members = new ArrayList<>(); - members.add(randomMemberUsername1); - members.add(randomMemberUsername2); - assertDoesNotThrow(() -> this.service.user().create(randomOwnerUsername, randomPassword) - .block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow(() -> this.service.user().create(randomMemberUsername1, randomPassword) - .block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow(() -> this.service.user().create(randomMemberUsername2, randomPassword) - .block(Utilities.IT_TIMEOUT)); - String roomId = assertDoesNotThrow(() -> this.service.room() - .createRoom("chat room", "room description", randomOwnerUsername, members, 200) - .block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow(() -> this.service.block() - .blockUserSendMsgToRoom(members, roomId, Duration.ofMillis(6000)) - .block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow( - () -> this.service.block().unblockUserSendMsgToRoom(members, roomId) - .block(Utilities.IT_TIMEOUT)); - - List blocks = assertDoesNotThrow( - () -> this.service.block().listUsersBlockedSendMsgToRoom(roomId).collectList() - .block(Utilities.IT_TIMEOUT)); - assertEquals(blocks.size(), 0); - assertDoesNotThrow( - () -> this.service.room().destroyRoom(roomId).block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow( - () -> this.service.user().delete(randomOwnerUsername).block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow(() -> this.service.user().delete(randomMemberUsername1) - .block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow(() -> this.service.user().delete(randomMemberUsername2) - .block(Utilities.IT_TIMEOUT)); - } - - @Test - void testRoomAssign(){ - String randomOwnerUsername = Utilities.randomUserName(); - String randomPassword = Utilities.randomPassword(); - - String randomMemberUsername = Utilities.randomUserName(); - List members = new ArrayList<>(); - members.add(randomMemberUsername); - assertDoesNotThrow(() -> this.service.user().create(randomOwnerUsername, randomPassword) - .block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow(() -> this.service.user().create(randomMemberUsername, randomPassword) - .block(Utilities.IT_TIMEOUT)); - String roomId = assertDoesNotThrow(() -> this.service.room() - .createRoom("chat room", "room description", randomOwnerUsername, members, 200) - .block(Utilities.IT_TIMEOUT)); - - assertDoesNotThrow(()->this.service.room().assignRoom(roomId, randomMemberUsername).block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow( - () -> this.service.room().destroyRoom(roomId).block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow( - () -> this.service.user().delete(randomOwnerUsername).block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow(() -> this.service.user().delete(randomMemberUsername) - .block(Utilities.IT_TIMEOUT)); - } - - @Test - void testRoomGetAnnouncement() { - - String randomOwnerUsername = Utilities.randomUserName(); - String randomPassword = Utilities.randomPassword(); - - String randomMemberUsername = Utilities.randomUserName(); - List members = new ArrayList<>(); - members.add(randomMemberUsername); - assertDoesNotThrow(() -> this.service.user().create(randomOwnerUsername, randomPassword) - .block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow(() -> this.service.user().create(randomMemberUsername, randomPassword) - .block(Utilities.IT_TIMEOUT)); - String roomId = assertDoesNotThrow(() -> this.service.room() - .createRoom("chat room", "room description", randomOwnerUsername, members, 200) - .block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow(() -> this.service.block() - .blockAllUserSendMsgToRoom(roomId) - .block(Utilities.IT_TIMEOUT)); - - EMRoom blockRoom = assertDoesNotThrow( - () -> this.service.room().getRoom(roomId).block(Utilities.IT_TIMEOUT)); - assertNotNull(blockRoom); - assertEquals(true, blockRoom.mute()); - - assertDoesNotThrow( - () -> this.service.block().unblockAllUserSendMsgToRoom(roomId) - .block(Utilities.IT_TIMEOUT)); - - EMRoom unblockRoom = assertDoesNotThrow( - () -> this.service.room().getRoom(roomId).block(Utilities.IT_TIMEOUT)); - assertNotNull(unblockRoom); - assertEquals(false, unblockRoom.mute()); - - assertDoesNotThrow(() -> this.service.room().assignRoom(roomId, randomMemberUsername) - .block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow(() -> this.service.room().getRoomAnnouncement(roomId) - .block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow( - () -> this.service.room().destroyRoom(roomId).block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow( - () -> this.service.user().delete(randomOwnerUsername).block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow(() -> this.service.user().delete(randomMemberUsername) - .block(Utilities.IT_TIMEOUT)); - - } - - @Test - void testRoomUpdateAnnouncement() { - String randomOwnerUsername = Utilities.randomUserName(); - String randomPassword = Utilities.randomPassword(); - - String randomMemberUsername = Utilities.randomUserName(); - List members = new ArrayList<>(); - members.add(randomMemberUsername); - assertDoesNotThrow(() -> this.service.user().create(randomOwnerUsername, randomPassword) - .block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow(() -> this.service.user().create(randomMemberUsername, randomPassword) - .block(Utilities.IT_TIMEOUT)); - String roomId = assertDoesNotThrow(() -> this.service.room() - .createRoom("chat room", "room description", randomOwnerUsername, members, 200) - .block(Utilities.IT_TIMEOUT)); - - String updateAnnouncement = "update announcement"; - - assertDoesNotThrow( - () -> this.service.room().updateRoomAnnouncement(roomId, updateAnnouncement) - .block(Utilities.IT_TIMEOUT)); - String newAnnouncement = assertDoesNotThrow( - () -> this.service.room().getRoomAnnouncement(roomId) - .block(Utilities.IT_TIMEOUT)); - if (!updateAnnouncement.equals(newAnnouncement)) { - throw new RuntimeException(String.format("update %s group announcement fail", roomId)); - } - assertDoesNotThrow( - () -> this.service.room().destroyRoom(roomId).block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow( - () -> this.service.user().delete(randomOwnerUsername).block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow(() -> this.service.user().delete(randomMemberUsername) - .block(Utilities.IT_TIMEOUT)); - } - - @Test - void testGetRoomList() { - String randomOwnerUsername = Utilities.randomUserName(); - String randomPassword = Utilities.randomPassword(); - - String randomMemberUsername = Utilities.randomUserName(); - List members = new ArrayList<>(); - members.add(randomMemberUsername); - assertDoesNotThrow(() -> this.service.user().create(randomOwnerUsername, randomPassword) - .block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow(() -> this.service.user().create(randomMemberUsername, randomPassword) - .block(Utilities.IT_TIMEOUT)); - String roomId1 = assertDoesNotThrow(() -> this.service.room() - .createRoom("chat room", "room description", randomOwnerUsername, members, 200) - .block(Utilities.IT_TIMEOUT)); - - String roomId2 = assertDoesNotThrow(() -> this.service.room() - .createRoom("chat room", "room description", randomOwnerUsername, members, 200) - .block(Utilities.IT_TIMEOUT)); - - List roomIds = new ArrayList<>(); - roomIds.add(roomId1); - roomIds.add(roomId2); - - assertDoesNotThrow(() -> { - List roomList = this.service.room().getRoomList(roomIds).block(Utilities.IT_TIMEOUT); - assertNotNull(roomList); - }); - - assertDoesNotThrow( - () -> this.service.room().destroyRoom(roomId1).block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow( - () -> this.service.room().destroyRoom(roomId2).block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow( - () -> this.service.user().delete(randomOwnerUsername).block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow(() -> this.service.user().delete(randomMemberUsername) - .block(Utilities.IT_TIMEOUT)); - } - -} diff --git a/im-sdk-core/src/integration-test/java/com/easemob/im/server/api/user/UserIT.java b/im-sdk-core/src/integration-test/java/com/easemob/im/server/api/user/UserIT.java deleted file mode 100644 index e5e0ef034..000000000 --- a/im-sdk-core/src/integration-test/java/com/easemob/im/server/api/user/UserIT.java +++ /dev/null @@ -1,433 +0,0 @@ -package com.easemob.im.server.api.user; - -import com.easemob.im.server.api.AbstractIT; -import com.easemob.im.server.api.util.Utilities; -import com.easemob.im.server.exception.EMNotFoundException; -import com.easemob.im.server.model.EMBlock; -import com.easemob.im.server.model.EMCreateUser; -import org.junit.jupiter.api.Disabled; -import org.junit.jupiter.api.Test; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; - -import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; -import static org.junit.jupiter.api.Assertions.assertThrows; - -class UserIT extends AbstractIT { - - UserIT() { - super(); - } - - @Test - void testUserLifeCycles() { - String randomUsername = Utilities.randomUserName(); - String randomPassword = Utilities.randomPassword(); - assertDoesNotThrow(() -> this.service.user().create(randomUsername, randomPassword) - .block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow( - () -> this.service.user().get(randomUsername).block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow( - () -> this.service.user().delete(randomUsername).block(Utilities.IT_TIMEOUT)); - assertThrows(EMNotFoundException.class, - () -> this.service.user().get(randomUsername).block(Utilities.IT_TIMEOUT)); - } - - @Test - void testBatchCreateUser() { - String randomUsername = Utilities.randomUserName(); - String randomUsername1 = Utilities.randomUserName(); - String randomPassword = Utilities.randomPassword(); - - List createUserList = new ArrayList<>(); - EMCreateUser createUser = new EMCreateUser(randomUsername, randomPassword); - EMCreateUser createUser1 = new EMCreateUser(randomUsername1, randomPassword); - createUserList.add(createUser); - createUserList.add(createUser1); - - assertDoesNotThrow(() -> this.service.user().create(createUserList) - .block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow( - () -> this.service.user().get(randomUsername).block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow( - () -> this.service.user().get(randomUsername1).block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow( - () -> this.service.user().delete(randomUsername).block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow( - () -> this.service.user().delete(randomUsername1).block(Utilities.IT_TIMEOUT)); - assertThrows(EMNotFoundException.class, - () -> this.service.user().get(randomUsername).block(Utilities.IT_TIMEOUT)); - assertThrows(EMNotFoundException.class, - () -> this.service.user().get(randomUsername1).block(Utilities.IT_TIMEOUT)); - } - - @Test - void testUserForceLogout() { - String randomUsername = Utilities.randomUserName(); - String randomPassword = Utilities.randomPassword(); - assertDoesNotThrow(() -> this.service.user().create(randomUsername, randomPassword) - .block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow(() -> this.service.user().forceLogoutAllDevices(randomUsername) - .block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow( - () -> this.service.user().delete(randomUsername).block(Utilities.IT_TIMEOUT)); - } - - @Test - void testUserUpdatePassword() { - String randomUsername = Utilities.randomUserName(); - String randomPassword = Utilities.randomPassword(); - assertDoesNotThrow(() -> this.service.user().create(randomUsername, randomPassword) - .block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow(() -> this.service.user().updateUserPassword(randomUsername, "password") - .block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow( - () -> this.service.user().delete(randomUsername).block(Utilities.IT_TIMEOUT)); - } - - @Test - void testUserListUsers() { - String randomUsername = Utilities.randomUserName(); - String randomPassword = Utilities.randomPassword(); - assertDoesNotThrow(() -> this.service.user().create(randomUsername, randomPassword) - .block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow( - () -> this.service.user().listUsers(1, null).block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow( - () -> this.service.user().delete(randomUsername).block(Utilities.IT_TIMEOUT)); - } - - // TODO: enable this once we can use a clean appkey for tests - // currently we use easemob-demo#easechatui for the gateway token007 tests and this appkey has too many users - @Disabled - void testUserListAll() { - String randomUsername = Utilities.randomUserName(); - String randomPassword = Utilities.randomPassword(); - assertDoesNotThrow(() -> this.service.user().create(randomUsername, randomPassword) - .block(Utilities.IT_TIMEOUT)); - String username = assertDoesNotThrow( - () -> this.service.user().listAllUsers().blockLast(Utilities.IT_TIMEOUT)); - if (!username.equals(randomUsername)) { - throw new RuntimeException( - String.format("%s is not found in the user list", randomUsername)); - } - assertDoesNotThrow( - () -> this.service.user().delete(randomUsername).block(Utilities.IT_TIMEOUT)); - } - - @Test - void testUserContactAdd() { - String randomUsername = Utilities.randomUserName(); - String randomPassword = Utilities.randomPassword(); - - String randomContactUsername = Utilities.randomUserName(); - String randomContactPassword = randomContactUsername; - assertDoesNotThrow(() -> this.service.user().create(randomUsername, randomPassword) - .block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow( - () -> this.service.user().create(randomContactUsername, randomContactPassword) - .block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow(() -> this.service.contact().add(randomUsername, randomContactUsername) - .block(Utilities.IT_TIMEOUT)); - String username = assertDoesNotThrow( - () -> this.service.contact().list(randomUsername).blockLast(Utilities.IT_TIMEOUT)); - if (!username.equals(randomContactUsername)) { - throw new RuntimeException( - String.format("%s did not found %s in his contact list", randomUsername, - randomContactUsername)); - } - assertDoesNotThrow( - () -> this.service.user().delete(randomUsername).block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow(() -> this.service.user().delete(randomContactUsername) - .block(Utilities.IT_TIMEOUT)); - } - - @Test - void testUserContactRemove() { - String randomUsername = Utilities.randomUserName(); - String randomPassword = Utilities.randomPassword(); - - String randomContactUsername = Utilities.randomUserName(); - String randomContactPassword = randomContactUsername; - assertDoesNotThrow(() -> this.service.user().create(randomUsername, randomPassword) - .block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow( - () -> this.service.user().create(randomContactUsername, randomContactPassword) - .block(Utilities.IT_TIMEOUT)); - - assertDoesNotThrow(() -> this.service.contact().add(randomUsername, randomContactUsername) - .block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow( - () -> this.service.contact().remove(randomUsername, randomContactUsername) - .block(Utilities.IT_TIMEOUT)); - String username = assertDoesNotThrow( - () -> this.service.contact().list(randomUsername).blockLast(Utilities.IT_TIMEOUT)); - if (username != null) { - throw new RuntimeException(String.format("%s contact remove fail", username)); - } - assertDoesNotThrow( - () -> this.service.user().delete(randomUsername).block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow(() -> this.service.user().delete(randomContactUsername) - .block(Utilities.IT_TIMEOUT)); - } - - @Test - void testUserContactList() { - // add bob to alice's contact list - String aliceUserName = Utilities.randomUserName(); - String bobUserName = Utilities.randomUserName(); - String randomPassword = Utilities.randomPassword(); - - assertDoesNotThrow(() -> this.service.user().create(aliceUserName, randomPassword) - .block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow(() -> this.service.user().create(bobUserName, randomPassword) - .block(Utilities.IT_TIMEOUT)); - - assertDoesNotThrow(() -> this.service.contact().add(aliceUserName, bobUserName) - .block(Utilities.IT_TIMEOUT)); - String aliceFirstFriend = - assertDoesNotThrow(() -> this.service.contact().list(aliceUserName)) - .blockFirst(Utilities.IT_TIMEOUT); - if (aliceFirstFriend == null) { - throw new RuntimeException(String.format("%s contact list is null", aliceUserName)); - } - - if (!aliceFirstFriend.equals(bobUserName)) { - throw new RuntimeException(String.format("%s did not found %s in his contact list", - aliceUserName, bobUserName)); - } - assertDoesNotThrow( - () -> this.service.user().delete(aliceUserName).block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow(() -> this.service.user().delete(bobUserName) - .block(Utilities.IT_TIMEOUT)); - } - - @Test - void testUserGetUsersBlockedFromSendMsg() { - String randomUsername = Utilities.randomUserName(); - String randomPassword = Utilities.randomPassword(); - - String randomUsernameCodeJack = Utilities.randomUserName(); - assertDoesNotThrow(() -> this.service.user().create(randomUsername, randomPassword) - .block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow(() -> this.service.user().create(randomUsernameCodeJack, randomPassword) - .block(Utilities.IT_TIMEOUT)); - - assertDoesNotThrow(() -> this.service.block() - .blockUserSendMsgToUser(randomUsernameCodeJack, randomUsername) - .block(Utilities.IT_TIMEOUT)); - EMBlock block = assertDoesNotThrow( - () -> this.service.block().getUsersBlockedFromSendMsgToUser(randomUsername)) - .blockFirst(Utilities.IT_TIMEOUT); - if (!block.getUsername().equals(randomUsernameCodeJack)) { - throw new RuntimeException( - String.format("%s did not found %s in his block list", randomUsername, - randomUsernameCodeJack)); - } - assertDoesNotThrow( - () -> this.service.user().delete(randomUsername).block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow(() -> this.service.user().delete(randomUsernameCodeJack) - .block(Utilities.IT_TIMEOUT)); - } - - @Test - void testUserBlockUserSendMsg() { - String randomUsername = Utilities.randomUserName(); - String randomPassword = Utilities.randomPassword(); - - String randomUsernameCodeJack = Utilities.randomUserName(); - assertDoesNotThrow(() -> this.service.user().create(randomUsername, randomPassword) - .block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow(() -> this.service.user().create(randomUsernameCodeJack, randomPassword) - .block(Utilities.IT_TIMEOUT)); - - assertDoesNotThrow(() -> this.service.contact().add(randomUsername, randomUsernameCodeJack) - .block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow(() -> this.service.block() - .blockUserSendMsgToUser(randomUsernameCodeJack, randomUsername) - .block(Utilities.IT_TIMEOUT)); - EMBlock block = assertDoesNotThrow( - () -> this.service.block().getUsersBlockedFromSendMsgToUser(randomUsername) - .blockLast(Utilities.IT_TIMEOUT)); - String username = assertDoesNotThrow( - () -> this.service.contact().list(randomUsername).blockLast(Utilities.IT_TIMEOUT)); - if (!block.getUsername().equals(randomUsernameCodeJack)) { - throw new RuntimeException( - String.format("%s did not found %s in his block list", randomUsername, - randomUsernameCodeJack)); - } - - if (username == null) { - throw new RuntimeException( - String.format("%s does not exist in %s contact list", randomUsernameCodeJack, - randomUsername)); - } - assertDoesNotThrow( - () -> this.service.user().delete(randomUsername).block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow(() -> this.service.user().delete(randomUsernameCodeJack) - .block(Utilities.IT_TIMEOUT)); - } - - @Test - void testUserUnblockUserSendMsg() { - String randomUsername = Utilities.randomUserName(); - String randomPassword = Utilities.randomPassword(); - - String randomUsernameCodeJack = Utilities.randomUserName(); - assertDoesNotThrow(() -> this.service.user().create(randomUsername, randomPassword) - .block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow(() -> this.service.user().create(randomUsernameCodeJack, randomPassword) - .block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow(() -> this.service.contact().add(randomUsername, randomUsernameCodeJack) - .block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow(() -> this.service.block() - .blockUserSendMsgToUser(randomUsernameCodeJack, randomUsername) - .block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow(() -> this.service.block() - .unblockUserSendMsgToUser(randomUsernameCodeJack, randomUsername) - .block(Utilities.IT_TIMEOUT)); - EMBlock block = assertDoesNotThrow( - () -> this.service.block().getUsersBlockedFromSendMsgToUser(randomUsername) - .blockLast(Utilities.IT_TIMEOUT)); - String username = assertDoesNotThrow( - () -> this.service.contact().list(randomUsername).blockLast(Utilities.IT_TIMEOUT)); - if (block != null) { - throw new RuntimeException( - String.format("%s unblock %s fail", randomUsername, randomUsernameCodeJack)); - } - if (!username.equals(randomUsernameCodeJack)) { - throw new RuntimeException( - String.format("%s does not exist in %s contact list", randomUsernameCodeJack, - randomUsername)); - } - assertDoesNotThrow( - () -> this.service.user().delete(randomUsername).block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow(() -> this.service.user().delete(randomUsernameCodeJack) - .block(Utilities.IT_TIMEOUT)); - } - - @Test - void testUserCountMissedMessages() { - String randomUsername = Utilities.randomUserName(); - String randomPassword = Utilities.randomPassword(); - - String randomUsernameCodeJack = Utilities.randomUserName(); - assertDoesNotThrow(() -> this.service.user().create(randomUsername, randomPassword) - .block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow(() -> this.service.user().create(randomUsernameCodeJack, randomPassword) - .block(Utilities.IT_TIMEOUT)); - - assertDoesNotThrow(() -> this.service.message().send() - .fromUser(randomUsernameCodeJack) - .toUser(randomUsername) - .text(msg -> msg.text("offlineMessage")) - .send() - .block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow(() -> this.service.message().countMissedMessages(randomUsername) - .blockFirst(Utilities.IT_TIMEOUT)); - - assertDoesNotThrow( - () -> this.service.user().delete(randomUsername).block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow(() -> this.service.user().delete(randomUsernameCodeJack) - .block(Utilities.IT_TIMEOUT)); - } - - @Test - void testUserBlockLogin() { - String randomUsername = Utilities.randomUserName(); - String randomPassword = Utilities.randomPassword(); - assertDoesNotThrow(() -> this.service.user().create(randomUsername, randomPassword) - .block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow(() -> this.service.block().blockUserLogin(randomUsername) - .block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow( - () -> this.service.user().delete(randomUsername).block(Utilities.IT_TIMEOUT)); - } - - @Test - void testUserUnblockLogin() { - String randomUsername = Utilities.randomUserName(); - String randomPassword = Utilities.randomPassword(); - assertDoesNotThrow(() -> this.service.user().create(randomUsername, randomPassword) - .block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow(() -> this.service.block().blockUserLogin(randomUsername) - .block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow(() -> this.service.block().unblockUserLogin(randomUsername) - .block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow( - () -> this.service.user().delete(randomUsername).block(Utilities.IT_TIMEOUT)); - } - - @Test - void testUserOnlineStatus() { - String randomUsername = Utilities.randomUserName(); - String randomPassword = Utilities.randomPassword(); - assertDoesNotThrow(() -> this.service.user().create(randomUsername, randomPassword) - .block(Utilities.IT_TIMEOUT)); - boolean isOnline = assertDoesNotThrow(() -> this.service.user().isUserOnline(randomUsername) - .block(Utilities.IT_TIMEOUT)); - if (isOnline) { - throw new RuntimeException(String.format("%s is online status", randomUsername)); - } - assertDoesNotThrow( - () -> this.service.user().delete(randomUsername).block(Utilities.IT_TIMEOUT)); - } - - @Test - void testIsUsersOnline() { - String randomUsername = Utilities.randomUserName(); - String randomPassword = Utilities.randomPassword(); - assertDoesNotThrow(() -> this.service.user().create(randomUsername, randomPassword) - .block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow(() -> this.service.user().isUsersOnline(Arrays.asList(randomUsername)) - .block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow( - () -> this.service.user().delete(randomUsername).block(Utilities.IT_TIMEOUT)); - } - - @Test - void testGetUserToken() { - String randomUsername = Utilities.randomUserName(); - String randomPassword = Utilities.randomPassword(); - assertDoesNotThrow( - () -> this.service.user().create(randomUsername, randomPassword) - .block(Utilities.IT_TIMEOUT)); - // notice the deprecated stuff - assertDoesNotThrow(() -> this.service.user().getToken(randomUsername, randomPassword) - .block(Utilities.IT_TIMEOUT)); - } - - - @Test - public void testGetUserTokenWithInherit() throws Exception { - String randomUsername = Utilities.randomUserName(); - // notice the deprecated stuff - assertDoesNotThrow(() -> { - service.token().getUserTokenWithInherit(randomUsername); - }); - assertDoesNotThrow(() -> { - service.user().get(randomUsername).block(Utilities.IT_TIMEOUT); - }); - assertDoesNotThrow(() -> { - service.user().delete(randomUsername).block(Utilities.IT_TIMEOUT); - }); - } - - @Test - public void testGetUserTokenTtlWithInherit() throws Exception { - String randomUsername = Utilities.randomUserName(); - // notice the deprecated stuff - assertDoesNotThrow(() -> { - service.token().getUserTokenWithInherit(randomUsername, 1000); - }); - assertDoesNotThrow(() -> { - service.user().get(randomUsername).block(Utilities.IT_TIMEOUT); - }); - assertDoesNotThrow(() -> { - service.user().delete(randomUsername).block(Utilities.IT_TIMEOUT); - }); - } - -} diff --git a/im-sdk-core/src/integration-test/java/com/easemob/im/server/api/user/UserNameIT.java b/im-sdk-core/src/integration-test/java/com/easemob/im/server/api/user/UserNameIT.java deleted file mode 100644 index 0f8c51e20..000000000 --- a/im-sdk-core/src/integration-test/java/com/easemob/im/server/api/user/UserNameIT.java +++ /dev/null @@ -1,105 +0,0 @@ -package com.easemob.im.server.api.user; - -import com.easemob.im.server.EMProperties; -import com.easemob.im.server.EMService; -import com.easemob.im.server.api.util.Utilities; -import com.easemob.im.server.exception.EMInvalidArgumentException; -import org.junit.jupiter.api.Test; - -import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; -import static org.junit.jupiter.api.Assertions.assertThrows; - -public class UserNameIT { - - /*EMService serviceWithUserNameValidation; - EMService serviceNoUserNameValidation; - - public UserNameIT() { - String realm = System.getenv("IM_REALM"); - String appkey = System.getenv("IM_APPKEY"); - String baseUri = System.getenv("IM_BASE_URI"); - - EMProperties propertiesWithUserNameValidation = null; - EMProperties propertiesNoUserNameValidation = null; - - if (realm != null && realm.equals(EMProperties.Realm.AGORA_REALM.toString())) { - String appId = System.getenv("IM_APP_ID"); - String appCert = System.getenv("IM_APP_CERT"); - - propertiesWithUserNameValidation = EMProperties.builder() - .setBaseUri(baseUri) - .setRealm(EMProperties.Realm.AGORA_REALM) - .setAppkey(appkey) - .setAppId(appId) - .setAppCert(appCert) - .build(); - - propertiesNoUserNameValidation = EMProperties.builder() - .turnOffUserNameValidation() - .setBaseUri(baseUri) - .setRealm(EMProperties.Realm.AGORA_REALM) - .setAppkey(appkey) - .setAppId(appId) - .setAppCert(appCert) - .build(); - - } else { - String clientId = System.getenv("IM_CLIENT_ID"); - String clientSecret = System.getenv("IM_CLIENT_SECRET"); - - propertiesWithUserNameValidation = EMProperties.builder() - .setRealm(EMProperties.Realm.EASEMOB_REALM) - .setBaseUri(baseUri) - .setAppkey(appkey) - .setClientId(clientId) - .setClientSecret(clientSecret) - .setHttpConnectionPoolSize(10) - .setServerTimezone("+8") - .build(); - - propertiesNoUserNameValidation = EMProperties.builder() - .turnOffUserNameValidation() - .setRealm(EMProperties.Realm.EASEMOB_REALM) - .setBaseUri(baseUri) - .setAppkey(appkey) - .setClientId(clientId) - .setClientSecret(clientSecret) - .setHttpConnectionPoolSize(10) - .setServerTimezone("+8") - .build(); - } - - this.serviceWithUserNameValidation = new EMService(propertiesWithUserNameValidation); - this.serviceNoUserNameValidation = new EMService(propertiesNoUserNameValidation); - } - - @Test - public void withUserNameValidation() { - String goodUserName = Utilities.randomUserName(); - String badUserName = "000" + Utilities.randomUserName(); - String password = Utilities.randomPassword(); - assertThrows(EMInvalidArgumentException.class, - () -> serviceWithUserNameValidation.user().create(badUserName, password) - .block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow(()-> serviceWithUserNameValidation.user().create(goodUserName, password) - .block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow(()-> serviceWithUserNameValidation.user().delete(goodUserName) - .block(Utilities.IT_TIMEOUT)); - - } - - @Test - public void noUserNameValidation() { - String goodUserName = Utilities.randomUserName(); - String badUserName = "000" + Utilities.randomUserName(); - String password = Utilities.randomPassword(); - assertDoesNotThrow(()-> serviceNoUserNameValidation.user().create(goodUserName, password) - .block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow(()-> serviceNoUserNameValidation.user().create(badUserName, password) - .block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow(()-> serviceNoUserNameValidation.user().delete(goodUserName) - .block(Utilities.IT_TIMEOUT)); - assertDoesNotThrow(()-> serviceNoUserNameValidation.user().delete(badUserName) - .block(Utilities.IT_TIMEOUT)); - }*/ -} diff --git a/im-sdk-core/src/integration-test/resources/download/attachment/image.png b/im-sdk-core/src/integration-test/resources/download/attachment/image.png deleted file mode 100644 index aa4d6b94a..000000000 Binary files a/im-sdk-core/src/integration-test/resources/download/attachment/image.png and /dev/null differ diff --git a/im-sdk-core/src/integration-test/resources/upload/image.png b/im-sdk-core/src/integration-test/resources/upload/image.png deleted file mode 100644 index aa4d6b94a..000000000 Binary files a/im-sdk-core/src/integration-test/resources/upload/image.png and /dev/null differ diff --git a/im-sdk-core/src/main/java-templates/com/easemob/im/server/EMVersion.java b/im-sdk-core/src/main/java-templates/com/easemob/im/server/EMVersion.java deleted file mode 100644 index ed5a85f00..000000000 --- a/im-sdk-core/src/main/java-templates/com/easemob/im/server/EMVersion.java +++ /dev/null @@ -1,9 +0,0 @@ -package com.easemob.im.server; - -public class EMVersion { - public static String version = "${project.version}"; - - public static String getVersion() { - return EMVersion.version; - } -} diff --git a/im-sdk-core/src/main/java/com/easemob/im/server/AgoraAppCredentials.java b/im-sdk-core/src/main/java/com/easemob/im/server/AgoraAppCredentials.java deleted file mode 100644 index ad6c10a96..000000000 --- a/im-sdk-core/src/main/java/com/easemob/im/server/AgoraAppCredentials.java +++ /dev/null @@ -1,35 +0,0 @@ -package com.easemob.im.server; - -import com.easemob.im.server.api.util.Utilities; -import com.easemob.im.server.exception.EMInvalidArgumentException; -import io.netty.util.internal.StringUtil; - -public class AgoraAppCredentials implements Credentials { - private final String appId; - private final String appCert; - - public AgoraAppCredentials(String appId, String appCert) { - if (StringUtil.isNullOrEmpty(appId) || StringUtil.isNullOrEmpty(appCert)) { - throw new EMInvalidArgumentException("appId/appCert cannot be blank"); - } - this.appId = appId; - this.appCert = appCert; - } - - @Override - public String getId() { - return appId; - } - - @Override - public String getSecret() { - return appCert; - } - - @Override public String toString() { - return "AgoraAppCredentials{" + - "appId='" + Utilities.mask(appId) + '\'' + - ", appCert='" + Utilities.mask(appCert) + '\'' + - '}'; - } -} diff --git a/im-sdk-core/src/main/java/com/easemob/im/server/Credentials.java b/im-sdk-core/src/main/java/com/easemob/im/server/Credentials.java deleted file mode 100644 index d26ef94d0..000000000 --- a/im-sdk-core/src/main/java/com/easemob/im/server/Credentials.java +++ /dev/null @@ -1,8 +0,0 @@ -package com.easemob.im.server; - -public interface Credentials { - - String getId(); - - String getSecret(); -} diff --git a/im-sdk-core/src/main/java/com/easemob/im/server/EMErrorResponse.java b/im-sdk-core/src/main/java/com/easemob/im/server/EMErrorResponse.java deleted file mode 100644 index 710eb1817..000000000 --- a/im-sdk-core/src/main/java/com/easemob/im/server/EMErrorResponse.java +++ /dev/null @@ -1,16 +0,0 @@ -package com.easemob.im.server; - -import com.fasterxml.jackson.annotation.JsonProperty; - -public class EMErrorResponse { - @JsonProperty("error_description") - private String errorDescription; - - public EMErrorResponse(@JsonProperty("error_description") String errorDescription) { - this.errorDescription = errorDescription; - } - - public String getErrorDescription() { - return errorDescription; - } -} diff --git a/im-sdk-core/src/main/java/com/easemob/im/server/EMException.java b/im-sdk-core/src/main/java/com/easemob/im/server/EMException.java deleted file mode 100644 index f82e88003..000000000 --- a/im-sdk-core/src/main/java/com/easemob/im/server/EMException.java +++ /dev/null @@ -1,24 +0,0 @@ -package com.easemob.im.server; - -public class EMException extends RuntimeException { - /** - *错误码(HttpResponseStatus.code) - */ - private Integer errorCode; - - public EMException(String message) { - super(message); - } - - public EMException(String message, Throwable cause) { - super(message, cause); - } - - public Integer getErrorCode() { - return errorCode; - } - - public void setErrorCode(Integer errorCode) { - this.errorCode = errorCode; - } -} diff --git a/im-sdk-core/src/main/java/com/easemob/im/server/EMProperties.java b/im-sdk-core/src/main/java/com/easemob/im/server/EMProperties.java deleted file mode 100644 index 7b82d0dfd..000000000 --- a/im-sdk-core/src/main/java/com/easemob/im/server/EMProperties.java +++ /dev/null @@ -1,533 +0,0 @@ -package com.easemob.im.server; - -import com.easemob.im.server.api.util.Utilities; -import com.easemob.im.server.exception.EMInvalidArgumentException; -import com.easemob.im.server.exception.EMInvalidStateException; -import com.easemob.im.server.exception.EMUnsupportedEncodingException; -import io.netty.util.internal.StringUtil; -import reactor.netty.transport.logging.AdvancedByteBufFormat; - -import java.io.UnsupportedEncodingException; -import java.net.URLEncoder; - -public class EMProperties { - - private final Realm realm; - private final String appKey; - private final Credentials credentials; - private final String baseUri; - private final EMProxy proxy; - private final int httpConnectionPoolSize; - private final int httpConnectionMaxIdleTime; - private final int httpConnectionMaxLifeTime; - private final int httpConnectionEvictInBackground; - private final int httpConnectionPendingAcquireMaxCount; - private final int httpConnectionPendingAcquireTimeout; - private final int nettyWorkerCount; - private final String serverTimezone; - private final int agoraTokenExpireInSeconds; - private final AdvancedByteBufFormat httpLogFormat; - private final boolean validateUserName; - - public EMProperties(Realm realm, String appKey, Credentials credentials, String baseUri, - EMProxy proxy, int httpConnectionPoolSize, int httpConnectionMaxIdleTime, - int httpConnectionMaxLifeTime, int httpConnectionEvictInBackground, - int httpConnectionPendingAcquireMaxCount, int httpConnectionPendingAcquireTimeout, - int nettyWorkerCount, String serverTimezone, int agoraTokenExpireInSeconds, - AdvancedByteBufFormat httpLogFormat, boolean validateUserName) { - this.realm = realm; - this.appKey = appKey; - this.credentials = credentials; - this.baseUri = baseUri; - this.proxy = proxy; - this.httpConnectionPoolSize = httpConnectionPoolSize; - this.httpConnectionMaxIdleTime = httpConnectionMaxIdleTime; - this.httpConnectionMaxLifeTime = httpConnectionMaxLifeTime; - this.httpConnectionEvictInBackground = httpConnectionEvictInBackground; - this.httpConnectionPendingAcquireMaxCount = httpConnectionPendingAcquireMaxCount; - this.httpConnectionPendingAcquireTimeout = httpConnectionPendingAcquireTimeout; - this.nettyWorkerCount = nettyWorkerCount; - this.serverTimezone = serverTimezone; - this.agoraTokenExpireInSeconds = agoraTokenExpireInSeconds; - this.httpLogFormat = httpLogFormat; - this.validateUserName = validateUserName; - } - - /** - * @param baseUri baseUri - * @param appKey appKey - * @param proxy proxy - * @param clientId clientId - * @param clientSecret clientSecret - * @param httpConnectionPoolSize httpConnectionPoolSize - * @param serverTimezone serverTimezone - * @param httpConnectionMaxIdleTime httpConnectionMaxIdleTime - * @param httpConnectionMaxLifeTime - * @param httpConnectionEvictInBackground - * @param nettyWorkerCount nettyWorkerCount - * @param httpConnectionPendingAcquireMaxCount httpConnectionPendingAcquireMaxCount - * @param httpConnectionPendingAcquireTimeout - * @deprecated use {@link #builder()} instead. - */ - @Deprecated - public EMProperties(String baseUri, String appKey, EMProxy proxy, String clientId, - String clientSecret, int httpConnectionPoolSize, String serverTimezone, - int httpConnectionMaxIdleTime, int httpConnectionMaxLifeTime, - int httpConnectionEvictInBackground, int nettyWorkerCount, int httpConnectionPendingAcquireMaxCount, - int httpConnectionPendingAcquireTimeout) { - this.httpConnectionMaxLifeTime = httpConnectionMaxLifeTime; - this.httpConnectionEvictInBackground = httpConnectionEvictInBackground; - this.nettyWorkerCount = nettyWorkerCount; - this.httpConnectionPendingAcquireTimeout = httpConnectionPendingAcquireTimeout; - this.realm = Realm.EASEMOB_REALM; - this.appKey = appKey; - this.credentials = new EasemobAppCredentials(clientId, clientSecret); - this.baseUri = baseUri; - this.proxy = proxy; - this.httpConnectionPoolSize = httpConnectionPoolSize; - this.serverTimezone = serverTimezone; - this.agoraTokenExpireInSeconds = Utilities.DEFAULT_AGORA_TOKEN_EXPIRE_IN_SECONDS; - this.httpLogFormat = AdvancedByteBufFormat.SIMPLE; - this.validateUserName = true; - this.httpConnectionMaxIdleTime = httpConnectionMaxIdleTime; - this.httpConnectionPendingAcquireMaxCount = httpConnectionPendingAcquireMaxCount; - } - - // easemob realm by default - public static Builder builder() { - return new Builder().setRealm(Realm.EASEMOB_REALM); - } - - public String getAppkey() { - return this.appKey; - } - - public String getClientId() { - if (this.realm.equals(Realm.EASEMOB_REALM)) { - return this.credentials.getId(); - - } else if (this.realm.equals(Realm.AGORA_REALM)) { - return null; - } else { - throw new EMInvalidStateException( - String.format("invalid realm type %s", this.realm.toString())); - } - } - - public String getClientSecret() { - if (this.realm.equals(Realm.EASEMOB_REALM)) { - return this.credentials.getSecret(); - - } else if (this.realm.equals(Realm.AGORA_REALM)) { - return null; - } else { - throw new EMInvalidStateException( - String.format("invalid realm type %s", this.realm.toString())); - } - } - - public String getAppId() { - if (this.realm.equals(Realm.AGORA_REALM)) { - return this.credentials.getId(); - - } else if (this.realm.equals(Realm.EASEMOB_REALM)) { - return null; - } else { - throw new EMInvalidStateException( - String.format("invalid realm type %s", this.realm.toString())); - } - } - - public String getAppCert() { - if (this.realm.equals(Realm.AGORA_REALM)) { - return this.credentials.getSecret(); - - } else if (this.realm.equals(Realm.EASEMOB_REALM)) { - return null; - } else { - throw new EMInvalidStateException( - String.format("invalid realm type %s", this.realm.toString())); - } - } - - public Realm getRealm() { - return realm; - } - - public Credentials getCredentials() { - return credentials; - } - - public String getBaseUri() { - return baseUri; - } - - public EMProxy getProxy() { - return this.proxy; - } - - public String getAppkeyUrlEncoded() { - try { - return URLEncoder.encode(this.appKey, "UTF-8"); - } catch (UnsupportedEncodingException e) { - throw new EMUnsupportedEncodingException(e.getMessage()); - } - } - - public String getAppkeySlashDelimited() { - return this.appKey.replace('#', '/'); - } - - public int getHttpConnectionPoolSize() { - return this.httpConnectionPoolSize; - } - - public int getHttpConnectionMaxIdleTime() { - return this.httpConnectionMaxIdleTime; - } - - public int getHttpConnectionMaxLifeTime() { - return httpConnectionMaxLifeTime; - } - - public int getHttpConnectionEvictInBackground() { - return httpConnectionEvictInBackground; - } - - public int getHttpConnectionPendingAcquireMaxCount() { - return httpConnectionPendingAcquireMaxCount; - } - - public int getHttpConnectionPendingAcquireTimeout() { - return httpConnectionPendingAcquireTimeout; - } - - public String getServerTimezone() { - return this.serverTimezone; - } - - public String getAppKey() { - return appKey; - } - - public int getAgoraTokenExpireInSeconds() { - return agoraTokenExpireInSeconds; - } - - public AdvancedByteBufFormat getHttpLogFormat() { - return httpLogFormat; - } - - public boolean getValidateUserName() { - return validateUserName; - } - - public int getNettyWorkerCount() { - return nettyWorkerCount; - } - - @Override - public String toString() { - return "EMProperties{" + - "realm=" + realm + - ", appKey='" + appKey + '\'' + - ", credentials=" + credentials + - ", baseUri='" + baseUri + '\'' + - ", proxy=" + proxy + - ", httpConnectionPoolSize=" + httpConnectionPoolSize + - ", httpConnectionMaxIdleTime=" + httpConnectionMaxIdleTime + - ", httpConnectionPendingAcquireMaxCount=" + httpConnectionPendingAcquireMaxCount + - ", serverTimezone='" + serverTimezone + '\'' + - ", agoraTokenExpireInSeconds=" + agoraTokenExpireInSeconds + - ", httpLogFormat=" + httpLogFormat + - ", validateUserName=" + validateUserName + - '}'; - } - - public enum Realm { - AGORA_REALM(1), - EASEMOB_REALM(2), - ; - public short intValue; - - Realm(int value) { - intValue = (short) value; - } - } - - - public static class Builder { - private Realm realm; - private String appKey; - private String clientId; - private String clientSecret; - private String appId; - private String appCert; - - private String baseUri; - private EMProxy proxy; - private int httpConnectionPoolSize = 50; - private int httpConnectionMaxIdleTime = 10 * 1000; - private int httpConnectionMaxLifeTime = 60 * 1000; - private int httpConnectionEvictInBackground = 60 * 1000; - private int nettyWorkerCount = 0; - private int httpConnectionPendingAcquireMaxCount = 100; - private int httpConnectionPendingAcquireTimeout = 60 * 1000; - private String serverTimezone = "+8"; - private int agoraTokenExpireInSeconds = Utilities.DEFAULT_AGORA_TOKEN_EXPIRE_IN_SECONDS; - private AdvancedByteBufFormat httpLogFormat = AdvancedByteBufFormat.SIMPLE; - private boolean validateUserName = true; - - public Builder setRealm(Realm realm) { - this.realm = realm; - return this; - } - - public Builder setAppkey(String appKey) { - if (StringUtil.isNullOrEmpty(appKey)) { - throw new EMInvalidArgumentException("appKey must not be null or blank"); - } - String[] tokens = appKey.split("#"); - if (tokens.length != 2) { - throw new EMInvalidArgumentException("appKey must contains #"); - } - if (tokens[0].isEmpty()) { - throw new EMInvalidArgumentException("appKey must contains {org}"); - } - if (tokens[1].isEmpty()) { - throw new EMInvalidArgumentException("appKey must contains {app}"); - } - this.appKey = appKey; - return this; - } - - public Builder setClientId(String clientId) { - if (StringUtil.isNullOrEmpty(clientId)) { - throw new EMInvalidArgumentException("clientId must not be null or blank"); - } - this.clientId = clientId; - return this; - } - - public Builder setClientSecret(String clientSecret) { - if (StringUtil.isNullOrEmpty(clientSecret)) { - throw new EMInvalidArgumentException("clientSecret must not be null or blank"); - } - this.clientSecret = clientSecret; - return this; - } - - public Builder setAppId(String appId) { - if (StringUtil.isNullOrEmpty(appId)) { - throw new EMInvalidArgumentException("appId must not be null or blank"); - } - this.appId = appId; - return this; - } - - public Builder setAppCert(String appCert) { - if (StringUtil.isNullOrEmpty(appCert)) { - throw new EMInvalidArgumentException("appCert must not be null or blank"); - } - this.appCert = appCert; - return this; - } - - public Builder setBaseUri(String baseUri) { - this.baseUri = baseUri; - return this; - } - - public Builder setProxy(EMProxy proxy) { - this.proxy = proxy; - return this; - } - - public Builder setHttpConnectionPoolSize(int httpConnectionPoolSize) { - if (httpConnectionPoolSize < 0) { - throw new EMInvalidArgumentException("httpConnectionPoolSize must not be negative"); - } - this.httpConnectionPoolSize = httpConnectionPoolSize; - return this; - } - - public Builder setServerTimezone(String timezone) { - this.serverTimezone = timezone; - return this; - } - - public Builder setAgoraTokenExpireInSeconds(int agoraTokenExpireInSeconds) { - this.agoraTokenExpireInSeconds = agoraTokenExpireInSeconds; - return this; - } - - public Builder setHttpLogFormat(AdvancedByteBufFormat httpLogFormat) { - this.httpLogFormat = httpLogFormat; - return this; - } - - public Builder turnOffUserNameValidation() { - this.validateUserName = false; - return this; - } - - /** - * @param httpConnectionMaxIdleTime httpConnection最大空闲时间,单位:毫秒 - * @return Builder - */ - public Builder httpConnectionMaxIdleTime(int httpConnectionMaxIdleTime) { - if (httpConnectionMaxIdleTime <= 0) { - throw new EMInvalidArgumentException("httpConnectionMaxIdleTime must not be negative"); - } - this.httpConnectionMaxIdleTime = httpConnectionMaxIdleTime; - return this; - } - - /** - * @param httpConnectionMaxIdleTime httpConnection最大空闲时间,单位:毫秒 - * @return Builder - */ - public Builder setHttpConnectionMaxIdleTime(int httpConnectionMaxIdleTime) { - if (httpConnectionMaxIdleTime <= 0) { - throw new EMInvalidArgumentException("httpConnectionMaxIdleTime must not be negative"); - } - this.httpConnectionMaxIdleTime = httpConnectionMaxIdleTime; - return this; - } - - /** - * @param httpConnectionMaxLifeTime httpConnection最大存活时间,单位:毫秒 - * @return Builder - */ - public Builder setHttpConnectionMaxLifeTime(int httpConnectionMaxLifeTime) { - if (httpConnectionMaxLifeTime <= 0) { - throw new EMInvalidArgumentException("httpConnectionMaxLifeTime must not be negative"); - } - this.httpConnectionMaxLifeTime = httpConnectionMaxLifeTime; - return this; - } - - /** - * @param nettyWorkerCount netty最大工作线程数 - * @return Builder - */ - public Builder setNettyWorkerCount(int nettyWorkerCount) { - if (nettyWorkerCount <= 0) { - throw new EMInvalidArgumentException("nettyWorkerCount must not be negative"); - } - this.nettyWorkerCount = nettyWorkerCount; - return this; - } - - /** - * @param httpConnectionPendingAcquireMaxCount pendingAcquire最大数量 - * @return Builder - */ - public Builder setHttpConnectionPendingAcquireMaxCount(int httpConnectionPendingAcquireMaxCount) { - if (httpConnectionPendingAcquireMaxCount <= 0) { - throw new EMInvalidArgumentException("httpConnectionPendingAcquireMaxCount must not be negative"); - } - this.httpConnectionPendingAcquireMaxCount = httpConnectionPendingAcquireMaxCount; - return this; - } - - /** - * @param httpConnectionPendingAcquireTimeout pendingAcquire超时时间,单位:毫秒 - * @return Builder - */ - public Builder setHttpConnectionPendingAcquireTimeout(int httpConnectionPendingAcquireTimeout) { - if (httpConnectionPendingAcquireTimeout <= 0) { - throw new EMInvalidArgumentException("httpConnectionPendingAcquireTimeout must not be negative"); - } - this.httpConnectionPendingAcquireTimeout = httpConnectionPendingAcquireTimeout; - return this; - } - - /** - * @param httpConnectionEvictInBackground 后台检查连接池中适用于删除连接的时间间隔,单位:毫秒 - * @return Builder - */ - public Builder setHttpConnectionEvictInBackground(int httpConnectionEvictInBackground) { - if (httpConnectionEvictInBackground <= 0) { - throw new EMInvalidArgumentException("httpConnectionEvictInBackground must not be negative"); - } - this.httpConnectionEvictInBackground = httpConnectionEvictInBackground; - return this; - } - - public EMProperties build() { - if (this.realm == null) { - throw new EMInvalidStateException("realm not set"); - } - if (this.appKey == null) { - throw new EMInvalidStateException("appKey not set"); - } - if (this.realm.equals(Realm.EASEMOB_REALM)) { - if (this.clientId == null) { - throw new EMInvalidStateException("clientId not set"); - } - if (this.clientSecret == null) { - throw new EMInvalidStateException("clientSecret not set"); - } - if (this.appId != null || this.appCert != null) { - throw new EMInvalidStateException("appId and appCert must be blank"); - } - Credentials credentials = - new EasemobAppCredentials(this.clientId, this.clientSecret); - return new EMProperties(this.realm, this.appKey, credentials, this.baseUri, - this.proxy, this.httpConnectionPoolSize, this.httpConnectionMaxIdleTime, - this.httpConnectionMaxLifeTime, this.httpConnectionEvictInBackground, - this.httpConnectionPendingAcquireMaxCount, - this.httpConnectionPendingAcquireTimeout, - this.nettyWorkerCount, this.serverTimezone, - this.agoraTokenExpireInSeconds, this.httpLogFormat, this.validateUserName); - } else if (this.realm.equals(Realm.AGORA_REALM)) { - if (this.appId == null) { - throw new EMInvalidStateException("appId not set"); - } - if (this.appCert == null) { - throw new EMInvalidStateException("appCert not set"); - } - if (this.clientId != null || this.clientSecret != null) { - throw new EMInvalidStateException("clientId and clientSecret must be blank"); - } - Credentials credentials = new AgoraAppCredentials(this.appId, this.appCert); - return new EMProperties(this.realm, this.appKey, credentials, this.baseUri, - this.proxy, this.httpConnectionPoolSize, this.httpConnectionMaxIdleTime, - this.httpConnectionMaxLifeTime, this.httpConnectionEvictInBackground, - this.httpConnectionPendingAcquireMaxCount, - this.httpConnectionPendingAcquireTimeout, - this.nettyWorkerCount, this.serverTimezone, - this.agoraTokenExpireInSeconds, this.httpLogFormat, this.validateUserName); - } else { - throw new EMInvalidStateException( - String.format("invalid realm type %s", this.realm.toString())); - } - } - - @Override - public String toString() { - return "Builder{" + - "realm=" + realm + - ", appKey='" + appKey + '\'' + - ", clientId='" + Utilities.mask(clientId) + '\'' + - ", clientSecret='" + Utilities.mask(clientSecret) + '\'' + - ", appId='" + Utilities.mask(appId) + '\'' + - ", appCert='" + Utilities.mask(appCert) + '\'' + - ", baseUri='" + baseUri + '\'' + - ", proxy=" + proxy + - ", httpConnectionPoolSize=" + httpConnectionPoolSize + - ", httpConnectionMaxIdleTime=" + httpConnectionMaxIdleTime + - ", httpConnectionMaxLifeTime=" + httpConnectionMaxLifeTime + - ", httpConnectionEvictInBackground=" + httpConnectionEvictInBackground + - ", nettyWorkerCount=" + nettyWorkerCount + - ", httpConnectionPendingAcquireMaxCount=" + httpConnectionPendingAcquireMaxCount + - ", httpConnectionPendingAcquireTimeout=" + httpConnectionPendingAcquireTimeout + - ", serverTimezone='" + serverTimezone + '\'' + - ", agoraTokenExpireInSeconds=" + agoraTokenExpireInSeconds + - ", httpLogFormat=" + httpLogFormat + - ", validateUserName=" + validateUserName + - '}'; - } - } -} diff --git a/im-sdk-core/src/main/java/com/easemob/im/server/EMProxy.java b/im-sdk-core/src/main/java/com/easemob/im/server/EMProxy.java deleted file mode 100644 index 4fca1f906..000000000 --- a/im-sdk-core/src/main/java/com/easemob/im/server/EMProxy.java +++ /dev/null @@ -1,100 +0,0 @@ -package com.easemob.im.server; - -import com.easemob.im.server.exception.EMInvalidArgumentException; -import io.netty.util.internal.StringUtil; - -public class EMProxy { - private String ip; - private int port; - private String username; - private String password; - - public EMProxy(String ip, int port, String username, String password) { - this.ip = ip; - this.port = port; - this.username = username; - this.password = password; - } - - public static Builder builder() { - return new Builder(); - } - - public String getIp() { - return ip; - } - - public int getPort() { - return port; - } - - public String getUsername() { - return username; - } - - public String getPassword() { - return password; - } - - @Override - public String toString() { - return "EMProxy{" + - "ip='" + ip + '\'' + - ", port=" + port + - ", username='" + username + '\'' + - ", password='" + password + '\'' + - '}'; - } - - public static class Builder { - private String ip; - private int port; - private String username; - private String password; - - public Builder setIP(String ip) { - if (StringUtil.isNullOrEmpty(ip)) { - throw new EMInvalidArgumentException("ip must not be null or blank"); - } - this.ip = ip; - return this; - } - - public Builder setPort(int port) { - if (port < 0 || port > 65535) { - throw new EMInvalidArgumentException(String.format("port %s is illegal", port)); - } - this.port = port; - return this; - } - - public Builder setUsername(String username) { - this.username = username; - return this; - } - - public Builder setPassword(String password) { - this.password = password; - return this; - } - - public EMProxy build() { - if (StringUtil.isNullOrEmpty(this.ip)) { - throw new EMInvalidArgumentException( - "the IP of setting proxy cannot be null or blank"); - } - return new EMProxy(this.ip, this.port, this.username, this.password); - } - - @Override - public String toString() { - return "Builder{" + - "ip='" + ip + '\'' + - ", port=" + port + - ", username='" + username + '\'' + - ", password='" + password + '\'' + - '}'; - } - } -} - diff --git a/im-sdk-core/src/main/java/com/easemob/im/server/EMService.java b/im-sdk-core/src/main/java/com/easemob/im/server/EMService.java deleted file mode 100644 index a87de67fc..000000000 --- a/im-sdk-core/src/main/java/com/easemob/im/server/EMService.java +++ /dev/null @@ -1,268 +0,0 @@ -package com.easemob.im.server; - -import com.easemob.im.server.api.Context; -import com.easemob.im.server.api.DefaultContext; -import com.easemob.im.server.api.block.BlockApi; -import com.easemob.im.server.api.attachment.AttachmentApi; -import com.easemob.im.server.api.message.MessageApi; -import com.easemob.im.server.api.metadata.MetadataApi; -import com.easemob.im.server.api.moderation.ModerationApi; -import com.easemob.im.server.api.mute.MuteApi; -import com.easemob.im.server.api.push.PushApi; -import com.easemob.im.server.api.token.TokenApi; -import com.easemob.im.server.api.room.RoomApi; -import com.easemob.im.server.api.group.GroupApi; -import com.easemob.im.server.api.contact.ContactApi; -import com.easemob.im.server.api.user.UserApi; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * Server SDK API服务类 - */ -public class EMService { - - private static final Logger log = LoggerFactory.getLogger(EMService.class); - - private final Context context; - - private final BlockApi blockV1; - - private final ContactApi contactApi; - - private final AttachmentApi attachmentApi; - - private final GroupApi groupApi; - - private final MessageApi messageApi; - - private final RoomApi roomApi; - - private final UserApi userApi; - - private final MetadataApi metadataApi; - - private final TokenApi tokenApi; - - private final PushApi pushApi; - - private final ModerationApi moderationApi; - - private final MuteApi muteApi; - - public EMService(EMProperties properties) { - log.debug("EMService properties: {}", properties); - this.context = new DefaultContext(properties); - - this.blockV1 = new BlockApi(this.context); - this.contactApi = new ContactApi(this.context); - this.attachmentApi = new AttachmentApi(this.context); - this.messageApi = new MessageApi(this.context); - this.groupApi = new GroupApi(this.context); - this.roomApi = new RoomApi(this.context); - this.userApi = new UserApi(this.context); - this.metadataApi = new MetadataApi(this.context); - this.tokenApi = new TokenApi(this.context); - this.pushApi = new PushApi(this.context); - this.moderationApi = new ModerationApi(this.context); - this.muteApi = new MuteApi(this.context); - } - - public Context getContext() { - return context; - } - - /** - * 封禁API.
- * 支持:
- * - 用户禁言
- * - 群禁言(可以定时解除)
- * - 聊天室禁言(可以定时解除)
- * - 禁止加入群
- * - 禁止加入聊天室
- * - 禁止登录
- * - * @return {@code BlockApi} - */ - public BlockApi block() { - return this.blockV1; - } - - /** - * 通讯录API.
- * 支持:
- * - 添加联系人
- * - 移除联系人
- * - 获取联系人列表
- *

- * 目前联系人只作为通讯录之用. - * - * @return {@code ContactApi} - */ - public ContactApi contact() { - return this.contactApi; - } - - /** - * 附件API.
- * 支持:
- * - 附件上传
- * - 附件下载
- *

- * 目前,只支持本地文件的上传和下载. - * - * @return {@code AttachmentApi} - */ - public AttachmentApi attachment() { - return this.attachmentApi; - } - - /** - * 群API.
- *

支持群管理:
- * - 创建群
- * - 删除群
- * - 获取群列表
- * - 获取群详情
- * - 获取用户加入的群
- * - 修改群详情
- * - 修改群主
- *
- *

支持群成员管理:
- * - 获取群成员列表
- * - 添加群成员
- * - 删除群成员
- *
- *

支持群管理员管理:
- * - 获取群管理员列表
- * - 添加群管理员
- * - 删除群管理员
- *

- * 群与聊天室都是多人聊天,与聊天室主要差别在于群支持离线消息,即群成员上线时可以收到离线时错过的消息。 - * 如果配置了推送,则离线消息也会产生推送。 - * 群分为公开群和私有群,区别在于:在设备SDK中(指iOS、Android、Web、小程序等),私有群不会出现在群列表API的返回结果。 - * - * @return {@code GroupApi} - * @see com.easemob.im.server.api.block.BlockApi - */ - public GroupApi group() { - return this.groupApi; - } - - /** - * 消息API.
- * 支持:
- * - 发送消息
- * - 查询离线消息数
- * - 获取/下载聊天历史
- * - * @return {@code MessageApi} - */ - public MessageApi message() { - return this.messageApi; - } - - /** - * 用户API.
- * 支持:
- * - 创建用户
- * - 删除用户
- * - 获取用户
- * - 修改用户密码
- * - 强制用户下线
- * - 获取用户在线状态
- * - 获取用户token
- * - * @return {@code UserApi} - */ - public UserApi user() { - return this.userApi; - } - - /** - * 聊天室API.
- * 支持聊天室管理:
- * - 创建聊天室
- * - 获取聊天室详情
- * - 修改聊天室
- * - 获取聊天室列表
- * - 获取用户加入的聊天室列表
- *
- *

支持聊天室成员管理:
- * - 获取聊天室成员列表
- * - 添加聊天室成员
- * - 移除聊天室成员
- *
- *

支持聊天室管理员管理:
- * - 获取聊天室管理员
- * - 添加聊天室管理员
- * - * @return {@code RoomApi} - * @see com.easemob.im.server.api.block.BlockApi - */ - public RoomApi room() { - return this.roomApi; - } - - /** - * 用户属性API.
- * 支持:
- * - 设置用户属性
- * - 获取用户属性
- * - 获取app用户属性容量
- * - 删除用户属性
- * - * @return {@code MetadataApi} - */ - public MetadataApi metadata() { - return this.metadataApi; - } - - /** - * token API.
- * 支持:
- * - TODO: generate user token
- * - * @return {@code TokenApi} - */ - public TokenApi token() { - return this.tokenApi; - } - - /** - * 推送API.
- * 支持:
- * - 设置推送昵称
- * - * @return {@code PushApi} - */ - public PushApi push() { - return this.pushApi; - } - - /** - * 内容审核记录API. - * 支持:
- * - 按查询条件导出文件
- * - 获取导出详情列表
- * - 下载内容审核记录文件
- * - * @return {@code ModerationApi} - */ - public ModerationApi moderation() { - return this.moderationApi; - } - - /** - * 用户全局禁言API. - * 支持:
- * - 设置用户全局禁言
- * - 查询单个用户全局禁言剩余时间
- * - 查询所有用户全局禁言剩余时间
- * - * @return {@code MuteApi} - */ - public MuteApi mute() { - return this.muteApi; - } -} diff --git a/im-sdk-core/src/main/java/com/easemob/im/server/EasemobAppCredentials.java b/im-sdk-core/src/main/java/com/easemob/im/server/EasemobAppCredentials.java deleted file mode 100644 index 3e1c3e266..000000000 --- a/im-sdk-core/src/main/java/com/easemob/im/server/EasemobAppCredentials.java +++ /dev/null @@ -1,37 +0,0 @@ -package com.easemob.im.server; - -import com.easemob.im.server.api.util.Utilities; -import com.easemob.im.server.exception.EMInvalidArgumentException; -import io.netty.util.internal.StringUtil; - -public class EasemobAppCredentials implements Credentials { - private final String clientId; - private final String clientSecret; - - public EasemobAppCredentials(String clientId, String clientSecret) { - if (StringUtil.isNullOrEmpty(clientId) || StringUtil.isNullOrEmpty(clientSecret)) { - throw new EMInvalidArgumentException("clientId/clientSecret cannot be blank"); - } - this.clientId = clientId; - this.clientSecret = clientSecret; - } - - @Override - public String getId() { - return this.clientId; - } - - @Override - public String getSecret() { - return this.clientSecret; - } - - @Override - public String toString() { - return "EasemobAppCredentials{" + - "clientId='" + Utilities.mask(clientId) + '\'' + - ", clientSecret='" + Utilities.mask(clientSecret) + '\'' + - '}'; - } - -} diff --git a/im-sdk-core/src/main/java/com/easemob/im/server/api/BearerAuthorization.java b/im-sdk-core/src/main/java/com/easemob/im/server/api/BearerAuthorization.java deleted file mode 100644 index 51ee13192..000000000 --- a/im-sdk-core/src/main/java/com/easemob/im/server/api/BearerAuthorization.java +++ /dev/null @@ -1,23 +0,0 @@ -package com.easemob.im.server.api; - -import com.easemob.im.server.api.token.allocate.TokenProvider; -import io.netty.handler.codec.http.HttpHeaders; -import reactor.core.publisher.Mono; - -import java.util.function.Function; - -public class BearerAuthorization implements Function> { - - private TokenProvider tokenProvider; - - public BearerAuthorization(TokenProvider tokenProvider) { - this.tokenProvider = tokenProvider; - } - - @Override - public Mono apply(HttpHeaders headers) { - return this.tokenProvider.fetchAppToken() - .map(t -> headers.add("Authorization", String.format("Bearer %s", t.getValue()))); - } - -} diff --git a/im-sdk-core/src/main/java/com/easemob/im/server/api/Codec.java b/im-sdk-core/src/main/java/com/easemob/im/server/api/Codec.java deleted file mode 100644 index 6a5fcb7d4..000000000 --- a/im-sdk-core/src/main/java/com/easemob/im/server/api/Codec.java +++ /dev/null @@ -1,9 +0,0 @@ -package com.easemob.im.server.api; - -import io.netty.buffer.ByteBuf; - -public interface Codec { - ByteBuf encode(Object object); - - T decode(ByteBuf buffer, Class tClass); -} diff --git a/im-sdk-core/src/main/java/com/easemob/im/server/api/Context.java b/im-sdk-core/src/main/java/com/easemob/im/server/api/Context.java deleted file mode 100644 index 39734b29c..000000000 --- a/im-sdk-core/src/main/java/com/easemob/im/server/api/Context.java +++ /dev/null @@ -1,20 +0,0 @@ -package com.easemob.im.server.api; - -import com.easemob.im.server.EMProperties; -import com.easemob.im.server.api.token.allocate.TokenProvider; -import reactor.core.publisher.Mono; -import reactor.netty.http.client.HttpClient; - -public interface Context { - - Mono getHttpClient(); - - EMProperties getProperties(); - - TokenProvider getTokenProvider(); - - Codec getCodec(); - - ErrorMapper getErrorMapper(); - -} diff --git a/im-sdk-core/src/main/java/com/easemob/im/server/api/DefaultContext.java b/im-sdk-core/src/main/java/com/easemob/im/server/api/DefaultContext.java deleted file mode 100644 index 327699761..000000000 --- a/im-sdk-core/src/main/java/com/easemob/im/server/api/DefaultContext.java +++ /dev/null @@ -1,101 +0,0 @@ -package com.easemob.im.server.api; - -import com.easemob.im.server.EMProperties; -import com.easemob.im.server.api.codec.JsonCodec; -import com.easemob.im.server.api.loadbalance.*; -import com.easemob.im.server.api.token.allocate.AgoraTokenProvider; -import com.easemob.im.server.api.token.allocate.DefaultTokenProvider; -import com.easemob.im.server.api.token.allocate.TokenProvider; -import com.easemob.im.server.exception.EMInvalidStateException; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import reactor.core.publisher.Mono; -import reactor.netty.http.client.HttpClient; - -import java.time.Duration; - -public class DefaultContext implements Context { - - private static final Logger log = LoggerFactory.getLogger(DefaultContext.class); - - private final EMProperties properties; - - private final HttpClient httpClient; - - private final TokenProvider tokenProvider; - - private final Codec codec; - - private final ErrorMapper errorMapper; - - private final LoadBalancer loadBalancer; - - private final EndpointProvider endpointProvider; - - private final EndpointRegistry endpointRegistry; - - public DefaultContext(EMProperties properties) { - this.properties = properties; - HttpClient httpClient = EMHttpClientFactory.create(properties); - this.codec = new JsonCodec(); - this.errorMapper = new DefaultErrorMapper(); - this.loadBalancer = new UniformRandomLoadBalancer(); - EndpointProviderFactory endpointProviderFactory = - new DefaultEndpointProviderFactory(this.properties, this.codec, - httpClient.baseUrl("http://rs.easemob.com"), this.errorMapper); - this.endpointProvider = endpointProviderFactory.create(); - this.endpointRegistry = - new TimedRefreshEndpointRegistry(this.endpointProvider, Duration.ofMinutes(5)); - - EMProperties.Realm realm = properties.getRealm(); - if (realm == EMProperties.Realm.AGORA_REALM) { - this.tokenProvider = - new AgoraTokenProvider(properties, httpClient, this.endpointRegistry, - this.loadBalancer, this.codec, this.errorMapper); - } else if (realm == EMProperties.Realm.EASEMOB_REALM) { - this.tokenProvider = - new DefaultTokenProvider(properties, httpClient, this.endpointRegistry, - this.loadBalancer, this.codec, this.errorMapper); - } else { - throw new EMInvalidStateException( - String.format("Realm value = %d is illegal", realm.intValue)); - } - - this.httpClient = httpClient.headersWhen(headers -> this.tokenProvider.fetchAppToken() - .map(token -> headers - .set("Authorization", String.format("Bearer %s", token.getValue())))); - } - - @Override - public EMProperties getProperties() { - return this.properties; - } - - @Override - public Mono getHttpClient() { - return this.endpointRegistry.endpoints().map(endpoints -> { - Endpoint endpoint = this.loadBalancer.loadBalance(endpoints); - String baseUri = String.format("%s/%s", endpoint.getUri(), - this.properties.getAppkeySlashDelimited()); - if (log.isDebugEnabled()) { - log.debug("load balanced base uri: {}", baseUri); - } - return this.httpClient.baseUrl(baseUri); - }); - } - - @Override - public TokenProvider getTokenProvider() { - return this.tokenProvider; - } - - @Override - public Codec getCodec() { - return this.codec; - } - - @Override - public ErrorMapper getErrorMapper() { - return this.errorMapper; - } -} diff --git a/im-sdk-core/src/main/java/com/easemob/im/server/api/DefaultErrorMapper.java b/im-sdk-core/src/main/java/com/easemob/im/server/api/DefaultErrorMapper.java deleted file mode 100644 index 0c4e1e758..000000000 --- a/im-sdk-core/src/main/java/com/easemob/im/server/api/DefaultErrorMapper.java +++ /dev/null @@ -1,98 +0,0 @@ -package com.easemob.im.server.api; - -import com.easemob.im.server.EMErrorResponse; -import com.easemob.im.server.EMException; -import com.easemob.im.server.exception.*; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.databind.DeserializationFeature; -import com.fasterxml.jackson.databind.ObjectMapper; -import io.netty.buffer.ByteBuf; -import io.netty.buffer.ByteBufUtil; -import io.netty.handler.codec.http.HttpResponseStatus; -import reactor.netty.http.client.HttpClientResponse; - -import java.io.IOException; - -public class DefaultErrorMapper implements ErrorMapper { - - private ObjectMapper objectMapper; - - private HttpClientResponse httpClientResponse; - - private int statusCode; - - public DefaultErrorMapper() { - this.objectMapper = new ObjectMapper(); - this.objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); - this.objectMapper.setSerializationInclusion(JsonInclude.Include.NON_NULL); - } - - @Override - public void statusCode(HttpClientResponse response) { - this.statusCode = response.status().code(); - this.httpClientResponse = response; - } - - @Override - public void checkError(ByteBuf buf) { - if (this.statusCode >= 400) { - throw toException(this.httpClientResponse, decode(buf, EMErrorResponse.class)); - } - } - - private EMException toException(HttpClientResponse response, EMErrorResponse errorResponse) { - String reason = - String.format("%s %s -> %d %s, \n error_description -> %s", response.method().toString(), response.uri(), - response.status().code(), response.status().reasonPhrase(), errorResponse.getErrorDescription()); - HttpResponseStatus status = response.status(); - EMException emException = new EMUnknownException(reason); - if (HttpResponseStatus.BAD_REQUEST.equals(status) - || HttpResponseStatus.METHOD_NOT_ALLOWED.equals(status) - || HttpResponseStatus.NOT_ACCEPTABLE.equals(status) - || HttpResponseStatus.UNSUPPORTED_MEDIA_TYPE.equals(status)) { - emException = new EMBadRequestException(reason); - } else if (HttpResponseStatus.UNAUTHORIZED.equals(status)) { - emException = new EMUnauthorizedException(reason); - } else if (HttpResponseStatus.PAYMENT_REQUIRED.equals(status) - || HttpResponseStatus.FORBIDDEN.equals(status)) { - emException = new EMForbiddenException(reason); - } else if (HttpResponseStatus.NOT_FOUND.equals(status)) { - emException = new EMNotFoundException(reason); - } else if (HttpResponseStatus.TOO_MANY_REQUESTS.equals(status)) { - emException = new EMTooManyRequestsException(reason); - } else if (HttpResponseStatus.INTERNAL_SERVER_ERROR.equals(status)) { - emException = new EMInternalServerErrorException(reason); - } else if (HttpResponseStatus.BAD_GATEWAY.equals(status)) { - emException = new EMBadGatewayException(reason); - } else if (HttpResponseStatus.SERVICE_UNAVAILABLE.equals(status)) { - emException = new EMServiceUnavailableException(reason); - } else if (HttpResponseStatus.GATEWAY_TIMEOUT.equals(status)) { - emException = new EMGatewayTimeoutException(reason); - } - //设置错误状态码 - emException.setErrorCode(statusCode); - return emException; - } - - public T decode(ByteBuf buffer, Class tClass) { - byte[] array; - final int offset; - int len = buffer.readableBytes(); - if (buffer.hasArray()) { - array = buffer.array(); - offset = buffer.arrayOffset() + buffer.readerIndex(); - } else { - array = ByteBufUtil.getBytes(buffer, buffer.readerIndex(), len, false); - offset = 0; - } - - try { - return this.objectMapper.readValue(array, offset, len, tClass); - } catch (IOException e) { - throw new EMJsonException( - String.format("could not decode class %s: %s", tClass.getName(), - e.getMessage()), e); - } - } - -} \ No newline at end of file diff --git a/im-sdk-core/src/main/java/com/easemob/im/server/api/EMHttpClientFactory.java b/im-sdk-core/src/main/java/com/easemob/im/server/api/EMHttpClientFactory.java deleted file mode 100644 index a39bec50b..000000000 --- a/im-sdk-core/src/main/java/com/easemob/im/server/api/EMHttpClientFactory.java +++ /dev/null @@ -1,69 +0,0 @@ -package com.easemob.im.server.api; - -import com.easemob.im.server.EMProperties; -import com.easemob.im.server.EMProxy; -import com.easemob.im.server.EMVersion; -import io.github.resilience4j.core.StringUtils; -import io.netty.channel.ChannelOption; -import io.netty.handler.logging.LogLevel; -import io.netty.handler.timeout.ReadTimeoutHandler; -import reactor.netty.http.client.HttpClient; -import reactor.netty.resources.ConnectionProvider; -import reactor.netty.transport.ProxyProvider; - -import java.net.InetSocketAddress; -import java.time.Duration; -import java.util.concurrent.TimeUnit; - -import static reactor.netty.ReactorNetty.IO_WORKER_COUNT; - -public class EMHttpClientFactory { - - public static HttpClient create(EMProperties properties) { - ConnectionProvider connectionProvider = ConnectionProvider.builder("easemob-sdk") - .maxConnections(properties.getHttpConnectionPoolSize()) - .maxIdleTime(Duration.ofMillis(properties.getHttpConnectionMaxIdleTime())) - .maxLifeTime(Duration.ofMillis(properties.getHttpConnectionMaxLifeTime())) - .pendingAcquireMaxCount(properties.getHttpConnectionPendingAcquireMaxCount()) - .pendingAcquireTimeout(Duration.ofMillis(properties.getHttpConnectionPendingAcquireTimeout())) - .evictInBackground(Duration.ofMillis(properties.getHttpConnectionEvictInBackground())) - .lifo() - .build(); - - if (properties.getNettyWorkerCount() > 0) { - System.setProperty(IO_WORKER_COUNT, String.valueOf(properties.getNettyWorkerCount())); - } - - HttpClient httpClient = HttpClient.create(connectionProvider) - .option(ChannelOption.CONNECT_TIMEOUT_MILLIS, 60000) - .doOnConnected(conn -> conn - .addHandlerLast(new ReadTimeoutHandler(60000, TimeUnit.MILLISECONDS))) - .headers(headers -> headers.add("User-Agent", - String.format("EasemobServerSDK/%s", EMVersion.getVersion()))) - .wiretap("com.easemob.im.http", LogLevel.DEBUG, properties.getHttpLogFormat()); - - EMProxy proxyInfo = properties.getProxy(); - if (proxyInfo == null) { - return httpClient; - } else { - final String username = proxyInfo.getUsername(); - final String password = proxyInfo.getPassword(); - final String ip = proxyInfo.getIp(); - final int port = proxyInfo.getPort(); - - if (StringUtils.isNotEmpty(username) && StringUtils.isNotEmpty(password)) { - return httpClient.proxy( - proxy -> proxy.type(ProxyProvider.Proxy.HTTP) - .address(new InetSocketAddress(ip, port)) - .username(username) - .password(p -> password) - ); - } else { - return httpClient.proxy( - proxy -> proxy.type(ProxyProvider.Proxy.HTTP) - .address(new InetSocketAddress(ip, port)) - ); - } - } - } -} diff --git a/im-sdk-core/src/main/java/com/easemob/im/server/api/ErrorMapper.java b/im-sdk-core/src/main/java/com/easemob/im/server/api/ErrorMapper.java deleted file mode 100644 index 083509e5e..000000000 --- a/im-sdk-core/src/main/java/com/easemob/im/server/api/ErrorMapper.java +++ /dev/null @@ -1,10 +0,0 @@ -package com.easemob.im.server.api; - -import io.netty.buffer.ByteBuf; -import reactor.netty.http.client.HttpClientResponse; - -public interface ErrorMapper { - void statusCode(HttpClientResponse response); - - void checkError(ByteBuf buf); -} diff --git a/im-sdk-core/src/main/java/com/easemob/im/server/api/attachment/AttachmentApi.java b/im-sdk-core/src/main/java/com/easemob/im/server/api/attachment/AttachmentApi.java deleted file mode 100644 index 07bbacd42..000000000 --- a/im-sdk-core/src/main/java/com/easemob/im/server/api/attachment/AttachmentApi.java +++ /dev/null @@ -1,82 +0,0 @@ -package com.easemob.im.server.api.attachment; - -import com.easemob.im.server.api.Context; -import com.easemob.im.server.api.attachment.download.Download; -import com.easemob.im.server.api.attachment.upload.Upload; -import com.easemob.im.server.model.EMAttachment; -import reactor.core.publisher.Mono; - -import java.nio.file.Path; - -/** - * 附件API - * TODO: 支持上传和下载带有密码的附件 - */ -public class AttachmentApi { - - private Context context; - - private Upload upload; - - private Download download; - - public AttachmentApi(Context context) { - this.context = context; - this.upload = new Upload(context); - this.download = new Download(context); - } - - /** - * 上传附件。 - *

- * API使用示例: - *

 {@code
-     * EMService service;
-     * Path uploadPath = Paths.get("/local/path/.../icon_180.png");
-     * try {
-     *     EMAttachment attachment = service.attachment().uploadFile(uploadPath).block();
-     *     String fileId = attachment.getId();
-     *     String url = attachment.getUrl();
-     *     String secret = attachment.getSecret();
-     * } catch (EMException e) {
-     *     e.getErrorCode();
-     *     e.getMessage();
-     * }
-     * }
- * - * @param path 要上传的文件的路径 - * @return 上传完成后返回附件的id - * @see 上传附件 - */ - public Mono uploadFile(Path path) { - return this.upload.fromLocalFile(path, false); - } - - /* TODO: 上传带有密码保护的附件 */ - - /** - * 下载附件。 - *

- * API使用示例: - *

 {@code
-     * EMService service;
-     * try {
-     *     Path downloadPath = Paths.get("/local/path/...");
-     *     Path path = service.attachment().downloadFile("fileId", downloadPath, "filename").block();
-     * } catch (EMException e) {
-     *     e.getErrorCode();
-     *     e.getMessage();
-     * }
-     * }
- * - * @param fileId 附件的id - * @param dir 下载到哪个目录,如果不存在会自动创建 - * @param filename 下载到哪个文件 - * @return 下载完成后返回文件路径 - * @see 下载附件 - */ - public Mono downloadFile(String fileId, Path dir, String filename) { - return this.download.toLocalFile(fileId, dir, filename); - } - -} diff --git a/im-sdk-core/src/main/java/com/easemob/im/server/api/attachment/download/Download.java b/im-sdk-core/src/main/java/com/easemob/im/server/api/attachment/download/Download.java deleted file mode 100644 index 0d9966b50..000000000 --- a/im-sdk-core/src/main/java/com/easemob/im/server/api/attachment/download/Download.java +++ /dev/null @@ -1,45 +0,0 @@ -package com.easemob.im.server.api.attachment.download; - -import com.easemob.im.server.api.Context; -import com.easemob.im.server.api.DefaultErrorMapper; -import com.easemob.im.server.api.ErrorMapper; -import com.easemob.im.server.api.util.FileSystem; -import com.easemob.im.server.exception.EMUnknownException; -import reactor.core.publisher.Flux; -import reactor.core.publisher.Mono; - -import java.io.OutputStream; -import java.nio.file.Path; - -public class Download { - - private Context context; - - public Download(Context context) { - this.context = context; - } - - public Mono toLocalFile(String id, Path dir, String filename) { - Path local = FileSystem.choosePath(dir, filename); - return Mono.create(sink -> sink.success(FileSystem.open(local))) - .flatMap(out -> this.context.getHttpClient() - .flatMap(httpClient -> httpClient.get() - .uri(String.format("/chatfiles/%s", id)) - .responseSingle((rsp, buf) -> { - return buf.switchIfEmpty( - Mono.error(new EMUnknownException("response is null"))) - .flatMap(byteBuf -> { - ErrorMapper mapper = new DefaultErrorMapper(); - mapper.statusCode(rsp); - mapper.checkError(byteBuf); - return Mono.just(byteBuf); - }); - })) - .doOnSuccess(suc -> { - FileSystem.close(out); - }) - .then()) - .thenReturn(local); - } - -} diff --git a/im-sdk-core/src/main/java/com/easemob/im/server/api/attachment/upload/Upload.java b/im-sdk-core/src/main/java/com/easemob/im/server/api/attachment/upload/Upload.java deleted file mode 100644 index 2577613ba..000000000 --- a/im-sdk-core/src/main/java/com/easemob/im/server/api/attachment/upload/Upload.java +++ /dev/null @@ -1,51 +0,0 @@ -package com.easemob.im.server.api.attachment.upload; - -import com.easemob.im.server.api.Context; -import com.easemob.im.server.api.DefaultErrorMapper; -import com.easemob.im.server.api.ErrorMapper; -import com.easemob.im.server.exception.EMUnknownException; -import com.easemob.im.server.model.EMAttachment; -import reactor.core.publisher.Mono; - -import java.nio.file.Path; - -public class Upload { - - private Context context; - - public Upload(Context context) { - this.context = context; - } - - public Mono fromLocalFile(Path path, boolean restrictAccess) { - return this.context.getHttpClient() - .flatMap(httpClient -> httpClient - .headers(headers -> headers.add("restrict-access", restrictAccess)) - .post() - .uri("/chatfiles") - .sendForm((req, form) -> form.multipart(true) - .attr("filename", path.getFileName().toString()) - .file("file", path.toFile())) - .responseSingle((rsp, buf) -> { - return buf.switchIfEmpty( - Mono.error(new EMUnknownException("response is null"))) - .flatMap(byteBuf -> { - ErrorMapper mapper = new DefaultErrorMapper(); - mapper.statusCode(rsp); - mapper.checkError(byteBuf); - return Mono.just(byteBuf); - }); - })) - .map(buf -> this.context.getCodec().decode(buf, UploadFileResponse.class)) - .handle((rsp, sink) -> { - if (rsp.getFiles().isEmpty()) { - sink.error(new EMUnknownException("unknown")); - return; - } - String id = rsp.getFiles().get(0).getId(); - String url = rsp.getBaseUrl() + "/" + id; - String secret = rsp.getFiles().get(0).getSecret(); - sink.next(new EMAttachment(id, url, secret)); - }); - } -} diff --git a/im-sdk-core/src/main/java/com/easemob/im/server/api/attachment/upload/UploadFileResponse.java b/im-sdk-core/src/main/java/com/easemob/im/server/api/attachment/upload/UploadFileResponse.java deleted file mode 100644 index 5e9cc631b..000000000 --- a/im-sdk-core/src/main/java/com/easemob/im/server/api/attachment/upload/UploadFileResponse.java +++ /dev/null @@ -1,61 +0,0 @@ -package com.easemob.im.server.api.attachment.upload; - -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonProperty; - -import java.util.List; - -public class UploadFileResponse { - - @JsonProperty("uri") - private String baseUrl; - - @JsonProperty("entities") - private List files; - - @JsonCreator - public UploadFileResponse(@JsonProperty("entities") List files, - @JsonProperty("uri") String baseUrl) { - this.files = files; - this.baseUrl = baseUrl; - } - - public String getBaseUrl() { - return this.baseUrl; - } - - public List getFiles() { - return this.files; - } - - public static class FileUploaded { - @JsonProperty("uuid") - private String id; - @JsonProperty("type") - private String type; - @JsonProperty("share-secret") - private String secret; - - @JsonCreator - public FileUploaded(@JsonProperty("uuid") String id, - @JsonProperty("type") String type, - @JsonProperty("share-secret") String secret) { - this.id = id; - this.type = type; - this.secret = secret; - } - - public String getId() { - return this.id; - } - - public String getType() { - return this.type; - } - - public String getSecret() { - return this.secret; - } - } - -} diff --git a/im-sdk-core/src/main/java/com/easemob/im/server/api/block/BlockApi.java b/im-sdk-core/src/main/java/com/easemob/im/server/api/block/BlockApi.java deleted file mode 100644 index 35aa2315c..000000000 --- a/im-sdk-core/src/main/java/com/easemob/im/server/api/block/BlockApi.java +++ /dev/null @@ -1,621 +0,0 @@ -package com.easemob.im.server.api.block; - -import com.easemob.im.server.api.Context; -import com.easemob.im.server.api.block.group.join.BlockUserJoinGroup; -import com.easemob.im.server.api.block.group.msg.BlockAllUserSendMsgToGroup; -import com.easemob.im.server.api.block.group.msg.BlockUserSendMsgToGroup; -import com.easemob.im.server.api.block.group.msg.UnblockAllUserSendMsgToGroup; -import com.easemob.im.server.api.block.login.BlockUserLogin; -import com.easemob.im.server.api.block.room.join.BlockUserJoinRoom; -import com.easemob.im.server.api.block.room.msg.block.BlockAllUserSendMsgToRoom; -import com.easemob.im.server.api.block.room.msg.block.BlockUserSendMsgToRoom; -import com.easemob.im.server.api.block.room.msg.list.ListUsersBlockedSendMsgToRoom; -import com.easemob.im.server.api.block.room.msg.unblock.UnblockAllUserSendMsgToRoom; -import com.easemob.im.server.api.block.room.msg.unblock.UnblockUserSendMsgToRoom; -import com.easemob.im.server.api.block.user.SendMsgToUser; -import com.easemob.im.server.model.EMBlock; -import reactor.core.publisher.Flux; -import reactor.core.publisher.Mono; - -import java.time.Duration; -import java.util.ArrayList; -import java.util.List; - -/** - * 封禁API,提供封禁相关的功能。 - */ -public class BlockApi { - - private SendMsgToUser sendMsgToUser; - - private BlockUserLogin blockUserLogin; - - private BlockUserJoinGroup blockUserJoinGroup; - - private BlockUserJoinRoom blockUserJoinRoom; - - private BlockUserSendMsgToGroup blockUserSendMsgToGroup; - - private UnblockUserSendMsgToRoom unblockUserSendMsgToRoom; - - private BlockUserSendMsgToRoom blockUserSendMsgToRoom; - - private ListUsersBlockedSendMsgToRoom listUsersBlockedSendMsgToRoom; - - private UnblockAllUserSendMsgToRoom unblockAllUserSendMsgToRoom; - - private BlockAllUserSendMsgToRoom blockAllUserSendMsgToRoom; - - private UnblockAllUserSendMsgToGroup unblockAllUserSendMsgToGroup; - - private BlockAllUserSendMsgToGroup blockAllUserSendMsgToGroup; - - public BlockApi(Context context) { - this.sendMsgToUser = new SendMsgToUser(context); - this.blockUserLogin = new BlockUserLogin(context); - this.blockUserJoinGroup = new BlockUserJoinGroup(context); - this.blockUserJoinRoom = new BlockUserJoinRoom(context); - this.blockUserSendMsgToGroup = new BlockUserSendMsgToGroup(context); - this.unblockUserSendMsgToRoom = new UnblockUserSendMsgToRoom(context); - this.blockUserSendMsgToRoom = new BlockUserSendMsgToRoom(context); - this.listUsersBlockedSendMsgToRoom = new ListUsersBlockedSendMsgToRoom(context); - this.unblockAllUserSendMsgToRoom = new UnblockAllUserSendMsgToRoom(context); - this.blockAllUserSendMsgToRoom = new BlockAllUserSendMsgToRoom(context); - this.unblockAllUserSendMsgToGroup = new UnblockAllUserSendMsgToGroup(context); - this.blockAllUserSendMsgToGroup = new BlockAllUserSendMsgToGroup(context); - } - - /** - * 获取禁言列表,即这个用户禁言的其他用户。 - *

- * API使用示例: - *

 {@code
-     * EMService service;
-     * try {
-     *     List blocks = service.block().getUsersBlockedFromSendMsgToUser("username").collectList().block();
-     * } catch (EMException e) {
-     *     e.getErrorCode();
-     *     e.getMessage();
-     * }
-     * }
- * - * @param username 发起禁言的用户名 - * @return 每个被禁言用户的用户的用户名或错误 - * @see 获取用户禁言列表 - */ - public Flux getUsersBlockedFromSendMsgToUser(String username) { - return this.sendMsgToUser.getUsersBlocked(username); - } - - /** - * 用户禁言,阻止向这个用户发消息。 - *

- * 要阻止 userA 给 userB发送消息: - *

- * API使用示例: - *

 {@code
-     * EMService service;
-     * try {
-     *     service.block().blockUserSendMsgToUser("userA", "userB").block();
-     * } catch (EMException e) {
-     *     e.getErrorCode();
-     *     e.getMessage();
-     * }
-     * }
- * - * @param fromUser 被阻止的用户的用户名 - * @param toUser 接收消息的用户的用户名 - * @return 成功或错误 - * @see 添加用户禁言 - */ - public Mono blockUserSendMsgToUser(String fromUser, String toUser) { - return this.sendMsgToUser.blockUser(fromUser, toUser); - } - - /** - * 解除用户禁言,恢复向这个用户发消息。 - *

- * 要恢复 userA 给 userB发送消息: - *

- * API使用示例: - *

 {@code
-     * EMService service;
-     * try {
-     *     service.block().unblockUserSendMsgToUser("userA", "userB").block();
-     * } catch (EMException e) {
-     *     e.getErrorCode();
-     *     e.getMessage();
-     * }
-     * }
- * - * @param fromUser 被阻止的用户的用户名 - * @param toUser 接受消息的用户的用户名 - * @return 成功或错误 - * @see 解除用户禁言 - */ - public Mono unblockUserSendMsgToUser(String fromUser, String toUser) { - return this.sendMsgToUser.unblockUser(fromUser, toUser); - } - - /** - * 用户账号禁用,阻止该用户登录。 - *

- * API使用示例: - *

 {@code
-     * EMService service;
-     * try {
-     *     service.block().blockUserLogin("username").block();
-     * } catch (EMException e) {
-     *     e.getErrorCode();
-     *     e.getMessage();
-     * }
-     * }
- * - * @param username 被阻止的用户的用户名 - * @return 成功或失败 - * @see 用户账号禁用 - */ - public Mono blockUserLogin(String username) { - return this.blockUserLogin.blockUser(username); - } - - /** - * 用户账号解禁,恢复该用户登录。 - *

- * API使用示例: - *

 {@code
-     * EMService service;
-     * try {
-     *     service.block().unblockUserLogin("username").block();
-     * } catch (EMException e) {
-     *     e.getErrorCode();
-     *     e.getMessage();
-     * }
-     * }
- * - * @param username 被阻止的用户的用户名 - * @return 成功或失败 - * @see 用户账号解禁 - */ - public Mono unblockUserLogin(String username) { - return this.blockUserLogin.unblockUser(username); - } - - /** - * 获取阻止进群的用户列表。 - *

- * API使用示例: - *

 {@code
-     * EMService service;
-     * try {
-     *     List blocks = service.block().getUsersBlockedJoinGroup("groupId").collectList().block();
-     * } catch (EMException e) {
-     *     e.getErrorCode();
-     *     e.getMessage();
-     * }
-     * }
- * - * @param groupId 群id - * @return 被阻止进入的用户名 - * @see 获取阻止进群列表 - */ - public Flux getUsersBlockedJoinGroup(String groupId) { - return this.blockUserJoinGroup.getBlockedUsers(groupId); - } - - /** - * 阻止进群。 - *

- * API使用示例: - *

 {@code
-     * EMService service;
-     * try {
-     *     service.block().blockUserJoinGroup("username", "groupId").block();
-     * } catch (EMException e) {
-     *     e.getErrorCode();
-     *     e.getMessage();
-     * }
-     * }
- * - * @param username 被阻止的用户的用户名 - * @param groupId 群id - * @return 成功或错误 - * @see 阻止进群 - */ - public Mono blockUserJoinGroup(String username, String groupId) { - return this.blockUserJoinGroup.blockUser(username, groupId); - } - - /** - * 解除阻止进群。 - *

- * API使用示例: - *

 {@code
-     * EMService service;
-     * try {
-     *     service.block().unblockUserJoinGroup("username", "groupId").block();
-     * } catch (EMException e) {
-     *     e.getErrorCode();
-     *     e.getMessage();
-     * }
-     * }
- * - * @param username 被阻止的用户的用户名 - * @param groupId 群id - * @return 成功或错误 - * @see - */ - public Mono unblockUserJoinGroup(String username, String groupId) { - return this.blockUserJoinGroup.unblockUser(username, groupId); - } - - /** - * 获取阻止进聊天室的用户列表。 - *

- * API使用示例: - *

 {@code
-     * EMService service;
-     * try {
-     *     List blocks = service.block().getUsersBlockedJoinRoom("roomId").collectList().block();
-     * } catch (EMException e) {
-     *     e.getErrorCode();
-     *     e.getMessage();
-     * }
-     * }
- * - * @param roomId 聊天室id - * @return 被阻止进入的用户名 - */ - public Flux getUsersBlockedJoinRoom(String roomId) { - return this.blockUserJoinRoom.getBlockedUsers(roomId); - } - - /** - * 阻止进聊天室。 - *

- * API使用示例: - *

 {@code
-     * EMService service;
-     * try {
-     *     service.block().blockUserJoinRoom("username", "roomId").block();
-     * } catch (EMException e) {
-     *     e.getErrorCode();
-     *     e.getMessage();
-     * }
-     * }
- * - * @param username 被阻止的用户的用户名 - * @param roomId 聊天室id - * @return 成功或错误 - */ - public Mono blockUserJoinRoom(String username, String roomId) { - return this.blockUserJoinRoom.blockUser(username, roomId); - } - - /** - * 解除阻止进聊天室。 - *

- * API使用示例: - *

 {@code
-     * EMService service;
-     * try {
-     *     service.block().unblockUserJoinRoom("username", "roomId").block();
-     * } catch (EMException e) {
-     *     e.getErrorCode();
-     *     e.getMessage();
-     * }
-     * }
- * - * @param username 被阻止的用户的用户名 - * @param roomId 聊天室id - * @return 成功或错误 - */ - public Mono unblockUserJoinRoom(String username, String roomId) { - return this.blockUserJoinRoom.unblockUser(username, roomId); - } - - /** - * 获取群禁言列表。 - *

- * API使用示例: - *

 {@code
-     * EMService service;
-     * try {
-     *     List blocks = service.block().getUsersBlockedSendMsgToGroup("groupId").collectList().block();
-     * } catch (EMException e) {
-     *     e.getErrorCode();
-     *     e.getMessage();
-     * }
-     * }
- * - * @param groupId 群id - * @return 每个禁言或错误. - * @see 获取禁言列表 - */ - public Flux getUsersBlockedSendMsgToGroup(String groupId) { - return this.blockUserSendMsgToGroup.getBlockedUsers(groupId); - } - - /** - * 添加群禁言。 - *

- * API使用示例: - *

 {@code
-     * EMService service;
-     * try {
-     *     service.block().blockUserSendMsgToGroup("username", "groupId", Duration.ofMillis(6000)).block();
-     * } catch (EMException e) {
-     *     e.getErrorCode();
-     *     e.getMessage();
-     * }
-     * }
- * - * @param username 被禁言的用户的用户名 - * @param groupId 群id - * @param duration 禁言多长时间,为null则永久禁言 - * @return 成功或错误 - * @see 添加禁言 - */ - public Mono blockUserSendMsgToGroup(String username, String groupId, Duration duration) { - return this.blockUserSendMsgToGroup.blockUser(username, groupId, duration); - } - - /** - * 添加群禁言,支持同时禁言多个用户。 - *

- * API使用示例: - *

 {@code
-     * EMService service;
-     * try {
-     *     List usernames = new ArrayList<>();
-     *     usernames.add("user1");
-     *     usernames.add("user2");
-     *
-     *     service.block().blockUsersSendMsgToGroup(usernames, "groupId", Duration.ofMillis(6000)).block();
-     * } catch (EMException e) {
-     *     e.getErrorCode();
-     *     e.getMessage();
-     * }
-     * }
- * - * @param usernames 被禁言的用户的用户名列表 - * @param groupId 群id - * @param duration 禁言多长时间,为null则永久禁言 - * @return 成功或错误 - * @see 添加禁言 - */ - public Mono blockUsersSendMsgToGroup(List usernames, String groupId, Duration duration) { - return this.blockUserSendMsgToGroup.blockUsers(usernames, groupId, duration); - } - - /** - * 解除群禁言。 - *

- * API使用示例: - *

 {@code
-     * EMService service;
-     * try {
-     *     service.block().unblockUserSendMsgToGroup("username", "groupId").block();
-     * } catch (EMException e) {
-     *     e.getErrorCode();
-     *     e.getMessage();
-     * }
-     * }
- * - * @param username 被禁言的用户的用户名 - * @param groupId 群id - * @return 成功或错误 - * @see 移除禁言 - */ - public Mono unblockUserSendMsgToGroup(String username, String groupId) { - return this.blockUserSendMsgToGroup.unblockUser(username, groupId); - } - - /** - * 解除群组全员禁言。 - *

- * API使用示例: - *

 {@code
-     * EMService service;
-     * try {
-     *     service.block().unblockAllUserSendMsgToGroup("groupId").block();
-     * } catch (EMException e) {
-     *     e.getErrorCode();
-     *     e.getMessage();
-     * }
-     * }
- * - * @param groupId 群组id - * @return 成功或错误 - * @see 解除群组全员禁言 - */ - public Mono unblockAllUserSendMsgToGroup(String groupId) { - return this.unblockAllUserSendMsgToGroup.single(groupId); - } - - /** - * 禁言群组全体成员。 - *

- * API使用示例: - *

 {@code
-     * EMService service;
-     * try {
-     *     service.block().blockAllUserSendMsgToGroup("groupId").block();
-     * } catch (EMException e) {
-     *     e.getErrorCode();
-     *     e.getMessage();
-     * }
-     * }
- * - * @param groupId 群组id - * @return 成功或错误 - * @see 禁言群组全体成员 - */ - public Mono blockAllUserSendMsgToGroup(String groupId) { - return this.blockAllUserSendMsgToGroup.single(groupId); - } - - /** - * 获取聊天室禁言列表。 - *

- * API使用示例: - *

 {@code
-     * EMService service;
-     * try {
-     *     List blocks = service.block().listUsersBlockedSendMsgToRoom("roomId").collectList().block();
-     * } catch (EMException e) {
-     *     e.getErrorCode();
-     *     e.getMessage();
-     * }
-     * }
- * - * @param roomId 聊天室id - * @return 每个禁言或错误 - * @see 获取禁言列表 - */ - public Flux listUsersBlockedSendMsgToRoom(String roomId) { - return this.listUsersBlockedSendMsgToRoom.all(roomId); - } - - /** - * 添加聊天室禁言。 - *

- * API使用示例: - *

 {@code
-     * EMService service;
-     * try {
-     *     service.block().blockUserSendMsgToRoom("username", "roomId", Duration.ofMillis(6000)).block();
-     * } catch (EMException e) {
-     *     e.getErrorCode();
-     *     e.getMessage();
-     * }
-     * }
- * - * @param username 被禁言的用户的用户名 - * @param roomId 聊天室id - * @param duration 禁言时长,为null则永久禁言 - * @return 成功或错误 - * @see 添加禁言 - */ - public Mono blockUserSendMsgToRoom(String username, String roomId, Duration duration) { - return this.blockUserSendMsgToRoom.single(username, roomId, duration); - } - - /** - * 将多个用户添加聊天室禁言。 - *

- * API使用示例: - *

 {@code
-     * EMService service;
-     * try {
-     *     List usernames = new ArrayList<>();
-     *     usernames.add("user1");
-     *     service.block().blockUserSendMsgToRoom(usernames, "roomId", Duration.ofMillis(6000)).block();
-     * } catch (EMException e) {
-     *     e.getErrorCode();
-     *     e.getMessage();
-     * }
-     * }
- * - * @param usernames 被禁言的用户名列表 - * @param roomId 聊天室id - * @param duration 禁言时长,为null则永久禁言 - * @return 成功或错误 - * @see 添加禁言 - */ - public Mono blockUserSendMsgToRoom(List usernames, String roomId, Duration duration) { - return this.blockUserSendMsgToRoom.batch(usernames, roomId, duration); - } - - /** - * 解除聊天室禁言。 - *

- * API使用示例: - *

 {@code
-     * EMService service;
-     * try {
-     *     service.block().unblockUserSendMsgToRoom("username", "roomId").block();
-     * } catch (EMException e) {
-     *     e.getErrorCode();
-     *     e.getMessage();
-     * }
-     * }
- * - * @param username 被解除禁言的用户的用户名 - * @param roomId 聊天室id - * @return 成功或错误 - * @see 移除禁言 - */ - public Mono unblockUserSendMsgToRoom(String username, String roomId) { - return this.unblockUserSendMsgToRoom.single(username, roomId); - } - - /** - * 将多个用户解除聊天室禁言。 - *

- * API使用示例: - *

 {@code
-     * EMService service;
-     * try {
-     *     List usernames = new ArrayList<>();
-     *     usernames.add("user1");
-     *     service.block().unblockUserSendMsgToRoom(usernames, "roomId").block();
-     * } catch (EMException e) {
-     *     e.getErrorCode();
-     *     e.getMessage();
-     * }
-     * }
- * - * @param usernames 被解除禁言的用户名列表 - * @param roomId 聊天室id - * @return 成功或错误 - * @see 移除禁言 - */ - public Mono unblockUserSendMsgToRoom(List usernames, String roomId) { - return this.unblockUserSendMsgToRoom.batch(usernames, roomId); - } - - /** - * 解除聊天室全员禁言。 - *

- * API使用示例: - *

 {@code
-     * EMService service;
-     * try {
-     *     service.block().unblockAllUserSendMsgToRoom("roomId").block();
-     * } catch (EMException e) {
-     *     e.getErrorCode();
-     *     e.getMessage();
-     * }
-     * }
- * - * @param roomId 聊天室id - * @return 成功或错误 - * @see 解除聊天室全员禁言 - */ - public Mono unblockAllUserSendMsgToRoom(String roomId) { - return this.unblockAllUserSendMsgToRoom.single(roomId); - } - - /** - * 禁言聊天室全体成员。 - *

- * API使用示例: - *

 {@code
-     * EMService service;
-     * try {
-     *     service.block().blockAllUserSendMsgToRoom("roomId").block();
-     * } catch (EMException e) {
-     *     e.getErrorCode();
-     *     e.getMessage();
-     * }
-     * }
- * - * @param roomId 聊天室id - * @return 成功或错误 - * @see 禁言聊天室全体成员 - */ - public Mono blockAllUserSendMsgToRoom(String roomId) { - return this.blockAllUserSendMsgToRoom.single(roomId); - } -} diff --git a/im-sdk-core/src/main/java/com/easemob/im/server/api/block/group/join/BlockUserJoinGroup.java b/im-sdk-core/src/main/java/com/easemob/im/server/api/block/group/join/BlockUserJoinGroup.java deleted file mode 100644 index 4ff7e6abb..000000000 --- a/im-sdk-core/src/main/java/com/easemob/im/server/api/block/group/join/BlockUserJoinGroup.java +++ /dev/null @@ -1,85 +0,0 @@ -package com.easemob.im.server.api.block.group.join; - -import com.easemob.im.server.api.Context; -import com.easemob.im.server.api.DefaultErrorMapper; -import com.easemob.im.server.api.ErrorMapper; -import com.easemob.im.server.exception.EMUnknownException; -import com.easemob.im.server.model.EMBlock; -import reactor.core.publisher.Flux; -import reactor.core.publisher.Mono; - -public class BlockUserJoinGroup { - - private Context context; - - public BlockUserJoinGroup(Context context) { - this.context = context; - } - - public Flux getBlockedUsers(String groupId) { - return this.context.getHttpClient() - .flatMap(httpClient -> httpClient.get() - .uri(String.format("/chatgroups/%s/blocks/users", groupId)) - .responseSingle((rsp, buf) -> { - return buf.switchIfEmpty( - Mono.error(new EMUnknownException("response is null"))) - .flatMap(byteBuf -> { - ErrorMapper mapper = new DefaultErrorMapper(); - mapper.statusCode(rsp); - mapper.checkError(byteBuf); - return Mono.just(byteBuf); - }); - })) - .map(buf -> context.getCodec().decode(buf, GetBlockedUsersResponse.class)) - .flatMapIterable(GetBlockedUsersResponse::getUsernames) - .map(username -> new EMBlock(username, null)); - } - - public Mono blockUser(String username, String groupId) { - return this.context.getHttpClient() - .flatMap(httpClient -> httpClient.post() - .uri(String.format("/chatgroups/%s/blocks/users/%s", groupId, username)) - .responseSingle((rsp, buf) -> { - return buf.switchIfEmpty( - Mono.error(new EMUnknownException("response is null"))) - .flatMap(byteBuf -> { - ErrorMapper mapper = new DefaultErrorMapper(); - mapper.statusCode(rsp); - mapper.checkError(byteBuf); - return Mono.just(byteBuf); - }); - })) - .map(buf -> this.context.getCodec().decode(buf, BlockUserJoinGroupResponse.class)) - .handle((rsp, sink) -> { - if (!rsp.getSuccess()) { - sink.error(new EMUnknownException("unknown")); - return; - } - sink.complete(); - }); - } - - public Mono unblockUser(String username, String groupId) { - return this.context.getHttpClient() - .flatMap(httpClient -> httpClient.delete() - .uri(String.format("/chatgroups/%s/blocks/users/%s", groupId, username)) - .responseSingle((rsp, buf) -> { - return buf.switchIfEmpty( - Mono.error(new EMUnknownException("response is null"))) - .flatMap(byteBuf -> { - ErrorMapper mapper = new DefaultErrorMapper(); - mapper.statusCode(rsp); - mapper.checkError(byteBuf); - return Mono.just(byteBuf); - }); - })) - .map(buf -> this.context.getCodec().decode(buf, UnblockUserJoinGroupResponse.class)) - .handle((rsp, sink) -> { - if (!rsp.getSuccess()) { - sink.error(new EMUnknownException("unknown")); - return; - } - sink.complete(); - }); - } -} diff --git a/im-sdk-core/src/main/java/com/easemob/im/server/api/block/group/join/BlockUserJoinGroupResponse.java b/im-sdk-core/src/main/java/com/easemob/im/server/api/block/group/join/BlockUserJoinGroupResponse.java deleted file mode 100644 index 8ac7ae084..000000000 --- a/im-sdk-core/src/main/java/com/easemob/im/server/api/block/group/join/BlockUserJoinGroupResponse.java +++ /dev/null @@ -1,29 +0,0 @@ -package com.easemob.im.server.api.block.group.join; - -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonProperty; - -public class BlockUserJoinGroupResponse { - @JsonProperty("data") - private BlockUserJoinGroupResource resource; - - @JsonCreator - public BlockUserJoinGroupResponse(@JsonProperty("data") BlockUserJoinGroupResource resource) { - this.resource = resource; - } - - public boolean getSuccess() { - return this.resource != null && this.resource.success; - } - - public static class BlockUserJoinGroupResource { - @JsonProperty("result") - private boolean success; - - @JsonCreator - public BlockUserJoinGroupResource(@JsonProperty("result") boolean success) { - this.success = success; - } - - } -} diff --git a/im-sdk-core/src/main/java/com/easemob/im/server/api/block/group/join/GetBlockedUsersResponse.java b/im-sdk-core/src/main/java/com/easemob/im/server/api/block/group/join/GetBlockedUsersResponse.java deleted file mode 100644 index 33505cad7..000000000 --- a/im-sdk-core/src/main/java/com/easemob/im/server/api/block/group/join/GetBlockedUsersResponse.java +++ /dev/null @@ -1,20 +0,0 @@ -package com.easemob.im.server.api.block.group.join; - -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonProperty; - -import java.util.List; - -public class GetBlockedUsersResponse { - @JsonProperty("data") - private List usernames; - - @JsonCreator - public GetBlockedUsersResponse(@JsonProperty("data") List usernames) { - this.usernames = usernames; - } - - public List getUsernames() { - return this.usernames; - } -} diff --git a/im-sdk-core/src/main/java/com/easemob/im/server/api/block/group/join/UnblockUserJoinGroupResponse.java b/im-sdk-core/src/main/java/com/easemob/im/server/api/block/group/join/UnblockUserJoinGroupResponse.java deleted file mode 100644 index 7bc0ef86d..000000000 --- a/im-sdk-core/src/main/java/com/easemob/im/server/api/block/group/join/UnblockUserJoinGroupResponse.java +++ /dev/null @@ -1,30 +0,0 @@ -package com.easemob.im.server.api.block.group.join; - -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonProperty; - -public class UnblockUserJoinGroupResponse { - @JsonProperty("data") - private UnblockUserJoinGroupResource resource; - - @JsonCreator - public UnblockUserJoinGroupResponse( - @JsonProperty("data") UnblockUserJoinGroupResource resource) { - this.resource = resource; - } - - public boolean getSuccess() { - return this.resource != null && this.resource.success; - } - - public static class UnblockUserJoinGroupResource { - @JsonProperty("result") - private boolean success; - - @JsonCreator - public UnblockUserJoinGroupResource(@JsonProperty("result") boolean success) { - this.success = success; - } - - } -} diff --git a/im-sdk-core/src/main/java/com/easemob/im/server/api/block/group/msg/BlockAllUserSendMsgToGroup.java b/im-sdk-core/src/main/java/com/easemob/im/server/api/block/group/msg/BlockAllUserSendMsgToGroup.java deleted file mode 100644 index 0d6b11fb3..000000000 --- a/im-sdk-core/src/main/java/com/easemob/im/server/api/block/group/msg/BlockAllUserSendMsgToGroup.java +++ /dev/null @@ -1,33 +0,0 @@ -package com.easemob.im.server.api.block.group.msg; - -import com.easemob.im.server.api.Context; -import com.easemob.im.server.api.DefaultErrorMapper; -import com.easemob.im.server.api.ErrorMapper; -import com.easemob.im.server.exception.EMUnknownException; -import reactor.core.publisher.Mono; - -public class BlockAllUserSendMsgToGroup { - - private Context context; - - public BlockAllUserSendMsgToGroup(Context context) { - this.context = context; - } - - public Mono single(String groupId) { - return this.context.getHttpClient() - .flatMap(httpClient -> httpClient.post() - .uri(String.format("/chatgroups/%s/ban", groupId)) - .responseSingle((rsp, buf) -> { - return buf.switchIfEmpty( - Mono.error(new EMUnknownException("response is null"))) - .flatMap(byteBuf -> { - ErrorMapper mapper = new DefaultErrorMapper(); - mapper.statusCode(rsp); - mapper.checkError(byteBuf); - return Mono.just(byteBuf); - }); - })) - .then(); - } -} diff --git a/im-sdk-core/src/main/java/com/easemob/im/server/api/block/group/msg/BlockUserSendMsgToGroup.java b/im-sdk-core/src/main/java/com/easemob/im/server/api/block/group/msg/BlockUserSendMsgToGroup.java deleted file mode 100644 index 7820390ef..000000000 --- a/im-sdk-core/src/main/java/com/easemob/im/server/api/block/group/msg/BlockUserSendMsgToGroup.java +++ /dev/null @@ -1,114 +0,0 @@ -package com.easemob.im.server.api.block.group.msg; - -import com.easemob.im.server.api.Context; -import com.easemob.im.server.api.DefaultErrorMapper; -import com.easemob.im.server.api.ErrorMapper; -import com.easemob.im.server.exception.EMUnknownException; -import com.easemob.im.server.model.EMBlock; -import reactor.core.publisher.Flux; -import reactor.core.publisher.Mono; - -import java.time.Duration; -import java.util.List; - -public class BlockUserSendMsgToGroup { - - private Context context; - - public BlockUserSendMsgToGroup(Context context) { - this.context = context; - } - - public Flux getBlockedUsers(String groupId) { - return this.context.getHttpClient() - .flatMap(httpClient -> httpClient.get() - .uri(String.format("/chatgroups/%s/mute", groupId)) - .responseSingle((rsp, buf) -> { - return buf.switchIfEmpty( - Mono.error(new EMUnknownException("response is null"))) - .flatMap(byteBuf -> { - ErrorMapper mapper = new DefaultErrorMapper(); - mapper.statusCode(rsp); - mapper.checkError(byteBuf); - return Mono.just(byteBuf); - }); - })) - .map(rsp -> this.context.getCodec() - .decode(rsp, GetUsersBlockedSendMsgToGroupResponse.class)) - .flatMapIterable(GetUsersBlockedSendMsgToGroupResponse::getEMBlocks); - - } - - public Mono blockUser(String username, String groupId, Duration duration) { - return this.context.getHttpClient() - .flatMap(httpClient -> httpClient.post() - .uri(String.format("/chatgroups/%s/mute", groupId)) - .send(Mono.create(sink -> sink.success(this.context.getCodec() - .encode(BlockUserSendMsgToGroupRequest.of(username, duration))))) - .responseSingle((rsp, buf) -> { - return buf.switchIfEmpty( - Mono.error(new EMUnknownException("response is null"))) - .flatMap(byteBuf -> { - ErrorMapper mapper = new DefaultErrorMapper(); - mapper.statusCode(rsp); - mapper.checkError(byteBuf); - return Mono.just(byteBuf); - }); - })) - .map(buf -> this.context.getCodec() - .decode(buf, BlockUserSendMsgToGroupResponse.class)) - .handle((rsp, sink) -> { - if (!rsp.getSuccess(username)) { - sink.error(new EMUnknownException("unknown")); - return; - } - sink.complete(); - }); - } - - public Mono blockUsers(List usernames, String groupId, Duration duration) { - return this.context.getHttpClient() - .flatMap(httpClient -> httpClient.post() - .uri(String.format("/chatgroups/%s/mute", groupId)) - .send(Mono.create(sink -> sink.success(this.context.getCodec() - .encode(BlockUserSendMsgToGroupRequest.of(usernames, duration))))) - .responseSingle((rsp, buf) -> { - return buf.switchIfEmpty( - Mono.error(new EMUnknownException("response is null"))) - .flatMap(byteBuf -> { - ErrorMapper mapper = new DefaultErrorMapper(); - mapper.statusCode(rsp); - mapper.checkError(byteBuf); - return Mono.just(byteBuf); - }); - })) - .map(buf -> this.context.getCodec() - .decode(buf, BlockUserSendMsgToGroupResponse.class)) - .then(); - } - - public Mono unblockUser(String username, String groupId) { - return this.context.getHttpClient() - .flatMap(httpClient -> httpClient.delete() - .uri(String.format("/chatgroups/%s/mute/%s", groupId, username)) - .responseSingle((rsp, buf) -> { - return buf.switchIfEmpty( - Mono.error(new EMUnknownException("response is null"))) - .flatMap(byteBuf -> { - ErrorMapper mapper = new DefaultErrorMapper(); - mapper.statusCode(rsp); - mapper.checkError(byteBuf); - return Mono.just(byteBuf); - }); - })) - .map(buf -> this.context.getCodec() - .decode(buf, UnblockUserSendMsgToGroupResponse.class)) - .handle((rsp, sink) -> { - if (!rsp.getSuccess(username)) { - sink.error(new EMUnknownException("unknown")); - return; - } - sink.complete(); - }); - } -} diff --git a/im-sdk-core/src/main/java/com/easemob/im/server/api/block/group/msg/BlockUserSendMsgToGroupRequest.java b/im-sdk-core/src/main/java/com/easemob/im/server/api/block/group/msg/BlockUserSendMsgToGroupRequest.java deleted file mode 100644 index 74dfbd46d..000000000 --- a/im-sdk-core/src/main/java/com/easemob/im/server/api/block/group/msg/BlockUserSendMsgToGroupRequest.java +++ /dev/null @@ -1,35 +0,0 @@ -package com.easemob.im.server.api.block.group.msg; - -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonProperty; - -import java.time.Duration; -import java.util.ArrayList; -import java.util.List; - -public class BlockUserSendMsgToGroupRequest { - @JsonProperty("usernames") - private List usernames; - - @JsonProperty("mute_duration") - private long durationInMillis; - - @JsonCreator - public BlockUserSendMsgToGroupRequest(@JsonProperty("usernames") List usernames, - @JsonProperty("mute_duration") long durationInMillis) { - this.usernames = usernames; - this.durationInMillis = durationInMillis; - } - - public static BlockUserSendMsgToGroupRequest of(String username, Duration duration) { - List usernames = new ArrayList<>(); - usernames.add(username); - return new BlockUserSendMsgToGroupRequest(usernames, - duration == null ? -1 : duration.toMillis()); - } - - public static BlockUserSendMsgToGroupRequest of(List usernames, Duration duration) { - return new BlockUserSendMsgToGroupRequest(usernames, - duration == null ? -1 : duration.toMillis()); - } -} diff --git a/im-sdk-core/src/main/java/com/easemob/im/server/api/block/group/msg/BlockUserSendMsgToGroupResponse.java b/im-sdk-core/src/main/java/com/easemob/im/server/api/block/group/msg/BlockUserSendMsgToGroupResponse.java deleted file mode 100644 index eb4a7ed36..000000000 --- a/im-sdk-core/src/main/java/com/easemob/im/server/api/block/group/msg/BlockUserSendMsgToGroupResponse.java +++ /dev/null @@ -1,47 +0,0 @@ -package com.easemob.im.server.api.block.group.msg; - -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonProperty; - -import java.util.List; - -public class BlockUserSendMsgToGroupResponse { - @JsonProperty("data") - private List resources; - - @JsonCreator - public BlockUserSendMsgToGroupResponse( - @JsonProperty("data") List resources) { - this.resources = resources; - } - - public boolean getSuccess(String username) { - return this.resources.stream() - .filter(res -> res.getUsername().equals(username)) - .findFirst().map(BlockUsersResource::getSuccess) - .orElse(false); - } - - public static class BlockUsersResource { - @JsonProperty("result") - private boolean success; - - @JsonProperty("user") - private String username; - - @JsonCreator - public BlockUsersResource(@JsonProperty("result") boolean success, - @JsonProperty("user") String username) { - this.success = success; - this.username = username; - } - - public boolean getSuccess() { - return this.success; - } - - public String getUsername() { - return this.username; - } - } -} diff --git a/im-sdk-core/src/main/java/com/easemob/im/server/api/block/group/msg/GetUsersBlockedSendMsgToGroupResponse.java b/im-sdk-core/src/main/java/com/easemob/im/server/api/block/group/msg/GetUsersBlockedSendMsgToGroupResponse.java deleted file mode 100644 index bb86a67ed..000000000 --- a/im-sdk-core/src/main/java/com/easemob/im/server/api/block/group/msg/GetUsersBlockedSendMsgToGroupResponse.java +++ /dev/null @@ -1,42 +0,0 @@ -package com.easemob.im.server.api.block.group.msg; - -import com.easemob.im.server.model.EMBlock; -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonProperty; - -import java.time.Instant; -import java.util.List; -import java.util.stream.Collectors; - -public class GetUsersBlockedSendMsgToGroupResponse { - @JsonProperty("data") - private List resources; - - @JsonCreator - public GetUsersBlockedSendMsgToGroupResponse( - @JsonProperty("data") List resources) { - this.resources = resources; - } - - public List getEMBlocks() { - return this.resources.stream().map(UserBlockedSendMsgToGroupResource::toEMBlock) - .collect(Collectors.toList()); - } - - public static class UserBlockedSendMsgToGroupResource { - @JsonProperty("user") - private String username; - @JsonProperty("expire") - private long expireTimestamp; - - public UserBlockedSendMsgToGroupResource(@JsonProperty("user") String username, - @JsonProperty("expire") long expireTimestamp) { - this.username = username; - this.expireTimestamp = expireTimestamp; - } - - public EMBlock toEMBlock() { - return new EMBlock(this.username, Instant.ofEpochMilli(this.expireTimestamp)); - } - } -} diff --git a/im-sdk-core/src/main/java/com/easemob/im/server/api/block/group/msg/UnblockAllUserSendMsgToGroup.java b/im-sdk-core/src/main/java/com/easemob/im/server/api/block/group/msg/UnblockAllUserSendMsgToGroup.java deleted file mode 100644 index 2c93a5cef..000000000 --- a/im-sdk-core/src/main/java/com/easemob/im/server/api/block/group/msg/UnblockAllUserSendMsgToGroup.java +++ /dev/null @@ -1,33 +0,0 @@ -package com.easemob.im.server.api.block.group.msg; - -import com.easemob.im.server.api.Context; -import com.easemob.im.server.api.DefaultErrorMapper; -import com.easemob.im.server.api.ErrorMapper; -import com.easemob.im.server.exception.EMUnknownException; -import reactor.core.publisher.Mono; - -public class UnblockAllUserSendMsgToGroup { - - private Context context; - - public UnblockAllUserSendMsgToGroup(Context context) { - this.context = context; - } - - public Mono single(String groupId) { - return this.context.getHttpClient() - .flatMap(httpClient -> httpClient.delete() - .uri(String.format("/chatgroups/%s/ban", groupId)) - .responseSingle((rsp, buf) -> { - return buf.switchIfEmpty( - Mono.error(new EMUnknownException("response is null"))) - .flatMap(byteBuf -> { - ErrorMapper mapper = new DefaultErrorMapper(); - mapper.statusCode(rsp); - mapper.checkError(byteBuf); - return Mono.just(byteBuf); - }); - })) - .then(); - } -} diff --git a/im-sdk-core/src/main/java/com/easemob/im/server/api/block/group/msg/UnblockUserSendMsgToGroupResponse.java b/im-sdk-core/src/main/java/com/easemob/im/server/api/block/group/msg/UnblockUserSendMsgToGroupResponse.java deleted file mode 100644 index 6555ba758..000000000 --- a/im-sdk-core/src/main/java/com/easemob/im/server/api/block/group/msg/UnblockUserSendMsgToGroupResponse.java +++ /dev/null @@ -1,47 +0,0 @@ -package com.easemob.im.server.api.block.group.msg; - -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonProperty; - -import java.util.List; - -public class UnblockUserSendMsgToGroupResponse { - @JsonProperty("data") - private List resources; - - @JsonCreator - public UnblockUserSendMsgToGroupResponse( - @JsonProperty("data") List resources) { - this.resources = resources; - } - - public boolean getSuccess(String username) { - return this.resources.stream() - .filter(res -> res.getUsername().equals(username)) - .findFirst().map(UnblockUsersResource::getSuccess) - .orElse(false); - } - - public static class UnblockUsersResource { - @JsonProperty("result") - private boolean success; - - @JsonProperty("user") - private String username; - - @JsonCreator - public UnblockUsersResource(@JsonProperty("result") boolean success, - @JsonProperty("user") String username) { - this.success = success; - this.username = username; - } - - public boolean getSuccess() { - return this.success; - } - - public String getUsername() { - return this.username; - } - } -} diff --git a/im-sdk-core/src/main/java/com/easemob/im/server/api/block/login/BlockUserLogin.java b/im-sdk-core/src/main/java/com/easemob/im/server/api/block/login/BlockUserLogin.java deleted file mode 100644 index ca08a5f3a..000000000 --- a/im-sdk-core/src/main/java/com/easemob/im/server/api/block/login/BlockUserLogin.java +++ /dev/null @@ -1,50 +0,0 @@ -package com.easemob.im.server.api.block.login; - -import com.easemob.im.server.api.Context; -import com.easemob.im.server.api.DefaultErrorMapper; -import com.easemob.im.server.api.ErrorMapper; -import com.easemob.im.server.exception.EMUnknownException; -import reactor.core.publisher.Mono; - -public class BlockUserLogin { - - private Context context; - - public BlockUserLogin(Context context) { - this.context = context; - } - - public Mono blockUser(String username) { - return this.context.getHttpClient() - .flatMap(httpClient -> httpClient.post() - .uri(String.format("/users/%s/deactivate", username)) - .responseSingle((rsp, buf) -> { - return buf.switchIfEmpty( - Mono.error(new EMUnknownException("response is null"))) - .flatMap(byteBuf -> { - ErrorMapper mapper = new DefaultErrorMapper(); - mapper.statusCode(rsp); - mapper.checkError(byteBuf); - return Mono.just(byteBuf); - }); - })) - .then(); - } - - public Mono unblockUser(String username) { - return this.context.getHttpClient() - .flatMap(httpClient -> httpClient.post() - .uri(String.format("/users/%s/activate", username)) - .responseSingle((rsp, buf) -> { - return buf.switchIfEmpty( - Mono.error(new EMUnknownException("response is null"))) - .flatMap(byteBuf -> { - ErrorMapper mapper = new DefaultErrorMapper(); - mapper.statusCode(rsp); - mapper.checkError(byteBuf); - return Mono.just(byteBuf); - }); - })) - .then(); - } -} diff --git a/im-sdk-core/src/main/java/com/easemob/im/server/api/block/room/join/BlockUserJoinRoom.java b/im-sdk-core/src/main/java/com/easemob/im/server/api/block/room/join/BlockUserJoinRoom.java deleted file mode 100644 index 797c954f1..000000000 --- a/im-sdk-core/src/main/java/com/easemob/im/server/api/block/room/join/BlockUserJoinRoom.java +++ /dev/null @@ -1,85 +0,0 @@ -package com.easemob.im.server.api.block.room.join; - -import com.easemob.im.server.api.Context; -import com.easemob.im.server.api.DefaultErrorMapper; -import com.easemob.im.server.api.ErrorMapper; -import com.easemob.im.server.exception.EMUnknownException; -import com.easemob.im.server.model.EMBlock; -import reactor.core.publisher.Flux; -import reactor.core.publisher.Mono; - -public class BlockUserJoinRoom { - - private Context context; - - public BlockUserJoinRoom(Context context) { - this.context = context; - } - - public Flux getBlockedUsers(String roomId) { - return this.context.getHttpClient() - .flatMap(httpClient -> httpClient.get() - .uri(String.format("/chatrooms/%s/blocks/users", roomId)) - .responseSingle((rsp, buf) -> { - return buf.switchIfEmpty( - Mono.error(new EMUnknownException("response is null"))) - .flatMap(byteBuf -> { - ErrorMapper mapper = new DefaultErrorMapper(); - mapper.statusCode(rsp); - mapper.checkError(byteBuf); - return Mono.just(byteBuf); - }); - })) - .map(buf -> this.context.getCodec().decode(buf, GetBlockedUsersResponse.class)) - .flatMapIterable(GetBlockedUsersResponse::getUsernames) - .map(username -> new EMBlock(username, null)); - } - - public Mono blockUser(String username, String roomId) { - return this.context.getHttpClient() - .flatMap(httpClient -> httpClient.post() - .uri(String.format("/chatrooms/%s/blocks/users/%s", roomId, username)) - .responseSingle((rsp, buf) -> { - return buf.switchIfEmpty( - Mono.error(new EMUnknownException("response is null"))) - .flatMap(byteBuf -> { - ErrorMapper mapper = new DefaultErrorMapper(); - mapper.statusCode(rsp); - mapper.checkError(byteBuf); - return Mono.just(byteBuf); - }); - })) - .map(buf -> this.context.getCodec().decode(buf, BlockUserJoinRoomResponse.class)) - .handle((rsp, sink) -> { - if (!rsp.isSuccess()) { - sink.error(new EMUnknownException("unknown")); - return; - } - sink.complete(); - }); - } - - public Mono unblockUser(String username, String roomId) { - return this.context.getHttpClient() - .flatMap(httpClient -> httpClient.delete() - .uri(String.format("/chatrooms/%s/blocks/users/%s", roomId, username)) - .responseSingle((rsp, buf) -> { - return buf.switchIfEmpty( - Mono.error(new EMUnknownException("response is null"))) - .flatMap(byteBuf -> { - ErrorMapper mapper = new DefaultErrorMapper(); - mapper.statusCode(rsp); - mapper.checkError(byteBuf); - return Mono.just(byteBuf); - }); - })) - .map(buf -> this.context.getCodec().decode(buf, UnblockUserJoinRoomResponse.class)) - .handle((rsp, sink) -> { - if (!rsp.isSuccess()) { - sink.error(new EMUnknownException("unknown")); - return; - } - sink.complete(); - }); - } -} diff --git a/im-sdk-core/src/main/java/com/easemob/im/server/api/block/room/join/BlockUserJoinRoomResponse.java b/im-sdk-core/src/main/java/com/easemob/im/server/api/block/room/join/BlockUserJoinRoomResponse.java deleted file mode 100644 index 73db0e591..000000000 --- a/im-sdk-core/src/main/java/com/easemob/im/server/api/block/room/join/BlockUserJoinRoomResponse.java +++ /dev/null @@ -1,30 +0,0 @@ -package com.easemob.im.server.api.block.room.join; - -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonProperty; - -public class BlockUserJoinRoomResponse { - - @JsonProperty("data") - private BlockUserJoinRoomResource resource; - - @JsonCreator - public BlockUserJoinRoomResponse(@JsonProperty("data") BlockUserJoinRoomResource resource) { - this.resource = resource; - } - - public boolean isSuccess() { - return this.resource != null && this.resource.success; - } - - public static class BlockUserJoinRoomResource { - @JsonProperty("result") - private boolean success; - - @JsonCreator - public BlockUserJoinRoomResource(@JsonProperty("result") boolean success) { - this.success = success; - } - - } -} diff --git a/im-sdk-core/src/main/java/com/easemob/im/server/api/block/room/join/GetBlockedUsersResponse.java b/im-sdk-core/src/main/java/com/easemob/im/server/api/block/room/join/GetBlockedUsersResponse.java deleted file mode 100644 index 7cc9393aa..000000000 --- a/im-sdk-core/src/main/java/com/easemob/im/server/api/block/room/join/GetBlockedUsersResponse.java +++ /dev/null @@ -1,21 +0,0 @@ -package com.easemob.im.server.api.block.room.join; - -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonProperty; - -import java.util.List; - -public class GetBlockedUsersResponse { - - @JsonProperty("data") - private List usernames; - - @JsonCreator - public GetBlockedUsersResponse(@JsonProperty("data") List usernames) { - this.usernames = usernames; - } - - public List getUsernames() { - return this.usernames; - } -} diff --git a/im-sdk-core/src/main/java/com/easemob/im/server/api/block/room/join/UnblockUserJoinRoomResponse.java b/im-sdk-core/src/main/java/com/easemob/im/server/api/block/room/join/UnblockUserJoinRoomResponse.java deleted file mode 100644 index cf23eb9b3..000000000 --- a/im-sdk-core/src/main/java/com/easemob/im/server/api/block/room/join/UnblockUserJoinRoomResponse.java +++ /dev/null @@ -1,30 +0,0 @@ -package com.easemob.im.server.api.block.room.join; - -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonProperty; - -public class UnblockUserJoinRoomResponse { - - @JsonProperty("data") - private UnblockUserJoinRoomResource resource; - - @JsonCreator - public UnblockUserJoinRoomResponse(@JsonProperty("data") UnblockUserJoinRoomResource resource) { - this.resource = resource; - } - - public boolean isSuccess() { - return this.resource != null && this.resource.success; - } - - public static class UnblockUserJoinRoomResource { - @JsonProperty("result") - private boolean success; - - @JsonCreator - public UnblockUserJoinRoomResource(@JsonProperty("result") boolean success) { - this.success = success; - } - - } -} diff --git a/im-sdk-core/src/main/java/com/easemob/im/server/api/block/room/msg/block/BlockAllUserSendMsgToRoom.java b/im-sdk-core/src/main/java/com/easemob/im/server/api/block/room/msg/block/BlockAllUserSendMsgToRoom.java deleted file mode 100644 index 35a390b3c..000000000 --- a/im-sdk-core/src/main/java/com/easemob/im/server/api/block/room/msg/block/BlockAllUserSendMsgToRoom.java +++ /dev/null @@ -1,33 +0,0 @@ -package com.easemob.im.server.api.block.room.msg.block; - -import com.easemob.im.server.api.Context; -import com.easemob.im.server.api.DefaultErrorMapper; -import com.easemob.im.server.api.ErrorMapper; -import com.easemob.im.server.exception.EMUnknownException; -import reactor.core.publisher.Mono; - -public class BlockAllUserSendMsgToRoom { - - private Context context; - - public BlockAllUserSendMsgToRoom(Context context) { - this.context = context; - } - - public Mono single(String roomId) { - return this.context.getHttpClient() - .flatMap(httpClient -> httpClient.post() - .uri(String.format("/chatrooms/%s/ban", roomId)) - .responseSingle((rsp, buf) -> { - return buf.switchIfEmpty( - Mono.error(new EMUnknownException("response is null"))) - .flatMap(byteBuf -> { - ErrorMapper mapper = new DefaultErrorMapper(); - mapper.statusCode(rsp); - mapper.checkError(byteBuf); - return Mono.just(byteBuf); - }); - })) - .then(); - } -} diff --git a/im-sdk-core/src/main/java/com/easemob/im/server/api/block/room/msg/block/BlockUserSendMsgToRoom.java b/im-sdk-core/src/main/java/com/easemob/im/server/api/block/room/msg/block/BlockUserSendMsgToRoom.java deleted file mode 100644 index 4c275a16f..000000000 --- a/im-sdk-core/src/main/java/com/easemob/im/server/api/block/room/msg/block/BlockUserSendMsgToRoom.java +++ /dev/null @@ -1,67 +0,0 @@ -package com.easemob.im.server.api.block.room.msg.block; - -import com.easemob.im.server.api.Context; -import com.easemob.im.server.api.DefaultErrorMapper; -import com.easemob.im.server.api.ErrorMapper; -import com.easemob.im.server.exception.EMUnknownException; -import reactor.core.publisher.Mono; - -import java.time.Duration; -import java.util.List; - -public class BlockUserSendMsgToRoom { - - private Context context; - - public BlockUserSendMsgToRoom(Context context) { - this.context = context; - } - - public Mono single(String username, String roomId, Duration duration) { - return this.context.getHttpClient() - .flatMap(httpClient -> httpClient.post() - .uri(String.format("/chatrooms/%s/mute", roomId)) - .send(Mono.create(sink -> sink.success(this.context.getCodec() - .encode(BlockUserSendMsgToRoomRequest.of(username, duration))))) - .responseSingle((rsp, buf) -> { - return buf.switchIfEmpty( - Mono.error(new EMUnknownException("response is null"))) - .flatMap(byteBuf -> { - ErrorMapper mapper = new DefaultErrorMapper(); - mapper.statusCode(rsp); - mapper.checkError(byteBuf); - return Mono.just(byteBuf); - }); - })) - .map(buf -> this.context.getCodec() - .decode(buf, BlockUserSendMsgToRoomResponse.class)) - .handle((rsp, sink) -> { - if (!rsp.getSuccess(username)) { - sink.error(new EMUnknownException("unknown")); - return; - } - sink.complete(); - }); - } - - public Mono batch(List usernames, String roomId, Duration duration) { - return this.context.getHttpClient() - .flatMap(httpClient -> httpClient.post() - .uri(String.format("/chatrooms/%s/mute", roomId)) - .send(Mono.create(sink -> sink.success(this.context.getCodec() - .encode(BlockUserSendMsgToRoomRequest.of(usernames, duration))))) - .responseSingle((rsp, buf) -> { - return buf.switchIfEmpty( - Mono.error(new EMUnknownException("response is null"))) - .flatMap(byteBuf -> { - ErrorMapper mapper = new DefaultErrorMapper(); - mapper.statusCode(rsp); - mapper.checkError(byteBuf); - return Mono.just(byteBuf); - }); - })) - .map(buf -> this.context.getCodec() - .decode(buf, BlockUserSendMsgToRoomResponse.class)) - .then(); - } -} diff --git a/im-sdk-core/src/main/java/com/easemob/im/server/api/block/room/msg/block/BlockUserSendMsgToRoomRequest.java b/im-sdk-core/src/main/java/com/easemob/im/server/api/block/room/msg/block/BlockUserSendMsgToRoomRequest.java deleted file mode 100644 index 276c66724..000000000 --- a/im-sdk-core/src/main/java/com/easemob/im/server/api/block/room/msg/block/BlockUserSendMsgToRoomRequest.java +++ /dev/null @@ -1,36 +0,0 @@ -package com.easemob.im.server.api.block.room.msg.block; - -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonProperty; - -import java.time.Duration; -import java.util.ArrayList; -import java.util.List; - -public class BlockUserSendMsgToRoomRequest { - - @JsonProperty("usernames") - private List usernames; - - @JsonProperty("mute_duration") - private long durationInMillis; - - @JsonCreator - public BlockUserSendMsgToRoomRequest(@JsonProperty("usernames") List usernames, - @JsonProperty("mute_duration") long durationInMillis) { - this.usernames = usernames; - this.durationInMillis = durationInMillis; - } - - public static BlockUserSendMsgToRoomRequest of(String username, Duration duration) { - List usernames = new ArrayList<>(); - usernames.add(username); - return new BlockUserSendMsgToRoomRequest(usernames, - duration == null ? -1 : duration.toMillis()); - } - - public static BlockUserSendMsgToRoomRequest of(List usernames, Duration duration) { - return new BlockUserSendMsgToRoomRequest(usernames, - duration == null ? -1 : duration.toMillis()); - } -} diff --git a/im-sdk-core/src/main/java/com/easemob/im/server/api/block/room/msg/block/BlockUserSendMsgToRoomResponse.java b/im-sdk-core/src/main/java/com/easemob/im/server/api/block/room/msg/block/BlockUserSendMsgToRoomResponse.java deleted file mode 100644 index 817117efb..000000000 --- a/im-sdk-core/src/main/java/com/easemob/im/server/api/block/room/msg/block/BlockUserSendMsgToRoomResponse.java +++ /dev/null @@ -1,53 +0,0 @@ -package com.easemob.im.server.api.block.room.msg.block; - -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonProperty; - -import java.util.List; - -public class BlockUserSendMsgToRoomResponse { - - @JsonProperty("data") - private List results; - - @JsonCreator - public BlockUserSendMsgToRoomResponse(@JsonProperty("data") List results) { - this.results = results; - } - - public boolean getSuccess(String username) { - return this.results.stream() - .filter(result -> result.getUsername().equals(username)) - .findFirst() - .map(result -> result.isSuccess) - .orElse(false); - } - - public static class BlockResult { - @JsonProperty("result") - private boolean isSuccess; - - @JsonProperty("expire") - private long expireTimestamp; - - @JsonProperty("user") - private String username; - - @JsonCreator - public BlockResult(@JsonProperty("result") boolean isSuccess, - @JsonProperty("expire") long expireTimestamp, - @JsonProperty("user") String username) { - this.isSuccess = isSuccess; - this.expireTimestamp = expireTimestamp; - this.username = username; - } - - public String getUsername() { - return this.username; - } - - public boolean getSuccess() { - return this.isSuccess; - } - } -} diff --git a/im-sdk-core/src/main/java/com/easemob/im/server/api/block/room/msg/list/ListUsersBlockedSendMsgToRoom.java b/im-sdk-core/src/main/java/com/easemob/im/server/api/block/room/msg/list/ListUsersBlockedSendMsgToRoom.java deleted file mode 100644 index d128e16e0..000000000 --- a/im-sdk-core/src/main/java/com/easemob/im/server/api/block/room/msg/list/ListUsersBlockedSendMsgToRoom.java +++ /dev/null @@ -1,38 +0,0 @@ -package com.easemob.im.server.api.block.room.msg.list; - -import com.easemob.im.server.api.Context; -import com.easemob.im.server.api.DefaultErrorMapper; -import com.easemob.im.server.api.ErrorMapper; -import com.easemob.im.server.exception.EMUnknownException; -import com.easemob.im.server.model.EMBlock; -import reactor.core.publisher.Flux; -import reactor.core.publisher.Mono; - -public class ListUsersBlockedSendMsgToRoom { - - private Context context; - - public ListUsersBlockedSendMsgToRoom(Context context) { - this.context = context; - } - - public Flux all(String roomId) { - return this.context.getHttpClient() - .flatMap(httpClient -> httpClient.get() - .uri(String.format("/chatrooms/%s/mute", roomId)) - .responseSingle((rsp, buf) -> { - return buf.switchIfEmpty( - Mono.error(new EMUnknownException("response is null"))) - .flatMap(byteBuf -> { - ErrorMapper mapper = new DefaultErrorMapper(); - mapper.statusCode(rsp); - mapper.checkError(byteBuf); - return Mono.just(byteBuf); - }); - })) - .map(buf -> this.context.getCodec() - .decode(buf, ListUsersBlockedSendMsgToRoomResponse.class)) - .flatMapIterable(ListUsersBlockedSendMsgToRoomResponse::getEMBlocks); - } - -} diff --git a/im-sdk-core/src/main/java/com/easemob/im/server/api/block/room/msg/list/ListUsersBlockedSendMsgToRoomResponse.java b/im-sdk-core/src/main/java/com/easemob/im/server/api/block/room/msg/list/ListUsersBlockedSendMsgToRoomResponse.java deleted file mode 100644 index 73b78c148..000000000 --- a/im-sdk-core/src/main/java/com/easemob/im/server/api/block/room/msg/list/ListUsersBlockedSendMsgToRoomResponse.java +++ /dev/null @@ -1,41 +0,0 @@ -package com.easemob.im.server.api.block.room.msg.list; - -import com.easemob.im.server.model.EMBlock; -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonProperty; - -import java.time.Instant; -import java.util.List; -import java.util.stream.Collectors; - -public class ListUsersBlockedSendMsgToRoomResponse { - @JsonProperty("data") - private List blockedUsers; - - @JsonCreator - public ListUsersBlockedSendMsgToRoomResponse( - @JsonProperty("data") List blockedUsers) { - this.blockedUsers = blockedUsers; - } - - public List getEMBlocks() { - return this.blockedUsers.stream().map(BlockedUser::toEMBlock).collect(Collectors.toList()); - } - - public static class BlockedUser { - @JsonProperty("expire") - private long expireAt; - @JsonProperty("user") - private String username; - - public BlockedUser(@JsonProperty("expire") long expireAt, - @JsonProperty("user") String username) { - this.expireAt = expireAt; - this.username = username; - } - - public EMBlock toEMBlock() { - return new EMBlock(this.username, Instant.ofEpochMilli(this.expireAt)); - } - } -} diff --git a/im-sdk-core/src/main/java/com/easemob/im/server/api/block/room/msg/unblock/UnblockAllUserSendMsgToRoom.java b/im-sdk-core/src/main/java/com/easemob/im/server/api/block/room/msg/unblock/UnblockAllUserSendMsgToRoom.java deleted file mode 100644 index ce946ba8e..000000000 --- a/im-sdk-core/src/main/java/com/easemob/im/server/api/block/room/msg/unblock/UnblockAllUserSendMsgToRoom.java +++ /dev/null @@ -1,33 +0,0 @@ -package com.easemob.im.server.api.block.room.msg.unblock; - -import com.easemob.im.server.api.Context; -import com.easemob.im.server.api.DefaultErrorMapper; -import com.easemob.im.server.api.ErrorMapper; -import com.easemob.im.server.exception.EMUnknownException; -import reactor.core.publisher.Mono; - -public class UnblockAllUserSendMsgToRoom { - - private Context context; - - public UnblockAllUserSendMsgToRoom(Context context) { - this.context = context; - } - - public Mono single(String roomId) { - return this.context.getHttpClient() - .flatMap(httpClient -> httpClient.delete() - .uri(String.format("/chatrooms/%s/ban", roomId)) - .responseSingle((rsp, buf) -> { - return buf.switchIfEmpty( - Mono.error(new EMUnknownException("response is null"))) - .flatMap(byteBuf -> { - ErrorMapper mapper = new DefaultErrorMapper(); - mapper.statusCode(rsp); - mapper.checkError(byteBuf); - return Mono.just(byteBuf); - }); - })) - .then(); - } -} diff --git a/im-sdk-core/src/main/java/com/easemob/im/server/api/block/room/msg/unblock/UnblockUserSendMsgToRoom.java b/im-sdk-core/src/main/java/com/easemob/im/server/api/block/room/msg/unblock/UnblockUserSendMsgToRoom.java deleted file mode 100644 index 571a64372..000000000 --- a/im-sdk-core/src/main/java/com/easemob/im/server/api/block/room/msg/unblock/UnblockUserSendMsgToRoom.java +++ /dev/null @@ -1,76 +0,0 @@ -package com.easemob.im.server.api.block.room.msg.unblock; - -import com.easemob.im.server.api.Context; -import com.easemob.im.server.api.DefaultErrorMapper; -import com.easemob.im.server.api.ErrorMapper; -import com.easemob.im.server.exception.EMUnknownException; -import reactor.core.publisher.Mono; - -import java.util.Collection; -import java.util.Iterator; -import java.util.List; - -public class UnblockUserSendMsgToRoom { - - private Context context; - - public UnblockUserSendMsgToRoom(Context context) { - this.context = context; - } - - public Mono single(String username, String roomId) { - return this.context.getHttpClient() - .flatMap(httpClient -> httpClient.delete() - .uri(String.format("/chatrooms/%s/mute/%s", roomId, username)) - .responseSingle((rsp, buf) -> { - return buf.switchIfEmpty( - Mono.error(new EMUnknownException("response is null"))) - .flatMap(byteBuf -> { - ErrorMapper mapper = new DefaultErrorMapper(); - mapper.statusCode(rsp); - mapper.checkError(byteBuf); - return Mono.just(byteBuf); - }); - })) - .map(buf -> this.context.getCodec() - .decode(buf, UnblockUserSendMsgToRoomResponse.class)) - .handle((rsp, sink) -> { - if (!rsp.isSuccess(username)) { - sink.error(new EMUnknownException("unknown")); - return; - } - sink.complete(); - }); - } - - public Mono batch(List usernames, String roomId) { - return this.context.getHttpClient() - .flatMap(httpClient -> httpClient.delete() - .uri(String.format("/chatrooms/%s/mute/%s", roomId, join(usernames, ","))) - .responseSingle((rsp, buf) -> { - return buf.switchIfEmpty( - Mono.error(new EMUnknownException("response is null"))) - .flatMap(byteBuf -> { - ErrorMapper mapper = new DefaultErrorMapper(); - mapper.statusCode(rsp); - mapper.checkError(byteBuf); - return Mono.just(byteBuf); - }); - })) - .map(buf -> this.context.getCodec() - .decode(buf, UnblockUserSendMsgToRoomResponse.class)) - .then(); - } - - public static String join(Collection var0, String var1) { - StringBuffer var2 = new StringBuffer(); - - for(Iterator var3 = var0.iterator(); var3.hasNext(); var2.append((String)var3.next())) { - if (var2.length() != 0) { - var2.append(var1); - } - } - - return var2.toString(); - } -} diff --git a/im-sdk-core/src/main/java/com/easemob/im/server/api/block/room/msg/unblock/UnblockUserSendMsgToRoomResponse.java b/im-sdk-core/src/main/java/com/easemob/im/server/api/block/room/msg/unblock/UnblockUserSendMsgToRoomResponse.java deleted file mode 100644 index 0c07c8551..000000000 --- a/im-sdk-core/src/main/java/com/easemob/im/server/api/block/room/msg/unblock/UnblockUserSendMsgToRoomResponse.java +++ /dev/null @@ -1,45 +0,0 @@ -package com.easemob.im.server.api.block.room.msg.unblock; - -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonProperty; - -import java.util.List; - -public class UnblockUserSendMsgToRoomResponse { - @JsonProperty("data") - private List results; - - @JsonCreator - public UnblockUserSendMsgToRoomResponse(@JsonProperty("data") List results) { - this.results = results; - } - - public boolean isSuccess(String username) { - return this.results.stream().filter(result -> result.getUsername().equals(username)) - .findFirst().map(result -> result.isSuccess).orElse(false); - } - - public static class Result { - @JsonProperty("result") - private boolean isSuccess; - - @JsonProperty("user") - private String username; - - @JsonCreator - public Result(@JsonProperty("result") boolean isSuccess, - @JsonProperty("user") String username) { - this.isSuccess = isSuccess; - this.username = username; - } - - public boolean isSuccess() { - return this.isSuccess; - } - - public String getUsername() { - return this.username; - } - } - -} diff --git a/im-sdk-core/src/main/java/com/easemob/im/server/api/block/user/BlockUsersSendMsgToUserRequest.java b/im-sdk-core/src/main/java/com/easemob/im/server/api/block/user/BlockUsersSendMsgToUserRequest.java deleted file mode 100644 index 3fb56ad04..000000000 --- a/im-sdk-core/src/main/java/com/easemob/im/server/api/block/user/BlockUsersSendMsgToUserRequest.java +++ /dev/null @@ -1,21 +0,0 @@ -package com.easemob.im.server.api.block.user; - -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonProperty; - -import java.util.List; - -public class BlockUsersSendMsgToUserRequest { - @JsonProperty("usernames") - private List usernames; - - @JsonCreator - public BlockUsersSendMsgToUserRequest(@JsonProperty("usernames") List usernames) { - this.usernames = usernames; - } - - public List getUsernames() { - return usernames; - } - -} diff --git a/im-sdk-core/src/main/java/com/easemob/im/server/api/block/user/GetUsersBlockedSendMsgToUserResponse.java b/im-sdk-core/src/main/java/com/easemob/im/server/api/block/user/GetUsersBlockedSendMsgToUserResponse.java deleted file mode 100644 index 35b132981..000000000 --- a/im-sdk-core/src/main/java/com/easemob/im/server/api/block/user/GetUsersBlockedSendMsgToUserResponse.java +++ /dev/null @@ -1,21 +0,0 @@ -package com.easemob.im.server.api.block.user; - -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonProperty; - -import java.util.List; - -public class GetUsersBlockedSendMsgToUserResponse { - @JsonProperty("data") - private List usernames; - - @JsonCreator - public GetUsersBlockedSendMsgToUserResponse(@JsonProperty("data") List usernames) { - this.usernames = usernames; - } - - public List getUsernames() { - return usernames; - } - -} diff --git a/im-sdk-core/src/main/java/com/easemob/im/server/api/block/user/SendMsgToUser.java b/im-sdk-core/src/main/java/com/easemob/im/server/api/block/user/SendMsgToUser.java deleted file mode 100644 index 1b39d90a4..000000000 --- a/im-sdk-core/src/main/java/com/easemob/im/server/api/block/user/SendMsgToUser.java +++ /dev/null @@ -1,81 +0,0 @@ -package com.easemob.im.server.api.block.user; - -import com.easemob.im.server.api.Context; -import com.easemob.im.server.api.DefaultErrorMapper; -import com.easemob.im.server.api.ErrorMapper; -import com.easemob.im.server.exception.EMInvalidArgumentException; -import com.easemob.im.server.exception.EMUnknownException; -import com.easemob.im.server.model.EMBlock; -import reactor.core.publisher.Flux; -import reactor.core.publisher.Mono; - -import java.util.Arrays; - -public class SendMsgToUser { - private Context context; - - public SendMsgToUser(Context context) { - this.context = context; - } - - public Flux getUsersBlocked(String username) { - return this.context.getHttpClient() - .flatMap(httpClient -> httpClient.get() - .uri(String.format("/users/%s/blocks/users", username)) - .responseSingle((rsp, buf) -> { - return buf.switchIfEmpty( - Mono.error(new EMUnknownException("response is null"))) - .flatMap(byteBuf -> { - ErrorMapper mapper = new DefaultErrorMapper(); - mapper.statusCode(rsp); - mapper.checkError(byteBuf); - return Mono.just(byteBuf); - }); - })) - .map(buf -> this.context.getCodec() - .decode(buf, GetUsersBlockedSendMsgToUserResponse.class)) - .flatMapIterable(GetUsersBlockedSendMsgToUserResponse::getUsernames) - .map(blockedUsername -> new EMBlock(blockedUsername, null)); - } - - public Mono blockUser(String fromUser, String toUser) { - if (fromUser.equals(toUser)) { - return Mono.error(new EMInvalidArgumentException("user could not block himself")); - } - return this.context.getHttpClient() - .flatMap(httpClient -> httpClient.post() - .uri(String.format("/users/%s/blocks/users", toUser)) - .send(Mono.create(sink -> sink.success(this.context.getCodec() - .encode(new BlockUsersSendMsgToUserRequest( - Arrays.asList(fromUser)))))) - .responseSingle((rsp, buf) -> { - return buf.switchIfEmpty( - Mono.error(new EMUnknownException("response is null"))) - .flatMap(byteBuf -> { - ErrorMapper mapper = new DefaultErrorMapper(); - mapper.statusCode(rsp); - mapper.checkError(byteBuf); - return Mono.just(byteBuf); - }); - })) - .then(); - } - - public Mono unblockUser(String fromUser, String toUser) { - return this.context.getHttpClient() - .flatMap(httpClient -> httpClient.delete() - .uri(String.format("/users/%s/blocks/users/%s", toUser, fromUser)) - .responseSingle((rsp, buf) -> { - return buf.switchIfEmpty( - Mono.error(new EMUnknownException("response is null"))) - .flatMap(byteBuf -> { - ErrorMapper mapper = new DefaultErrorMapper(); - mapper.statusCode(rsp); - mapper.checkError(byteBuf); - return Mono.just(byteBuf); - }); - })) - .then(); - } - -} diff --git a/im-sdk-core/src/main/java/com/easemob/im/server/api/block/user/UnblockUsersSendMsgToUserRequest.java b/im-sdk-core/src/main/java/com/easemob/im/server/api/block/user/UnblockUsersSendMsgToUserRequest.java deleted file mode 100644 index 1690cde70..000000000 --- a/im-sdk-core/src/main/java/com/easemob/im/server/api/block/user/UnblockUsersSendMsgToUserRequest.java +++ /dev/null @@ -1,21 +0,0 @@ -package com.easemob.im.server.api.block.user; - -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonProperty; - -import java.util.List; - -public class UnblockUsersSendMsgToUserRequest { - @JsonProperty("usernames") - private List usernames; - - @JsonCreator - public UnblockUsersSendMsgToUserRequest(@JsonProperty("usernames") List usernames) { - this.usernames = usernames; - } - - public List getUsernames() { - return usernames; - } - -} diff --git a/im-sdk-core/src/main/java/com/easemob/im/server/api/codec/JsonCodec.java b/im-sdk-core/src/main/java/com/easemob/im/server/api/codec/JsonCodec.java deleted file mode 100644 index c935e9936..000000000 --- a/im-sdk-core/src/main/java/com/easemob/im/server/api/codec/JsonCodec.java +++ /dev/null @@ -1,60 +0,0 @@ -package com.easemob.im.server.api.codec; - -import com.easemob.im.server.api.Codec; -import com.easemob.im.server.exception.EMJsonException; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.core.JsonProcessingException; -import com.fasterxml.jackson.databind.DeserializationFeature; -import com.fasterxml.jackson.databind.ObjectMapper; -import io.netty.buffer.ByteBuf; -import io.netty.buffer.ByteBufUtil; -import io.netty.buffer.Unpooled; - -import java.io.IOException; - -public class JsonCodec implements Codec { - - private ObjectMapper objectMapper; - - public JsonCodec() { - this.objectMapper = new ObjectMapper(); - this.objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); - this.objectMapper.setSerializationInclusion(JsonInclude.Include.NON_NULL); - } - - public ByteBuf encode(Object object) { - ByteBuf buffer = Unpooled.buffer(); - try { - byte[] bytes = this.objectMapper.writeValueAsBytes(object); - buffer.writeBytes(bytes); - } catch (JsonProcessingException e) { - throw new EMJsonException(String.format("could not encode object: %s", e.getMessage()), - e); - } - - return buffer; - } - - public T decode(ByteBuf buffer, Class tClass) { - - byte[] array; - final int offset; - int len = buffer.readableBytes(); - if (buffer.hasArray()) { - array = buffer.array(); - offset = buffer.arrayOffset() + buffer.readerIndex(); - } else { - array = ByteBufUtil.getBytes(buffer, buffer.readerIndex(), len, false); - offset = 0; - } - - try { - return this.objectMapper.readValue(array, offset, len, tClass); - } catch (IOException e) { - throw new EMJsonException( - String.format("could not decode class %s: %s", tClass.getName(), - e.getMessage()), e); - } - } - -} diff --git a/im-sdk-core/src/main/java/com/easemob/im/server/api/contact/ContactApi.java b/im-sdk-core/src/main/java/com/easemob/im/server/api/contact/ContactApi.java deleted file mode 100644 index 391d1082c..000000000 --- a/im-sdk-core/src/main/java/com/easemob/im/server/api/contact/ContactApi.java +++ /dev/null @@ -1,87 +0,0 @@ -package com.easemob.im.server.api.contact; - -import com.easemob.im.server.api.Context; -import com.easemob.im.server.api.contact.user.ContactUser; -import reactor.core.publisher.Flux; -import reactor.core.publisher.Mono; - -/** - * 通讯录API。 - */ -public class ContactApi { - - private ContactUser contactUser; - - public ContactApi(Context context) { - this.contactUser = new ContactUser(context); - } - - /** - * 向用户通讯录添加联系人。 - * - * API使用示例: - *
 {@code
-     * EMService service;
-     * try {
-     *     service.contact().add("user", "contact").block();
-     * } catch (EMException e) {
-     *     e.getErrorCode();
-     *     e.getMessage();
-     * }
-     * }
- * - * @param user 所属用户的用户名 - * @param contact 联系人的用户名 - * @return 成功或错误 - * @see 添加联系人 - */ - public Mono add(String user, String contact) { - return this.contactUser.add(user, contact); - } - - /** - * 从用户通讯录移除联系人 - * - * API使用示例: - *
 {@code
-     * EMService service;
-     * try {
-     *     service.contact().remove("user", "contact").block();
-     * } catch (EMException e) {
-     *     e.getErrorCode();
-     *     e.getMessage();
-     * }
-     * }
- * - * @param user 所属用户的用户名 - * @param contact 联系人的用户名 - * @return 成功或错误 - * @see 移除联系人 - */ - public Mono remove(String user, String contact) { - return this.contactUser.remove(user, contact); - } - - /** - * 获取用户联系人列表。 - * - * API使用示例: - *
 {@code
-     * EMService service;
-     * try {
-     *     List users = service.contact().list("user").collectList().block();
-     * } catch (EMException e) {
-     *     e.getErrorCode();
-     *     e.getMessage();
-     * }
-     * }
- * - * @param user 所属用户的用户名 - * @return 每个联系人的用户名 - * @see 获取联系人列表 - */ - public Flux list(String user) { - return this.contactUser.list(user); - } - -} diff --git a/im-sdk-core/src/main/java/com/easemob/im/server/api/contact/user/ContactUser.java b/im-sdk-core/src/main/java/com/easemob/im/server/api/contact/user/ContactUser.java deleted file mode 100644 index 76cd1ca84..000000000 --- a/im-sdk-core/src/main/java/com/easemob/im/server/api/contact/user/ContactUser.java +++ /dev/null @@ -1,71 +0,0 @@ -package com.easemob.im.server.api.contact.user; - -import com.easemob.im.server.api.Context; -import com.easemob.im.server.api.DefaultErrorMapper; -import com.easemob.im.server.api.ErrorMapper; -import com.easemob.im.server.exception.EMUnknownException; -import reactor.core.publisher.Flux; -import reactor.core.publisher.Mono; - -public class ContactUser { - - private Context context; - - public ContactUser(Context context) { - this.context = context; - } - - public Mono add(String user, String contact) { - return this.context.getHttpClient() - .flatMap(httpClient -> httpClient.post() - .uri(String.format("/users/%s/contacts/users/%s", user, contact)) - .responseSingle((rsp, buf) -> { - return buf.switchIfEmpty( - Mono.error(new EMUnknownException("response is null"))) - .flatMap(byteBuf -> { - ErrorMapper mapper = new DefaultErrorMapper(); - mapper.statusCode(rsp); - mapper.checkError(byteBuf); - return Mono.just(byteBuf); - }); - })) - .then(); - } - - public Mono remove(String user, String contact) { - return this.context.getHttpClient() - .flatMap(httpClient -> httpClient.delete() - .uri(String.format("/users/%s/contacts/users/%s", user, contact)) - .responseSingle((rsp, buf) -> { - return buf.switchIfEmpty( - Mono.error(new EMUnknownException("response is null"))) - .flatMap(byteBuf -> { - ErrorMapper mapper = new DefaultErrorMapper(); - mapper.statusCode(rsp); - mapper.checkError(byteBuf); - return Mono.just(byteBuf); - }); - })) - .then(); - } - - public Flux list(String user) { - return this.context.getHttpClient() - .flatMap(httpClient -> httpClient.get() - .uri(String.format("/users/%s/contacts/users", user)) - .responseSingle((rsp, buf) -> { - return buf.switchIfEmpty( - Mono.error(new EMUnknownException("response is null"))) - .flatMap(byteBuf -> { - ErrorMapper mapper = new DefaultErrorMapper(); - mapper.statusCode(rsp); - mapper.checkError(byteBuf); - return Mono.just(byteBuf); - }); - })) - .map(buf -> this.context.getCodec() - .decode(buf, ContactUserListResponse.class)) - .flatMapIterable(ContactUserListResponse::getUsernames); - } - -} diff --git a/im-sdk-core/src/main/java/com/easemob/im/server/api/contact/user/ContactUserListResponse.java b/im-sdk-core/src/main/java/com/easemob/im/server/api/contact/user/ContactUserListResponse.java deleted file mode 100644 index ce5fdd951..000000000 --- a/im-sdk-core/src/main/java/com/easemob/im/server/api/contact/user/ContactUserListResponse.java +++ /dev/null @@ -1,21 +0,0 @@ -package com.easemob.im.server.api.contact.user; - -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonProperty; - -import java.util.List; - -public class ContactUserListResponse { - @JsonProperty("data") - private List usernames; - - @JsonCreator - public ContactUserListResponse(@JsonProperty("data") List usernames) { - this.usernames = usernames; - } - - public List getUsernames() { - return usernames; - } - -} diff --git a/im-sdk-core/src/main/java/com/easemob/im/server/api/group/GroupApi.java b/im-sdk-core/src/main/java/com/easemob/im/server/api/group/GroupApi.java deleted file mode 100644 index d9abfb672..000000000 --- a/im-sdk-core/src/main/java/com/easemob/im/server/api/group/GroupApi.java +++ /dev/null @@ -1,1440 +0,0 @@ -package com.easemob.im.server.api.group; - -import com.easemob.im.server.api.Context; -import com.easemob.im.server.api.group.admin.GroupAdminAdd; -import com.easemob.im.server.api.group.admin.GroupAdminList; -import com.easemob.im.server.api.group.admin.GroupAdminRemove; -import com.easemob.im.server.api.group.announcement.GroupAnnouncement; -import com.easemob.im.server.api.group.create.CreateGroup; -import com.easemob.im.server.api.group.delete.DeleteGroup; -import com.easemob.im.server.api.group.get.GetGroup; -import com.easemob.im.server.api.group.management.GroupDisable; -import com.easemob.im.server.api.group.management.GroupEnable; -import com.easemob.im.server.api.group.membershipcheck.GroupMembershipCheck; -import com.easemob.im.server.api.group.list.*; -import com.easemob.im.server.api.group.member.add.GroupMemberAdd; -import com.easemob.im.server.api.group.member.list.GroupMemberList; -import com.easemob.im.server.api.group.member.remove.GroupMemberRemove; -import com.easemob.im.server.api.group.settings.UpdateGroup; -import com.easemob.im.server.api.group.settings.UpdateGroupRequest; -import com.easemob.im.server.api.group.assign.AssignGroup; -import com.easemob.im.server.model.EMGroup; -import com.easemob.im.server.model.EMPage; -import com.easemob.im.server.model.EMRemoveMember; -import reactor.core.publisher.Flux; -import reactor.core.publisher.Mono; - -import java.util.List; -import java.util.Map; -import java.util.function.Consumer; - -/** - * 群API。 - */ -public class GroupApi { - - private GroupList groupList; - private CreateGroup createGroup; - private DeleteGroup deleteGroup; - - private GetGroup getGroup; - private UpdateGroup updateGroup; - private AssignGroup assignGroup; - private GroupMembershipCheck groupMembershipCheck; - - private GroupAnnouncement groupAnnouncement; - private GroupMemberList groupMemberList; - private GroupMemberAdd groupMemberAdd; - private GroupMemberRemove groupMemberRemove; - - private GroupAdminList groupAdminList; - private GroupAdminAdd groupAdminAdd; - private GroupAdminRemove groupAdminRemove; - - private GroupDisable groupDisable; - private GroupEnable groupEnable; - - public GroupApi(Context context) { - this.groupList = new GroupList(context); - this.createGroup = new CreateGroup(context); - this.deleteGroup = new DeleteGroup(context); - - this.getGroup = new GetGroup(context); - this.updateGroup = new UpdateGroup(context); - this.assignGroup = new AssignGroup(context); - this.groupMembershipCheck = new GroupMembershipCheck(context); - - this.groupAnnouncement = new GroupAnnouncement(context); - - this.groupMemberList = new GroupMemberList(context); - this.groupMemberAdd = new GroupMemberAdd(context); - this.groupMemberRemove = new GroupMemberRemove(context); - - this.groupAdminList = new GroupAdminList(context); - this.groupAdminAdd = new GroupAdminAdd(context); - this.groupAdminRemove = new GroupAdminRemove(context); - - this.groupDisable = new GroupDisable(context); - this.groupEnable = new GroupEnable(context); - } - - /** - * 创建公开群。 - *

- * 需要注意的是,目前公开群不允许成员邀请其他用户加入。如果要允许,可以用修改群API设置: - *

- * API使用示例: - *

 {@code
-     * EMService service;
-     * List members = new ArrayList<>();
-     * members.add("userA");
-     * try {
-     *     String groupId = service.group().createPublicGroup("owner", "groupName", "description", members, 200, true).block();
-     * } catch (EMException e) {
-     *     e.getErrorCode();
-     *     e.getMessage();
-     * }
-     * }
- * - * @param owner 群主的用户名 - * @param groupName 群名,最大长度为 128 字符 - * @param description 群介绍,最大长度为 512 字符 - * @param members 初始群成员的用户名列表 - * @param maxMembers 群最大成员数 - * @param needApproveToJoin 新成员加入需要管理员审批 - * @return 群id或错误 - * @see 创建群 - */ - public Mono createPublicGroup(String owner, String groupName, String description, - List members, int maxMembers, boolean needApproveToJoin) { - return this.createGroup - .publicGroup(owner, groupName, description, members, maxMembers, needApproveToJoin); - } - - /** - * 创建公开群。 - *

- * 需要注意的是,目前公开群不允许成员邀请其他用户加入。如果要允许,可以用修改群API设置: - *

- * API使用示例: - *

 {@code
-     * EMService service;
-     * List members = new ArrayList<>();
-     * members.add("userA");
-     * try {
-     *     String groupId = service.group().createPublicGroup("owner", "groupName", "description", members, 200, true, "custom").block();
-     * } catch (EMException e) {
-     *     e.getErrorCode();
-     *     e.getMessage();
-     * }
-     * }
- * - *
{@code
-     * EMService service;
-     * try {
-     *     // 修改群组API,允许成员邀请其他用户加入
-     *     service.group().updateSetting("group-id", settings -> settings.memberCanInvite(true)).block();
-     * } catch (EMException e) {
-     *     e.getErrorCode();
-     *     e.getMessage();
-     * }
-     * }
- * - * @param owner 群主的用户名 - * @param groupName 群名,最大长度为 128 字符 - * @param description 群介绍,最大长度为 512 字符 - * @param members 初始群成员的用户名列表 - * @param maxMembers 群最大成员数 - * @param needApproveToJoin 新成员加入需要管理员审批 - * @param custom 群组扩展信息,例如可以给群组添加业务相关的标记,最大长度为 1024 字符 - * @return 群id或错误 - * @see 创建群 - */ - public Mono createPublicGroup(String owner, String groupName, String description, - List members, int maxMembers, boolean needApproveToJoin, String custom) { - return this.createGroup - .publicGroup(owner, groupName, description, members, maxMembers, needApproveToJoin, custom); - } - - /** - * 创建公开群。 - *

- * 需要注意的是,目前公开群不允许成员邀请其他用户加入。如果要允许,可以用修改群API设置: - *

- * API使用示例: - *

 {@code
-     * EMService service;
-     * List members = new ArrayList<>();
-     * members.add("userA");
-     * try {
-     *     String groupId = service.group().createPublicGroup("owner", "groupName", "description", members, 200, true, "custom", true).block();
-     * } catch (EMException e) {
-     *     e.getErrorCode();
-     *     e.getMessage();
-     * }
-     * }
- * - *
{@code
-     * EMService service;
-     * try {
-     *     // 修改群组API,允许成员邀请其他用户加入
-     *     service.group().updateSetting("group-id", settings -> settings.memberCanInvite(true)).block();
-     * } catch (EMException e) {
-     *     e.getErrorCode();
-     *     e.getMessage();
-     * }
-     * }
- * - * @param owner 群主的用户名 - * @param groupName 群名,最大长度为 128 字符 - * @param description 群介绍,最大长度为 512 字符 - * @param members 初始群成员的用户名列表 - * @param maxMembers 群最大成员数 - * @param needApproveToJoin 新成员加入需要管理员审批 - * @param custom 群组扩展信息,例如可以给群组添加业务相关的标记,最大长度为 1024 字符 - * @param needVerify 是否审核群名称(付费功能,需联系商务开通) - * @return 群id或错误 - * @see 创建群 - */ - public Mono createPublicGroup(String owner, String groupName, String description, - List members, int maxMembers, boolean needApproveToJoin, String custom, boolean needVerify) { - return this.createGroup - .publicGroup(owner, groupName, description, members, maxMembers, needApproveToJoin, custom, needVerify); - } - - /** - * 创建大型公开群。 - *

- * 大型群,群成员总数超过 3000。大型群不支持离线推送。如需默认创建大型群,请联系环信商务。 - *

- * 需要注意的是,目前公开群不允许成员邀请其他用户加入。如果要允许,可以用修改群API设置: - *

- * API使用示例: - *

 {@code
-     * EMService service;
-     * List members = new ArrayList<>();
-     * members.add("userA");
-     * try {
-     *     String groupId = service.group().createLargePublicGroup("owner", "groupName", "description", , members, 200, true, "custom", true).block();
-     * } catch (EMException e) {
-     *     e.getErrorCode();
-     *     e.getMessage();
-     * }
-     * }
- * - *
{@code
-     * EMService service;
-     * try {
-     *     // 修改群组API,允许成员邀请其他用户加入
-     *     service.group().updateSetting("group-id", settings -> settings.memberCanInvite(true)).block();
-     * } catch (EMException e) {
-     *     e.getErrorCode();
-     *     e.getMessage();
-     * }
-     * }
- * - * @param owner 群主的用户名 - * @param groupName 群名,最大长度为 128 字符 - * @param description 群介绍,最大长度为 512 字符 - * @param members 初始群成员的用户名列表 - * @param maxMembers 群最大成员数 - * @param needApproveToJoin 新成员加入需要管理员审批 - * @param custom 群组扩展信息,例如可以给群组添加业务相关的标记,最大长度为 1024 字符 - * @param needVerify 是否审核群名称(付费功能,需联系商务开通) - * @return 群id或错误 - * @see 创建群 - */ - public Mono createLargePublicGroup(String owner, String groupName, String description, - List members, int maxMembers, boolean needApproveToJoin, String custom, boolean needVerify) { - return this.createGroup - .largePublicGroup(owner, groupName, description, members, maxMembers, needApproveToJoin, custom, needVerify); - } - - /** - * 指定群组ID,创建公开群。 - * 需要联系商务开通此功能才可以使用。 - *

- * 需要注意的是,目前公开群不允许成员邀请其他用户加入。如果要允许,可以用修改群API设置: - *

- * API使用示例: - *

 {@code
-     * EMService service;
-     * List members = new ArrayList<>();
-     * members.add("userA");
-     * try {
-     *     String groupId = service.group().createPublicGroup("groupId", "owner", "groupName", "description", members, 200, true, "custom", true).block();
-     * } catch (EMException e) {
-     *     e.getErrorCode();
-     *     e.getMessage();
-     * }
-     * }
- * - *
{@code
-     * EMService service;
-     * try {
-     *     // 修改群组API,允许成员邀请其他用户加入
-     *     service.group().updateSetting("group-id", settings -> settings.memberCanInvite(true)).block();
-     * } catch (EMException e) {
-     *     e.getErrorCode();
-     *     e.getMessage();
-     * }
-     * }
- * - * @param groupId 群组id - * @param owner 群主的用户名 - * @param groupName 群名,最大长度为 128 字符 - * @param description 群介绍,最大长度为 512 字符 - * @param members 初始群成员的用户名列表 - * @param maxMembers 群最大成员数 - * @param needApproveToJoin 新成员加入需要管理员审批 - * @param custom 群组扩展信息,例如可以给群组添加业务相关的标记,最大长度为 1024 字符 - * @param needVerify 是否审核群名称(付费功能,需联系商务开通) - * @return 群id或错误 - * @see 创建群 - */ - public Mono createPublicGroup(String groupId, String owner, String groupName, String description, - List members, int maxMembers, boolean needApproveToJoin, String custom, boolean needVerify) { - return this.createGroup.publicGroup(groupId, owner, groupName, description, members, - maxMembers, needApproveToJoin, custom, needVerify); - } - - /** - * 指定群组ID,创建大型公开群。 - * 需要联系商务开通此功能才可以使用。 - *

- * 大型群,群成员总数超过 3000。大型群不支持离线推送。如需默认创建大型群,请联系环信商务。 - *

- * 需要注意的是,目前公开群不允许成员邀请其他用户加入。如果要允许,可以用修改群API设置: - *

- * API使用示例: - *

 {@code
-     * EMService service;
-     * List members = new ArrayList<>();
-     * members.add("userA");
-     * try {
-     *     String groupId = service.group().createLargePublicGroup("groupId", "owner", "groupName", "description", members, 200, true, "custom", true).block();
-     * } catch (EMException e) {
-     *     e.getErrorCode();
-     *     e.getMessage();
-     * }
-     * }
- * - *
{@code
-     * EMService service;
-     * try {
-     *     // 修改群组API,允许成员邀请其他用户加入
-     *     service.group().updateSetting("group-id", settings -> settings.memberCanInvite(true)).block();
-     * } catch (EMException e) {
-     *     e.getErrorCode();
-     *     e.getMessage();
-     * }
-     * }
- * - * @param groupId 群组id - * @param owner 群主的用户名 - * @param groupName 群名,最大长度为 128 字符 - * @param description 群介绍,最大长度为 512 字符 - * @param members 初始群成员的用户名列表 - * @param maxMembers 群最大成员数 - * @param needApproveToJoin 新成员加入需要管理员审批 - * @param custom 群组扩展信息,例如可以给群组添加业务相关的标记,最大长度为 1024 字符 - * @param needVerify 是否审核群名称(付费功能,需联系商务开通) - * @return 群id或错误 - * @see 创建群 - */ - public Mono createLargePublicGroup(String groupId, String owner, String groupName, String description, - List members, int maxMembers, boolean needApproveToJoin, String custom, boolean needVerify) { - return this.createGroup.largePublicGroup(groupId, owner, groupName, description, members, - maxMembers, needApproveToJoin, custom, needVerify); - } - - /** - * 创建私有群。 - *

- * API使用示例: - *

 {@code
-     * EMService service;
-     * List members = new ArrayList<>();
-     * members.add("userA");
-     * try {
-     *     String groupId = service.group().privateGroup("owner", "groupName", "description", members, 200, true).block();
-     * } catch (EMException e) {
-     *     e.getErrorCode();
-     *     e.getMessage();
-     * }
-     * }
- * - * @param owner 群主的用户名 - * @param groupName 群名,最大长度为 128 字符 - * @param description 群介绍,最大长度为 512 字符 - * @param members 初始群成员的用户名列表 - * @param maxMembers 群最大成员数 - * @param canMemberInvite 普通群成员是否允许邀请新用户入群 - * @return 群id或错误 - * @see 创建群 - */ - public Mono createPrivateGroup(String owner, String groupName, String description, - List members, int maxMembers, boolean canMemberInvite) { - return this.createGroup - .privateGroup(owner, groupName, description, members, maxMembers, canMemberInvite); - } - - /** - * 创建私有群。 - *

- * API使用示例: - *

 {@code
-     * EMService service;
-     * List members = new ArrayList<>();
-     * members.add("userA");
-     * try {
-     *     String groupId = service.group().privateGroup("owner", "groupName", "description", members, 200, true, "custom").block();
-     * } catch (EMException e) {
-     *     e.getErrorCode();
-     *     e.getMessage();
-     * }
-     * }
- * - * @param owner 群主的用户名 - * @param groupName 群名,最大长度为 128 字符 - * @param description 群介绍,最大长度为 512 字符 - * @param members 初始群成员的用户名列表 - * @param maxMembers 群最大成员数 - * @param canMemberInvite 普通群成员是否允许邀请新用户入群 - * @param custom 群组扩展信息,例如可以给群组添加业务相关的标记,最大长度为 1024 字符 - * @return 群id或错误 - * @see 创建群 - */ - public Mono createPrivateGroup(String owner, String groupName, String description, - List members, int maxMembers, boolean canMemberInvite, String custom) { - return this.createGroup - .privateGroup(owner, groupName, description, members, maxMembers, canMemberInvite, custom); - } - - /** - * 创建私有群。 - *

- * API使用示例: - *

 {@code
-     * EMService service;
-     * List members = new ArrayList<>();
-     * members.add("userA");
-     * try {
-     *     String groupId = service.group().privateGroup("owner", "groupName", "description", members, 200, true, true, true, "custom").block();
-     * } catch (EMException e) {
-     *     e.getErrorCode();
-     *     e.getMessage();
-     * }
-     * }
- * - * @param owner 群主的用户名 - * @param groupName 群名,最大长度为 128 字符 - * @param description 群介绍,最大长度为 512 字符 - * @param members 初始群成员的用户名列表 - * @param maxMembers 群最大成员数 - * @param canMemberInvite 普通群成员是否允许邀请新用户入群 - * @param needInviteConfirm 邀请加群,受邀用户是否需要确认 - * @param needApproveToJoin 新成员加入是否需要管理员审批 - * @param custom 群组扩展信息,例如可以给群组添加业务相关的标记,最大长度为 1024 字符 - * @return 群id或错误 - * @see 创建群 - */ - public Mono createPrivateGroup(String owner, String groupName, String description, - List members, int maxMembers, boolean canMemberInvite, boolean needApproveToJoin, boolean needInviteConfirm, String custom) { - return this.createGroup - .privateGroup(owner, groupName, description, members, maxMembers, canMemberInvite, needInviteConfirm, needApproveToJoin, custom); - } - - /** - * 创建私有群。 - *

- * API使用示例: - *

 {@code
-     * EMService service;
-     * List members = new ArrayList<>();
-     * members.add("userA");
-     * try {
-     *     String groupId = service.group().privateGroup("owner", "groupName", "description", members, 200, true, true, true, "custom", true).block();
-     * } catch (EMException e) {
-     *     e.getErrorCode();
-     *     e.getMessage();
-     * }
-     * }
- * - * @param owner 群主的用户名 - * @param groupName 群名,最大长度为 128 字符 - * @param description 群介绍,最大长度为 512 字符 - * @param members 初始群成员的用户名列表 - * @param maxMembers 群最大成员数 - * @param canMemberInvite 普通群成员是否允许邀请新用户入群 - * @param needInviteConfirm 邀请加群,受邀用户是否需要确认 - * @param needApproveToJoin 新成员加入是否需要管理员审批 - * @param custom 群组扩展信息,例如可以给群组添加业务相关的标记,最大长度为 1024 字符 - * @param needVerify 是否审核群名称(付费功能,需联系商务开通) - * @return 群id或错误 - * @see 创建群 - */ - public Mono createPrivateGroup(String owner, String groupName, String description, - List members, int maxMembers, boolean canMemberInvite, boolean needApproveToJoin, - boolean needInviteConfirm, String custom, boolean needVerify) { - return this.createGroup - .privateGroup(owner, groupName, description, members, maxMembers, canMemberInvite, needInviteConfirm, needApproveToJoin, custom, needVerify); - } - - /** - * 创建大型私有群。 - *

- * 大型群,群成员总数超过 3000。大型群不支持离线推送。如需默认创建大型群,请联系环信商务。 - *

- * API使用示例: - *

 {@code
-     * EMService service;
-     * List members = new ArrayList<>();
-     * members.add("userA");
-     * try {
-     *     String groupId = service.group().createLargePrivateGroup("owner", "groupName", "description", members, 200, true, true, true, "custom", true).block();
-     * } catch (EMException e) {
-     *     e.getErrorCode();
-     *     e.getMessage();
-     * }
-     * }
- * - * @param owner 群主的用户名 - * @param groupName 群名,最大长度为 128 字符 - * @param description 群介绍,最大长度为 512 字符 - * @param members 初始群成员的用户名列表 - * @param maxMembers 群最大成员数 - * @param canMemberInvite 普通群成员是否允许邀请新用户入群 - * @param needInviteConfirm 邀请加群,受邀用户是否需要确认 - * @param needApproveToJoin 新成员加入是否需要管理员审批 - * @param custom 群组扩展信息,例如可以给群组添加业务相关的标记,最大长度为 1024 字符 - * @param needVerify 是否审核群名称(付费功能,需联系商务开通) - * @return 群id或错误 - * @see 创建群 - */ - public Mono createLargePrivateGroup(String owner, String groupName, String description, - List members, int maxMembers, boolean canMemberInvite, boolean needApproveToJoin, - boolean needInviteConfirm, String custom, boolean needVerify) { - return this.createGroup.largePrivateGroup(owner, groupName, description, members, - maxMembers, canMemberInvite, needInviteConfirm, needApproveToJoin, custom, - needVerify); - } - - /** - * 指定群组ID,创建私有群。 - * 需要联系商务开通此功能才可以使用。 - *

- * API使用示例: - *

 {@code
-     * EMService service;
-     * List members = new ArrayList<>();
-     * members.add("userA");
-     * try {
-     *     String groupId = service.group().privateGroup("groupId", "owner", "groupName", "description", members, 200, true, true, true, "custom", true).block();
-     * } catch (EMException e) {
-     *     e.getErrorCode();
-     *     e.getMessage();
-     * }
-     * }
- * - * @param groupId 群组ID - * @param owner 群主的用户名 - * @param groupName 群名,最大长度为 128 字符 - * @param description 群介绍,最大长度为 512 字符 - * @param members 初始群成员的用户名列表 - * @param maxMembers 群最大成员数 - * @param canMemberInvite 普通群成员是否允许邀请新用户入群 - * @param needInviteConfirm 邀请加群,受邀用户是否需要确认 - * @param needApproveToJoin 新成员加入是否需要管理员审批 - * @param custom 群组扩展信息,例如可以给群组添加业务相关的标记,最大长度为 1024 字符 - * @param needVerify 是否审核群名称(付费功能,需联系商务开通) - * @return 群id或错误 - * @see 创建群 - */ - public Mono createPrivateGroup(String groupId, String owner, String groupName, String description, - List members, int maxMembers, boolean canMemberInvite, boolean needApproveToJoin, - boolean needInviteConfirm, String custom, boolean needVerify) { - return this.createGroup - .privateGroup(groupId, owner, groupName, description, members, maxMembers, canMemberInvite, needInviteConfirm, needApproveToJoin, custom, needVerify); - } - - /** - * 指定群组ID,创建大型私有群。 - * 需要联系商务开通此功能才可以使用。 - *

- * 大型群,群成员总数超过 3000。大型群不支持离线推送。如需默认创建大型群,请联系环信商务。 - *

- * API使用示例: - *

 {@code
-     * EMService service;
-     * List members = new ArrayList<>();
-     * members.add("userA");
-     * try {
-     *     String groupId = service.group().createLargePrivateGroup("groupId", "owner", "groupName", "description", members, 200, true, true, true, "custom", true).block();
-     * } catch (EMException e) {
-     *     e.getErrorCode();
-     *     e.getMessage();
-     * }
-     * }
- * - * @param groupId 群组ID - * @param owner 群主的用户名 - * @param groupName 群名,最大长度为 128 字符 - * @param description 群介绍,最大长度为 512 字符 - * @param members 初始群成员的用户名列表 - * @param maxMembers 群最大成员数 - * @param canMemberInvite 普通群成员是否允许邀请新用户入群 - * @param needInviteConfirm 邀请加群,受邀用户是否需要确认 - * @param needApproveToJoin 新成员加入是否需要管理员审批 - * @param custom 群组扩展信息,例如可以给群组添加业务相关的标记,最大长度为 1024 字符 - * @param needVerify 是否审核群名称(付费功能,需联系商务开通) - * @return 群id或错误 - * @see 创建群 - */ - public Mono createLargePrivateGroup(String groupId, String owner, String groupName, String description, - List members, int maxMembers, boolean canMemberInvite, boolean needApproveToJoin, - boolean needInviteConfirm, String custom, boolean needVerify) { - return this.createGroup - .largePrivateGroup(groupId, owner, groupName, description, members, maxMembers, canMemberInvite, needInviteConfirm, needApproveToJoin, custom, needVerify); - } - - /** - * 注销群。 - *

- * 请谨慎使用。 - *

- * API使用示例: - *

 {@code
-     * EMService service;
-     * try {
-     *     String groupId = service.group().destroyGroup("groupId").block();
-     * } catch (EMException e) {
-     *     e.getErrorCode();
-     *     e.getMessage();
-     * }
-     * }
- * - * @param groupId 群id - * @return 成功或错误 - */ - public Mono destroyGroup(String groupId) { - return this.deleteGroup.execute(groupId); - } - - /** - * 获取全部群列表。 - *

- * API使用示例: - *

 {@code
-     * EMService service;
-     * try {
-     *     List groups = service.group().listAllGroups().collectList().block();
-     * } catch (EMException e) {
-     *     e.getErrorCode();
-     *     e.getMessage();
-     * }
-     * }
- * - * @return 每个群id或错误 - * @see 获取群列表 - */ - public Flux listAllGroups() { - return this.groupList.all(20); - } - - /** - * 获取全部群列表,返回值携带群组信息。 - *

- * API使用示例: - *

 {@code
-     * EMService service;
-     * try {
-     *     List groups = service.group().listAllGroupsWithInfo().collectList().block();
-     * } catch (EMException e) {
-     *     e.getErrorCode();
-     *     e.getMessage();
-     * }
-     * }
- * - * @return 每个群组或错误 - * @see 获取群列表 - */ - public Flux listAllGroupsWithInfo() { - return this.groupList.allWithInfo(20); - } - - /** - * 分页获取群列表。 - *

- * 初次调用时,{@code cursor} 传 {@code null}。之后的调用,{@code cursor} 传上次返回的值。 - *

- * API使用示例: - *

{@code
-     * EMPage page = null;
-     * try {
-     *     page = service.group().listGroups(10, null).block();
-     *     List groupIds = page.getValues();
-     *     System.out.println("群组列表:" + groupIds);
-     * } catch (EMException e) {
-     *     e.getErrorCode();
-     *     e.getMessage();
-     * }
-     *
-     * // ... do something with the groupIds ...
-     * if (page != null) {
-     *      String cursor = page.getCursor();
-     *      // cursor == null indicates the end of the list
-     *      while (cursor != null) {
-     *          try {
-     *              page = service.group().listGroups(10, cursor).block();
-     *              System.out.println("群组列表:" + page.getValues());
-     *              // ... do something to the groupIds ...
-     *              cursor = page.getCursor();
-     *          } catch (EMException e) {
-     *              e.getErrorCode();
-     *              e.getMessage();
-     *          }
-     *      }
-     * }
-     * }
- * - * @param limit 每次取回多少个群id - * @param cursor 上次返回的{@code cursor} - * @return 群列表响应或错误 - * @see com.easemob.im.server.model.EMPage - * @see 获取群列表 - */ - public Mono> listGroups(int limit, String cursor) { - return this.groupList.next(limit, cursor); - } - - /** - * 分页获取群列表,返回值携带群组信息。 - *

- * 初次调用时,{@code cursor} 传 {@code null}。之后的调用,{@code cursor} 传上次返回的值。 - *

- * API使用示例: - *

{@code
-     * EMPage page = null;
-     * try {
-     *     page = service.group().listGroupsWithInfo(10, null).block();
-     *     List groupIds = page.getValues();
-     *     System.out.println("群组列表:" + groupIds);
-     * } catch (EMException e) {
-     *     e.getErrorCode();
-     *     e.getMessage();
-     * }
-     *
-     * // ... do something with the groupIds ...
-     * if (page != null) {
-     *      String cursor = page.getCursor();
-     *      // cursor == null indicates the end of the list
-     *      while (cursor != null) {
-     *          try {
-     *              page = service.group().listGroupsWithInfo(10, cursor).block();
-     *              System.out.println("群组列表:" + page.getValues());
-     *              // ... do something to the groupIds ...
-     *              cursor = page.getCursor();
-     *          } catch (EMException e) {
-     *              e.getErrorCode();
-     *              e.getMessage();
-     *          }
-     *      }
-     * }
-     * }
- * - * @param limit 每次取回多少个群组 - * @param cursor 上次返回的{@code cursor} - * @return 群列表响应或错误 - * @see com.easemob.im.server.model.EMPage - * @see 获取群列表 - */ - public Mono> listGroupsWithInfo(int limit, String cursor) { - return this.groupList.nextWithInfo(limit, cursor); - } - - /** - * 获取用户加入的所有群组。 - *

- * API使用示例: - *

 {@code
-     * EMService service;
-     * try {
-     *     List groups = service.group().listGroupsUserJoined("username").collectList().block();
-     * } catch (EMException e) {
-     *     e.getErrorCode();
-     *     e.getMessage();
-     * }
-     * }
- * - * @param username the username - * @return A {@code Flux} which emits {@code EMGroup} on successful. - */ - public Flux listGroupsUserJoined(String username) { - return this.groupList.userJoined(username); - } - - /** - * 获取用户加入的所有群组,返回值携带群组信息。 - *

- * API使用示例: - *

 {@code
-     * EMService service;
-     * try {
-     *     List groups = service.group().listGroupsUserJoined("username").collectList().block();
-     * } catch (EMException e) {
-     *     e.getErrorCode();
-     *     e.getMessage();
-     * }
-     * }
- * - * @param username the username - * @return A {@code Flux} which emits {@code EMGroup} on successful. - */ - public Flux listGroupsUserJoinedWithInfo(String username) { - return this.groupList.userJoinedWithInfo(username); - } - - /** - * 分页获取用户加入的所有群组,返回值携带群组信息。 - *

- * 初次调用时,{@code cursor} 传 {@code null}。之后的调用,{@code cursor} 传上次返回的值。 - *

- * API使用示例: - *

{@code
-     * try {
-     *     List groupResources = service.group().listGroupsUserJoinedWithInfo("username", 1, 10).block();
-     *     if (groupResources != null && groupResources.size() > 0) {
-     *          groupResources.forEach(groupResource -> {
-     *          System.out.println("groupId : " + groupResource.getGroupId());
-     *          System.out.println("groupName : " + groupResource.getGroupName());
-     *      });
-     *     }
-     * } catch (EMException e) {
-     *     e.getErrorCode();
-     *     e.getMessage();
-     * }
-     * }
- * - * @param username the username - * @param pageNum 当前页码 - * @param pageSize 每页获取已加入的群组数量 - * @return 群列表响应或错误 - */ - public Mono> listGroupsUserJoinedWithInfo(String username, int pageNum, int pageSize) { - return this.groupList.userJoinedWithInfo(username, pageNum, pageSize); - } - - /** - * 获取群详情。 - *

- * API使用示例: - *

 {@code
-     * EMService service;
-     * try {
-     *     EMGroup group = service.group().getGroup("groupId").block();
-     *     String groupName = group.getName();
-     * } catch (EMException e) {
-     *     e.getErrorCode();
-     *     e.getMessage();
-     * }
-     * }
- * - * @param groupId 群id - * @return 群详情或错误 - * @see 获取群详情 - */ - public Mono getGroup(String groupId) { - return this.getGroup.execute(groupId); - } - - /** - * 获取多个群详情。 - *

- * API使用示例: - *

 {@code
-     * EMService service;
-     * try {
-     *     List groupIdList = new ArrayList<>();
-     *     groupIdList.add("193100825821185");
-     *     groupIdList.add("193100825821186");
-     *
-     *     List groupList = service.group().getGroupList(groupIdList).block();
-     * } catch (EMException e) {
-     *     e.getErrorCode();
-     *     e.getMessage();
-     * }
-     * }
- * - * @param groupIdList 群id列表 - * @return 群详情或错误 - * @see 获取群详情 - */ - public Mono> getGroupList(List groupIdList) { - return this.getGroup.execute(groupIdList); - } - - /** - * 修改群详情。 - *

- * 支持修改的参数见{@code GroupSettingsUpdateRequest} - *

- * API使用示例: - *

- * 比如,更新群最大成员数: - *

{@code
-     * EMService service;
-     * try {
-     *     service.group().updateGroup("1", settings -> settings.maxMembers(100)).block();
-     * } catch (EMException e) {
-     *     e.getErrorCode();
-     *     e.getMessage();
-     * }
-     * }
- * - * @param groupId 群id - * @param customizer 请求定制器 - * @return 成功或错误 - * @see UpdateGroupRequest - * @see 修改群详情 - */ - public Mono updateGroup(String groupId, Consumer customizer) { - return this.updateGroup.update(groupId, customizer); - } - - /** - * 修改群主。新群主需要已经是群成员,否则会报错{@code EMForbiddenException}。 - *

- * API使用示例: - *

 {@code
-     * EMService service;
-     * try {
-     *     service.group().updateGroupOwner("groupId", "username").block();
-     * } catch (EMException e) {
-     *     e.getErrorCode();
-     *     e.getMessage();
-     * }
-     * }
- * - * @param groupId 群id - * @param username 新群主的用户名 - * @return 成功或错误 - * @see 修改群主 - */ - public Mono updateGroupOwner(String groupId, String username) { - return this.updateGroup.updateOwner(groupId, username); - } - - /** - * 获取群公告。 - *

- * API使用示例: - *

 {@code
-     * EMService service;
-     * try {
-     *     String groupAnnouncement = service.group().getGroupAnnouncement("groupId").block();
-     * } catch (EMException e) {
-     *     e.getErrorCode();
-     *     e.getMessage();
-     * }
-     * }
- * - * @param groupId 群id - * @return 群公告或错误 - * @see 获取群公告 - */ - public Mono getGroupAnnouncement(String groupId) { - return this.groupAnnouncement.get(groupId); - } - - /** - * 更新群公告。 - *

- * API使用示例: - *

 {@code
-     * EMService service;
-     * try {
-     *     service.group().updateGroupAnnouncement("groupId", "announcement").block();
-     * } catch (EMException e) {
-     *     e.getErrorCode();
-     *     e.getMessage();
-     * }
-     * }
- * - * @param groupId 群id - * @param announcement 群公告 - * @return 成功或错误 - * @see 更新群公告 - */ - public Mono updateGroupAnnouncement(String groupId, String announcement) { - return this.groupAnnouncement.set(groupId, announcement); - } - - /** - * 获取群全部成员,不包括群组的 Owner。 - *

- * API使用示例: - *

 {@code
-     * EMService service;
-     * try {
-     *     List members = service.group().listAllGroupMembers("groupId").collectList().block();
-     * } catch (EMException e) {
-     *     e.getErrorCode();
-     *     e.getMessage();
-     * }
-     * }
- * - * @param groupId 群id - * @return 每个群成员或错误 - * @see 获取群成员 - */ - public Flux listAllGroupMembers(String groupId) { - return this.groupMemberList.all(groupId, 20, null); - } - - /** - * 获取群全部成员,不包括群组的 Owner。 - *

- * API使用示例: - *

 {@code
-     * EMService service;
-     * try {
-     *     List members = service.group().listAllGroupMembers("groupId", "asc").collectList().block();
-     * } catch (EMException e) {
-     *     e.getErrorCode();
-     *     e.getMessage();
-     * }
-     * }
- * - * @param groupId 群id - * @param sort 群成员排序方法 asc:根据加入顺序升序排序 desc:根据加入顺序降序排序 - * @return 每个群成员或错误 - * @see 获取群成员 - */ - public Flux listAllGroupMembers(String groupId, String sort) { - return this.groupMemberList.all(groupId, 20, sort); - } - - /** - * 获取群全部成员,包括群组的 Owner。 - *

- * API使用示例: - *

 {@code
-     * EMService service;
-     * try {
-     *     List> members = service.group().listAllGroupMembersIncludeOwner("groupId", "asc").collectList().block();
-     * } catch (EMException e) {
-     *     e.getErrorCode();
-     *     e.getMessage();
-     * }
-     * }
- * - * @param groupId 群id - * @param sort asc:根据加入顺序升序排序 desc:根据加入顺序降序排序 - * @return 每个群成员或错误 - * @see 获取群成员 - */ - public Flux> listAllGroupMembersIncludeOwner(String groupId, String sort) { - return this.groupMemberList.allIncludeOwner(groupId, 20, sort); - } - - /** - * 分页获取群组成员列表,包括群组的 Owner。 - *

- * API使用示例: - *

 {@code
-     * EMService service;
-     * EMPage page = null;
-     * try {
-     *     List> members = service.room().listGroupMembersIncludeOwner(groupId, 1, 10, asc).block();
-     *     System.out.println("群组成员列表:" + members);
-     * } catch (EMException e) {
-     *     e.getErrorCode();
-     *     e.getMessage();
-     * }
-     *}
- * - * @param groupId 群组id - * @param pageNum 当前页码。默认从第 1 页开始获取 - * @param pageSize 每页期望返回的群组成员数量。取值范围为[1,100]。默认为 10。 - * @param sort asc:根据加入顺序升序排序 desc:根据加入顺序降序排序 - * @return 获取聊天室成员响应或错误 - * @see 获取群成员 - */ - public Mono>> listGroupMembersIncludeOwner(String groupId, int pageNum, int pageSize, String sort) { - if (pageNum < 1) { - pageNum = 1; - } - - if (pageSize < 1) { - pageSize = 20; - } - - return this.groupMemberList.nextIncludeOwner(groupId, pageNum, pageSize, sort).map( - ListGroupMembersResponse::getMembers); - } - - /** - * 分页获取群成员。 - *

- * API使用示例: - *

- * 首次调用时,{@code cursor} 传 {@code null}。之后每次调用,{@code cursor} 传上次返回的值。 - *

- * 比如: - * - *

{@code
-     * EMService service;
-     * EMPage page = null;
-     * try {
-     *     page = service.group().listGroupMembers(groupId, 1, null).block();
-     *     List members = page.getValues();
-     *     System.out.println("群组成员列表:" + members);
-     * } catch (EMException e) {
-     *     e.getErrorCode();
-     *     e.getMessage();
-     * }
-     *
-     * // ... do something to the members ...
-     * if (page != null) {
-     *      String cursor = page.getCursor();
-     *      while (cursor != null) {
-     *              try {
-     *              page = service.group().listGroupMembers(groupId, 1, cursor).block();
-     *              System.out.println("群组成员列表:" + page.getValues());
-     *              // ... do something to the members ...
-     *              cursor = page.getCursor();
-     *          } catch (EMException e) {
-     *              e.getErrorCode();
-     *              e.getMessage();
-     *          }
-     *      }
-     * }
-     * }
- * - * @param groupId 群id - * @param limit 返回多少群成员id - * @param cursor 开始位置 - * @return 获取群成员响应或错误 - * @see com.easemob.im.server.api.group.member.list.GroupMemberListResponse - * @see 获取群成员 - */ - public Mono> listGroupMembers(String groupId, int limit, String cursor) { - return this.groupMemberList.next(groupId, limit, cursor, null); - } - - /** - * 分页获取群成员。 - *

- * API使用示例: - *

- * 首次调用时,{@code cursor} 传 {@code null}。之后每次调用,{@code cursor} 传上次返回的值。 - *

- * 比如: - * - *

{@code
-     * EMService service;
-     * EMPage page = null;
-     * try {
-     *     page = service.group().listGroupMembers(groupId, 1, null, "asc").block();
-     *     List members = page.getValues();
-     *     System.out.println("群组成员列表:" + members);
-     * } catch (EMException e) {
-     *     e.getErrorCode();
-     *     e.getMessage();
-     * }
-     *
-     * // ... do something to the members ...
-     * if (page != null) {
-     *      String cursor = page.getCursor();
-     *      while (cursor != null) {
-     *              try {
-     *              page = service.group().listGroupMembers(groupId, 1, cursor, "asc").block();
-     *              System.out.println("群组成员列表:" + page.getValues());
-     *              // ... do something to the members ...
-     *              cursor = page.getCursor();
-     *          } catch (EMException e) {
-     *              e.getErrorCode();
-     *              e.getMessage();
-     *          }
-     *      }
-     * }
-     * }
- * - * @param groupId 群id - * @param limit 返回多少群成员id - * @param cursor 开始位置 - * @param sort 群成员排序方法 asc:根据加入顺序升序排序 desc:根据加入顺序降序排序 - * @return 获取群成员响应或错误 - * @see com.easemob.im.server.api.group.member.list.GroupMemberListResponse - * @see 获取群成员 - */ - public Mono> listGroupMembers(String groupId, int limit, String cursor, String sort) { - return this.groupMemberList.next(groupId, limit, cursor, sort); - } - - /** - * 添加群成员(单个)。 - *

- * API使用示例: - *

 {@code
-     * EMService service;
-     * try {
-     *     service.group().addGroupMember("groupId", "username").block();
-     * } catch (EMException e) {
-     *     e.getErrorCode();
-     *     e.getMessage();
-     * }
-     * }
- * - * @param groupId 群id - * @param username 要添加的用户的用户名 - * @return 成功或错误 - * @see 添加群成员 - */ - public Mono addGroupMember(String groupId, String username) { - return this.groupMemberAdd.single(groupId, username); - } - - /** - * 添加群成员(多个)。 - *

- * API使用示例: - *

 {@code
-     * EMService service;
-     * try {
-     *     List members = new ArrayList<>();
-     *     members.add("member1");
-     *     members.add("member2");
-     *
-     *     service.group().addGroupMembers("groupId", members).block();
-     * } catch (EMException e) {
-     *     e.getErrorCode();
-     *     e.getMessage();
-     * }
-     * }
- * - * @param groupId 群id - * @param usernames 要添加的用户的用户名列表 - * @return 成功或错误 - * @see 添加群成员(多个) - */ - public Mono addGroupMembers(String groupId, List usernames) { - return this.groupMemberAdd.batch(groupId, usernames); - } - - /** - * 移除群成员。 - *

- * API使用示例: - *

 {@code
-     * EMService service;
-     * try {
-     *     service.group().removeGroupMember("groupId", "username").block();
-     * } catch (EMException e) {
-     *     e.getErrorCode();
-     *     e.getMessage();
-     * }
-     * }
- * - * @param groupId 群id - * @param username 要移除的用户的用户名 - * @return 成功或错误 - * @see 移除群成员 - */ - public Mono removeGroupMember(String groupId, String username) { - return this.groupMemberRemove.single(groupId, username); - } - - /** - * 移除群成员(多个)。 - *

- * API使用示例: - *

 {@code
-     * EMService service;
-     * try {
-     *     List members = new ArrayList<>();
-     *     members.add("member1");
-     *     members.add("member2");
-     *
-     *     List removeMembers = service.group().removeGroupMembers("groupId", members).block();
-     * } catch (EMException e) {
-     *     e.getErrorCode();
-     *     e.getMessage();
-     * }
-     * }
- * - * @param groupId 群id - * @param usernames 要移除的用户的用户名列表 - * @return EMRemoveMember或错误 - * @see 移除群成员(多个) - */ - public Mono> removeGroupMembers(String groupId, List usernames) { - return this.groupMemberRemove.batch(groupId, usernames); - } - - /** - * 获取群全部管理员。 - *

- * API使用示例: - *

 {@code
-     * EMService service;
-     * try {
-     *     List admins = service.group().listGroupAdmins("groupId").collectList().block();
-     * } catch (EMException e) {
-     *     e.getErrorCode();
-     *     e.getMessage();
-     * }
-     * }
- * - * @param groupId 群id - * @return 每个管理员或错误 - * @see 获取群管理员 - */ - public Flux listGroupAdmins(String groupId) { - return this.groupAdminList.all(groupId); - } - - /** - * 升级群成员为群管理员。 - *

- * API使用示例: - *

 {@code
-     * EMService service;
-     * try {
-     *     service.group().addGroupAdmin("groupId", "username").block();
-     * } catch (EMException e) {
-     *     e.getErrorCode();
-     *     e.getMessage();
-     * }
-     * }
- * - * @param groupId 群id - * @param username 被升级的群成员的用户名 - * @return 成功或错误 - * @see 升级群成员 - */ - public Mono addGroupAdmin(String groupId, String username) { - return this.groupAdminAdd.single(groupId, username); - } - - /** - * 降级群管理员为群成员。 - *

- * API使用示例: - *

 {@code
-     * EMService service;
-     * try {
-     *     service.group().removeGroupAdmin("groupId", "username").block();
-     * } catch (EMException e) {
-     *     e.getErrorCode();
-     *     e.getMessage();
-     * }
-     * }
- * - * @param groupId 群id - * @param username 被降级的群管理员的用户名 - * @return 成功或错误 - * @see 降级群管理员 - */ - public Mono removeGroupAdmin(String groupId, String username) { - return this.groupAdminRemove.single(groupId, username); - } - - /** - * 转让群组。 - *

- * API使用示例: - *

 {@code
-     * EMService service;
-     * try {
-     *     service.group().assignGroup("groupId", "newOwner").block();
-     * } catch (EMException e) {
-     *     e.getErrorCode();
-     *     e.getMessage();
-     * }
-     * }
- * - * @param groupId 群id - * @param newOwner 被转让群组的用户名 - * @return 成功或错误 - * @see 转让群组 - */ - public Mono assignGroup(String groupId, String newOwner){ - return this.assignGroup.execute(groupId, newOwner); - } - - /** - * 查看指定用户是否已加入群组 - *

- * API使用示例: - *

 {@code
-     * EMService service;
-     * try {
-     *     Boolean result = service.group().userIsJoined("groupId", "username").block();
-     * } catch (EMException e) {
-     *     e.getErrorCode();
-     *     e.getMessage();
-     * }
-     * }
- * - * @param groupId 群组id - * @param username 需要查看的用户名 - * @return 是否已加入群组 - * @see 查看指定用户是否已加入群组 - */ - public Mono userIsJoined(String groupId, String username) { - return this.groupMembershipCheck.execute(groupId, username); - } - - /** - * 封禁群组 - *

- * 封禁指定的群组。例如,群成员经常在群中发送违规消息,可以调用该 API 对该群进行封禁。 - * 群组被封禁后,群中任何成员均无法在群组以及该群组下的子区中发送和接收消息,也无法进行群组和子区管理操作。 - *

- * API使用示例: - *

 {@code
-     * EMService service;
-     * try {
-     *     Boolean result = service.group().disableGroup("groupId").block();
-     * } catch (EMException e) {
-     *     e.getErrorCode();
-     *     e.getMessage();
-     * }
-     * }
- * - * @param groupId 群组id - * @return 封禁群组结果 - * @see 封禁群组 - */ - public Mono disableGroup(String groupId) { - return this.groupDisable.execute(groupId); - } - - /** - * 解禁群组 - *

- * 解除对指定群组的封禁。群组解禁后,群成员可以在该群组以及该群组下的子区中发送和接收消息并进行群组和子区管理相关操作。 - *

- * API使用示例: - *

 {@code
-     * EMService service;
-     * try {
-     *     Boolean result = service.group().enableGroup("groupId").block();
-     * } catch (EMException e) {
-     *     e.getErrorCode();
-     *     e.getMessage();
-     * }
-     * }
- * - * @param groupId 群组id - * @return 解禁群组结果 - * @see 解禁群组 - */ - public Mono enableGroup(String groupId) { - return this.groupEnable.execute(groupId); - } - - -} diff --git a/im-sdk-core/src/main/java/com/easemob/im/server/api/group/GroupMemberResource.java b/im-sdk-core/src/main/java/com/easemob/im/server/api/group/GroupMemberResource.java deleted file mode 100644 index 8ebd2471d..000000000 --- a/im-sdk-core/src/main/java/com/easemob/im/server/api/group/GroupMemberResource.java +++ /dev/null @@ -1,25 +0,0 @@ -package com.easemob.im.server.api.group; - -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonProperty; - -public class GroupMemberResource { - - @JsonProperty("member") - private String memberUsername; - - @JsonProperty("owner") - private String ownerUsername; - - @JsonCreator - public GroupMemberResource(@JsonProperty("member") String memberUsername, - @JsonProperty("owner") String ownerUsername) { - this.memberUsername = memberUsername; - this.ownerUsername = ownerUsername; - } - - public String getUsername() { - return this.memberUsername != null ? this.memberUsername : this.ownerUsername; - } - -} diff --git a/im-sdk-core/src/main/java/com/easemob/im/server/api/group/admin/GroupAdminAdd.java b/im-sdk-core/src/main/java/com/easemob/im/server/api/group/admin/GroupAdminAdd.java deleted file mode 100644 index 0a0687732..000000000 --- a/im-sdk-core/src/main/java/com/easemob/im/server/api/group/admin/GroupAdminAdd.java +++ /dev/null @@ -1,36 +0,0 @@ -package com.easemob.im.server.api.group.admin; - -import com.easemob.im.server.api.Context; -import com.easemob.im.server.api.DefaultErrorMapper; -import com.easemob.im.server.api.ErrorMapper; -import com.easemob.im.server.exception.EMNotFoundException; -import com.easemob.im.server.exception.EMUnknownException; -import reactor.core.publisher.Mono; - -public class GroupAdminAdd { - - private Context context; - - public GroupAdminAdd(Context context) { - this.context = context; - } - - public Mono single(String groupId, String username) { - return this.context.getHttpClient() - .flatMap(httpClient -> httpClient.post() - .uri(String.format("/chatgroups/%s/admin", groupId)) - .send(Mono.create(sink -> sink.success(this.context.getCodec() - .encode(new GroupAdminAddRequest(username))))) - .responseSingle((rsp, buf) -> { - return buf.switchIfEmpty( - Mono.error(new EMUnknownException("response is null"))) - .flatMap(byteBuf -> { - ErrorMapper mapper = new DefaultErrorMapper(); - mapper.statusCode(rsp); - mapper.checkError(byteBuf); - return Mono.just(byteBuf); - }); - })) - .then(); - } -} diff --git a/im-sdk-core/src/main/java/com/easemob/im/server/api/group/admin/GroupAdminAddRequest.java b/im-sdk-core/src/main/java/com/easemob/im/server/api/group/admin/GroupAdminAddRequest.java deleted file mode 100644 index e07622689..000000000 --- a/im-sdk-core/src/main/java/com/easemob/im/server/api/group/admin/GroupAdminAddRequest.java +++ /dev/null @@ -1,15 +0,0 @@ -package com.easemob.im.server.api.group.admin; - -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonProperty; - -public class GroupAdminAddRequest { - @JsonProperty("newadmin") - private String username; - - @JsonCreator - public GroupAdminAddRequest(@JsonProperty("newadmin") String username) { - this.username = username; - } - -} diff --git a/im-sdk-core/src/main/java/com/easemob/im/server/api/group/admin/GroupAdminList.java b/im-sdk-core/src/main/java/com/easemob/im/server/api/group/admin/GroupAdminList.java deleted file mode 100644 index 9a1eabfff..000000000 --- a/im-sdk-core/src/main/java/com/easemob/im/server/api/group/admin/GroupAdminList.java +++ /dev/null @@ -1,36 +0,0 @@ -package com.easemob.im.server.api.group.admin; - -import com.easemob.im.server.api.Context; -import com.easemob.im.server.api.DefaultErrorMapper; -import com.easemob.im.server.api.ErrorMapper; -import com.easemob.im.server.exception.EMUnknownException; -import reactor.core.publisher.Flux; -import reactor.core.publisher.Mono; - -public class GroupAdminList { - - private Context context; - - public GroupAdminList(Context context) { - this.context = context; - } - - public Flux all(String groupId) { - return this.context.getHttpClient() - .flatMap(httpClient -> httpClient.get() - .uri(String.format("/chatgroups/%s/admin", groupId)) - .responseSingle((rsp, buf) -> { - return buf.switchIfEmpty( - Mono.error(new EMUnknownException("response is null"))) - .flatMap(byteBuf -> { - ErrorMapper mapper = new DefaultErrorMapper(); - mapper.statusCode(rsp); - mapper.checkError(byteBuf); - return Mono.just(byteBuf); - }); - })) - .map(buf -> this.context.getCodec().decode(buf, GroupAdminListResponse.class)) - .flatMapIterable(GroupAdminListResponse::getAdmins); - } - -} diff --git a/im-sdk-core/src/main/java/com/easemob/im/server/api/group/admin/GroupAdminListResponse.java b/im-sdk-core/src/main/java/com/easemob/im/server/api/group/admin/GroupAdminListResponse.java deleted file mode 100644 index 47fa5a454..000000000 --- a/im-sdk-core/src/main/java/com/easemob/im/server/api/group/admin/GroupAdminListResponse.java +++ /dev/null @@ -1,21 +0,0 @@ -package com.easemob.im.server.api.group.admin; - -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonProperty; - -import java.util.List; - -public class GroupAdminListResponse { - @JsonProperty("data") - private List admins; - - @JsonCreator - public GroupAdminListResponse(@JsonProperty("data") List admins) { - this.admins = admins; - } - - public List getAdmins() { - return admins; - } - -} diff --git a/im-sdk-core/src/main/java/com/easemob/im/server/api/group/admin/GroupAdminRemove.java b/im-sdk-core/src/main/java/com/easemob/im/server/api/group/admin/GroupAdminRemove.java deleted file mode 100644 index b1ab0bc53..000000000 --- a/im-sdk-core/src/main/java/com/easemob/im/server/api/group/admin/GroupAdminRemove.java +++ /dev/null @@ -1,33 +0,0 @@ -package com.easemob.im.server.api.group.admin; - -import com.easemob.im.server.api.Context; -import com.easemob.im.server.api.DefaultErrorMapper; -import com.easemob.im.server.api.ErrorMapper; -import com.easemob.im.server.exception.EMUnknownException; -import reactor.core.publisher.Mono; - -public class GroupAdminRemove { - - private Context context; - - public GroupAdminRemove(Context context) { - this.context = context; - } - - public Mono single(String groupId, String username) { - return this.context.getHttpClient() - .flatMap(httpClient -> httpClient.delete() - .uri(String.format("/chatgroups/%s/admin/%s", groupId, username)) - .responseSingle((rsp, buf) -> { - return buf.switchIfEmpty( - Mono.error(new EMUnknownException("response is null"))) - .flatMap(byteBuf -> { - ErrorMapper mapper = new DefaultErrorMapper(); - mapper.statusCode(rsp); - mapper.checkError(byteBuf); - return Mono.just(byteBuf); - }); - })) - .then(); - } -} diff --git a/im-sdk-core/src/main/java/com/easemob/im/server/api/group/announcement/GroupAnnouncement.java b/im-sdk-core/src/main/java/com/easemob/im/server/api/group/announcement/GroupAnnouncement.java deleted file mode 100644 index 2b133aa42..000000000 --- a/im-sdk-core/src/main/java/com/easemob/im/server/api/group/announcement/GroupAnnouncement.java +++ /dev/null @@ -1,59 +0,0 @@ -package com.easemob.im.server.api.group.announcement; - -import com.easemob.im.server.api.Context; -import com.easemob.im.server.api.DefaultErrorMapper; -import com.easemob.im.server.api.ErrorMapper; -import com.easemob.im.server.exception.EMInvalidArgumentException; -import com.easemob.im.server.exception.EMUnknownException; -import reactor.core.publisher.Mono; - -public class GroupAnnouncement { - - private Context context; - - public GroupAnnouncement(Context context) { - this.context = context; - } - - public Mono get(String groupId) { - return context.getHttpClient() - .flatMap(httpClient -> httpClient.get() - .uri(String.format("/chatgroups/%s/announcement", groupId)) - .responseSingle((rsp, buf) -> { - return buf.switchIfEmpty( - Mono.error(new EMUnknownException("response is null"))) - .flatMap(byteBuf -> { - ErrorMapper mapper = new DefaultErrorMapper(); - mapper.statusCode(rsp); - mapper.checkError(byteBuf); - return Mono.just(byteBuf); - }); - })) - .map(buf -> this.context.getCodec().decode(buf, GroupAnnouncementGetResponse.class)) - .map(GroupAnnouncementGetResponse::getAnnouncement); - } - - public Mono set(String groupId, String announcement) { - if (announcement.length() > 512) { - return Mono.error(new EMInvalidArgumentException( - "announcement must not be longer than 512 characters")); - } - return context.getHttpClient() - .flatMap(httpClient -> httpClient.post() - .uri(String.format("/chatgroups/%s/announcement", groupId)) - .send(Mono.create(sink -> sink.success(this.context.getCodec() - .encode(new GroupAnnouncementResource(announcement))))) - .responseSingle((rsp, buf) -> { - return buf.switchIfEmpty( - Mono.error(new EMUnknownException("response is null"))) - .flatMap(byteBuf -> { - ErrorMapper mapper = new DefaultErrorMapper(); - mapper.statusCode(rsp); - mapper.checkError(byteBuf); - return Mono.just(byteBuf); - }); - })) - .then(); - } -} - diff --git a/im-sdk-core/src/main/java/com/easemob/im/server/api/group/announcement/GroupAnnouncementGetResponse.java b/im-sdk-core/src/main/java/com/easemob/im/server/api/group/announcement/GroupAnnouncementGetResponse.java deleted file mode 100644 index e6de6c5e9..000000000 --- a/im-sdk-core/src/main/java/com/easemob/im/server/api/group/announcement/GroupAnnouncementGetResponse.java +++ /dev/null @@ -1,19 +0,0 @@ -package com.easemob.im.server.api.group.announcement; - -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonProperty; - -public class GroupAnnouncementGetResponse { - @JsonProperty("data") - private GroupAnnouncementResource resource; - - @JsonCreator - public GroupAnnouncementGetResponse(@JsonProperty("data") GroupAnnouncementResource resource) { - this.resource = resource; - } - - public String getAnnouncement() { - return resource.getText(); - } - -} diff --git a/im-sdk-core/src/main/java/com/easemob/im/server/api/group/announcement/GroupAnnouncementResource.java b/im-sdk-core/src/main/java/com/easemob/im/server/api/group/announcement/GroupAnnouncementResource.java deleted file mode 100644 index 46ba663ee..000000000 --- a/im-sdk-core/src/main/java/com/easemob/im/server/api/group/announcement/GroupAnnouncementResource.java +++ /dev/null @@ -1,19 +0,0 @@ -package com.easemob.im.server.api.group.announcement; - -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonProperty; - -public class GroupAnnouncementResource { - @JsonProperty("announcement") - private String text; - - @JsonCreator - public GroupAnnouncementResource(@JsonProperty("announcement") String text) { - this.text = text; - } - - public String getText() { - return text; - } - -} diff --git a/im-sdk-core/src/main/java/com/easemob/im/server/api/group/assign/AssignGroup.java b/im-sdk-core/src/main/java/com/easemob/im/server/api/group/assign/AssignGroup.java deleted file mode 100644 index 7a5c63bb5..000000000 --- a/im-sdk-core/src/main/java/com/easemob/im/server/api/group/assign/AssignGroup.java +++ /dev/null @@ -1,43 +0,0 @@ -package com.easemob.im.server.api.group.assign; - -import com.easemob.im.server.api.Context; -import com.easemob.im.server.api.DefaultErrorMapper; -import com.easemob.im.server.api.ErrorMapper; -import com.easemob.im.server.exception.EMNotFoundException; -import com.easemob.im.server.exception.EMUnknownException; -import reactor.core.publisher.Mono; - -import java.util.HashMap; -import java.util.Map; - -public class AssignGroup { - - private Context context; - - public AssignGroup(Context context) { - this.context = context; - } - - public Mono execute(String groupId, String newOwner) { - return this.context.getHttpClient() - .flatMap(httpClient -> httpClient.put() - .uri(String.format("/chatgroups/%s", groupId)) - .send(Mono.create(sink -> { - Map paramsMap = new HashMap<>(); - paramsMap.put("newowner", newOwner); - sink.success(this.context.getCodec().encode(paramsMap)); - })) - .responseSingle((rsp, buf) -> { - return buf.switchIfEmpty( - Mono.error(new EMUnknownException("response is null"))) - .flatMap(byteBuf -> { - ErrorMapper mapper = new DefaultErrorMapper(); - mapper.statusCode(rsp); - mapper.checkError(byteBuf); - return Mono.just(byteBuf); - }); - })) - .onErrorResume(EMNotFoundException.class, errorIgnored -> Mono.empty()) - .then(); - } -} diff --git a/im-sdk-core/src/main/java/com/easemob/im/server/api/group/create/CreateGroup.java b/im-sdk-core/src/main/java/com/easemob/im/server/api/group/create/CreateGroup.java deleted file mode 100644 index 777b9f455..000000000 --- a/im-sdk-core/src/main/java/com/easemob/im/server/api/group/create/CreateGroup.java +++ /dev/null @@ -1,394 +0,0 @@ -package com.easemob.im.server.api.group.create; - -import com.easemob.im.server.api.Context; -import com.easemob.im.server.api.DefaultErrorMapper; -import com.easemob.im.server.api.ErrorMapper; -import com.easemob.im.server.exception.EMUnknownException; -import reactor.core.publisher.Mono; - -import java.util.List; - -public class CreateGroup { - - private Context context; - - public CreateGroup(Context context) { - this.context = context; - } - - public Mono publicGroup(String owner, String groupName, String description, - List members, int maxMembers, boolean needApproveToJoin) { - return this.context.getHttpClient() - .flatMap(httpClient -> httpClient.post() - .uri("/chatgroups") - .send(Mono.create(sink -> sink.success(this.context.getCodec() - .encode(new CreateGroupRequest(groupName, description, true, owner, - members, maxMembers, false, needApproveToJoin))))) - .responseSingle((rsp, buf) -> { - return buf.switchIfEmpty(Mono.error(new EMUnknownException("response is null"))) - .flatMap(byteBuf -> { - ErrorMapper mapper = new DefaultErrorMapper(); - mapper.statusCode(rsp); - mapper.checkError(byteBuf); - return Mono.just(byteBuf); - }); - })) - .map(buf -> this.context.getCodec().decode(buf, CreateGroupResponse.class)) - .handle((rsp, sink) -> { - String groupId = rsp.getGroupId(); - if (groupId == null) { - sink.error(new EMUnknownException("groupId is null")); - } - sink.next(groupId); - }); - } - - public Mono publicGroup(String owner, String groupName, String description, - List members, int maxMembers, boolean needApproveToJoin, String custom) { - return this.context.getHttpClient() - .flatMap(httpClient -> httpClient.post() - .uri("/chatgroups") - .send(Mono.create(sink -> sink.success(this.context.getCodec() - .encode(new CreateGroupRequest(groupName, description, true, owner, - members, maxMembers, false, needApproveToJoin, custom))))) - .responseSingle((rsp, buf) -> { - return buf.switchIfEmpty( - Mono.error(new EMUnknownException("response is null"))) - .flatMap(byteBuf -> { - ErrorMapper mapper = new DefaultErrorMapper(); - mapper.statusCode(rsp); - mapper.checkError(byteBuf); - return Mono.just(byteBuf); - }); - })) - .map(buf -> this.context.getCodec().decode(buf, CreateGroupResponse.class)) - .handle((rsp, sink) -> { - String groupId = rsp.getGroupId(); - if (groupId == null) { - sink.error(new EMUnknownException("groupId is null")); - } - sink.next(groupId); - }); - } - - public Mono publicGroup(String owner, String groupName, String description, - List members, int maxMembers, boolean needApproveToJoin, String custom, boolean needVerify) { - return this.context.getHttpClient() - .flatMap(httpClient -> httpClient.post() - .uri("/chatgroups") - .send(Mono.create(sink -> sink.success(this.context.getCodec() - .encode(new CreateGroupRequest(groupName, description, true, owner, - members, maxMembers, false, needApproveToJoin, custom, needVerify))))) - .responseSingle((rsp, buf) -> { - return buf.switchIfEmpty( - Mono.error(new EMUnknownException("response is null"))) - .flatMap(byteBuf -> { - ErrorMapper mapper = new DefaultErrorMapper(); - mapper.statusCode(rsp); - mapper.checkError(byteBuf); - return Mono.just(byteBuf); - }); - })) - .map(buf -> this.context.getCodec().decode(buf, CreateGroupResponse.class)) - .handle((rsp, sink) -> { - String groupId = rsp.getGroupId(); - if (groupId == null) { - sink.error(new EMUnknownException("groupId is null")); - } - sink.next(groupId); - }); - } - - public Mono largePublicGroup(String owner, String groupName, String description, - List members, int maxMembers, boolean needApproveToJoin, String custom, - boolean needVerify) { - return this.context.getHttpClient() - .flatMap(httpClient -> httpClient.post() - .uri("/chatgroups") - .send(Mono.create(sink -> sink.success(this.context.getCodec() - .encode(new CreateGroupRequest(groupName, description, true, - "large", owner, members, maxMembers, false, - needApproveToJoin, custom, needVerify))))) - .responseSingle((rsp, buf) -> { - return buf.switchIfEmpty( - Mono.error(new EMUnknownException("response is null"))) - .flatMap(byteBuf -> { - ErrorMapper mapper = new DefaultErrorMapper(); - mapper.statusCode(rsp); - mapper.checkError(byteBuf); - return Mono.just(byteBuf); - }); - })) - .map(buf -> this.context.getCodec().decode(buf, CreateGroupResponse.class)) - .handle((rsp, sink) -> { - String groupId = rsp.getGroupId(); - if (groupId == null) { - sink.error(new EMUnknownException("groupId is null")); - } - sink.next(groupId); - }); - } - - public Mono publicGroup(String groupId, String owner, String groupName, String description, - List members, int maxMembers, boolean needApproveToJoin, String custom, boolean needVerify) { - return this.context.getHttpClient() - .flatMap(httpClient -> httpClient.post() - .uri("/chatgroups") - .send(Mono.create(sink -> sink.success(this.context.getCodec() - .encode(new CreateGroupRequest(groupId, groupName, description, true, owner, - members, maxMembers, false, needApproveToJoin, custom, needVerify))))) - .responseSingle((rsp, buf) -> { - return buf.switchIfEmpty( - Mono.error(new EMUnknownException("response is null"))) - .flatMap(byteBuf -> { - ErrorMapper mapper = new DefaultErrorMapper(); - mapper.statusCode(rsp); - mapper.checkError(byteBuf); - return Mono.just(byteBuf); - }); - })) - .map(buf -> this.context.getCodec().decode(buf, CreateGroupResponse.class)) - .handle((rsp, sink) -> { - String id = rsp.getGroupId(); - if (id == null) { - sink.error(new EMUnknownException("groupId is null")); - } - sink.next(id); - }); - } - - public Mono largePublicGroup(String groupId, String owner, String groupName, - String description, - List members, int maxMembers, boolean needApproveToJoin, String custom, - boolean needVerify) { - return this.context.getHttpClient() - .flatMap(httpClient -> httpClient.post() - .uri("/chatgroups") - .send(Mono.create(sink -> sink.success(this.context.getCodec() - .encode(new CreateGroupRequest(groupId, groupName, description, - true, "large", owner, members, maxMembers, false, - needApproveToJoin, custom, needVerify))))) - .responseSingle((rsp, buf) -> { - return buf.switchIfEmpty( - Mono.error(new EMUnknownException("response is null"))) - .flatMap(byteBuf -> { - ErrorMapper mapper = new DefaultErrorMapper(); - mapper.statusCode(rsp); - mapper.checkError(byteBuf); - return Mono.just(byteBuf); - }); - })) - .map(buf -> this.context.getCodec().decode(buf, CreateGroupResponse.class)) - .handle((rsp, sink) -> { - String id = rsp.getGroupId(); - if (id == null) { - sink.error(new EMUnknownException("groupId is null")); - } - sink.next(id); - }); - } - - public Mono privateGroup(String owner, String groupName, String description, - List members, int maxMembers, boolean canMemberInvite) { - return this.context.getHttpClient() - .flatMap(httpClient -> httpClient.post() - .uri("/chatgroups") - .send(Mono.create(sink -> sink.success(this.context.getCodec() - .encode(new CreateGroupRequest(groupName, description, false, owner, - members, maxMembers, canMemberInvite, !canMemberInvite))))) - .responseSingle((rsp, buf) -> { - return buf.switchIfEmpty( - Mono.error(new EMUnknownException("response is null"))) - .flatMap(byteBuf -> { - ErrorMapper mapper = new DefaultErrorMapper(); - mapper.statusCode(rsp); - mapper.checkError(byteBuf); - return Mono.just(byteBuf); - }); - })) - .map(buf -> this.context.getCodec().decode(buf, CreateGroupResponse.class)) - .handle((rsp, sink) -> { - String groupId = rsp.getGroupId(); - if (groupId == null) { - sink.error(new EMUnknownException("groupId is null")); - } - sink.next(groupId); - }); - } - - public Mono privateGroup(String owner, String groupName, String description, - List members, int maxMembers, boolean canMemberInvite, String custom) { - return this.context.getHttpClient() - .flatMap(httpClient -> httpClient.post() - .uri("/chatgroups") - .send(Mono.create(sink -> sink.success(this.context.getCodec() - .encode(new CreateGroupRequest(groupName, description, false, owner, - members, maxMembers, canMemberInvite, !canMemberInvite, custom))))) - .responseSingle((rsp, buf) -> { - return buf.switchIfEmpty( - Mono.error(new EMUnknownException("response is null"))) - .flatMap(byteBuf -> { - ErrorMapper mapper = new DefaultErrorMapper(); - mapper.statusCode(rsp); - mapper.checkError(byteBuf); - return Mono.just(byteBuf); - }); - })) - .map(buf -> this.context.getCodec().decode(buf, CreateGroupResponse.class)) - .handle((rsp, sink) -> { - String groupId = rsp.getGroupId(); - if (groupId == null) { - sink.error(new EMUnknownException("groupId is null")); - } - sink.next(groupId); - }); - } - - public Mono privateGroup(String owner, String groupName, String description, - List members, int maxMembers, boolean canMemberInvite, boolean needInviteConfirm, boolean needApproveToJoin, String custom) { - return this.context.getHttpClient() - .flatMap(httpClient -> httpClient.post() - .uri("/chatgroups") - .send(Mono.create(sink -> sink.success(this.context.getCodec() - .encode(new CreateGroupRequest(groupName, description, false, owner, - members, maxMembers, canMemberInvite, needInviteConfirm, needApproveToJoin, custom))))) - .responseSingle((rsp, buf) -> { - return buf.switchIfEmpty( - Mono.error(new EMUnknownException("response is null"))) - .flatMap(byteBuf -> { - ErrorMapper mapper = new DefaultErrorMapper(); - mapper.statusCode(rsp); - mapper.checkError(byteBuf); - return Mono.just(byteBuf); - }); - })) - .map(buf -> this.context.getCodec().decode(buf, CreateGroupResponse.class)) - .handle((rsp, sink) -> { - String groupId = rsp.getGroupId(); - if (groupId == null) { - sink.error(new EMUnknownException("groupId is null")); - } - sink.next(groupId); - }); - } - - public Mono privateGroup(String owner, String groupName, String description, - List members, int maxMembers, boolean canMemberInvite, boolean needInviteConfirm, - boolean needApproveToJoin, String custom, boolean needVerify) { - return this.context.getHttpClient() - .flatMap(httpClient -> httpClient.post() - .uri("/chatgroups") - .send(Mono.create(sink -> sink.success(this.context.getCodec() - .encode(new CreateGroupRequest(groupName, description, false, owner, - members, maxMembers, canMemberInvite, needInviteConfirm, needApproveToJoin, custom, needVerify))))) - .responseSingle((rsp, buf) -> { - return buf.switchIfEmpty( - Mono.error(new EMUnknownException("response is null"))) - .flatMap(byteBuf -> { - ErrorMapper mapper = new DefaultErrorMapper(); - mapper.statusCode(rsp); - mapper.checkError(byteBuf); - return Mono.just(byteBuf); - }); - })) - .map(buf -> this.context.getCodec().decode(buf, CreateGroupResponse.class)) - .handle((rsp, sink) -> { - String groupId = rsp.getGroupId(); - if (groupId == null) { - sink.error(new EMUnknownException("groupId is null")); - } - sink.next(groupId); - }); - } - - public Mono largePrivateGroup(String owner, String groupName, String description, - List members, int maxMembers, boolean canMemberInvite, boolean needInviteConfirm, - boolean needApproveToJoin, String custom, boolean needVerify) { - return this.context.getHttpClient() - .flatMap(httpClient -> httpClient.post() - .uri("/chatgroups") - .send(Mono.create(sink -> sink.success(this.context.getCodec() - .encode(new CreateGroupRequest(groupName, description, false, - "large", owner, members, maxMembers, canMemberInvite, - needInviteConfirm, needApproveToJoin, custom, - needVerify))))) - .responseSingle((rsp, buf) -> { - return buf.switchIfEmpty( - Mono.error(new EMUnknownException("response is null"))) - .flatMap(byteBuf -> { - ErrorMapper mapper = new DefaultErrorMapper(); - mapper.statusCode(rsp); - mapper.checkError(byteBuf); - return Mono.just(byteBuf); - }); - })) - .map(buf -> this.context.getCodec().decode(buf, CreateGroupResponse.class)) - .handle((rsp, sink) -> { - String groupId = rsp.getGroupId(); - if (groupId == null) { - sink.error(new EMUnknownException("groupId is null")); - } - sink.next(groupId); - }); - } - - public Mono privateGroup(String groupId, String owner, String groupName, String description, - List members, int maxMembers, boolean canMemberInvite, boolean needInviteConfirm, - boolean needApproveToJoin, String custom, boolean needVerify) { - return this.context.getHttpClient() - .flatMap(httpClient -> httpClient.post() - .uri("/chatgroups") - .send(Mono.create(sink -> sink.success(this.context.getCodec() - .encode(new CreateGroupRequest(groupId, groupName, description, false, owner, - members, maxMembers, canMemberInvite, needInviteConfirm, needApproveToJoin, custom, needVerify))))) - .responseSingle((rsp, buf) -> { - return buf.switchIfEmpty( - Mono.error(new EMUnknownException("response is null"))) - .flatMap(byteBuf -> { - ErrorMapper mapper = new DefaultErrorMapper(); - mapper.statusCode(rsp); - mapper.checkError(byteBuf); - return Mono.just(byteBuf); - }); - })) - .map(buf -> this.context.getCodec().decode(buf, CreateGroupResponse.class)) - .handle((rsp, sink) -> { - String id = rsp.getGroupId(); - if (id == null) { - sink.error(new EMUnknownException("groupId is null")); - } - sink.next(id); - }); - } - - public Mono largePrivateGroup(String groupId, String owner, String groupName, String description, - List members, int maxMembers, boolean canMemberInvite, boolean needInviteConfirm, - boolean needApproveToJoin, String custom, boolean needVerify) { - return this.context.getHttpClient() - .flatMap(httpClient -> httpClient.post() - .uri("/chatgroups") - .send(Mono.create(sink -> sink.success(this.context.getCodec() - .encode(new CreateGroupRequest(groupId, groupName, description, - false, "large", owner, members, maxMembers, canMemberInvite, - needInviteConfirm, needApproveToJoin, custom, - needVerify))))) - .responseSingle((rsp, buf) -> { - return buf.switchIfEmpty( - Mono.error(new EMUnknownException("response is null"))) - .flatMap(byteBuf -> { - ErrorMapper mapper = new DefaultErrorMapper(); - mapper.statusCode(rsp); - mapper.checkError(byteBuf); - return Mono.just(byteBuf); - }); - })) - .map(buf -> this.context.getCodec().decode(buf, CreateGroupResponse.class)) - .handle((rsp, sink) -> { - String id = rsp.getGroupId(); - if (id == null) { - sink.error(new EMUnknownException("groupId is null")); - } - sink.next(id); - }); - } -} diff --git a/im-sdk-core/src/main/java/com/easemob/im/server/api/group/create/CreateGroupRequest.java b/im-sdk-core/src/main/java/com/easemob/im/server/api/group/create/CreateGroupRequest.java deleted file mode 100644 index 1ff8e447c..000000000 --- a/im-sdk-core/src/main/java/com/easemob/im/server/api/group/create/CreateGroupRequest.java +++ /dev/null @@ -1,285 +0,0 @@ -package com.easemob.im.server.api.group.create; - -import com.fasterxml.jackson.annotation.JsonProperty; - -import java.util.List; - -public class CreateGroupRequest { - - @JsonProperty("groupid") - private String groupId; - - @JsonProperty("groupname") - private String groupName; - - @JsonProperty("desc") - private String description; - - @JsonProperty("scale") - private String scale; - - @JsonProperty("public") - private boolean isPublic; - - @JsonProperty("owner") - private String owner; - - @JsonProperty("members") - private List members; - - @JsonProperty("maxusers") - private int maxMembers; - - @JsonProperty("allowinvites") - private boolean memberCanInviteOthers; - - @JsonProperty("invite_need_confirm") - private boolean needInviteConfirm; - - @JsonProperty("members_only") - private boolean needApproveToJoin; - - @JsonProperty("custom") - private String custom; - - @JsonProperty("need_verify") - private boolean needVerify; - - { - this.needVerify = true; - } - - @SuppressWarnings("java:S107") - public CreateGroupRequest(String groupName, String description, boolean isPublic, String owner, - List members, int maxMembers, boolean memberCanInviteOthers, - boolean needApproveToJoin) { - this.groupName = groupName; - this.description = description; - this.isPublic = isPublic; - this.owner = owner; - this.members = members; - this.maxMembers = maxMembers; - this.memberCanInviteOthers = memberCanInviteOthers; - this.needApproveToJoin = needApproveToJoin; - } - - @SuppressWarnings("java:S107") - public CreateGroupRequest(String groupName, String description, boolean isPublic, String owner, - List members, int maxMembers, boolean memberCanInviteOthers, - boolean needApproveToJoin, String custom) { - this.groupName = groupName; - this.description = description; - this.isPublic = isPublic; - this.owner = owner; - this.members = members; - this.maxMembers = maxMembers; - this.memberCanInviteOthers = memberCanInviteOthers; - this.needApproveToJoin = needApproveToJoin; - this.custom = custom; - } - - public CreateGroupRequest(String groupName, String description, boolean isPublic, String owner, - List members, int maxMembers, boolean memberCanInviteOthers, - boolean needApproveToJoin, String custom, boolean needVerify) { - this.groupName = groupName; - this.description = description; - this.isPublic = isPublic; - this.owner = owner; - this.members = members; - this.maxMembers = maxMembers; - this.memberCanInviteOthers = memberCanInviteOthers; - this.needApproveToJoin = needApproveToJoin; - this.custom = custom; - this.needVerify = needVerify; - } - - public CreateGroupRequest(String groupName, String description, boolean isPublic, String scale, String owner, - List members, int maxMembers, boolean memberCanInviteOthers, - boolean needApproveToJoin, String custom, boolean needVerify) { - this.groupName = groupName; - this.description = description; - this.isPublic = isPublic; - this.scale = scale; - this.owner = owner; - this.members = members; - this.maxMembers = maxMembers; - this.memberCanInviteOthers = memberCanInviteOthers; - this.needApproveToJoin = needApproveToJoin; - this.custom = custom; - this.needVerify = needVerify; - } - - public CreateGroupRequest(String groupId, String groupName, String description, - boolean isPublic, String owner, - List members, int maxMembers, boolean memberCanInviteOthers, - boolean needApproveToJoin, String custom, boolean needVerify) { - this.groupId = groupId; - this.groupName = groupName; - this.description = description; - this.isPublic = isPublic; - this.owner = owner; - this.members = members; - this.maxMembers = maxMembers; - this.memberCanInviteOthers = memberCanInviteOthers; - this.needApproveToJoin = needApproveToJoin; - this.custom = custom; - this.needVerify = needVerify; - } - - public CreateGroupRequest(String groupId, String groupName, String description, - boolean isPublic, String scale, String owner, List members, int maxMembers, - boolean memberCanInviteOthers, boolean needApproveToJoin, String custom, - boolean needVerify) { - this.groupId = groupId; - this.groupName = groupName; - this.description = description; - this.isPublic = isPublic; - this.scale = scale; - this.owner = owner; - this.members = members; - this.maxMembers = maxMembers; - this.memberCanInviteOthers = memberCanInviteOthers; - this.needApproveToJoin = needApproveToJoin; - this.custom = custom; - this.needVerify = needVerify; - } - - @SuppressWarnings("java:S107") - public CreateGroupRequest(String groupName, String description, boolean isPublic, String owner, - List members, int maxMembers, boolean memberCanInviteOthers, - boolean needInviteConfirm, boolean needApproveToJoin, String custom) { - this.groupName = groupName; - this.description = description; - this.isPublic = isPublic; - this.owner = owner; - this.members = members; - this.maxMembers = maxMembers; - this.memberCanInviteOthers = memberCanInviteOthers; - this.needInviteConfirm = needInviteConfirm; - this.needApproveToJoin = needApproveToJoin; - this.custom = custom; - } - - @SuppressWarnings("java:S107") - public CreateGroupRequest(String groupName, String description, boolean isPublic, String owner, - List members, int maxMembers, boolean memberCanInviteOthers, - boolean needInviteConfirm, boolean needApproveToJoin, String custom, - boolean needVerify) { - this.groupName = groupName; - this.description = description; - this.isPublic = isPublic; - this.owner = owner; - this.members = members; - this.maxMembers = maxMembers; - this.memberCanInviteOthers = memberCanInviteOthers; - this.needInviteConfirm = needInviteConfirm; - this.needApproveToJoin = needApproveToJoin; - this.custom = custom; - this.needVerify = needVerify; - } - - @SuppressWarnings("java:S107") - public CreateGroupRequest(String groupName, String description, boolean isPublic, String scale, - String owner, List members, int maxMembers, boolean memberCanInviteOthers, - boolean needInviteConfirm, boolean needApproveToJoin, String custom, - boolean needVerify) { - this.groupName = groupName; - this.description = description; - this.isPublic = isPublic; - this.scale = scale; - this.owner = owner; - this.members = members; - this.maxMembers = maxMembers; - this.memberCanInviteOthers = memberCanInviteOthers; - this.needInviteConfirm = needInviteConfirm; - this.needApproveToJoin = needApproveToJoin; - this.custom = custom; - this.needVerify = needVerify; - } - - @SuppressWarnings("java:S107") - public CreateGroupRequest(String groupId, String groupName, String description, boolean isPublic, String owner, - List members, int maxMembers, boolean memberCanInviteOthers, - boolean needInviteConfirm, boolean needApproveToJoin, String custom, - boolean needVerify) { - this.groupId = groupId; - this.groupName = groupName; - this.description = description; - this.isPublic = isPublic; - this.owner = owner; - this.members = members; - this.maxMembers = maxMembers; - this.memberCanInviteOthers = memberCanInviteOthers; - this.needInviteConfirm = needInviteConfirm; - this.needApproveToJoin = needApproveToJoin; - this.custom = custom; - this.needVerify = needVerify; - } - - public CreateGroupRequest(String groupId, String groupName, String description, - boolean isPublic, String scale, String owner, List members, int maxMembers, - boolean memberCanInviteOthers, boolean needInviteConfirm, boolean needApproveToJoin, - String custom, boolean needVerify) { - this.groupId = groupId; - this.groupName = groupName; - this.description = description; - this.isPublic = isPublic; - this.scale = scale; - this.owner = owner; - this.members = members; - this.maxMembers = maxMembers; - this.memberCanInviteOthers = memberCanInviteOthers; - this.needInviteConfirm = needInviteConfirm; - this.needApproveToJoin = needApproveToJoin; - this.custom = custom; - this.needVerify = needVerify; - } - - public String getGroupId() { - return groupId; - } - - public String getGroupName() { - return groupName; - } - - public String getDescription() { - return description; - } - - public boolean isPublic() { - return isPublic; - } - - public String getOwner() { - return owner; - } - - public List getMembers() { - return members; - } - - public int getMaxMembers() { - return maxMembers; - } - - public boolean isMemberCanInviteOthers() { - return memberCanInviteOthers; - } - - public boolean isNeedInviteConfirm() { - return needInviteConfirm; - } - - public boolean isNeedApproveToJoin() { - return needApproveToJoin; - } - - public boolean isNeedVerify(){ - return needVerify; - } - - public String getCustom() { - return custom; - } -} diff --git a/im-sdk-core/src/main/java/com/easemob/im/server/api/group/create/CreateGroupResponse.java b/im-sdk-core/src/main/java/com/easemob/im/server/api/group/create/CreateGroupResponse.java deleted file mode 100644 index 5b59ee362..000000000 --- a/im-sdk-core/src/main/java/com/easemob/im/server/api/group/create/CreateGroupResponse.java +++ /dev/null @@ -1,29 +0,0 @@ -package com.easemob.im.server.api.group.create; - -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonProperty; - -public class CreateGroupResponse { - - @JsonProperty("data") - private GroupCreateResource group; - - public String getGroupId() { - return this.group == null ? null : this.group.getGroupId(); - } - - private static class GroupCreateResource { - @JsonProperty("groupid") - private String groupId; - - @JsonCreator - public GroupCreateResource(@JsonProperty("groupid") String groupId) { - this.groupId = groupId; - } - - public String getGroupId() { - return groupId; - } - - } -} diff --git a/im-sdk-core/src/main/java/com/easemob/im/server/api/group/delete/DeleteGroup.java b/im-sdk-core/src/main/java/com/easemob/im/server/api/group/delete/DeleteGroup.java deleted file mode 100644 index 6a1d14ee2..000000000 --- a/im-sdk-core/src/main/java/com/easemob/im/server/api/group/delete/DeleteGroup.java +++ /dev/null @@ -1,34 +0,0 @@ -package com.easemob.im.server.api.group.delete; - -import com.easemob.im.server.api.Context; -import com.easemob.im.server.api.DefaultErrorMapper; -import com.easemob.im.server.api.ErrorMapper; -import com.easemob.im.server.exception.EMNotFoundException; -import com.easemob.im.server.exception.EMUnknownException; -import reactor.core.publisher.Mono; - -public class DeleteGroup { - private Context context; - - public DeleteGroup(Context context) { - this.context = context; - } - - public Mono execute(String groupId) { - return this.context.getHttpClient() - .flatMap(httpClient -> httpClient.delete() - .uri(String.format("/chatgroups/%s", groupId)) - .responseSingle((rsp, buf) -> { - return buf.switchIfEmpty( - Mono.error(new EMUnknownException("response is null"))) - .flatMap(byteBuf -> { - ErrorMapper mapper = new DefaultErrorMapper(); - mapper.statusCode(rsp); - mapper.checkError(byteBuf); - return Mono.just(byteBuf); - }); - })) - .onErrorResume(EMNotFoundException.class, errorIgnored -> Mono.empty()) - .then(); - } -} diff --git a/im-sdk-core/src/main/java/com/easemob/im/server/api/group/get/GetGroup.java b/im-sdk-core/src/main/java/com/easemob/im/server/api/group/get/GetGroup.java deleted file mode 100644 index 2d9e998fb..000000000 --- a/im-sdk-core/src/main/java/com/easemob/im/server/api/group/get/GetGroup.java +++ /dev/null @@ -1,75 +0,0 @@ -package com.easemob.im.server.api.group.get; - -import com.easemob.im.server.api.Context; -import com.easemob.im.server.api.DefaultErrorMapper; -import com.easemob.im.server.api.ErrorMapper; -import com.easemob.im.server.exception.EMNotFoundException; -import com.easemob.im.server.exception.EMUnknownException; -import com.easemob.im.server.model.EMGroup; -import reactor.core.publisher.Mono; - -import java.util.Collection; -import java.util.Iterator; -import java.util.List; - -public class GetGroup { - private Context context; - - public GetGroup(Context context) { - this.context = context; - } - - public Mono execute(String groupId) { - return this.context.getHttpClient() - .flatMap(httpClient -> httpClient.get() - .uri(String.format("/chatgroups/%s", groupId)) - .responseSingle((rsp, buf) -> { - return buf.switchIfEmpty( - Mono.error(new EMUnknownException("response is null"))) - .flatMap(byteBuf -> { - ErrorMapper mapper = new DefaultErrorMapper(); - mapper.statusCode(rsp); - mapper.checkError(byteBuf); - return Mono.just(byteBuf); - }); - })) - .map(buf -> this.context.getCodec().decode(buf, GetGroupResponse.class)) - .map(rsp -> { - EMGroup detail = rsp.toGroupDetail(groupId); - if (detail == null) { - throw new EMNotFoundException(String.format("group:%s", groupId)); - } - return detail; - }); - } - - public Mono> execute(List groupIdList) { - return this.context.getHttpClient() - .flatMap(httpClient -> httpClient.get() - .uri(String.format("/chatgroups/%s", join(groupIdList, ","))) - .responseSingle((rsp, buf) -> { - return buf.switchIfEmpty( - Mono.error(new EMUnknownException("response is null"))) - .flatMap(byteBuf -> { - ErrorMapper mapper = new DefaultErrorMapper(); - mapper.statusCode(rsp); - mapper.checkError(byteBuf); - return Mono.just(byteBuf); - }); - })) - .map(buf -> this.context.getCodec().decode(buf, GetGroupResponse.class)) - .map(GetGroupResponse::toGroupDetails); - } - - public static String join(Collection var0, String var1) { - StringBuffer var2 = new StringBuffer(); - - for(Iterator var3 = var0.iterator(); var3.hasNext(); var2.append((String)var3.next())) { - if (var2.length() != 0) { - var2.append(var1); - } - } - - return var2.toString(); - } -} diff --git a/im-sdk-core/src/main/java/com/easemob/im/server/api/group/get/GetGroupResponse.java b/im-sdk-core/src/main/java/com/easemob/im/server/api/group/get/GetGroupResponse.java deleted file mode 100644 index eba93410e..000000000 --- a/im-sdk-core/src/main/java/com/easemob/im/server/api/group/get/GetGroupResponse.java +++ /dev/null @@ -1,105 +0,0 @@ -package com.easemob.im.server.api.group.get; - -import com.easemob.im.server.model.EMGroup; -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonProperty; -import io.netty.util.internal.StringUtil; - -import java.util.List; -import java.util.Optional; -import java.util.stream.Collectors; - -public class GetGroupResponse { - @JsonProperty("data") - private List groupDetails; - - @JsonCreator - public GetGroupResponse(@JsonProperty("data") List groupDetails) { - this.groupDetails = groupDetails; - } - - public EMGroup toGroupDetail(String groupId) { - return this.groupDetails.stream() - .filter(groupDetailResource -> groupDetailResource.groupId.equals(groupId)) - .map(GroupDetailResource::toEMGroup) - .findFirst() - .orElse(null); - } - - public List toGroupDetails() { - return this.groupDetails.stream() - .map(GroupDetailResource::toEMGroup) - .collect(Collectors.toList()); - } - - private static class GroupDetailResource { - @JsonProperty("id") - private String groupId; - - @JsonProperty("name") - private String name; - - @JsonProperty("description") - private String description; - - @JsonProperty("membersonly") - private boolean needApproveToJoin; - - @JsonProperty("allowinvites") - private boolean memberCanInviteOthers; // only works in private group - - @JsonProperty("owner") - private String owner; - - @JsonProperty("maxusers") - private int maxMembers; // does owner count here? - - @JsonProperty("public") - private boolean isPublic; - - @JsonProperty("affiliations_count") - private int affiliationsCount; - - @JsonProperty("affiliations") - private List affiliations; - - @JsonProperty("mute") - private boolean isMute; - - @JsonProperty("custom") - private String custom; - - @JsonProperty("disabled") - private boolean disabled; - - public EMGroup toEMGroup() { - String[] groupMembers = Optional.ofNullable(affiliations).map(list -> list.stream() - .filter(affiliation -> StringUtil.isNullOrEmpty(affiliation.getOwner())) - .map(Affiliation::getMember) - .toArray(String[]::new)) - .orElse(null); - return new EMGroup(this.groupId, this.name, this.description, this.isPublic, - this.needApproveToJoin, this.memberCanInviteOthers, - this.owner, this.maxMembers, this.affiliationsCount, groupMembers, this.isMute, - this.custom, this.disabled); - } - } - - private static class Affiliation { - - @JsonProperty("owner") - private String owner; - - @JsonProperty("member") - private String member; - - public String getOwner() { - return owner; - } - - public String getMember() { - return member; - } - } - -} diff --git a/im-sdk-core/src/main/java/com/easemob/im/server/api/group/list/GroupList.java b/im-sdk-core/src/main/java/com/easemob/im/server/api/group/list/GroupList.java deleted file mode 100644 index d7117e74a..000000000 --- a/im-sdk-core/src/main/java/com/easemob/im/server/api/group/list/GroupList.java +++ /dev/null @@ -1,144 +0,0 @@ -package com.easemob.im.server.api.group.list; - -import com.easemob.im.server.api.Context; -import com.easemob.im.server.api.DefaultErrorMapper; -import com.easemob.im.server.api.ErrorMapper; -import com.easemob.im.server.exception.EMUnknownException; -import com.easemob.im.server.model.EMPage; -import io.netty.handler.codec.http.QueryStringEncoder; -import reactor.core.publisher.Flux; -import reactor.core.publisher.Mono; - -import java.util.List; - -public class GroupList { - - private Context context; - - public GroupList(Context context) { - this.context = context; - } - - public Flux all(int limit) { - return next(limit, null) - .expand(rsp -> rsp.getCursor() == null ? - Mono.empty() : - next(limit, rsp.getCursor())) - .concatMapIterable(EMPage::getValues); - } - - public Mono> next(int limit, String cursor) { - QueryStringEncoder encoder = new QueryStringEncoder("/chatgroups"); - encoder.addParam("limit", String.valueOf(limit)); - if (cursor != null) { - encoder.addParam("cursor", cursor); - } - String uriString = encoder.toString(); - return this.context.getHttpClient() - .flatMap(httpClient -> httpClient.get() - .uri(uriString) - .responseSingle((rsp, buf) -> { - return buf.switchIfEmpty( - Mono.error(new EMUnknownException("response is null"))) - .flatMap(byteBuf -> { - ErrorMapper mapper = new DefaultErrorMapper(); - mapper.statusCode(rsp); - mapper.checkError(byteBuf); - return Mono.just(byteBuf); - }); - })) - .map(buf -> this.context.getCodec().decode(buf, GroupListResponse.class)) - .map(GroupListResponse::toEMPage); - } - - public Flux userJoined(String username) { - return this.context.getHttpClient() - .flatMap(httpClient -> httpClient.get() - .uri(String.format("/users/%s/joined_chatgroups", username)) - .responseSingle((rsp, buf) -> { - return buf.switchIfEmpty( - Mono.error(new EMUnknownException("response is null"))) - .flatMap(byteBuf -> { - ErrorMapper mapper = new DefaultErrorMapper(); - mapper.statusCode(rsp); - mapper.checkError(byteBuf); - return Mono.just(byteBuf); - }); - })) - .map(buf -> this.context.getCodec().decode(buf, JoinGroupListResponse.class)) - .flatMapIterable(JoinGroupListResponse::getGroupIds); - } - - public Flux allWithInfo(int limit) { - return nextWithInfo(limit, null) - .expand(rsp -> rsp.getCursor() == null ? - Mono.empty() : - nextWithInfo(limit, rsp.getCursor())) - .concatMapIterable(EMPage::getValues); - } - - public Mono> nextWithInfo(int limit, String cursor) { - QueryStringEncoder encoder = new QueryStringEncoder("/chatgroups"); - encoder.addParam("limit", String.valueOf(limit)); - if (cursor != null) { - encoder.addParam("cursor", cursor); - } - String uriString = encoder.toString(); - return this.context.getHttpClient() - .flatMap(httpClient -> httpClient.get() - .uri(uriString) - .responseSingle((rsp, buf) -> { - return buf.switchIfEmpty( - Mono.error(new EMUnknownException("response is null"))) - .flatMap(byteBuf -> { - ErrorMapper mapper = new DefaultErrorMapper(); - mapper.statusCode(rsp); - mapper.checkError(byteBuf); - return Mono.just(byteBuf); - }); - })) - .map(buf -> this.context.getCodec().decode(buf, GroupListResponse.class)) - .map(GroupListResponse::toEMPageWithInfo); - } - - public Flux userJoinedWithInfo(String username) { - return this.context.getHttpClient() - .flatMap(httpClient -> httpClient.get() - .uri(String.format("/users/%s/joined_chatgroups", username)) - .responseSingle((rsp, buf) -> { - return buf.switchIfEmpty( - Mono.error(new EMUnknownException("response is null"))) - .flatMap(byteBuf -> { - ErrorMapper mapper = new DefaultErrorMapper(); - mapper.statusCode(rsp); - mapper.checkError(byteBuf); - return Mono.just(byteBuf); - }); - })) - .map(buf -> this.context.getCodec().decode(buf, JoinGroupListResponse.class)) - .flatMapIterable(JoinGroupListResponse::getGroups); - } - - public Mono> userJoinedWithInfo(String username, int pageNum, int pageSize) { - QueryStringEncoder encoder = new QueryStringEncoder(String.format("/users/%s/joined_chatgroups", username)); - encoder.addParam("pagenum", String.valueOf(pageNum)); - encoder.addParam("pagesize", String.valueOf(pageSize)); - - String uriString = encoder.toString(); - return this.context.getHttpClient() - .flatMap(httpClient -> httpClient.get() - .uri(uriString) - .responseSingle((rsp, buf) -> { - return buf.switchIfEmpty( - Mono.error(new EMUnknownException("response is null"))) - .flatMap(byteBuf -> { - ErrorMapper mapper = new DefaultErrorMapper(); - mapper.statusCode(rsp); - mapper.checkError(byteBuf); - return Mono.just(byteBuf); - }); - })) - .map(buf -> this.context.getCodec().decode(buf, JoinGroupListResponse.class)) - .map(JoinGroupListResponse::getGroups); - } -} diff --git a/im-sdk-core/src/main/java/com/easemob/im/server/api/group/list/GroupListResponse.java b/im-sdk-core/src/main/java/com/easemob/im/server/api/group/list/GroupListResponse.java deleted file mode 100644 index df416ce48..000000000 --- a/im-sdk-core/src/main/java/com/easemob/im/server/api/group/list/GroupListResponse.java +++ /dev/null @@ -1,54 +0,0 @@ -package com.easemob.im.server.api.group.list; - -import com.easemob.im.server.model.EMPage; -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonProperty; - -import java.util.List; -import java.util.stream.Collectors; - -public class GroupListResponse { - - @JsonProperty("data") - private List groups; - - @JsonProperty("cursor") - private String cursor; - - @JsonCreator - public GroupListResponse(@JsonProperty("data") List groups, - @JsonProperty("cursor") String cursor) { - this.groups = groups; - this.cursor = cursor; - } - - public List getGroupIds() { - return groups.stream().map(GroupResource::getGroupId).collect(Collectors.toList()); - } - - public List getGroups() { - return groups; - } - - public EMPage toEMPage() { - List groupIds = - groups.stream().map(GroupResource::getGroupId).collect(Collectors.toList()); - return new EMPage<>(groupIds, cursor); - } - - public EMPage toEMPageWithInfo() { - return new EMPage<>(groups, cursor); - } - - public String getCursor() { - return cursor; - } - - @Override - public String toString() { - return "GroupListResponse{" + - "groups=" + groups + - ", cursor='" + cursor + '\'' + - '}'; - } -} diff --git a/im-sdk-core/src/main/java/com/easemob/im/server/api/group/list/GroupResource.java b/im-sdk-core/src/main/java/com/easemob/im/server/api/group/list/GroupResource.java deleted file mode 100644 index b4954123a..000000000 --- a/im-sdk-core/src/main/java/com/easemob/im/server/api/group/list/GroupResource.java +++ /dev/null @@ -1,73 +0,0 @@ -package com.easemob.im.server.api.group.list; - -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonProperty; - -import java.util.Objects; - -public class GroupResource { - @JsonProperty("groupid") - private String groupId; - - @JsonProperty("owner") - private String owner; - - @JsonProperty("groupname") - private String groupName; - - @JsonProperty("affiliations") - private Integer affiliations; - - @JsonCreator - public GroupResource(@JsonProperty("groupid") String groupId, - @JsonProperty("groupname") String groupName, - @JsonProperty("owner") String owner, - @JsonProperty("affiliations") Integer affiliations) { - this.groupId = groupId; - this.owner = owner; - this.groupName = groupName; - this.affiliations = affiliations; - } - - public String getGroupId() { - return this.groupId; - } - - public String getGroupName() { - return this.groupName; - } - - public String getOwner() { - return owner; - } - - public Integer getAffiliations() { - return affiliations; - } - - @Override public String toString() { - return "GroupResource{" + - "groupId='" + groupId + '\'' + - ", owner='" + owner + '\'' + - ", groupName='" + groupName + '\'' + - ", affiliations=" + affiliations + - '}'; - } - - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (!(o instanceof GroupResource)) { - return false; - } - GroupResource that = (GroupResource) o; - return Objects.equals(groupId, that.groupId); - } - - @Override - public int hashCode() { - return Objects.hash(groupId); - } -} diff --git a/im-sdk-core/src/main/java/com/easemob/im/server/api/group/list/JoinGroupListResponse.java b/im-sdk-core/src/main/java/com/easemob/im/server/api/group/list/JoinGroupListResponse.java deleted file mode 100644 index b549f0b6c..000000000 --- a/im-sdk-core/src/main/java/com/easemob/im/server/api/group/list/JoinGroupListResponse.java +++ /dev/null @@ -1,54 +0,0 @@ -package com.easemob.im.server.api.group.list; - -import com.easemob.im.server.model.EMPage; -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonProperty; - -import java.util.List; -import java.util.stream.Collectors; - -public class JoinGroupListResponse { - - @JsonProperty("data") - private List groups; - - @JsonProperty("cursor") - private String cursor; - - @JsonCreator - public JoinGroupListResponse(@JsonProperty("data") List groups, - @JsonProperty("cursor") String cursor) { - this.groups = groups; - this.cursor = cursor; - } - - public List getGroupIds() { - return groups.stream().map(JoinGroupResource::getGroupId).collect(Collectors.toList()); - } - - public List getGroups() { - return groups; - } - - public EMPage toEMPage() { - List groupIds = - groups.stream().map(JoinGroupResource::getGroupId).collect(Collectors.toList()); - return new EMPage<>(groupIds, cursor); - } - - public EMPage toEMPageWithInfo() { - return new EMPage<>(groups, cursor); - } - - public String getCursor() { - return cursor; - } - - @Override - public String toString() { - return "JoinGroupListResponse{" + - "groups=" + groups + - ", cursor='" + cursor + '\'' + - '}'; - } -} diff --git a/im-sdk-core/src/main/java/com/easemob/im/server/api/group/list/JoinGroupResource.java b/im-sdk-core/src/main/java/com/easemob/im/server/api/group/list/JoinGroupResource.java deleted file mode 100644 index 0a1a3bf6f..000000000 --- a/im-sdk-core/src/main/java/com/easemob/im/server/api/group/list/JoinGroupResource.java +++ /dev/null @@ -1,52 +0,0 @@ -package com.easemob.im.server.api.group.list; - -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonProperty; - -import java.util.Objects; - -public class JoinGroupResource { - @JsonProperty("groupid") - private String groupId; - - @JsonProperty("groupname") - private String groupName; - - @JsonCreator - public JoinGroupResource(@JsonProperty("groupid") String groupId, @JsonProperty("groupname") String groupName) { - this.groupId = groupId; - this.groupName = groupName; - } - - public String getGroupId() { - return this.groupId; - } - - public String getGroupName() { - return this.groupName; - } - - @Override public String toString() { - return "GroupResource{" + - "groupId='" + groupId + '\'' + - ", groupName='" + groupName + '\'' + - '}'; - } - - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (!(o instanceof JoinGroupResource)) { - return false; - } - JoinGroupResource that = (JoinGroupResource) o; - return Objects.equals(groupId, that.groupId); - } - - @Override - public int hashCode() { - return Objects.hash(groupId); - } -} diff --git a/im-sdk-core/src/main/java/com/easemob/im/server/api/group/list/ListGroupMembersResponse.java b/im-sdk-core/src/main/java/com/easemob/im/server/api/group/list/ListGroupMembersResponse.java deleted file mode 100644 index 0be853762..000000000 --- a/im-sdk-core/src/main/java/com/easemob/im/server/api/group/list/ListGroupMembersResponse.java +++ /dev/null @@ -1,64 +0,0 @@ -package com.easemob.im.server.api.group.list; - -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonProperty; - -import java.util.List; -import java.util.Map; - -// "data": [{"member": "username1"}, {"owner": "username2"}] -public class ListGroupMembersResponse { - @JsonProperty("data") - private List> members; - - @JsonProperty("count") - private Integer memberCount; - - @JsonProperty("params") - private ListGroupParams paramsInfo; - - public Integer getMemberCount() { - return memberCount; - } - - public List> getMembers() { - return members; - } - - @JsonCreator - public ListGroupMembersResponse(@JsonProperty("data") List> members, - @JsonProperty("count") Integer memberCount, - @JsonProperty("params") ListGroupParams paramsInfo) { - this.members = members; - this.memberCount = memberCount; - this.paramsInfo = paramsInfo; - } - - public ListGroupParams getParamsInfo() { - return paramsInfo; - } - - public static class ListGroupParams { - @JsonProperty("pagesize") - private List pageSize; - - @JsonProperty("pagenum") - private List pageNum; - - @JsonCreator - public ListGroupParams(@JsonProperty("pagesize") List pageSize, - @JsonProperty("pagenum") List pageNum) { - this.pageSize = pageSize; - this.pageNum = pageNum; - } - - public String getPageSize() { - return pageSize.get(0); - } - - public String getPageNum() { - return pageNum.get(0); - } - } - -} diff --git a/im-sdk-core/src/main/java/com/easemob/im/server/api/group/management/GroupDisable.java b/im-sdk-core/src/main/java/com/easemob/im/server/api/group/management/GroupDisable.java deleted file mode 100644 index 37e31d8c8..000000000 --- a/im-sdk-core/src/main/java/com/easemob/im/server/api/group/management/GroupDisable.java +++ /dev/null @@ -1,34 +0,0 @@ -package com.easemob.im.server.api.group.management; - -import com.easemob.im.server.api.Context; -import com.easemob.im.server.api.DefaultErrorMapper; -import com.easemob.im.server.api.ErrorMapper; -import com.easemob.im.server.exception.EMUnknownException; -import reactor.core.publisher.Mono; - -public class GroupDisable { - private Context context; - - public GroupDisable(Context context) { - this.context = context; - } - - public Mono execute(String groupId) { - return this.context.getHttpClient() - .flatMap(httpClient -> httpClient.post() - .uri(String.format("/chatgroups/%s/disable", groupId)) - .responseSingle((rsp, buf) -> { - return buf.switchIfEmpty( - Mono.error(new EMUnknownException("response is null"))) - .flatMap(byteBuf -> { - ErrorMapper mapper = new DefaultErrorMapper(); - mapper.statusCode(rsp); - mapper.checkError(byteBuf); - return Mono.just(byteBuf); - }); - })) - .map(buf -> this.context.getCodec().decode(buf, GroupDisableResponse.class)) - .map(groupDisableResponse -> groupDisableResponse.getResource().getDisabled()); - } - -} diff --git a/im-sdk-core/src/main/java/com/easemob/im/server/api/group/management/GroupDisableResponse.java b/im-sdk-core/src/main/java/com/easemob/im/server/api/group/management/GroupDisableResponse.java deleted file mode 100644 index d8b64dc1d..000000000 --- a/im-sdk-core/src/main/java/com/easemob/im/server/api/group/management/GroupDisableResponse.java +++ /dev/null @@ -1,32 +0,0 @@ -package com.easemob.im.server.api.group.management; - -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonProperty; - -public class GroupDisableResponse { - @JsonProperty("data") - private GroupDisableResource resource; - - @JsonCreator - public GroupDisableResponse(@JsonProperty("data") GroupDisableResource resource) { - this.resource = resource; - } - - public GroupDisableResource getResource() { - return resource; - } - - public static class GroupDisableResource { - @JsonProperty("disabled") - private Boolean disabled; - - @JsonCreator - public GroupDisableResource(@JsonProperty("disabled") Boolean disabled) { - this.disabled = disabled; - } - - public Boolean getDisabled() { - return disabled; - } - } -} diff --git a/im-sdk-core/src/main/java/com/easemob/im/server/api/group/management/GroupEnable.java b/im-sdk-core/src/main/java/com/easemob/im/server/api/group/management/GroupEnable.java deleted file mode 100644 index 37c614756..000000000 --- a/im-sdk-core/src/main/java/com/easemob/im/server/api/group/management/GroupEnable.java +++ /dev/null @@ -1,33 +0,0 @@ -package com.easemob.im.server.api.group.management; - -import com.easemob.im.server.api.Context; -import com.easemob.im.server.api.DefaultErrorMapper; -import com.easemob.im.server.api.ErrorMapper; -import com.easemob.im.server.exception.EMUnknownException; -import reactor.core.publisher.Mono; - -public class GroupEnable { - private Context context; - - public GroupEnable(Context context) { - this.context = context; - } - - public Mono execute(String groupId) { - return this.context.getHttpClient() - .flatMap(httpClient -> httpClient.post() - .uri(String.format("/chatgroups/%s/enable", groupId)) - .responseSingle((rsp, buf) -> { - return buf.switchIfEmpty( - Mono.error(new EMUnknownException("response is null"))) - .flatMap(byteBuf -> { - ErrorMapper mapper = new DefaultErrorMapper(); - mapper.statusCode(rsp); - mapper.checkError(byteBuf); - return Mono.just(byteBuf); - }); - })) - .map(buf -> this.context.getCodec().decode(buf, GroupEnableResponse.class)) - .map(groupEnableResponse -> groupEnableResponse.getResource().getDisabled()); - } -} diff --git a/im-sdk-core/src/main/java/com/easemob/im/server/api/group/management/GroupEnableResponse.java b/im-sdk-core/src/main/java/com/easemob/im/server/api/group/management/GroupEnableResponse.java deleted file mode 100644 index 1a7db811b..000000000 --- a/im-sdk-core/src/main/java/com/easemob/im/server/api/group/management/GroupEnableResponse.java +++ /dev/null @@ -1,32 +0,0 @@ -package com.easemob.im.server.api.group.management; - -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonProperty; - -public class GroupEnableResponse { - @JsonProperty("data") - private GroupEnableResource resource; - - @JsonCreator - public GroupEnableResponse(@JsonProperty("data") GroupEnableResource resource) { - this.resource = resource; - } - - public GroupEnableResource getResource() { - return resource; - } - - public static class GroupEnableResource { - @JsonProperty("disabled") - private Boolean disabled; - - @JsonCreator - public GroupEnableResource(@JsonProperty("disabled") Boolean disabled) { - this.disabled = disabled; - } - - public Boolean getDisabled() { - return disabled; - } - } -} diff --git a/im-sdk-core/src/main/java/com/easemob/im/server/api/group/member/add/GroupMemberAdd.java b/im-sdk-core/src/main/java/com/easemob/im/server/api/group/member/add/GroupMemberAdd.java deleted file mode 100644 index 8929dae61..000000000 --- a/im-sdk-core/src/main/java/com/easemob/im/server/api/group/member/add/GroupMemberAdd.java +++ /dev/null @@ -1,56 +0,0 @@ -package com.easemob.im.server.api.group.member.add; - -import com.easemob.im.server.api.Context; -import com.easemob.im.server.api.DefaultErrorMapper; -import com.easemob.im.server.api.ErrorMapper; -import com.easemob.im.server.api.user.create.CreateUserRequest; -import com.easemob.im.server.exception.EMUnknownException; -import reactor.core.publisher.Mono; - -import java.util.List; - -public class GroupMemberAdd { - - private Context context; - - public GroupMemberAdd(Context context) { - this.context = context; - } - - public Mono single(String groupId, String username) { - return this.context.getHttpClient() - .flatMap(httpClient -> httpClient.post() - .uri(String.format("/chatgroups/%s/users/%s", groupId, username)) - .responseSingle((rsp, buf) -> { - return buf.switchIfEmpty( - Mono.error(new EMUnknownException("response is null"))) - .flatMap(byteBuf -> { - ErrorMapper mapper = new DefaultErrorMapper(); - mapper.statusCode(rsp); - mapper.checkError(byteBuf); - return Mono.just(byteBuf); - }); - })) - .then(); - } - - public Mono batch(String groupId, List usernames) { - return this.context.getHttpClient() - .flatMap(httpClient -> httpClient.post() - .uri(String.format("/chatgroups/%s/users", groupId)) - .send(Mono.create(sink -> sink.success(this.context.getCodec() - .encode(new GroupMemberAddRequest(usernames))))) - .responseSingle((rsp, buf) -> { - return buf.switchIfEmpty( - Mono.error(new EMUnknownException("response is null"))) - .flatMap(byteBuf -> { - ErrorMapper mapper = new DefaultErrorMapper(); - mapper.statusCode(rsp); - mapper.checkError(byteBuf); - return Mono.just(byteBuf); - }); - })) - .then(); - } - -} diff --git a/im-sdk-core/src/main/java/com/easemob/im/server/api/group/member/add/GroupMemberAddRequest.java b/im-sdk-core/src/main/java/com/easemob/im/server/api/group/member/add/GroupMemberAddRequest.java deleted file mode 100644 index 30c6e0a3e..000000000 --- a/im-sdk-core/src/main/java/com/easemob/im/server/api/group/member/add/GroupMemberAddRequest.java +++ /dev/null @@ -1,16 +0,0 @@ -package com.easemob.im.server.api.group.member.add; - -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonProperty; - -import java.util.List; - -public class GroupMemberAddRequest { - @JsonProperty("usernames") - private List members; - - @JsonCreator - public GroupMemberAddRequest(@JsonProperty("usernames") List members) { - this.members = members; - } -} diff --git a/im-sdk-core/src/main/java/com/easemob/im/server/api/group/member/list/GroupMemberList.java b/im-sdk-core/src/main/java/com/easemob/im/server/api/group/member/list/GroupMemberList.java deleted file mode 100644 index 58edb7a4b..000000000 --- a/im-sdk-core/src/main/java/com/easemob/im/server/api/group/member/list/GroupMemberList.java +++ /dev/null @@ -1,96 +0,0 @@ -package com.easemob.im.server.api.group.member.list; - -import com.easemob.im.server.api.Context; -import com.easemob.im.server.api.DefaultErrorMapper; -import com.easemob.im.server.api.ErrorMapper; -import com.easemob.im.server.api.group.list.ListGroupMembersResponse; -import com.easemob.im.server.api.room.member.list.ListRoomMembersResponseV1; -import com.easemob.im.server.exception.EMUnknownException; -import com.easemob.im.server.model.EMPage; -import io.netty.handler.codec.http.QueryStringEncoder; -import reactor.core.publisher.Flux; -import reactor.core.publisher.Mono; - -import java.util.Map; - -public class GroupMemberList { - - private Context context; - - public GroupMemberList(Context context) { - this.context = context; - } - - public Flux all(String groupId, int limit, String sort) { - return next(groupId, limit, null, sort) - .expand(rsp -> rsp.getCursor() == null ? - Mono.empty() : - next(groupId, limit, rsp.getCursor(), sort)) - .concatMapIterable(EMPage::getValues); - } - - public Mono> next(String groupId, int limit, String cursor, String sort) { - final String uriPath = String.format("/chatgroups/%s/users", groupId); - QueryStringEncoder encoder = new QueryStringEncoder(uriPath); - encoder.addParam("version", "v3"); - encoder.addParam("limit", String.valueOf(limit)); - if (cursor != null) { - encoder.addParam("cursor", cursor); - } - if (sort != null) { - encoder.addParam("sort", sort); - } - String uriString = encoder.toString(); - return this.context.getHttpClient() - .flatMap(httpClient -> httpClient.get() - .uri(uriString) - .responseSingle((rsp, buf) -> { - return buf.switchIfEmpty( - Mono.error(new EMUnknownException("response is null"))) - .flatMap(byteBuf -> { - ErrorMapper mapper = new DefaultErrorMapper(); - mapper.statusCode(rsp); - mapper.checkError(byteBuf); - return Mono.just(byteBuf); - }); - })) - .map(buf -> this.context.getCodec().decode(buf, GroupMemberListResponse.class)) - .map(GroupMemberListResponse::toEMPage); - } - - public Flux> allIncludeOwner(String groupId, int pageSize, String sort) { - return nextIncludeOwner(groupId, 1, pageSize, sort) - .expand(rsp -> { - return rsp.getMemberCount() < pageSize ? - Mono.empty() : - nextIncludeOwner(groupId, Integer.parseInt(rsp.getParamsInfo().getPageNum()) + 1, pageSize, sort); - }) - .concatMapIterable(ListGroupMembersResponse::getMembers); - } - - public Mono nextIncludeOwner(String groupId, int pageNum, int pageSize, String sort) { - final String uriPath = String.format("/chatgroups/%s/users", groupId); - QueryStringEncoder encoder = new QueryStringEncoder(uriPath); - encoder.addParam("pagenum", String.valueOf(pageNum)); - encoder.addParam("pagesize", String.valueOf(pageSize)); - if (sort != null) { - encoder.addParam("sort", sort); - } - - String uriString = encoder.toString(); - return this.context.getHttpClient() - .flatMap(httpClient -> httpClient.get() - .uri(uriString) - .responseSingle((rsp, buf) -> { - return buf.switchIfEmpty( - Mono.error(new EMUnknownException("response is null"))) - .flatMap(byteBuf -> { - ErrorMapper mapper = new DefaultErrorMapper(); - mapper.statusCode(rsp); - mapper.checkError(byteBuf); - return Mono.just(byteBuf); - }); - })) - .map(buf -> this.context.getCodec().decode(buf, ListGroupMembersResponse.class)); - } -} diff --git a/im-sdk-core/src/main/java/com/easemob/im/server/api/group/member/list/GroupMemberListResponse.java b/im-sdk-core/src/main/java/com/easemob/im/server/api/group/member/list/GroupMemberListResponse.java deleted file mode 100644 index 4e07d076c..000000000 --- a/im-sdk-core/src/main/java/com/easemob/im/server/api/group/member/list/GroupMemberListResponse.java +++ /dev/null @@ -1,24 +0,0 @@ -package com.easemob.im.server.api.group.member.list; - -import com.easemob.im.server.model.EMPage; -import com.fasterxml.jackson.annotation.JsonProperty; - -import java.util.List; - -// "data": ["username1", "username2"] -public class GroupMemberListResponse { - - @JsonProperty("data") - private List members; - - @JsonProperty("cursor") - private String cursor; - - public EMPage toEMPage() { - return new EMPage<>(this.members, this.cursor); - } - - public String getCursor() { - return this.cursor; - } -} diff --git a/im-sdk-core/src/main/java/com/easemob/im/server/api/group/member/remove/GroupMemberRemove.java b/im-sdk-core/src/main/java/com/easemob/im/server/api/group/member/remove/GroupMemberRemove.java deleted file mode 100644 index f1bc5fe88..000000000 --- a/im-sdk-core/src/main/java/com/easemob/im/server/api/group/member/remove/GroupMemberRemove.java +++ /dev/null @@ -1,71 +0,0 @@ -package com.easemob.im.server.api.group.member.remove; - -import com.easemob.im.server.api.Context; -import com.easemob.im.server.api.DefaultErrorMapper; -import com.easemob.im.server.api.ErrorMapper; -import com.easemob.im.server.exception.EMNotFoundException; -import com.easemob.im.server.exception.EMUnknownException; -import com.easemob.im.server.model.EMRemoveMember; -import reactor.core.publisher.Mono; - -import java.util.Iterator; -import java.util.List; - -public class GroupMemberRemove { - - private Context context; - - public GroupMemberRemove(Context context) { - this.context = context; - } - - public Mono single(String groupId, String username) { - return this.context.getHttpClient() - .flatMap(httpClient -> httpClient.delete() - .uri(String.format("/chatgroups/%s/users/%s", groupId, username)) - .responseSingle((rsp, buf) -> { - return buf.switchIfEmpty( - Mono.error(new EMUnknownException("response is null"))) - .flatMap(byteBuf -> { - ErrorMapper mapper = new DefaultErrorMapper(); - mapper.statusCode(rsp); - mapper.checkError(byteBuf); - return Mono.just(byteBuf); - }); - })) - .onErrorResume(EMNotFoundException.class, errorIgnored -> Mono.empty()) - .then(); - } - - public Mono> batch(String groupId, List usernames) { - return this.context.getHttpClient() - .flatMap(httpClient -> httpClient.delete() - .uri(String.format("/chatgroups/%s/users/%s", groupId, convert(usernames))) - .responseSingle((rsp, buf) -> { - return buf.switchIfEmpty( - Mono.error(new EMUnknownException("response is null"))) - .flatMap(byteBuf -> { - ErrorMapper mapper = new DefaultErrorMapper(); - mapper.statusCode(rsp); - mapper.checkError(byteBuf); - return Mono.just(byteBuf); - }); - })) - .map(buf -> this.context.getCodec().decode(buf, GroupMemberRemoveResponse.class)) - .map(GroupMemberRemoveResponse::getMembers); - } - - private String convert(List var0) { - String var1 = ","; - - StringBuilder var2 = new StringBuilder(); - - for(Iterator var3 = var0.iterator(); var3.hasNext(); var2.append(var3.next())) { - if (var2.length() != 0) { - var2.append(var1); - } - } - - return var2.toString(); - } -} diff --git a/im-sdk-core/src/main/java/com/easemob/im/server/api/group/member/remove/GroupMemberRemoveResponse.java b/im-sdk-core/src/main/java/com/easemob/im/server/api/group/member/remove/GroupMemberRemoveResponse.java deleted file mode 100644 index ba9e5e0d3..000000000 --- a/im-sdk-core/src/main/java/com/easemob/im/server/api/group/member/remove/GroupMemberRemoveResponse.java +++ /dev/null @@ -1,38 +0,0 @@ -package com.easemob.im.server.api.group.member.remove; - -import com.easemob.im.server.model.EMRemoveMember; -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonProperty; - -import java.util.ArrayList; -import java.util.List; -import java.util.Map; - -public class GroupMemberRemoveResponse { - @JsonProperty("data") - private Object members; - - @JsonCreator - public GroupMemberRemoveResponse( - @JsonProperty("data") Object members) { - this.members = members; - } - - public List getMembers() { - List removeMembers = new ArrayList<>(); - - if (members instanceof List) { - ((List) members).forEach(member -> { - removeMembers.add(toRemoveMember((Map) member)); - }); - } else { - removeMembers.add(toRemoveMember((Map) members)); - } - - return removeMembers; - } - - private EMRemoveMember toRemoveMember(Map member) { - return new EMRemoveMember((Boolean) member.get("result"), String.valueOf(member.get("user")), String.valueOf(member.get("reason"))); - } -} diff --git a/im-sdk-core/src/main/java/com/easemob/im/server/api/group/membershipcheck/GroupMembershipCheck.java b/im-sdk-core/src/main/java/com/easemob/im/server/api/group/membershipcheck/GroupMembershipCheck.java deleted file mode 100644 index fc363e4cd..000000000 --- a/im-sdk-core/src/main/java/com/easemob/im/server/api/group/membershipcheck/GroupMembershipCheck.java +++ /dev/null @@ -1,34 +0,0 @@ -package com.easemob.im.server.api.group.membershipcheck; - -import com.easemob.im.server.api.Context; -import com.easemob.im.server.api.DefaultErrorMapper; -import com.easemob.im.server.api.ErrorMapper; -import com.easemob.im.server.exception.EMUnknownException; -import reactor.core.publisher.Mono; - -public class GroupMembershipCheck { - - private Context context; - - public GroupMembershipCheck(Context context) { - this.context = context; - } - - public Mono execute(String groupId, String username) { - return this.context.getHttpClient() - .flatMap(httpClient -> httpClient.get() - .uri(String.format("/chatgroups/%s/user/%s/is_joined", groupId, username)) - .responseSingle((rsp, buf) -> { - return buf.switchIfEmpty( - Mono.error(new EMUnknownException("response is null"))) - .flatMap(byteBuf -> { - ErrorMapper mapper = new DefaultErrorMapper(); - mapper.statusCode(rsp); - mapper.checkError(byteBuf); - return Mono.just(byteBuf); - }); - })) - .map(buf -> this.context.getCodec().decode(buf, GroupMembershipCheckResponse.class)) - .map(GroupMembershipCheckResponse::getData); - } -} diff --git a/im-sdk-core/src/main/java/com/easemob/im/server/api/group/membershipcheck/GroupMembershipCheckResponse.java b/im-sdk-core/src/main/java/com/easemob/im/server/api/group/membershipcheck/GroupMembershipCheckResponse.java deleted file mode 100644 index b63be02f9..000000000 --- a/im-sdk-core/src/main/java/com/easemob/im/server/api/group/membershipcheck/GroupMembershipCheckResponse.java +++ /dev/null @@ -1,19 +0,0 @@ -package com.easemob.im.server.api.group.membershipcheck; - -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonProperty; - -public class GroupMembershipCheckResponse { - - @JsonProperty("data") - private Boolean data; - - @JsonCreator - public GroupMembershipCheckResponse(@JsonProperty("data") Boolean data) { - this.data = data; - } - - public Boolean getData() { - return data; - } -} diff --git a/im-sdk-core/src/main/java/com/easemob/im/server/api/group/settings/UpdateGroup.java b/im-sdk-core/src/main/java/com/easemob/im/server/api/group/settings/UpdateGroup.java deleted file mode 100644 index 782067d14..000000000 --- a/im-sdk-core/src/main/java/com/easemob/im/server/api/group/settings/UpdateGroup.java +++ /dev/null @@ -1,78 +0,0 @@ -package com.easemob.im.server.api.group.settings; - -import com.easemob.im.server.api.Context; -import com.easemob.im.server.api.DefaultErrorMapper; -import com.easemob.im.server.api.ErrorMapper; -import com.easemob.im.server.exception.EMUnknownException; -import reactor.core.publisher.Mono; - -import java.util.function.Consumer; - -public class UpdateGroup { - - private Context context; - - public UpdateGroup(Context context) { - this.context = context; - } - - public Mono update(String groupId, Consumer customizer) { - UpdateGroupRequest request = new UpdateGroupRequest(); - customizer.accept(request); - - return this.context.getHttpClient() - .flatMap(httpClient -> httpClient.put() - .uri(String.format("/chatgroups/%s", groupId)) - .send(Mono.create(sink -> sink - .success(this.context.getCodec().encode(request)))) - .responseSingle((rsp, buf) -> { - return buf.switchIfEmpty( - Mono.error(new EMUnknownException("response is null"))) - .flatMap(byteBuf -> { - ErrorMapper mapper = new DefaultErrorMapper(); - mapper.statusCode(rsp); - mapper.checkError(byteBuf); - return Mono.just(byteBuf); - }); - })) - .map(buf -> this.context.getCodec().decode(buf, UpdateGroupResponse.class)) - .doOnNext(rsp -> { - if (request.getMaxMembers() != null && (rsp.getMaxMembersUpdated() == null - || !rsp.getMaxMembersUpdated())) { - throw new EMUnknownException("maxMembers"); - } - - if (request.getCanMemberInviteOthers() != null && ( - rsp.getMemberCanInviteOthersUpdated() == null || !rsp - .getMemberCanInviteOthersUpdated())) { - throw new EMUnknownException("memberCanInviteOthers"); - } - - if (request.getNeedApproveToJoin() != null && ( - rsp.getNeedApproveToJoinUpdated() == null || !rsp - .getNeedApproveToJoinUpdated())) { - throw new EMUnknownException("needApproveToJoin"); - } - }) - .then(); - } - - public Mono updateOwner(String groupId, String owner) { - return this.context.getHttpClient() - .flatMap(httpClient -> httpClient.put() - .uri(String.format("/chatgroups/%s", groupId)) - .send(Mono.create(sink -> sink.success(this.context.getCodec() - .encode(new UpdateGroupOwnerRequest(owner))))) - .responseSingle((rsp, buf) -> { - return buf.switchIfEmpty( - Mono.error(new EMUnknownException("response is null"))) - .flatMap(byteBuf -> { - ErrorMapper mapper = new DefaultErrorMapper(); - mapper.statusCode(rsp); - mapper.checkError(byteBuf); - return Mono.just(byteBuf); - }); - })) - .then(); - } -} diff --git a/im-sdk-core/src/main/java/com/easemob/im/server/api/group/settings/UpdateGroupOwnerRequest.java b/im-sdk-core/src/main/java/com/easemob/im/server/api/group/settings/UpdateGroupOwnerRequest.java deleted file mode 100644 index e0cf61548..000000000 --- a/im-sdk-core/src/main/java/com/easemob/im/server/api/group/settings/UpdateGroupOwnerRequest.java +++ /dev/null @@ -1,14 +0,0 @@ -package com.easemob.im.server.api.group.settings; - -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonProperty; - -public class UpdateGroupOwnerRequest { - @JsonProperty("newowner") - private String owner; - - @JsonCreator - public UpdateGroupOwnerRequest(@JsonProperty("newowner") String owner) { - this.owner = owner; - } -} diff --git a/im-sdk-core/src/main/java/com/easemob/im/server/api/group/settings/UpdateGroupRequest.java b/im-sdk-core/src/main/java/com/easemob/im/server/api/group/settings/UpdateGroupRequest.java deleted file mode 100644 index 8e1edc0d0..000000000 --- a/im-sdk-core/src/main/java/com/easemob/im/server/api/group/settings/UpdateGroupRequest.java +++ /dev/null @@ -1,192 +0,0 @@ -package com.easemob.im.server.api.group.settings; - -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; - -public class UpdateGroupRequest { - - @JsonProperty("name") - private String name; - - @JsonProperty("description") - private String description; - - @JsonProperty("allowinvites") - private Boolean canMemberInviteOthers; - - @JsonProperty("invite_need_confirm") - private Boolean needInviteConfirm; - - @JsonProperty("membersonly") - private Boolean needApproveToJoin; - - @JsonProperty("maxusers") - private Integer maxMembers; - - @JsonProperty("custom") - private String custom; - - @JsonProperty("need_verify") - @JsonInclude(JsonInclude.Include.NON_NULL) - private Boolean needVerify; - - @JsonProperty("public") - private Boolean isPublic; - - public UpdateGroupRequest() { - this.name = null; - this.description = null; - this.canMemberInviteOthers = null; - this.needInviteConfirm = null; - this.needApproveToJoin = null; - this.maxMembers = null; - this.custom = null; - this.isPublic = null; - } - - @JsonCreator - public UpdateGroupRequest(@JsonProperty("name") String name, - @JsonProperty("description") String description, - @JsonProperty("allowinvites") Boolean canMemberInviteOthers, - @JsonProperty("membersonly") Boolean needApproveToJoin, - @JsonProperty("maxusers") Integer maxMembers) { - this.name = name; - this.description = description; - this.canMemberInviteOthers = canMemberInviteOthers; - this.needApproveToJoin = needApproveToJoin; - this.maxMembers = maxMembers; - } - - @JsonCreator - public UpdateGroupRequest(@JsonProperty("name") String name, - @JsonProperty("description") String description, - @JsonProperty("allowinvites") Boolean canMemberInviteOthers, - @JsonProperty("membersonly") Boolean needApproveToJoin, - @JsonProperty("maxusers") Integer maxMembers, - @JsonProperty("custom") String custom) { - this.name = name; - this.description = description; - this.canMemberInviteOthers = canMemberInviteOthers; - this.needApproveToJoin = needApproveToJoin; - this.maxMembers = maxMembers; - this.custom = custom; - } - - @JsonCreator - public UpdateGroupRequest(@JsonProperty("name") String name, - @JsonProperty("description") String description, - @JsonProperty("allowinvites") Boolean canMemberInviteOthers, - @JsonProperty("invite_need_confirm") Boolean needInviteConfirm, - @JsonProperty("membersonly") Boolean needApproveToJoin, - @JsonProperty("maxusers") Integer maxMembers, - @JsonProperty("custom") String custom) { - this.name = name; - this.description = description; - this.canMemberInviteOthers = canMemberInviteOthers; - this.needInviteConfirm = needInviteConfirm; - this.needApproveToJoin = needApproveToJoin; - this.maxMembers = maxMembers; - this.custom = custom; - } - - @JsonCreator - public UpdateGroupRequest(@JsonProperty("name") String name, - @JsonProperty("description") String description, - @JsonProperty("allowinvites") Boolean canMemberInviteOthers, - @JsonProperty("invite_need_confirm") Boolean needInviteConfirm, - @JsonProperty("membersonly") Boolean needApproveToJoin, - @JsonProperty("maxusers") Integer maxMembers, - @JsonProperty("custom") String custom, - @JsonProperty("need_verify") Boolean needVerify) { - this.name = name; - this.description = description; - this.canMemberInviteOthers = canMemberInviteOthers; - this.needInviteConfirm = needInviteConfirm; - this.needApproveToJoin = needApproveToJoin; - this.maxMembers = maxMembers; - this.custom = custom; - this.needVerify = needVerify; - } - - public String getName() { - return name; - } - - public UpdateGroupRequest setName(String name) { - this.name = name; - return this; - } - - public String getDescription() { - return description; - } - - public UpdateGroupRequest setDescription(String description) { - this.description = description; - return this; - } - - public Boolean getCanMemberInviteOthers() { - return canMemberInviteOthers; - } - - public UpdateGroupRequest setCanMemberInviteOthers(Boolean canMemberInviteOthers) { - this.canMemberInviteOthers = canMemberInviteOthers; - return this; - } - - public Boolean getNeedApproveToJoin() { - return needApproveToJoin; - } - - public UpdateGroupRequest setNeedApproveToJoin(Boolean needApproveToJoin) { - this.needApproveToJoin = needApproveToJoin; - return this; - } - - public Boolean getNeedInviteConfirm() { - return needInviteConfirm; - } - - public UpdateGroupRequest setNeedInviteConfirm(Boolean needInviteConfirm) { - this.needInviteConfirm = needInviteConfirm; - return this; - } - - public Integer getMaxMembers() { - return maxMembers; - } - - public UpdateGroupRequest setMaxMembers(Integer maxMembers) { - this.maxMembers = maxMembers; - return this; - } - - public String getCustom() { - return custom; - } - - public UpdateGroupRequest setCustom(String custom) { - this.custom = custom; - return this; - } - - public UpdateGroupRequest setNeedVerify(Boolean needVerify) { - this.needVerify = needVerify; - return this; - } - - public Boolean getNeedVerify() { - return needVerify; - } - - public Boolean getPublic() { - return isPublic; - } - - public UpdateGroupRequest setPublic(Boolean aPublic) { - isPublic = aPublic; - return this; - } -} diff --git a/im-sdk-core/src/main/java/com/easemob/im/server/api/group/settings/UpdateGroupResponse.java b/im-sdk-core/src/main/java/com/easemob/im/server/api/group/settings/UpdateGroupResponse.java deleted file mode 100644 index 0a5b2823c..000000000 --- a/im-sdk-core/src/main/java/com/easemob/im/server/api/group/settings/UpdateGroupResponse.java +++ /dev/null @@ -1,57 +0,0 @@ -package com.easemob.im.server.api.group.settings; - -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonProperty; - -public class UpdateGroupResponse { - - @JsonProperty("data") - private GroupUpdateResource resource; - - @JsonCreator - public UpdateGroupResponse(@JsonProperty("data") GroupUpdateResource resource) { - this.resource = resource; - } - - public Boolean getMaxMembersUpdated() { - return this.resource.getMaxMembersUpdated(); - } - - public Boolean getNeedApproveToJoinUpdated() { - return this.resource.getNeedApproveToJoinUpdated(); - } - - public Boolean getMemberCanInviteOthersUpdated() { - return this.resource.getMemberCanInviteOthersUpdated(); - } - - private static class GroupUpdateResource { - @JsonProperty("maxusers") - private Boolean maxMembersUpdated; - @JsonProperty("membersonly") - private Boolean needApproveToJoinUpdated; - @JsonProperty("allowinvites") - private Boolean memberCanInviteOthersUpdated; - - @JsonCreator - public GroupUpdateResource(@JsonProperty("maxusers") Boolean maxMembersUpdated, - @JsonProperty("membersonly") Boolean needApproveToJoinUpdated, - @JsonProperty("allowinvites") Boolean memberCanInviteOthersUpdated) { - this.maxMembersUpdated = maxMembersUpdated; - this.needApproveToJoinUpdated = needApproveToJoinUpdated; - this.memberCanInviteOthersUpdated = memberCanInviteOthersUpdated; - } - - public Boolean getMaxMembersUpdated() { - return maxMembersUpdated; - } - - public Boolean getNeedApproveToJoinUpdated() { - return needApproveToJoinUpdated; - } - - public Boolean getMemberCanInviteOthersUpdated() { - return memberCanInviteOthersUpdated; - } - } -} diff --git a/im-sdk-core/src/main/java/com/easemob/im/server/api/loadbalance/DefaultEndpointProviderFactory.java b/im-sdk-core/src/main/java/com/easemob/im/server/api/loadbalance/DefaultEndpointProviderFactory.java deleted file mode 100644 index 8f83d3d07..000000000 --- a/im-sdk-core/src/main/java/com/easemob/im/server/api/loadbalance/DefaultEndpointProviderFactory.java +++ /dev/null @@ -1,33 +0,0 @@ -package com.easemob.im.server.api.loadbalance; - -import com.easemob.im.server.EMProperties; -import com.easemob.im.server.api.Codec; -import com.easemob.im.server.api.ErrorMapper; -import io.netty.util.internal.StringUtil; -import reactor.netty.http.client.HttpClient; - -public class DefaultEndpointProviderFactory implements EndpointProviderFactory { - - private final EMProperties properties; - private final Codec codec; - private final HttpClient httpClient; - private final ErrorMapper errorMapper; - - public DefaultEndpointProviderFactory(EMProperties properties, Codec codec, - HttpClient httpClient, ErrorMapper errorMapper) { - this.properties = properties; - this.codec = codec; - this.httpClient = httpClient; - this.errorMapper = errorMapper; - } - - @Override - public EndpointProvider create() { - final String baseUri = properties.getBaseUri(); - if (StringUtil.isNullOrEmpty(baseUri)) { - return new DnsConfigEndpointProvider(properties, codec, httpClient, errorMapper); - } else { - return new FixedEndpointProvider(properties); - } - } -} diff --git a/im-sdk-core/src/main/java/com/easemob/im/server/api/loadbalance/DnsConfigEndpointProvider.java b/im-sdk-core/src/main/java/com/easemob/im/server/api/loadbalance/DnsConfigEndpointProvider.java deleted file mode 100644 index 49cdbea83..000000000 --- a/im-sdk-core/src/main/java/com/easemob/im/server/api/loadbalance/DnsConfigEndpointProvider.java +++ /dev/null @@ -1,48 +0,0 @@ -package com.easemob.im.server.api.loadbalance; - -import com.easemob.im.server.EMProperties; -import com.easemob.im.server.api.Codec; -import com.easemob.im.server.api.DefaultErrorMapper; -import com.easemob.im.server.api.ErrorMapper; -import com.easemob.im.server.exception.EMUnknownException; -import reactor.core.publisher.Mono; -import reactor.netty.http.client.HttpClient; - -import java.util.List; - -public class DnsConfigEndpointProvider implements EndpointProvider { - - private final EMProperties properties; - - private final Codec codec; - - private final HttpClient httpClient; - - private final ErrorMapper errorMapper; - - public DnsConfigEndpointProvider(EMProperties properties, Codec codec, HttpClient httpClient, - ErrorMapper errorMapper) { - this.properties = properties; - this.codec = codec; - this.httpClient = httpClient; - this.errorMapper = errorMapper; - } - - public Mono> endpoints() { - return this.httpClient.get() - .uri(String.format("/easemob/server.json?app_key=%s", - this.properties.getAppkeyUrlEncoded())) - .responseSingle((rsp, buf) -> { - return buf.switchIfEmpty( - Mono.error(new EMUnknownException("response is null"))) - .flatMap(byteBuf -> { - ErrorMapper mapper = new DefaultErrorMapper(); - mapper.statusCode(rsp); - mapper.checkError(byteBuf); - return Mono.just(byteBuf); - }); - }) - .map(buf -> this.codec.decode(buf, GetDnsConfigResponse.class)) - .map(GetDnsConfigResponse::toEndpoints); - } -} diff --git a/im-sdk-core/src/main/java/com/easemob/im/server/api/loadbalance/Endpoint.java b/im-sdk-core/src/main/java/com/easemob/im/server/api/loadbalance/Endpoint.java deleted file mode 100644 index 85c4df187..000000000 --- a/im-sdk-core/src/main/java/com/easemob/im/server/api/loadbalance/Endpoint.java +++ /dev/null @@ -1,53 +0,0 @@ -package com.easemob.im.server.api.loadbalance; - -import java.util.Objects; - -public class Endpoint { - private String protocol; - private String host; - private int port; - - public Endpoint(String protocol, String host, int port) { - this.protocol = protocol; - this.host = host; - this.port = port; - } - - public Endpoint(String protocol, String host) { - this.protocol = protocol; - this.host = host; - } - - public String getUri() { - if (port > 0) { - return String.format("%s://%s:%d", protocol, host, port); - } else { - return String.format("%s://%s", protocol, host); - } - } - - @Override - public boolean equals(Object o) { - if (this == o) - return true; - if (o == null || getClass() != o.getClass()) - return false; - Endpoint endpoint = (Endpoint) o; - return port == endpoint.port && Objects.equals(protocol, endpoint.protocol) && Objects - .equals(host, endpoint.host); - } - - @Override - public int hashCode() { - return Objects.hash(protocol, host, port); - } - - @Override - public String toString() { - return "Endpoint{" + - "protocol='" + protocol + '\'' + - ", host='" + host + '\'' + - ", port=" + port + - '}'; - } -} diff --git a/im-sdk-core/src/main/java/com/easemob/im/server/api/loadbalance/EndpointProvider.java b/im-sdk-core/src/main/java/com/easemob/im/server/api/loadbalance/EndpointProvider.java deleted file mode 100644 index add3e5bec..000000000 --- a/im-sdk-core/src/main/java/com/easemob/im/server/api/loadbalance/EndpointProvider.java +++ /dev/null @@ -1,9 +0,0 @@ -package com.easemob.im.server.api.loadbalance; - -import reactor.core.publisher.Mono; - -import java.util.List; - -public interface EndpointProvider { - Mono> endpoints(); -} diff --git a/im-sdk-core/src/main/java/com/easemob/im/server/api/loadbalance/EndpointProviderFactory.java b/im-sdk-core/src/main/java/com/easemob/im/server/api/loadbalance/EndpointProviderFactory.java deleted file mode 100644 index 23490a1fc..000000000 --- a/im-sdk-core/src/main/java/com/easemob/im/server/api/loadbalance/EndpointProviderFactory.java +++ /dev/null @@ -1,5 +0,0 @@ -package com.easemob.im.server.api.loadbalance; - -public interface EndpointProviderFactory { - EndpointProvider create(); -} diff --git a/im-sdk-core/src/main/java/com/easemob/im/server/api/loadbalance/EndpointRegistry.java b/im-sdk-core/src/main/java/com/easemob/im/server/api/loadbalance/EndpointRegistry.java deleted file mode 100644 index 9257948a9..000000000 --- a/im-sdk-core/src/main/java/com/easemob/im/server/api/loadbalance/EndpointRegistry.java +++ /dev/null @@ -1,9 +0,0 @@ -package com.easemob.im.server.api.loadbalance; - -import reactor.core.publisher.Mono; - -import java.util.List; - -public interface EndpointRegistry { - Mono> endpoints(); -} diff --git a/im-sdk-core/src/main/java/com/easemob/im/server/api/loadbalance/FixedEndpointProvider.java b/im-sdk-core/src/main/java/com/easemob/im/server/api/loadbalance/FixedEndpointProvider.java deleted file mode 100644 index e31bce802..000000000 --- a/im-sdk-core/src/main/java/com/easemob/im/server/api/loadbalance/FixedEndpointProvider.java +++ /dev/null @@ -1,39 +0,0 @@ -package com.easemob.im.server.api.loadbalance; - -import com.easemob.im.server.EMProperties; -import com.easemob.im.server.exception.EMInvalidArgumentException; -import io.netty.util.internal.StringUtil; -import reactor.core.publisher.Mono; - -import java.net.URI; -import java.net.URISyntaxException; -import java.util.Collections; -import java.util.List; - -public class FixedEndpointProvider implements EndpointProvider { - - private final EMProperties properties; - - public FixedEndpointProvider(EMProperties properties) { - this.properties = properties; - } - - @Override - public Mono> endpoints() { - String baseUri = this.properties.getBaseUri(); - URI uri = baseUriStringToURI(baseUri); - return Mono.just(Collections - .singletonList(new Endpoint(uri.getScheme(), uri.getHost(), uri.getPort()))); - } - - private URI baseUriStringToURI(String baseUri) { - if (StringUtil.isNullOrEmpty(baseUri)) { - throw new EMInvalidArgumentException("baseUri must not be null or blank"); - } - try { - return new URI(baseUri); - } catch (URISyntaxException e) { - throw new EMInvalidArgumentException(String.format("baseUri %s is illegal", baseUri)); - } - } -} diff --git a/im-sdk-core/src/main/java/com/easemob/im/server/api/loadbalance/GetDnsConfigResponse.java b/im-sdk-core/src/main/java/com/easemob/im/server/api/loadbalance/GetDnsConfigResponse.java deleted file mode 100644 index 6821460ee..000000000 --- a/im-sdk-core/src/main/java/com/easemob/im/server/api/loadbalance/GetDnsConfigResponse.java +++ /dev/null @@ -1,73 +0,0 @@ -package com.easemob.im.server.api.loadbalance; - -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonProperty; - -import java.util.List; -import java.util.stream.Collectors; - -public class GetDnsConfigResponse { - @JsonProperty("deploy_name") - private String name; - @JsonProperty("file_version") - private String version; - @JsonProperty("rest") - private Service service; - - @JsonCreator - public GetDnsConfigResponse(@JsonProperty("deploy_name") String name, - @JsonProperty("file_version") String version, - @JsonProperty("rest") Service service) { - this.name = name; - this.version = version; - this.service = service; - } - - public List toEndpoints() { - return this.service.toEndpoints(); - } - - public static class Service { - @JsonProperty("hosts") - private List records; - - public Service(@JsonProperty("hosts") List records) { - this.records = records; - } - - public List toEndpoints() { - return this.records.stream() - .map(ServiceRecord::toEndpoint) - .collect(Collectors.toList()); - } - } - - - public static class ServiceRecord { - @JsonProperty("protocol") - private String protocol; - @JsonProperty("domain") - private String domainName; - @JsonProperty("ip") - private String ip; - @JsonProperty("port") - private int port; - - public ServiceRecord(@JsonProperty("protocol") String protocol, - @JsonProperty("domain") String domainName, - @JsonProperty("ip") String ip, - @JsonProperty("port") int port) { - this.protocol = protocol; - this.domainName = domainName; - this.ip = ip; - this.port = port; - } - - public Endpoint toEndpoint() { - if (this.domainName != null) { - return new Endpoint(this.protocol, this.domainName, this.port); - } - return new Endpoint(this.protocol, this.ip, this.port); - } - } -} diff --git a/im-sdk-core/src/main/java/com/easemob/im/server/api/loadbalance/LoadBalancer.java b/im-sdk-core/src/main/java/com/easemob/im/server/api/loadbalance/LoadBalancer.java deleted file mode 100644 index 846077211..000000000 --- a/im-sdk-core/src/main/java/com/easemob/im/server/api/loadbalance/LoadBalancer.java +++ /dev/null @@ -1,7 +0,0 @@ -package com.easemob.im.server.api.loadbalance; - -import java.util.List; - -public interface LoadBalancer { - Endpoint loadBalance(List candidates); -} diff --git a/im-sdk-core/src/main/java/com/easemob/im/server/api/loadbalance/TimedRefreshEndpointRegistry.java b/im-sdk-core/src/main/java/com/easemob/im/server/api/loadbalance/TimedRefreshEndpointRegistry.java deleted file mode 100644 index 362a253b3..000000000 --- a/im-sdk-core/src/main/java/com/easemob/im/server/api/loadbalance/TimedRefreshEndpointRegistry.java +++ /dev/null @@ -1,32 +0,0 @@ -package com.easemob.im.server.api.loadbalance; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import reactor.core.publisher.Mono; - -import java.time.Duration; -import java.time.Instant; -import java.util.List; - -public class TimedRefreshEndpointRegistry implements EndpointRegistry { - - private static final Logger log = LoggerFactory.getLogger(TimedRefreshEndpointRegistry.class); - - private final EndpointProvider endpointProvider; - - private Mono> endpoints; - - public TimedRefreshEndpointRegistry(EndpointProvider endpointProvider, - Duration refreshInterval) { - this.endpointProvider = endpointProvider; - this.endpoints = endpointProvider.endpoints() - .cache(endpoints -> Duration.ofSeconds(86400), - error -> Duration.ofSeconds(10), - () -> Duration.ofSeconds(10)); - } - - @Override - public Mono> endpoints() { - return this.endpoints; - } -} diff --git a/im-sdk-core/src/main/java/com/easemob/im/server/api/loadbalance/UniformRandomLoadBalancer.java b/im-sdk-core/src/main/java/com/easemob/im/server/api/loadbalance/UniformRandomLoadBalancer.java deleted file mode 100644 index dfa3a1e51..000000000 --- a/im-sdk-core/src/main/java/com/easemob/im/server/api/loadbalance/UniformRandomLoadBalancer.java +++ /dev/null @@ -1,16 +0,0 @@ -package com.easemob.im.server.api.loadbalance; - -import com.easemob.im.server.exception.EMLoadBalanceException; - -import java.util.List; -import java.util.concurrent.ThreadLocalRandom; - -public class UniformRandomLoadBalancer implements LoadBalancer { - @Override - public Endpoint loadBalance(List candidates) { - if (candidates.isEmpty()) { - throw new EMLoadBalanceException("endpoints is empty"); - } - return candidates.get(ThreadLocalRandom.current().nextInt(candidates.size())); - } -} diff --git a/im-sdk-core/src/main/java/com/easemob/im/server/api/message/ChatroomMsgLevel.java b/im-sdk-core/src/main/java/com/easemob/im/server/api/message/ChatroomMsgLevel.java deleted file mode 100644 index ad20a5ba8..000000000 --- a/im-sdk-core/src/main/java/com/easemob/im/server/api/message/ChatroomMsgLevel.java +++ /dev/null @@ -1,26 +0,0 @@ -package com.easemob.im.server.api.message; - -public enum ChatroomMsgLevel { - LOW("low"), - NORMAL("normal"), - HIGH("high"); - - private String level; - - ChatroomMsgLevel(String level) { - this.level = level; - } - - public String getLevel() { - return level; - } - - public static ChatroomMsgLevel of(String name) { - for (ChatroomMsgLevel level : ChatroomMsgLevel.values()) { - if (level.getLevel().equalsIgnoreCase(name)) { - return level; - } - } - return null; - } -} diff --git a/im-sdk-core/src/main/java/com/easemob/im/server/api/message/MessageApi.java b/im-sdk-core/src/main/java/com/easemob/im/server/api/message/MessageApi.java deleted file mode 100644 index f3eeefe00..000000000 --- a/im-sdk-core/src/main/java/com/easemob/im/server/api/message/MessageApi.java +++ /dev/null @@ -1,1443 +0,0 @@ -package com.easemob.im.server.api.message; - -import com.easemob.im.server.EMProperties; -import com.easemob.im.server.api.Context; -import com.easemob.im.server.api.message.deletechannel.DeleteMessageChannel; -import com.easemob.im.server.api.message.history.MessageHistory; -import com.easemob.im.server.api.message.send.message.MessageSend; -import com.easemob.im.server.api.message.missed.MessageMissed; -import com.easemob.im.server.api.message.missed.MissedMessageCount; -import com.easemob.im.server.api.message.recall.RecallMessage; -import com.easemob.im.server.api.message.recall.RecallMessageSource; -import com.easemob.im.server.api.message.send.SendMessage; -import com.easemob.im.server.api.message.status.MessageStatus; -import com.easemob.im.server.api.message.upload.ImportMessage; -import com.easemob.im.server.exception.EMInvalidArgumentException; -import com.easemob.im.server.model.EMKeyValue; -import com.easemob.im.server.model.EMMessage; -import com.easemob.im.server.model.EMSentMessageIds; -import com.easemob.im.server.model.EMSentMessageResults; -import io.github.resilience4j.core.StringUtils; -import reactor.core.publisher.Flux; -import reactor.core.publisher.Mono; - -import java.nio.file.Path; -import java.time.Instant; -import java.util.HashSet; -import java.util.List; -import java.util.Set; - -/** - * 消息API。 - */ -public class MessageApi { - - private MessageMissed missed; - - private SendMessage sendMessage; - - private MessageSend messageSend; - - private MessageHistory messageHistory; - - private MessageStatus messageStatus; - - private RecallMessage recallMessage; - - private DeleteMessageChannel deleteMessageChannel; - - private ImportMessage importMessage; - - public MessageApi(Context context) { - EMProperties properties = context.getProperties(); - this.missed = new MessageMissed(context); - this.sendMessage = new SendMessage(context); - this.messageSend = new MessageSend(context); - this.messageHistory = new MessageHistory(context, properties.getServerTimezone()); - this.messageStatus = new MessageStatus(context); - this.recallMessage = new RecallMessage(context); - this.deleteMessageChannel = new DeleteMessageChannel(context); - this.importMessage = new ImportMessage(context); - } - - /** - * 查询用户离线消息数。 - *

- * API使用示例: - *

 {@code
-     * EMService service;
-     * try {
-     *     List messages = service.message().countMissedMessages("username").collectList().block();
-     * } catch (EMException e) {
-     *     e.getErrorCode();
-     *     e.getMessage();
-     * }
-     * }
- * - * @param username 用户名 - * @return 每个对话的离线消息数 - * @see 获取用户离线消息数 - */ - public Flux countMissedMessages(String username) { - return this.missed.count(username); - } - - /** - * 查询某条离线消息的状态,如是否已经传达。 - *

- * API使用示例: - *

 {@code
-     * EMService service;
-     * try {
-     *     Boolean isDelivered = service.message().isMessageDeliveredToUser("messageId", "toUser").block();
-     * } catch (EMException e) {
-     *     e.getErrorCode();
-     *     e.getMessage();
-     * }
-     * }
- * - * @param messageId 要查看对消息ID - * @param toUser 消息接收方的用户名 - * @return 是否送达或错误 - * @see 获取某条离线消息状态 - */ - public Mono isMessageDeliveredToUser(String messageId, String toUser) { - return this.messageStatus.isMessageDeliveredToUser(messageId, toUser); - } - - /** - * 构造消息并发送。将在后续版本中移除,请使用sendMsg方法。 - *

- * 例如,向用户发送一条带有扩展字段的文本消息: - *

{@code
-     * EMService service;
-     * try {
-     *     service.message().send()
-     *                      .fromUser("alice").toUser("rabbit")
-     *                      .text(msg -> msg.text("hello"))
-     *                      .extension(exts -> exts.add(EMKeyValue.of("timeout", 1)))
-     *                      .send()
-     *                      .block();
-     * } catch (EMException e) {
-     *     e.getErrorCode();
-     *     e.getMessage();
-     * }
-     * }
- * - *

- * 如果需要向一个群组或聊天室发消息,将示例中的 toUser 改成 toGroup 或 toRoom,并传入对应的群组或聊天室id - *

- * 如果需要向多个用户或群组或聊天室发消息,将示例中的 toUser 改成 toUsers 或 toGroups 或 toRooms,并传入对应的用户或群组或聊天室id - *

- * 将上述发送文本消息示例中的 `.text(...) `替换掉,来发送其他类型消息示例: - *

- * 发送图片消息:{@code .image(msg -> msg.uri(URI.create("http://example/image.png")).secret("secret").displayName("image.png"))} - *

- * 发送语音消息:{@code .voice(msg -> msg.uri(URI.create("http://example/voice.amr")).duration(3).secret("secret").displayName("voice.amr"))} - *

- * 发送视频消息:{@code .video(msg -> msg.uri(URI.create("http://example/video.mp4")).duration(3).secret("secret").displayName("video.mp4").thumb("http://example/videoThumbnail").thumbSecret("thumbSecret"))} - *

- * 发送文件消息:{@code .file(msg -> msg.uri(URI.create("http://example/file.txt")).secret("secret").displayName("file.txt"))} - *

- * 发送位置消息:{@code .location(msg -> msg.latitude(1.234567).longitude(1.234567).address("some where"))} - *

- * 发送自定义类型消息:{@code .custom(msg -> msg.customEvent("liked").customExtension("name", "forest"))} - *

- * - * @return 发送消息的构造器 - * @see 发送消息 - */ - @Deprecated - public SendMessage send() { - return this.sendMessage; - } - - /** - * 构造消息并发送。 - *

- * 例如,向用户发送一条带有扩展字段的文本消息: - *

{@code
-     * EMService service;
-     * try {
-     *     service.message().sendMsg()
-     *                      .fromUser("alice").toUser("rabbit")
-     *                      .text(msg -> msg.text("hello"))
-     *                      .extension(exts -> exts.add(EMKeyValue.of("timeout", 1)))
-     *                      .send()
-     *                      .block();
-     * } catch (EMException e) {
-     *     e.getErrorCode();
-     *     e.getMessage();
-     * }
-     * }
- * - *

- * 如果需要向一个群组或聊天室发消息,将示例中的 toUser 改成 toGroup 或 toRoom,并传入对应的群组或聊天室id - *

- * 如果需要向多个用户或群组或聊天室发消息,将示例中的 toUser 改成 toUsers 或 toGroups 或 toRooms,并传入对应的用户或群组或聊天室id - *

- * 将上述发送文本消息示例中的 `.text(...) `替换掉,来发送其他类型消息示例: - *

- * 发送图片消息:{@code .image(msg -> msg.uri(URI.create("http://example/image.png")).secret("secret").displayName("image.png"))} - *

- * 发送语音消息:{@code .voice(msg -> msg.uri(URI.create("http://example/voice.amr")).duration(3).secret("secret").displayName("voice.amr"))} - *

- * 发送视频消息:{@code .video(msg -> msg.uri(URI.create("http://example/video.mp4")).duration(3).secret("secret").displayName("video.mp4").thumb("http://example/videoThumbnail").thumbSecret("thumbSecret"))} - *

- * 发送文件消息:{@code .file(msg -> msg.uri(URI.create("http://example/file.txt")).secret("secret").displayName("file.txt"))} - *

- * 发送位置消息:{@code .location(msg -> msg.latitude(1.234567).longitude(1.234567).address("some where"))} - *

- * 发送自定义类型消息:{@code .custom(msg -> msg.customEvent("liked").customExtension("name", "forest"))} - *

- * - * @return 发送消息的构造器 - * @see 发送消息 - */ - public MessageSend sendMsg() { - return this.messageSend; - } - - /** - * 发送消息。将在后续版本中移除,请使用sendMsg方法。 - *

- * API使用示例: - *

 {@code
-     * EMService service;
-     *
-     * 例如,向用户发送一条带有扩展字段的文本消息
-     * Set toUsers = new HashSet<>();
-     * toUsers.add("toUserName");
-     *
-     * EMTextMessage textMessage = new EMTextMessage().text("hello");
-     *
-     * Set exts = new HashSet<>();
-     * exts.add(EMKeyValue.of("key", "value"));
-     *
-     * try {
-     *     EMSentMessageIds messageIds = service.message().send("fromUserName", "users", toUsers, textMessage, exts).block();
-     * } catch (EMException e) {
-     *     e.getErrorCode();
-     *     e.getMessage();
-     * }
-     *
-     * 例如,向群组发送一条带有扩展字段的图片消息
-     * Set toGroups = new HashSet<>();
-     * toGroups.add("toGroupId");
-     *
-     * EMImageMessage imageMessage =
-     *         new EMImageMessage().uri(URI.create("http://example/image.png")).secret("secret")
-     *                 .displayName("image.png");
-     *
-     * Set exts1 = new HashSet<>();
-     * exts1.add(EMKeyValue.of("key", "value"));
-     * exts1.add(EMKeyValue.of("key1", 10));
-     * exts1.add(EMKeyValue.of("key2", new HashMap() {
-     *     {
-     *         put("mkey1", "mvalue1");
-     *         put("mkey2", "mvalue2");
-     *     }
-     * }));
-     *
-     * try {
-     *     EMSentMessageIds messageIds = service.message().send("fromUserName", "chatgroups", toGroups, imageMessage, exts1).block();
-     * } catch (EMException e) {
-     *     e.getErrorCode();
-     *     e.getMessage();
-     * }
-     *
-     * }
- * - * @param from 发送者用户名 - * @param toType 目标类型,可以是 `users`, `chatgroups`, `chatrooms` - * @param tos 目标id列表 - * @param message 要发送的消息,EMTextMessage文本消息,EMImageMessage图片消息,EMVoiceMessage语音消息, - * EMVideoMessage视频消息,EMFileMessage文件消息,EMCommandMessage透传消息,EMCustomMessage自定义类型消息, - * 各种类型消息需要自己构造 - * @param extensions 要发送的扩展,可以为空 - * @return 发消息响应或错误 - * @see 发送消息 - */ - @Deprecated - public Mono send(String from, String toType, Set tos, - EMMessage message, Set extensions) { - return this.sendMessage.send(from, toType, checkTos(tos), message, extensions); - } - - /** - * 发送消息。 - *

- * API使用示例: - *

 {@code
-     * EMService service;
-     *
-     * 例如,向用户发送一条带有扩展字段的文本消息
-     * Set toUsers = new HashSet<>();
-     * toUsers.add("toUserName");
-     *
-     * EMTextMessage textMessage = new EMTextMessage().text("hello");
-     *
-     * Set exts = new HashSet<>();
-     * exts.add(EMKeyValue.of("key", "value"));
-     *
-     * try {
-     *     EMSentMessageIds messageIds = service.message().sendMsg("fromUserName", "users", toUsers, textMessage, exts).block();
-     * } catch (EMException e) {
-     *     e.getErrorCode();
-     *     e.getMessage();
-     * }
-     *
-     * 例如,向群组发送一条带有扩展字段的图片消息
-     * Set toGroups = new HashSet<>();
-     * toGroups.add("toGroupId");
-     *
-     * EMImageMessage imageMessage =
-     *         new EMImageMessage().uri(URI.create("http://example/image.png")).secret("secret")
-     *                 .displayName("image.png");
-     *
-     * Set exts1 = new HashSet<>();
-     * exts1.add(EMKeyValue.of("key", "value"));
-     * exts1.add(EMKeyValue.of("key1", 10));
-     * exts1.add(EMKeyValue.of("key2", new HashMap() {
-     *     {
-     *         put("mkey1", "mvalue1");
-     *         put("mkey2", "mvalue2");
-     *     }
-     * }));
-     *
-     * try {
-     *     EMSentMessageIds messageIds = service.message().sendMsg("fromUserName", "chatgroups", toGroups, imageMessage, exts1).block();
-     * } catch (EMException e) {
-     *     e.getErrorCode();
-     *     e.getMessage();
-     * }
-     *
-     * }
- * - * @param from 发送者用户名 - * @param toType 目标类型,可以是 `users`, `chatgroups`, `chatrooms` - * @param tos 目标id列表 - * @param message 要发送的消息,EMTextMessage文本消息,EMImageMessage图片消息,EMVoiceMessage语音消息, - * EMVideoMessage视频消息,EMFileMessage文件消息,EMCommandMessage透传消息,EMCustomMessage自定义类型消息, - * 各种类型消息需要自己构造 - * @param extensions 要发送的扩展,可以为空 - * @return 发消息响应或错误 - * @see 发送消息 - */ - public Mono sendMsg(String from, String toType, Set tos, - EMMessage message, Set extensions) { - return this.messageSend.send(from, toType, checkTos(tos), message, extensions); - } - - /** - * 发送消息,不返回消息 ID。将在后续版本中移除。 - *

- * API使用示例: - *

 {@code
-     * EMService service;
-     *
-     * 例如,向用户发送一条带有扩展字段的文本消息
-     * Set toUsers = new HashSet<>();
-     * toUsers.add("toUserName");
-     *
-     * EMTextMessage textMessage = new EMTextMessage().text("hello");
-     *
-     * Set exts = new HashSet<>();
-     * exts.add(EMKeyValue.of("key", "value"));
-     *
-     * try {
-     *     EMSentMessageIds messageIds = service.message().sendWithoutMsgId("fromUserName", "users", toUsers, textMessage, exts).block();
-     * } catch (EMException e) {
-     *     e.getErrorCode();
-     *     e.getMessage();
-     * }
-     *
-     * 例如,向群组发送一条带有扩展字段的图片消息
-     * Set toGroups = new HashSet<>();
-     * toGroups.add("toGroupId");
-     *
-     * EMImageMessage imageMessage =
-     *         new EMImageMessage().uri(URI.create("http://example/image.png")).secret("secret")
-     *                 .displayName("image.png");
-     *
-     * Set exts1 = new HashSet<>();
-     * exts1.add(EMKeyValue.of("key", "value"));
-     * exts1.add(EMKeyValue.of("key1", 10));
-     * exts1.add(EMKeyValue.of("key2", new HashMap() {
-     *     {
-     *         put("mkey1", "mvalue1");
-     *         put("mkey2", "mvalue2");
-     *     }
-     * }));
-     *
-     * try {
-     *     EMSentMessageIds messageIds = service.message().sendWithoutMsgId("fromUserName", "chatgroups", toGroups, imageMessage, exts1).block();
-     * } catch (EMException e) {
-     *     e.getErrorCode();
-     *     e.getMessage();
-     * }
-     *
-     * }
- * - * @param from 发送者用户名 - * @param toType 目标类型,可以是 `users`, `chatgroups`, `chatrooms` - * @param tos 目标id列表 - * @param message 要发送的消息,EMTextMessage文本消息,EMImageMessage图片消息,EMVoiceMessage语音消息, - * EMVideoMessage视频消息,EMFileMessage文件消息,EMCommandMessage透传消息,EMCustomMessage自定义类型消息, - * 各种类型消息需要自己构造 - * @param extensions 要发送的扩展,可以为空 - * @return 发消息响应或错误 - * @see 发送消息 - */ - @Deprecated - public Mono sendWithoutMsgId(String from, String toType, Set tos, - EMMessage message, Set extensions) { - return this.sendMessage.sendWithoutMsgId(from, toType, checkTos(tos), message, extensions); - } - - /** - * 发送消息(只投递在线消息)。将在后续版本中移除,请使用sendMsg方法。 - *

- * API使用示例: - *

 {@code
-     * EMService service;
-     *
-     * 例如,向用户发送一条带有扩展字段的文本消息
-     * Set toUsers = new HashSet<>();
-     * toUsers.add("toUserName");
-     *
-     * EMTextMessage textMessage = new EMTextMessage().text("hello");
-     *
-     * Set exts = new HashSet<>();
-     * exts.add(EMKeyValue.of("key", "value"));
-     *
-     * try {
-     *     EMSentMessageIds messageIds = service.message().send("fromUserName", "users", toUsers, textMessage, exts, "ROUTE_ONLINE").block();
-     * } catch (EMException e) {
-     *     e.getErrorCode();
-     *     e.getMessage();
-     * }
-     *
-     * 例如,向群组发送一条带有扩展字段的图片消息
-     * Set toGroups = new HashSet<>();
-     * toGroups.add("toGroupId");
-     *
-     * EMImageMessage imageMessage =
-     *         new EMImageMessage().uri(URI.create("http://example/image.png")).secret("secret")
-     *                 .displayName("image.png");
-     *
-     * Set exts1 = new HashSet<>();
-     * exts1.add(EMKeyValue.of("key", "value"));
-     * exts1.add(EMKeyValue.of("key1", 10));
-     * exts1.add(EMKeyValue.of("key2", new HashMap() {
-     *     {
-     *         put("mkey1", "mvalue1");
-     *         put("mkey2", "mvalue2");
-     *     }
-     * }));
-     *
-     * try {
-     *     EMSentMessageIds messageIds = service.message().send("fromUserName", "chatgroups", toGroups, imageMessage, exts1, "ROUTE_ONLINE").block();
-     * } catch (EMException e) {
-     *     e.getErrorCode();
-     *     e.getMessage();
-     * }
-     *
-     * }
- * - * @param from 发送者用户名 - * @param toType 目标类型,可以是 `users`, `chatgroups`, `chatrooms` - * @param tos 目标id列表 - * @param message 要发送的消息 - * @param extensions 要发送的扩展,可以为空 - * @param routeType 只投递在线消息,请传入 `ROUTE_ONLINE` - * @return 发消息响应或错误 - * @see 发送消息 - */ - @Deprecated - public Mono send(String from, String toType, Set tos, - EMMessage message, Set extensions, String routeType) { - return this.sendMessage.send(from, toType, checkTos(tos), message, extensions, routeType); - } - /** - * 发送消息(只投递在线消息)。 - *

- * API使用示例: - *

 {@code
-     * EMService service;
-     *
-     * 例如,向用户发送一条带有扩展字段的文本消息
-     * Set toUsers = new HashSet<>();
-     * toUsers.add("toUserName");
-     *
-     * EMTextMessage textMessage = new EMTextMessage().text("hello");
-     *
-     * Set exts = new HashSet<>();
-     * exts.add(EMKeyValue.of("key", "value"));
-     *
-     * try {
-     *     EMSentMessageIds messageIds = service.message().sendMsg("fromUserName", "users", toUsers, textMessage, exts, "ROUTE_ONLINE").block();
-     * } catch (EMException e) {
-     *     e.getErrorCode();
-     *     e.getMessage();
-     * }
-     *
-     * 例如,向群组发送一条带有扩展字段的图片消息
-     * Set toGroups = new HashSet<>();
-     * toGroups.add("toGroupId");
-     *
-     * EMImageMessage imageMessage =
-     *         new EMImageMessage().uri(URI.create("http://example/image.png")).secret("secret")
-     *                 .displayName("image.png");
-     *
-     * Set exts1 = new HashSet<>();
-     * exts1.add(EMKeyValue.of("key", "value"));
-     * exts1.add(EMKeyValue.of("key1", 10));
-     * exts1.add(EMKeyValue.of("key2", new HashMap() {
-     *     {
-     *         put("mkey1", "mvalue1");
-     *         put("mkey2", "mvalue2");
-     *     }
-     * }));
-     *
-     * try {
-     *     EMSentMessageIds messageIds = service.message().sendMsg("fromUserName", "chatgroups", toGroups, imageMessage, exts1, "ROUTE_ONLINE").block();
-     * } catch (EMException e) {
-     *     e.getErrorCode();
-     *     e.getMessage();
-     * }
-     *
-     * }
- * - * @param from 发送者用户名 - * @param toType 目标类型,可以是 `users`, `chatgroups`, `chatrooms` - * @param tos 目标id列表 - * @param message 要发送的消息 - * @param extensions 要发送的扩展,可以为空 - * @param routeType 只投递在线消息,请传入 `ROUTE_ONLINE` - * @return 发消息响应或错误 - * @see 发送消息 - */ - public Mono sendMsg(String from, String toType, Set tos, - EMMessage message, Set extensions, String routeType) { - return this.messageSend.send(from, toType, checkTos(tos), message, extensions, routeType); - } - - /** - * 指定群组用户发送消息,你可以向群组中指定的一个或多个成员发送消息,但单次仅支持指定一个群组。 - * 对于定向消息,只有作为接收方的指定成员才能看到消息,其他群成员则看不到该消息。 - * - *

- * API使用示例: - *

 {@code
-     * EMService service;
-     *
-     * 例如,向指定群组用户发送一条带有扩展字段的文本消息
-     * Set toGroups = new HashSet<>();
-     * toGroups.add("toGroupId");
-     *
-     * Set toGroupUsers = new HashSet<>();
-     * toGroupUsers.add("toUserName");
-     *
-     * EMTextMessage textMessage = new EMTextMessage().text("hello");
-     *
-     * Set exts = new HashSet<>();
-     * exts.add(EMKeyValue.of("key", "value"));
-     *
-     * try {
-     *     EMSentMessageIds messageIds = service.message().sendMsg("fromUserName", toGroups, textMessage, toGroupUsers, exts, true).block();
-     * } catch (EMException e) {
-     *     e.getErrorCode();
-     *     e.getMessage();
-     * }
-     *
-     * }
- * - * @param from 发送者用户名 - * @param toGroups 消息接收方所属的群组 ID。目前每次只能传 1 个群组 ID。 - * @param message 要发送的消息 - * @param toGroupUsers 接收消息的群成员的用户 ID 数组。每次最多可传 20 个用户 ID。 - * @param extensions 要发送的扩展,可以为空 - * @param syncDevice 消息发送成功后,是否将消息同步到发送方,true:是同步给发送方,false:是不同给发送方 - * @return 发消息响应或错误 - * @see 发送定向消息 - */ - public Mono sendMsg(String from, Set toGroups, - EMMessage message, Set toGroupUsers, Set extensions, - Boolean syncDevice) { - return this.messageSend.send(from, checkTos(toGroups), message, checkTos(toGroupUsers), extensions, - syncDevice); - } - - /** - * 指定聊天室用户发送消息,你可以向聊天室中指定的一个或多个成员发送消息,但单次仅支持指定一个聊天室。 - * 对于定向消息,只有作为接收方的指定成员才能看到消息,其他聊天室成员则看不到该消息。 - * - *

- * API使用示例: - *

 {@code
-     * EMService service;
-     *
-     * 例如,向指定聊天室用户发送一条带有扩展字段的文本消息
-     * Set toRooms = new HashSet<>();
-     * toRooms.add("toRoomId");
-     *
-     * Set toRoomUsers = new HashSet<>();
-     * toRoomUsers.add("toUserName");
-     *
-     * EMTextMessage textMessage = new EMTextMessage().text("hello");
-     *
-     * Set exts = new HashSet<>();
-     * exts.add(EMKeyValue.of("key", "value"));
-     *
-     * try {
-     *     EMSentMessageIds messageIds = service.message().sendMsg("fromUserName", toRooms, textMessage, toRoomUsers, exts, true, ChatroomMsgLevel.NORMAL).block();
-     * } catch (EMException e) {
-     *     e.getErrorCode();
-     *     e.getMessage();
-     * }
-     *
-     * }
- * - * @param from 发送者用户名 - * @param toRooms 消息接收方所属的聊天室 ID。目前每次只能传 1 个聊天室 ID。 - * @param message 要发送的消息 - * @param toRoomUsers 接收消息的聊天室成员的用户 ID 数组。每次最多可传 20 个用户 ID。 - * @param extensions 要发送的扩展,可以为空 - * @param syncDevice 消息发送成功后,是否将消息同步到发送方,true:是同步给发送方,false:是不同给发送方 - * @param chatroomMsgLevel 聊天室消息优先级: LOW-低优先级,NORMAL-普通优先级,HIGH-高优先级 - * @return 发消息响应或错误 - * @see 发送定向消息 - */ - public Mono sendMsg(String from, Set toRooms, - EMMessage message, Set toRoomUsers, Set extensions, - Boolean syncDevice, ChatroomMsgLevel chatroomMsgLevel) { - return this.messageSend.send(from, checkTos(toRooms), message, checkTos(toRoomUsers), extensions, - syncDevice, chatroomMsgLevel); - } - - /** - * 发送消息(只投递在线消息),不返回消息 ID。将在后续版本中移除。 - *

- * API使用示例: - *

 {@code
-     * EMService service;
-     *
-     * 例如,向用户发送一条带有扩展字段的文本消息
-     * Set toUsers = new HashSet<>();
-     * toUsers.add("toUserName");
-     *
-     * EMTextMessage textMessage = new EMTextMessage().text("hello");
-     *
-     * Set exts = new HashSet<>();
-     * exts.add(EMKeyValue.of("key", "value"));
-     *
-     * try {
-     *     EMSentMessageResults messageResults = service.message().send("fromUserName", "users", toUsers, textMessage, exts, "ROUTE_ONLINE").block();
-     * } catch (EMException e) {
-     *     e.getErrorCode();
-     *     e.getMessage();
-     * }
-     *
-     * 例如,向群组发送一条带有扩展字段的图片消息
-     * Set toGroups = new HashSet<>();
-     * toGroups.add("toGroupId");
-     *
-     * EMImageMessage imageMessage =
-     *         new EMImageMessage().uri(URI.create("http://example/image.png")).secret("secret")
-     *                 .displayName("image.png");
-     *
-     * Set exts1 = new HashSet<>();
-     * exts1.add(EMKeyValue.of("key", "value"));
-     * exts1.add(EMKeyValue.of("key1", 10));
-     * exts1.add(EMKeyValue.of("key2", new HashMap() {
-     *     {
-     *         put("mkey1", "mvalue1");
-     *         put("mkey2", "mvalue2");
-     *     }
-     * }));
-     *
-     * try {
-     *     EMSentMessageResults messageResults = service.message().send("fromUserName", "chatgroups", toGroups, imageMessage, exts1, "ROUTE_ONLINE").block();
-     * } catch (EMException e) {
-     *     e.getErrorCode();
-     *     e.getMessage();
-     * }
-     *
-     * }
- * - * @param from 发送者用户名 - * @param toType 目标类型,可以是 `users`, `chatgroups`, `chatrooms` - * @param tos 目标id列表 - * @param message 要发送的消息 - * @param extensions 要发送的扩展,可以为空 - * @param routeType 只投递在线消息,请传入 `ROUTE_ONLINE` - * @return 发消息响应或错误 - * @see 发送消息 - */ - @Deprecated - public Mono sendWithoutMsgId(String from, String toType, Set tos, - EMMessage message, Set extensions, String routeType) { - return this.sendMessage.sendWithoutMsgId(from, toType, checkTos(tos), message, extensions, routeType); - } - - /** - * 发送消息。将在后续版本中移除,请使用sendMsg方法。 - *

- * API使用示例: - *

 {@code
-     * EMService service;
-     *
-     * 例如,向用户发送一条带有扩展字段的文本消息
-     * Set toUsers = new HashSet<>();
-     * toUsers.add("toUserName");
-     *
-     * EMTextMessage textMessage = new EMTextMessage().text("hello");
-     *
-     * Set exts = new HashSet<>();
-     * exts.add(EMKeyValue.of("key", "value"));
-     *
-     * try {
-     *     EMSentMessageIds messageIds = service.message().send("fromUserName", "users", toUsers, textMessage, exts, true).block();
-     * } catch (EMException e) {
-     *     e.getErrorCode();
-     *     e.getMessage();
-     * }
-     *
-     * 例如,向群组发送一条带有扩展字段的图片消息
-     * Set toGroups = new HashSet<>();
-     * toGroups.add("toGroupId");
-     *
-     * EMImageMessage imageMessage =
-     *         new EMImageMessage().uri(URI.create("http://example/image.png")).secret("secret")
-     *                 .displayName("image.png");
-     *
-     * Set exts1 = new HashSet<>();
-     * exts1.add(EMKeyValue.of("key", "value"));
-     * exts1.add(EMKeyValue.of("key1", 10));
-     * exts1.add(EMKeyValue.of("key2", new HashMap() {
-     *     {
-     *         put("mkey1", "mvalue1");
-     *         put("mkey2", "mvalue2");
-     *     }
-     * }));
-     *
-     * try {
-     *     EMSentMessageIds messageIds = service.message().send("fromUserName", "chatgroups", toGroups, imageMessage, exts1, true).block();
-     * } catch (EMException e) {
-     *     e.getErrorCode();
-     *     e.getMessage();
-     * }
-     *
-     * }
- * - * @param from 发送者用户名 - * @param toType 目标类型,可以是 `users`, `chatgroups`, `chatrooms` - * @param tos 目标id列表 - * @param message 要发送的消息 - * @param extensions 要发送的扩展,可以为空 - * @param syncDevice 消息发送成功后,是否将消息同步到发送方,true:是同步给发送方,false:是不同给发送方 - * @return 发消息响应或错误 - * @see 发送消息 - */ - @Deprecated - public Mono send(String from, String toType, Set tos, - EMMessage message, Set extensions, Boolean syncDevice) { - return this.sendMessage.send(from, toType, checkTos(tos), message, extensions, syncDevice); - } - - /** - * 发送消息。 - *

- * API使用示例: - *

 {@code
-     * EMService service;
-     *
-     * 例如,向用户发送一条带有扩展字段的文本消息
-     * Set toUsers = new HashSet<>();
-     * toUsers.add("toUserName");
-     *
-     * EMTextMessage textMessage = new EMTextMessage().text("hello");
-     *
-     * Set exts = new HashSet<>();
-     * exts.add(EMKeyValue.of("key", "value"));
-     *
-     * try {
-     *     EMSentMessageIds messageIds = service.message().sendMsg("fromUserName", "users", toUsers, textMessage, exts, true).block();
-     * } catch (EMException e) {
-     *     e.getErrorCode();
-     *     e.getMessage();
-     * }
-     *
-     * 例如,向群组发送一条带有扩展字段的图片消息
-     * Set toGroups = new HashSet<>();
-     * toGroups.add("toGroupId");
-     *
-     * EMImageMessage imageMessage =
-     *         new EMImageMessage().uri(URI.create("http://example/image.png")).secret("secret")
-     *                 .displayName("image.png");
-     *
-     * Set exts1 = new HashSet<>();
-     * exts1.add(EMKeyValue.of("key", "value"));
-     * exts1.add(EMKeyValue.of("key1", 10));
-     * exts1.add(EMKeyValue.of("key2", new HashMap() {
-     *     {
-     *         put("mkey1", "mvalue1");
-     *         put("mkey2", "mvalue2");
-     *     }
-     * }));
-     *
-     * try {
-     *     EMSentMessageIds messageIds = service.message().sendMsg("fromUserName", "chatgroups", toGroups, imageMessage, exts1, true).block();
-     * } catch (EMException e) {
-     *     e.getErrorCode();
-     *     e.getMessage();
-     * }
-     *
-     * }
- * - * @param from 发送者用户名 - * @param toType 目标类型,可以是 `users`, `chatgroups`, `chatrooms` - * @param tos 目标id列表 - * @param message 要发送的消息 - * @param extensions 要发送的扩展,可以为空 - * @param syncDevice 消息发送成功后,是否将消息同步到发送方,true:是同步给发送方,false:是不同给发送方 - * @return 发消息响应或错误 - * @see 发送消息 - */ - public Mono sendMsg(String from, String toType, Set tos, - EMMessage message, Set extensions, Boolean syncDevice) { - return this.messageSend.send(from, toType, checkTos(tos), message, extensions, syncDevice); - } - - /** - * 发送消息,不返回消息 ID。将在后续版本中移除。 - *

- * API使用示例: - *

 {@code
-     * EMService service;
-     *
-     * 例如,向用户发送一条带有扩展字段的文本消息
-     * Set toUsers = new HashSet<>();
-     * toUsers.add("toUserName");
-     *
-     * EMTextMessage textMessage = new EMTextMessage().text("hello");
-     *
-     * Set exts = new HashSet<>();
-     * exts.add(EMKeyValue.of("key", "value"));
-     *
-     * try {
-     *     EMSentMessageResults messageResults = service.message().sendWithoutMsgId("fromUserName", "users", toUsers, textMessage, exts, true).block();
-     * } catch (EMException e) {
-     *     e.getErrorCode();
-     *     e.getMessage();
-     * }
-     *
-     * 例如,向群组发送一条带有扩展字段的图片消息
-     * Set toGroups = new HashSet<>();
-     * toGroups.add("toGroupId");
-     *
-     * EMImageMessage imageMessage =
-     *         new EMImageMessage().uri(URI.create("http://example/image.png")).secret("secret")
-     *                 .displayName("image.png");
-     *
-     * Set exts1 = new HashSet<>();
-     * exts1.add(EMKeyValue.of("key", "value"));
-     * exts1.add(EMKeyValue.of("key1", 10));
-     * exts1.add(EMKeyValue.of("key2", new HashMap() {
-     *     {
-     *         put("mkey1", "mvalue1");
-     *         put("mkey2", "mvalue2");
-     *     }
-     * }));
-     *
-     * try {
-     *     EMSentMessageResults messageResults = service.message().sendWithoutMsgId("fromUserName", "chatgroups", toGroups, imageMessage, exts1, true).block();
-     * } catch (EMException e) {
-     *     e.getErrorCode();
-     *     e.getMessage();
-     * }
-     *
-     * }
- * - * @param from 发送者用户名 - * @param toType 目标类型,可以是 `users`, `chatgroups`, `chatrooms` - * @param tos 目标id列表 - * @param message 要发送的消息 - * @param extensions 要发送的扩展,可以为空 - * @param syncDevice 消息发送成功后,是否将消息同步到发送方,true:是同步给发送方,false:是不同给发送方 - * @return 发消息响应或错误 - * @see 发送消息 - */ - @Deprecated - public Mono sendWithoutMsgId(String from, String toType, Set tos, - EMMessage message, Set extensions, Boolean syncDevice) { - return this.sendMessage.sendWithoutMsgId(from, toType, checkTos(tos), message, extensions, syncDevice); - } - - /** - * 发送消息。将在后续版本中移除,请使用sendMsg方法。 - *

- * API使用示例: - *

 {@code
-     * EMService service;
-     *
-     * 例如,向用户发送一条带有扩展字段的文本消息
-     * Set toUsers = new HashSet<>();
-     * toUsers.add("toUserName");
-     *
-     * EMTextMessage textMessage = new EMTextMessage().text("hello");
-     *
-     * Set exts = new HashSet<>();
-     * exts.add(EMKeyValue.of("key", "value"));
-     *
-     * try {
-     *     EMSentMessageIds messageIds = service.message().send("fromUserName", "users", toUsers, textMessage, exts, "ROUTE_ONLINE", true).block();
-     * } catch (EMException e) {
-     *     e.getErrorCode();
-     *     e.getMessage();
-     * }
-     *
-     * 例如,向群组发送一条带有扩展字段的图片消息
-     * Set toGroups = new HashSet<>();
-     * toGroups.add("toGroupId");
-     *
-     * EMImageMessage imageMessage =
-     *         new EMImageMessage().uri(URI.create("http://example/image.png")).secret("secret")
-     *                 .displayName("image.png");
-     *
-     * Set exts1 = new HashSet<>();
-     * exts1.add(EMKeyValue.of("key", "value"));
-     * exts1.add(EMKeyValue.of("key1", 10));
-     * exts1.add(EMKeyValue.of("key2", new HashMap() {
-     *     {
-     *         put("mkey1", "mvalue1");
-     *         put("mkey2", "mvalue2");
-     *     }
-     * }));
-     *
-     * try {
-     *     EMSentMessageIds messageIds = service.message().send("fromUserName", "chatgroups", toGroups, imageMessage, exts1, "ROUTE_ONLINE", true).block();
-     * } catch (EMException e) {
-     *     e.getErrorCode();
-     *     e.getMessage();
-     * }
-     *
-     * }
- * - * @param from 发送者用户名 - * @param toType 目标类型,可以是 `users`, `chatgroups`, `chatrooms` - * @param tos 目标id列表 - * @param message 要发送的消息 - * @param extensions 要发送的扩展,可以为空 - * @param routeType 只投递在线消息,请传入 `ROUTE_ONLINE` - * @param syncDevice 消息发送成功后,是否将消息同步到发送方,true:是同步给发送方,false:是不同给发送方 - * @return 发消息响应或错误 - * @see 发送消息 - */ - @Deprecated - public Mono send(String from, String toType, Set tos, - EMMessage message, Set extensions, String routeType, Boolean syncDevice) { - return this.sendMessage.send(from, toType, checkTos(tos), message, extensions, routeType, syncDevice); - } - - /** - * 发送消息。 - *

- * API使用示例: - *

 {@code
-     * EMService service;
-     *
-     * 例如,向用户发送一条带有扩展字段的文本消息
-     * Set toUsers = new HashSet<>();
-     * toUsers.add("toUserName");
-     *
-     * EMTextMessage textMessage = new EMTextMessage().text("hello");
-     *
-     * Set exts = new HashSet<>();
-     * exts.add(EMKeyValue.of("key", "value"));
-     *
-     * try {
-     *     EMSentMessageIds messageIds = service.message().sendMsg("fromUserName", "users", toUsers, textMessage, exts, "ROUTE_ONLINE", true).block();
-     * } catch (EMException e) {
-     *     e.getErrorCode();
-     *     e.getMessage();
-     * }
-     *
-     * 例如,向群组发送一条带有扩展字段的图片消息
-     * Set toGroups = new HashSet<>();
-     * toGroups.add("toGroupId");
-     *
-     * EMImageMessage imageMessage =
-     *         new EMImageMessage().uri(URI.create("http://example/image.png")).secret("secret")
-     *                 .displayName("image.png");
-     *
-     * Set exts1 = new HashSet<>();
-     * exts1.add(EMKeyValue.of("key", "value"));
-     * exts1.add(EMKeyValue.of("key1", 10));
-     * exts1.add(EMKeyValue.of("key2", new HashMap() {
-     *     {
-     *         put("mkey1", "mvalue1");
-     *         put("mkey2", "mvalue2");
-     *     }
-     * }));
-     *
-     * try {
-     *     EMSentMessageIds messageIds = service.message().sendMsg("fromUserName", "chatgroups", toGroups, imageMessage, exts1, "ROUTE_ONLINE", true).block();
-     * } catch (EMException e) {
-     *     e.getErrorCode();
-     *     e.getMessage();
-     * }
-     *
-     * }
- * - * @param from 发送者用户名 - * @param toType 目标类型,可以是 `users`, `chatgroups`, `chatrooms` - * @param tos 目标id列表 - * @param message 要发送的消息 - * @param extensions 要发送的扩展,可以为空 - * @param routeType 只投递在线消息,请传入 `ROUTE_ONLINE` - * @param syncDevice 消息发送成功后,是否将消息同步到发送方,true:是同步给发送方,false:是不同给发送方 - * @return 发消息响应或错误 - * @see 发送消息 - */ - public Mono sendMsg(String from, String toType, Set tos, - EMMessage message, Set extensions, String routeType, Boolean syncDevice) { - return this.messageSend.send(from, toType, checkTos(tos), message, extensions, routeType, syncDevice); - } - - /** - * 发送消息,支持设置聊天室消息优先级。 - *

- * API使用示例: - *

 {@code
-     * EMService service;
-     *
-     * 例如,向聊天室发送一条带有扩展字段的图片消息
-     * Set toChatRooms = new HashSet<>();
-     * toChatRooms.add("toChatroomId");
-     *
-     * EMImageMessage imageMessage =
-     *         new EMImageMessage().uri(URI.create("http://example/image.png")).secret("secret")
-     *                 .displayName("image.png");
-     *
-     * Set exts = new HashSet<>();
-     * exts.add(EMKeyValue.of("key", "value"));
-     * exts.add(EMKeyValue.of("key1", 10));
-     * exts.add(EMKeyValue.of("key2", new HashMap() {
-     *     {
-     *         put("mkey1", "mvalue1");
-     *         put("mkey2", "mvalue2");
-     *     }
-     * }));
-     *
-     * try {
-     *     EMSentMessageIds messageIds = service.message().sendMsg("fromUserName", "chatrooms", toChatRooms, imageMessage, exts, "ROUTE_ONLINE", true, ChatroomMsgLevel.NORMAL).block();
-     * } catch (EMException e) {
-     *     e.getErrorCode();
-     *     e.getMessage();
-     * }
-     *
-     * }
- * - * @param from 发送者用户名 - * @param toType 目标类型,可以是 `users`, `chatgroups`, `chatrooms` - * @param tos 目标id列表 - * @param message 要发送的消息 - * @param extensions 要发送的扩展,可以为空 - * @param routeType 只投递在线消息,请传入 `ROUTE_ONLINE` - * @param syncDevice 消息发送成功后,是否将消息同步到发送方,true:是同步给发送方,false:是不同给发送方 - * @param chatroomMsgLevel 聊天室消息优先级: LOW-低优先级,NORMAL-普通优先级,HIGH-高优先级 - * @return 发消息响应或错误 - * @see 发送消息 - */ - public Mono sendMsg(String from, String toType, Set tos, - EMMessage message, Set extensions, String routeType, Boolean syncDevice, ChatroomMsgLevel chatroomMsgLevel) { - return this.messageSend.send(from, toType, checkTos(tos), message, extensions, routeType, syncDevice, chatroomMsgLevel); - } - - /** - * 发送聊天室全局广播消息。 - * 可通过该接口向 app 下的所有活跃聊天室(聊天室至少存在一个成员,而且曾经至少发送过一条消息)发送广播消息,支持所有消息类型。 - * 发送频率:每分钟最多可发 10 次,而且每天最多可发 100 次广播消息。 - *

- * API使用示例: - *

 {@code
-     * EMService service;
-     *
-     * 例如,发送一条带有扩展字段的文本消息
-     * EMTextMessage textMessage = new EMTextMessage().text("hello");
-     *
-     * Set exts = new HashSet<>();
-     * exts.add(EMKeyValue.of("key", "value"));
-     *
-     * try {
-     *     EMSentMessageIds messageIds = service.message().sendRoomBroadcastMsg("fromUserName", textMessage, exts, true, ChatroomMsgLevel.NORMAL).block();
-     * } catch (EMException e) {
-     *     e.getErrorCode();
-     *     e.getMessage();
-     * }
-     *
-     * }
- * - * @param from 发送者用户名 - * @param message 要发送的消息 - * @param extensions 要发送的扩展,可以为空 - * @param syncDevice 消息发送成功后,是否将消息同步到发送方,true:是同步给发送方,false:是不同给发送方 - * @param chatroomMsgLevel 聊天室消息优先级: LOW-低优先级,NORMAL-普通优先级,HIGH-高优先级 - * @return 发消息响应或错误 - * @see 发送聊天室全局广播消息 - */ - public Mono sendRoomBroadcastMsg(String from, EMMessage message, - Set extensions, Boolean syncDevice, ChatroomMsgLevel chatroomMsgLevel) { - return this.messageSend.sendRoomBroadcast(from, message, extensions, syncDevice, chatroomMsgLevel); - } - - /** - * 发送消息,不返回消息 ID。将在后续版本中移除。 - *

- * API使用示例: - *

 {@code
-     * EMService service;
-     *
-     * 例如,向用户发送一条带有扩展字段的文本消息
-     * Set toUsers = new HashSet<>();
-     * toUsers.add("toUserName");
-     *
-     * EMTextMessage textMessage = new EMTextMessage().text("hello");
-     *
-     * Set exts = new HashSet<>();
-     * exts.add(EMKeyValue.of("key", "value"));
-     *
-     * try {
-     *     EMSentMessageResults messageResults = service.message().sendWithoutMsgId("fromUserName", "users", toUsers, textMessage, exts, true).block();
-     * } catch (EMException e) {
-     *     e.getErrorCode();
-     *     e.getMessage();
-     * }
-     *
-     * 例如,向群组发送一条带有扩展字段的图片消息
-     * Set toGroups = new HashSet<>();
-     * toGroups.add("toGroupId");
-     *
-     * EMImageMessage imageMessage =
-     *         new EMImageMessage().uri(URI.create("http://example/image.png")).secret("secret")
-     *                 .displayName("image.png");
-     *
-     * Set exts1 = new HashSet<>();
-     * exts1.add(EMKeyValue.of("key", "value"));
-     * exts1.add(EMKeyValue.of("key1", 10));
-     * exts1.add(EMKeyValue.of("key2", new HashMap() {
-     *     {
-     *         put("mkey1", "mvalue1");
-     *         put("mkey2", "mvalue2");
-     *     }
-     * }));
-     *
-     * try {
-     *     EMSentMessageResults messageResults = service.message().sendWithoutMsgId("fromUserName", "chatgroups", toGroups, imageMessage, exts1, "ROUTE_ONLINE", true).block();
-     * } catch (EMException e) {
-     *     e.getErrorCode();
-     *     e.getMessage();
-     * }
-     *
-     * }
- * - * @param from 发送者用户名 - * @param toType 目标类型,可以是 `users`, `chatgroups`, `chatrooms` - * @param tos 目标id列表 - * @param message 要发送的消息 - * @param extensions 要发送的扩展,可以为空 - * @param routeType 只投递在线消息,请传入 `ROUTE_ONLINE` - * @param syncDevice 消息发送成功后,是否将消息同步到发送方,true:是同步给发送方,false:是不同给发送方 - * @return 发消息响应或错误 - * @see 发送消息 - */ - @Deprecated - public Mono sendWithoutMsgId(String from, String toType, Set tos, - EMMessage message, Set extensions, String routeType, Boolean syncDevice) { - return this.sendMessage.sendWithoutMsgId(from, toType, checkTos(tos), message, extensions, routeType, syncDevice); - } - - /** - * 获取消息历史文件的下载地址。 - *

- * 历史文件是每小时一个文件,比如指定12:10,则返回12点的历史文件。 - *

- * API使用示例: - *

 {@code
-     * EMService service;
-     * try {
-     *     Instant now = Instant.parse("2021-05-20T18:00:00.631Z").minusMillis((TimeUnit.HOURS.toMillis(8)));
-     *     String historyUrl = service.message().getHistoryAsUri(now).block();
-     * } catch (EMException e) {
-     *     e.getErrorCode();
-     *     e.getMessage();
-     * }
-     * }
- * - * @param instant 时间点 - * @return 下载地址或错误 - * @see 获取历史消息文件 - */ - public Mono getHistoryAsUri(Instant instant) { - return this.messageHistory.toUri(instant); - } - - /** - * 下载消息历史文件到本地。 - *

- * 消息历史文件是gz压缩的。 - *

- * - * API使用示例: - *

 {@code
-     * EMService service;
-     * Instant now = Instant.parse("2021-05-20T18:00:00.631Z").minusMillis((TimeUnit.HOURS.toMillis(8)));
-     * Path dir = Paths.get("/local/path/...");
-     * try {
-     *     Path path = service.message().getHistoryAsLocalFile(now, dir, "filename.gz").block();
-     * } catch (EMException e) {
-     *     e.getErrorCode();
-     *     e.getMessage();
-     * }
-     * }
- * - * @param instant 时间点 - * @param dir 下载目录 - * @param filename 文件名,如果为空,则默认为YYYYMMDD.gz - * @return 下载文件的路径或错误 - * @see 获取历史消息文件 - */ - public Mono getHistoryAsLocalFile(Instant instant, Path dir, String filename) { - return this.messageHistory.toLocalFile(instant, dir, filename); - } - - /** - * 消息撤回。将在后续版本中移除,请使用recallMsg方法。 - *

- * API使用示例: - *

 {@code
-     * EMService service;
-     * try {
-     *     List messageSources = new ArrayList<>();
-     *     messageSources.add(new RecallMessageSource("messageId", "chat", "u1", "u2", true));
-     *     service.message().recallMessage(messageSources).block();
-     * } catch (EMException e) {
-     *     e.getErrorCode();
-     *     e.getMessage();
-     * }
-     * }
- * @param messageSources messageSources - * @return 消息撤回响应或错误 - * @see 发送消息 - */ - @Deprecated - public Mono recallMessage(List messageSources) { - return this.recallMessage.execute(messageSources); - } - - /** - * 消息撤回。 - *

- * API使用示例: - *

 {@code
-     * EMService service;
-     * try {
-     *     RecallMessageSource recallMessage = new RecallMessageSource("messageId", "chat", "u1", "u2", true);
-     *     service.message().recallMessage(recallMessage).block();
-     * } catch (EMException e) {
-     *     e.getErrorCode();
-     *     e.getMessage();
-     * }
-     * }
- * @param recallMessage recallMessage - * @return 消息撤回响应或错误 - * @see 发送消息 - */ - public Mono recallMsg(RecallMessageSource recallMessage) { - return this.recallMessage.execute(recallMessage); - } - - /** - * 服务端单向删除会话。 - *

- * API使用示例: - *

 {@code
-     * EMService service;
-     * try {
-     *     service.message().deleteChannel("u1", "u2", "chat", false).block();
-     * } catch (EMException e) {
-     *     e.getErrorCode();
-     *     e.getMessage();
-     * }
-     * }
- * @param username username 删除会话方,例如 A 要将与 B 的单聊会话删除,username 为 A,channelName 为 B - * @param channelName channelName 要删除的会话 ID - * @param channelType channelType 会话类型。chat:单聊会话;groupchat:群聊会话 - * @param deleteRoam deleteRoam 是否删除服务端消息,不允许为空。true:是;false:否 - * @return 消息撤回响应或错误 - * @see 服务端单向删除会话 - */ - public Mono deleteChannel(String username, String channelName, String channelType, Boolean deleteRoam) { - return this.deleteMessageChannel.execute(username, channelName, channelType, deleteRoam); - } - - /** - * 构造消息并导入。 - *

- * 例如,导入一条带有扩展字段的单聊文本消息: - *

{@code
-     * EMService service;
-     * try {
-     *     service.message().importMessage()
-     *                      .from("alice")
-     *                      .toUser("rabbit")
-     *                      .text(msg -> msg.text("hello"))
-     *                      .extension(exts -> exts.add(EMKeyValue.of("timeout", 1)))
-     *                      .isAckRead(true)
-     *                      .msgTimestamp(Instant.now().toEpochMilli())
-     *                      .needDownload(true)
-     *                      .importChatMessage()
-     *                      .block();
-     * } catch (EMException e) {
-     *     e.getErrorCode();
-     *     e.getMessage();
-     * }
-     * }
- * - *

- * 如果需要向一个群组导入消息,将示例中的 toUser 改成 toGroup,并传入对应的群组或聊天室id - *

- * 将上述发送文本消息示例中的 `.text(...) `替换掉,来发送其他类型消息示例: - *

- * 导入图片消息:{@code .image(msg -> msg.uri(URI.create("http://example/image.png")).secret("secret").displayName("image.png"))} - *

- * 导入语音消息:{@code .voice(msg -> msg.uri(URI.create("http://example/voice.amr")).duration(3).secret("secret").displayName("voice.amr"))} - *

- * 导入视频消息:{@code .video(msg -> msg.uri(URI.create("http://example/video.mp4")).duration(3).secret("secret").displayName("video.mp4").thumb("http://example/videoThumbnail").thumbSecret("thumbSecret"))} - *

- * 导入文件消息:{@code .file(msg -> msg.uri(URI.create("http://example/file.txt")).secret("secret").displayName("file.txt"))} - *

- * 导入位置消息:{@code .location(msg -> msg.latitude(1.234567).longitude(1.234567).address("some where"))} - *

- * 导入自定义类型消息:{@code .custom(msg -> msg.customEvent("liked").customExtension("name", "forest"))} - *

- * - * @return 导入消息的构造器 - * - */ - public ImportMessage importMessage() { - return this.importMessage; - } - - - /** - * 导入单聊消息 - * - * API使用示例: - *

 {@code
-     *
-     * 例如,导入带扩展字段的文本消息
-     *
-     * EMTextMessage textMessage = new EMTextMessage().text("hello");
-     *
-     * Set exts = new HashSet<>();
-     * exts.add(EMKeyValue.of("key", "value"));
-     *
-     * try {
-     *     Instant time = Instant.parse("2021-05-20T18:00:00.631Z").minusMillis((TimeUnit.HOURS.toMillis(8)));
-     *     Long msgTimestamp = time.toEpochMilli();
-     *     String messageId = service.message()
-     *                               .importChatMessage("fromUserName", "toUserName",
-     *                                  textMessage, exts, true, msgTimestamp, false)
-     *                               .block();
-     * } catch (EMException e) {
-     *     e.getErrorCode();
-     *     e.getMessage();
-     * }
-     *
-     * }
- * - * @param from 发送者用户名 - * @param to 目标用户名 - * @param message 要导入的消息,EMTextMessage文本消息,EMImageMessage图片消息,EMVoiceMessage语音消息, - * EMVideoMessage视频消息,EMFileMessage文件消息,EMCommandMessage透传消息,EMCustomMessage自定义类型消息, - * 各种类型消息需要自己构造 - * @param extensions 要导入的扩展内容,可以为空 - * @param isAckRead 是否设置消息为已读 - * @param msgTimestamp 导入的消息的时间戳 - * @param needDownload 是否需要下载附件资源 - * @return 导入成功后消息的id - */ - public Mono importChatMessage(String from, String to, - EMMessage message, Set extensions, Boolean isAckRead, - Long msgTimestamp, Boolean needDownload) { - return this.importMessage.importChatMessage(from, to, message, extensions, - isAckRead, msgTimestamp, needDownload); - } - - /** - * 导入群聊消息 - * - * API使用示例: - *
 {@code
-     *
-     * 例如,导入带扩展字段的文本消息
-     *
-     * EMTextMessage textMessage = new EMTextMessage().text("hello");
-     *
-     * Set exts = new HashSet<>();
-     * exts.add(EMKeyValue.of("key", "value"));
-     *
-     * try {
-     *     Instant time = Instant.parse("2021-05-20T18:00:00.631Z").minusMillis((TimeUnit.HOURS.toMillis(8)));
-     *     Long msgTimestamp = time.toEpochMilli();
-     *     String groupId = "18273849454"
-     *     String messageId = service.message()
-     *                               .importChatGroupMessage("fromUserName", groupId,
-     *                                  textMessage, exts, true, msgTimestamp, false)
-     *                               .block();
-     * } catch (EMException e) {
-     *     e.getErrorCode();
-     *     e.getMessage();
-     * }
-     * }
- * - * @param from 发送者用户名 - * @param to 目标群id - * @param message 要导入的消息,EMTextMessage文本消息,EMImageMessage图片消息,EMVoiceMessage语音消息, - * EMVideoMessage视频消息,EMFileMessage文件消息,EMCommandMessage透传消息,EMCustomMessage自定义类型消息, - * 各种类型消息需要自己构造 - * @param extensions 要导入的扩展内容,可以为空 - * @param isAckRead 是否设置消息为已读 - * @param msgTimestamp 导入的消息的时间戳 - * @param needDownload 是否需要下载附件资源 - * @return 导入成功后消息的id - */ - public Mono importChatGroupMessage(String from, String to, - EMMessage message, Set extensions, Boolean isAckRead, - Long msgTimestamp, Boolean needDownload) { - return this.importMessage.importChatGroupMessage(from, to, message, extensions, isAckRead, - msgTimestamp, needDownload); - } - - private Set checkTos(Set tos) { - if (tos == null || tos.isEmpty()) { - throw new EMInvalidArgumentException("tos must not be null or empty"); - } - - Set usernames = new HashSet<>(); - tos.forEach(to -> { - if (StringUtils.isNotEmpty(to)) { - usernames.add(to); - } - }); - - if (tos.isEmpty()) { - throw new EMInvalidArgumentException("tos must not be null or empty"); - } - - return usernames; - } -} diff --git a/im-sdk-core/src/main/java/com/easemob/im/server/api/message/RouteType.java b/im-sdk-core/src/main/java/com/easemob/im/server/api/message/RouteType.java deleted file mode 100644 index 46bd3bebe..000000000 --- a/im-sdk-core/src/main/java/com/easemob/im/server/api/message/RouteType.java +++ /dev/null @@ -1,5 +0,0 @@ -package com.easemob.im.server.api.message; - -public enum RouteType { - ROUTE_ONLINE -} diff --git a/im-sdk-core/src/main/java/com/easemob/im/server/api/message/deletechannel/DeleteMessageChannel.java b/im-sdk-core/src/main/java/com/easemob/im/server/api/message/deletechannel/DeleteMessageChannel.java deleted file mode 100644 index fdf08f1a6..000000000 --- a/im-sdk-core/src/main/java/com/easemob/im/server/api/message/deletechannel/DeleteMessageChannel.java +++ /dev/null @@ -1,34 +0,0 @@ -package com.easemob.im.server.api.message.deletechannel; - -import com.easemob.im.server.api.Context; -import com.easemob.im.server.api.DefaultErrorMapper; -import com.easemob.im.server.api.ErrorMapper; -import com.easemob.im.server.exception.EMUnknownException; -import reactor.core.publisher.Mono; - -public class DeleteMessageChannel { - private final Context context; - - public DeleteMessageChannel(Context context) { - this.context = context; - } - - public Mono execute(String username, String channelName, String channelType, Boolean deleteRoam) { - return this.context.getHttpClient() - .flatMap(httpClient -> httpClient.delete() - .uri(String.format("/users/%s/user_channel", username)) - .send(Mono.create(sink -> sink.success(context.getCodec() - .encode(new DeleteMessageChannelRequest(channelName, channelType, deleteRoam))))) - .responseSingle((rsp, buf) -> { - return buf.switchIfEmpty( - Mono.error(new EMUnknownException("response is null"))) - .flatMap(byteBuf -> { - ErrorMapper mapper = new DefaultErrorMapper(); - mapper.statusCode(rsp); - mapper.checkError(byteBuf); - return Mono.just(byteBuf); - }); - })) - .then(); - } -} diff --git a/im-sdk-core/src/main/java/com/easemob/im/server/api/message/deletechannel/DeleteMessageChannelRequest.java b/im-sdk-core/src/main/java/com/easemob/im/server/api/message/deletechannel/DeleteMessageChannelRequest.java deleted file mode 100644 index 59063d3cc..000000000 --- a/im-sdk-core/src/main/java/com/easemob/im/server/api/message/deletechannel/DeleteMessageChannelRequest.java +++ /dev/null @@ -1,25 +0,0 @@ -package com.easemob.im.server.api.message.deletechannel; - -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonProperty; - -public class DeleteMessageChannelRequest { - - @JsonProperty("channel") - private String channelName; - - @JsonProperty("type") - private String channelType; - - @JsonProperty("delete_roam") - private Boolean deleteRoam; - - @JsonCreator - public DeleteMessageChannelRequest(@JsonProperty("channel") String channelName, - @JsonProperty("type") String channelType, - @JsonProperty("delete_roam") Boolean deleteRoam) { - this.channelName = channelName; - this.channelType = channelType; - this.deleteRoam = deleteRoam; - } -} diff --git a/im-sdk-core/src/main/java/com/easemob/im/server/api/message/history/MessageHistory.java b/im-sdk-core/src/main/java/com/easemob/im/server/api/message/history/MessageHistory.java deleted file mode 100644 index a95b121af..000000000 --- a/im-sdk-core/src/main/java/com/easemob/im/server/api/message/history/MessageHistory.java +++ /dev/null @@ -1,92 +0,0 @@ -package com.easemob.im.server.api.message.history; - -import com.easemob.im.server.api.Context; -import com.easemob.im.server.api.DefaultErrorMapper; -import com.easemob.im.server.api.ErrorMapper; -import com.easemob.im.server.api.util.FileSystem; -import com.easemob.im.server.exception.EMUnknownException; -import reactor.core.publisher.Mono; -import reactor.netty.http.client.HttpClient; - -import java.io.OutputStream; -import java.nio.file.Path; -import java.time.Instant; -import java.time.OffsetDateTime; -import java.time.ZoneOffset; - -public class MessageHistory { - - private Context context; - - private String timezone; - - public MessageHistory(Context context, String timezone) { - this.context = context; - this.timezone = timezone; - } - - public Mono toUri(Instant instant) { - return this.context.getHttpClient() - .flatMap(httpClient -> httpClient.get() - .uri(String.format("/chatmessages/%s", toPath(instant))) - .responseSingle((rsp, buf) -> { - return buf.switchIfEmpty( - Mono.error(new EMUnknownException("response is null"))) - .flatMap(byteBuf -> { - ErrorMapper mapper = new DefaultErrorMapper(); - mapper.statusCode(rsp); - mapper.checkError(byteBuf); - return Mono.just(byteBuf); - }); - })) - .map(buf -> this.context.getCodec().decode(buf, MessageHistoryResponse.class)) - .map(MessageHistoryResponse::getUrl); - } - - public Mono toLocalFile(Instant instant, Path dir, String filename) { - if (!dir.toFile().exists()) { - dir.toFile().mkdirs(); - } - - if (filename == null) { - filename = toPath(instant) + ".gz"; - } - - String finalFilename = filename; - - return toUri(instant) - .flatMap(uri -> { - Path local = FileSystem.choosePath(dir, finalFilename); - return Mono.create(sink -> sink.success(FileSystem.open(local))) - .flatMap(out -> { - return HttpClient.create().get() - .uri(uri) - .responseSingle((rsp, buf) -> { - return buf.switchIfEmpty( - Mono.error(new EMUnknownException( - "response is null"))) - .flatMap(byteBuf -> { - ErrorMapper mapper = - new DefaultErrorMapper(); - mapper.statusCode(rsp); - mapper.checkError(byteBuf); - return Mono.just(byteBuf); - }); - }) - .map(b -> FileSystem.append(out, b)) - .doOnSuccess(suc -> FileSystem.close(out)) - .then(); - }) - .thenReturn(local); - }); - } - - private String toPath(Instant instant) { - OffsetDateTime dateTime = instant.atOffset(ZoneOffset.of(this.timezone)); - int year = dateTime.getYear(); - int month = dateTime.getMonthValue(); - int day = dateTime.getDayOfMonth(); - int hour = dateTime.getHour(); - return String.format("%4d%02d%02d%02d", year, month, day, hour); - } -} diff --git a/im-sdk-core/src/main/java/com/easemob/im/server/api/message/history/MessageHistoryResponse.java b/im-sdk-core/src/main/java/com/easemob/im/server/api/message/history/MessageHistoryResponse.java deleted file mode 100644 index 79b64a740..000000000 --- a/im-sdk-core/src/main/java/com/easemob/im/server/api/message/history/MessageHistoryResponse.java +++ /dev/null @@ -1,37 +0,0 @@ -package com.easemob.im.server.api.message.history; - -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonProperty; - -import java.util.List; - -public class MessageHistoryResponse { - @JsonProperty("data") - private List messageHistories; - - @JsonCreator - public MessageHistoryResponse(@JsonProperty("data") List messageHistories) { - this.messageHistories = messageHistories; - } - - public String getUrl() { - return this.messageHistories == null || this.messageHistories.isEmpty() ? - null : - this.messageHistories.get(0).getUrl(); - } - - public static class MessageHistory { - @JsonProperty("url") - private String url; - - @JsonCreator - public MessageHistory(@JsonProperty("url") String url) { - this.url = url; - } - - public String getUrl() { - return this.url; - } - } - -} diff --git a/im-sdk-core/src/main/java/com/easemob/im/server/api/message/missed/MessageMissed.java b/im-sdk-core/src/main/java/com/easemob/im/server/api/message/missed/MessageMissed.java deleted file mode 100644 index 6398dfb3d..000000000 --- a/im-sdk-core/src/main/java/com/easemob/im/server/api/message/missed/MessageMissed.java +++ /dev/null @@ -1,34 +0,0 @@ -package com.easemob.im.server.api.message.missed; - -import com.easemob.im.server.api.Context; -import com.easemob.im.server.api.DefaultErrorMapper; -import com.easemob.im.server.api.ErrorMapper; -import com.easemob.im.server.exception.EMUnknownException; -import reactor.core.publisher.Flux; -import reactor.core.publisher.Mono; - -public class MessageMissed { - private Context context; - - public MessageMissed(Context context) { - this.context = context; - } - - public Flux count(String username) { - return this.context.getHttpClient() - .flatMap(httpClient -> httpClient.get() - .uri(String.format("/users/%s/offline_msg_count", username)) - .responseSingle((rsp, buf) -> { - return buf.switchIfEmpty( - Mono.error(new EMUnknownException("response is null"))) - .flatMap(byteBuf -> { - ErrorMapper mapper = new DefaultErrorMapper(); - mapper.statusCode(rsp); - mapper.checkError(byteBuf); - return Mono.just(byteBuf); - }); - })) - .map(buf -> this.context.getCodec().decode(buf, MessageMissedCountResponse.class)) - .flatMapIterable(MessageMissedCountResponse::getMissedMessageCounts); - } -} diff --git a/im-sdk-core/src/main/java/com/easemob/im/server/api/message/missed/MessageMissedCountResponse.java b/im-sdk-core/src/main/java/com/easemob/im/server/api/message/missed/MessageMissedCountResponse.java deleted file mode 100644 index 8e82d73fe..000000000 --- a/im-sdk-core/src/main/java/com/easemob/im/server/api/message/missed/MessageMissedCountResponse.java +++ /dev/null @@ -1,27 +0,0 @@ -package com.easemob.im.server.api.message.missed; - -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonProperty; - -import java.util.List; -import java.util.Map; -import java.util.stream.Collectors; - -public class MessageMissedCountResponse { - @JsonProperty("data") - private Map missedMessageCountByQueue; - - @JsonCreator - public MessageMissedCountResponse( - @JsonProperty("data") Map missedMessageCountByQueue) { - this.missedMessageCountByQueue = missedMessageCountByQueue; - } - - public List getMissedMessageCounts() { - return this.missedMessageCountByQueue.entrySet() - .stream() - .map(e -> new MissedMessageCount(e.getKey(), e.getValue())) - .collect(Collectors.toList()); - } - -} diff --git a/im-sdk-core/src/main/java/com/easemob/im/server/api/message/missed/MissedMessageCount.java b/im-sdk-core/src/main/java/com/easemob/im/server/api/message/missed/MissedMessageCount.java deleted file mode 100644 index 05fe2976c..000000000 --- a/im-sdk-core/src/main/java/com/easemob/im/server/api/message/missed/MissedMessageCount.java +++ /dev/null @@ -1,50 +0,0 @@ -package com.easemob.im.server.api.message.missed; - -import java.util.Objects; - -public class MissedMessageCount { - - private final String queueName; - - private final int messageCount; - - public MissedMessageCount(String queueName, int messageCount) { - this.queueName = queueName; - this.messageCount = messageCount; - } - - public String getQueueName() { - return queueName; - } - - public int getMessageCount() { - return messageCount; - } - - @Override - public String toString() { - return "MissedMessageCount{" + - "queueName='" + queueName + '\'' + - ", messageCount=" + messageCount + - '}'; - } - - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (!(o instanceof MissedMessageCount)) { - return false; - } - MissedMessageCount count = (MissedMessageCount) o; - return messageCount == count.messageCount && - queueName.equals(count.queueName); - } - - @Override - public int hashCode() { - return Objects.hash(queueName, messageCount); - } - -} diff --git a/im-sdk-core/src/main/java/com/easemob/im/server/api/message/recall/RecallMessage.java b/im-sdk-core/src/main/java/com/easemob/im/server/api/message/recall/RecallMessage.java deleted file mode 100644 index 64b35335c..000000000 --- a/im-sdk-core/src/main/java/com/easemob/im/server/api/message/recall/RecallMessage.java +++ /dev/null @@ -1,55 +0,0 @@ -package com.easemob.im.server.api.message.recall; - -import com.easemob.im.server.api.Context; -import com.easemob.im.server.api.DefaultErrorMapper; -import com.easemob.im.server.api.ErrorMapper; -import com.easemob.im.server.exception.EMUnknownException; -import reactor.core.publisher.Mono; - -import java.util.List; - -public class RecallMessage { - private final Context context; - - public RecallMessage(Context context) { - this.context = context; - } - - public Mono execute(List messageRequests) { - return this.context.getHttpClient() - .flatMap(httpClient -> httpClient.post() - .uri("/messages/recall") - .send(Mono.create(sink -> sink.success(context.getCodec() - .encode(new RecallMessageRequest(messageRequests))))) - .responseSingle((rsp, buf) -> { - return buf.switchIfEmpty( - Mono.error(new EMUnknownException("response is null"))) - .flatMap(byteBuf -> { - ErrorMapper mapper = new DefaultErrorMapper(); - mapper.statusCode(rsp); - mapper.checkError(byteBuf); - return Mono.just(byteBuf); - }); - })) - .then(); - } - - public Mono execute(RecallMessageSource recallMessage) { - return this.context.getHttpClient() - .flatMap(httpClient -> httpClient.post() - .uri("/messages/msg_recall") - .send(Mono.create(sink -> sink.success(context.getCodec() - .encode(recallMessage)))) - .responseSingle((rsp, buf) -> { - return buf.switchIfEmpty( - Mono.error(new EMUnknownException("response is null"))) - .flatMap(byteBuf -> { - ErrorMapper mapper = new DefaultErrorMapper(); - mapper.statusCode(rsp); - mapper.checkError(byteBuf); - return Mono.just(byteBuf); - }); - })) - .then(); - } -} diff --git a/im-sdk-core/src/main/java/com/easemob/im/server/api/message/recall/RecallMessageRequest.java b/im-sdk-core/src/main/java/com/easemob/im/server/api/message/recall/RecallMessageRequest.java deleted file mode 100644 index 61b47d76a..000000000 --- a/im-sdk-core/src/main/java/com/easemob/im/server/api/message/recall/RecallMessageRequest.java +++ /dev/null @@ -1,18 +0,0 @@ -package com.easemob.im.server.api.message.recall; - -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonProperty; - -import java.util.List; - -public class RecallMessageRequest { - - @JsonProperty("msgs") - private List recallMessages; - - @JsonCreator - public RecallMessageRequest(@JsonProperty("msgs") List recallMessages) { - this.recallMessages = recallMessages; - } - -} diff --git a/im-sdk-core/src/main/java/com/easemob/im/server/api/message/recall/RecallMessageSource.java b/im-sdk-core/src/main/java/com/easemob/im/server/api/message/recall/RecallMessageSource.java deleted file mode 100644 index cfb6b7270..000000000 --- a/im-sdk-core/src/main/java/com/easemob/im/server/api/message/recall/RecallMessageSource.java +++ /dev/null @@ -1,50 +0,0 @@ -package com.easemob.im.server.api.message.recall; - -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonProperty; - -public class RecallMessageSource { - /** - * 撤回消息的消息 ID - */ - @JsonProperty("msg_id") - private String messageId; - - /** - * 撤回消息的三种消息类型:chat:单聊 ;groupchat:群聊 ;chatroom:聊天室 - */ - @JsonProperty("chat_type") - private String chatType; - - /** - * 消息撤回方,不传默认使用的是 admin,默认消息撤回方为原消息发送者。你可以通过用户 ID 指定消息撤回方 - */ - @JsonProperty("from") - private String from; - - /** - * 撤回消息的接收方,如果不提供则消息体找不到就撤回不了。单聊为接收方用户名,群组为群 ID,聊天室为聊天室 ID - */ - @JsonProperty("to") - private String to; - - /** - * 是否为强制撤回:true:是,即超过服务器保存消息时间消息也可以被撤回,具体见服务器消息保存时长; - * false:否,若设置的消息撤回时限超过服务端的消息保存时间,请求消息撤回时消息可能由于过期已在服务端删除,消息撤回请求会失败,即无法从收到该消息的客户端撤回该消息 - */ - @JsonProperty("force") - private Boolean force; - - @JsonCreator - public RecallMessageSource(@JsonProperty("msg_id") String messageId, - @JsonProperty("chat_type") String chatType, - @JsonProperty("from") String from, - @JsonProperty("to") String to, - @JsonProperty("force") Boolean force) { - this.messageId = messageId; - this.chatType = chatType; - this.from = from; - this.to = to; - this.force = force; - } -} diff --git a/im-sdk-core/src/main/java/com/easemob/im/server/api/message/send/SendChatroomMessageRequest.java b/im-sdk-core/src/main/java/com/easemob/im/server/api/message/send/SendChatroomMessageRequest.java deleted file mode 100644 index bb753b607..000000000 --- a/im-sdk-core/src/main/java/com/easemob/im/server/api/message/send/SendChatroomMessageRequest.java +++ /dev/null @@ -1,407 +0,0 @@ -package com.easemob.im.server.api.message.send; - -import com.easemob.im.server.model.*; -import com.fasterxml.jackson.annotation.JsonAutoDetect; -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonProperty; - -import java.util.HashMap; -import java.util.HashSet; -import java.util.Map; -import java.util.Set; - -@JsonAutoDetect(getterVisibility = JsonAutoDetect.Visibility.NONE) -public class SendChatroomMessageRequest { - @JsonProperty("from") - private String from; - - @JsonProperty("target_type") - private String targetType; - - /* the server side does not preserve order of targets */ - @JsonProperty("target") - private Set targets; - - @JsonProperty("msg") - private Message message; - - @JsonProperty("ext") - private Map extensions; - - @JsonProperty("client_id") - private String clientId; - - @JsonCreator - public SendChatroomMessageRequest(@JsonProperty("from") String from, - @JsonProperty("target_type") String targetType, - @JsonProperty("target") Set targets, - @JsonProperty("msg") EMMessage message, - @JsonProperty("ext") Map extensions, - @JsonProperty("client_id") String clientId) { - this.from = from; - this.targetType = targetType; - this.targets = targets; - this.message = Message.of(message); - this.extensions = extensions; - this.clientId = clientId; - } - - public static Map parseExtensions(Set extensions) { - if (extensions == null || extensions.isEmpty()) { - return null; - } - Map mapped = new HashMap<>(); - for (EMKeyValue keyValue : extensions) { - switch (keyValue.type()) { - case BOOL: - mapped.put(keyValue.key(), keyValue.asBoolean()); - break; - case INT: - mapped.put(keyValue.key(), keyValue.asInt()); - break; - case UINT: - mapped.put(keyValue.key(), keyValue.asLong()); - break; - case LLINT: - mapped.put(keyValue.key(), keyValue.asLong()); - break; - case FLOAT: - mapped.put(keyValue.key(), keyValue.asFloat()); - break; - case DOUBLE: - mapped.put(keyValue.key(), keyValue.asDouble()); - break; - case STRING: - mapped.put(keyValue.key(), keyValue.asString()); - break; - case JSON_STRING: - mapped.put(keyValue.key(), keyValue.asString()); - break; - case OBJECT: - mapped.put(keyValue.key(), keyValue.asObject()); - break; - } - } - return mapped; - } - - public String getFrom() { - return this.from; - } - - public String getTargetType() { - return this.targetType; - } - - public Set getTargets() { - return this.targets; - } - - public Message getMessage() { - return this.message; - } - - public Set getExtensions() { - return populateExtensions(this.extensions); - } - - public String getClientId() { - return clientId; - } - - @SuppressWarnings("unchecked") - public Set populateExtensions(Map extensions) { - if (extensions == null || extensions.isEmpty()) { - return null; - } - Set mapped = new HashSet<>(); - for (String key : extensions.keySet()) { - Object value = extensions.get(key); - if (value instanceof Boolean) { - mapped.add(EMKeyValue.of(key, (boolean) value)); - } else if (value instanceof Integer) { - mapped.add(EMKeyValue.of(key, (int) value)); - } else if (value instanceof Long) { - mapped.add(EMKeyValue.of(key, (long) value)); - } else if (value instanceof Float) { - mapped.add(EMKeyValue.of(key, (float) value)); - } else if (value instanceof Double) { - mapped.add(EMKeyValue.of(key, (double) value)); - } else if (value instanceof String) { - mapped.add(EMKeyValue.of(key, (String) value)); - } - } - return mapped; - } - - static class Message { - @JsonProperty("type") - private String type; - - @JsonProperty("msg") - private String text; - - @JsonProperty("lng") - private Double longitude; - - @JsonProperty("lat") - private Double latitude; - - @JsonProperty("addr") - private String address; - - @JsonProperty("filename") - private String displayName; - - @JsonProperty("url") - private String uri; - - @JsonProperty("secret") - private String secret; - - @JsonProperty("file_length") - private Integer bytes; - - @JsonProperty("action") - private String action; - - @JsonProperty("param") - private Map params; - - @JsonProperty("length") - private Integer duration; - - @JsonProperty("size") - private Dimensions dimensions; - - @JsonProperty("thumb") - private String thumb; - - @JsonProperty("thumb_secret") - private String thumbSecret; - - @JsonProperty("customEvent") - private String customEvent; - - @JsonProperty("customExts") - private Map customExtensions; - - @JsonCreator - public Message(@JsonProperty("type") String type, - @JsonProperty("msg") String text, - @JsonProperty("lng") Double longitude, - @JsonProperty("lat") Double latitude, - @JsonProperty("addr") String address, - @JsonProperty("filename") String displayName, - @JsonProperty("url") String uri, - @JsonProperty("secret") String secretKey, - @JsonProperty("file_length") Integer bytes, - @JsonProperty("action") String action, - @JsonProperty("param") Map params, - @JsonProperty("length") Integer duration, - @JsonProperty("size") Dimensions dimensions, - @JsonProperty("customEvent") String customEvent, - @JsonProperty("customExts") Map customExtensions) { - this.type = type; - this.text = text; - this.longitude = longitude; - this.latitude = latitude; - this.address = address; - this.displayName = displayName; - this.uri = uri; - this.secret = secretKey; - this.bytes = bytes; - this.action = action; - this.params = params; - this.duration = duration; - this.dimensions = dimensions; - this.customEvent = customEvent; - this.customExtensions = customExtensions; - } - - public Message(String type) { - this.type = type; - } - - @SuppressWarnings("unchecked") - public static Message of(EMMessage msg) { - switch (msg.messageType()) { - case TEXT: - return Message.of((EMTextMessage) msg); - case IMAGE: - return Message.of((EMImageMessage) msg); - case AUDIO: - return Message.of((EMVoiceMessage) msg); - case VIDEO: - return Message.of((EMVideoMessage) msg); - case LOCATION: - return Message.of((EMLocationMessage) msg); - case FILE: - return Message.of((EMFileMessage) msg); - case COMMAND: - return Message.of((EMCommandMessage) msg); - case CUSTOM: - return Message.of((EMCustomMessage) msg); - default: - throw new IllegalArgumentException( - String.format("message type %s not supported", msg.messageType())); - } - } - - public static Message of(EMTextMessage msg) { - Message send = new Message("text"); - send.text = msg.text(); - return send; - } - - public static Message of(EMImageMessage msg) { - Message send = new Message("img"); - send.uri = msg.uri() == null ? null : msg.uri().toString(); - send.displayName = msg.displayName(); - send.bytes = msg.bytes(); - send.secret = msg.secret(); - if (msg.width() != null || msg.height() != null) { - send.dimensions = new Dimensions(msg.width(), msg.height()); - } - return send; - } - - public static Message of(EMVoiceMessage msg) { - Message send = new Message("audio"); - send.uri = msg.uri() == null ? null : msg.uri().toString(); - send.displayName = msg.displayName(); - send.bytes = msg.bytes(); - send.secret = msg.secret(); - send.duration = msg.duration(); - return send; - } - - public static Message of(EMVideoMessage msg) { - Message send = new Message("video"); - send.uri = msg.uri() == null ? null : msg.uri().toString(); - send.displayName = msg.displayName(); - send.bytes = msg.bytes(); - send.secret = msg.secret(); - send.duration = msg.duration(); - send.thumb = msg.thumb(); - send.thumbSecret = msg.thumbSecret(); - return send; - } - - public static Message of(EMLocationMessage msg) { - Message send = new Message("loc"); - send.longitude = msg.longitude(); - send.latitude = msg.latitude(); - send.address = msg.address(); - return send; - } - - public static Message of(EMFileMessage msg) { - Message send = new Message("file"); - send.uri = msg.uri() == null ? null : msg.uri().toString(); - send.displayName = msg.displayName(); - send.bytes = msg.bytes(); - send.secret = msg.secret(); - return send; - } - - public static Message of(EMCommandMessage msg) { - Message send = new Message("cmd"); - send.action = msg.action(); - if (msg.params() == null) { - return send; - } - send.params = new HashMap<>(); - for (EMKeyValue kv : msg.params()) { - switch (kv.type()) { - case BOOL: - send.params.put(kv.key(), kv.asBoolean()); - break; - case INT: - send.params.put(kv.key(), kv.asInt()); - break; - case UINT: - send.params.put(kv.key(), kv.asLong()); - break; - case LLINT: - send.params.put(kv.key(), kv.asLong()); - break; - case FLOAT: - send.params.put(kv.key(), kv.asFloat()); - break; - case DOUBLE: - send.params.put(kv.key(), kv.asDouble()); - break; - case STRING: - send.params.put(kv.key(), kv.asString()); - break; - case JSON_STRING: - send.params.put(kv.key(), kv.asString()); - break; - } - } - return send; - } - - public static Message of(EMCustomMessage msg) { - Message send = new Message("custom"); - send.customEvent = msg.customEvent(); - if (msg.customExtensions() == null) { - return send; - } - send.customExtensions = new HashMap<>(); - for (EMKeyValue kv : msg.customExtensions()) { - switch (kv.type()) { - case BOOL: - send.customExtensions.put(kv.key(), kv.asBoolean()); - break; - case INT: - send.customExtensions.put(kv.key(), kv.asInt()); - break; - case UINT: - send.customExtensions.put(kv.key(), kv.asLong()); - break; - case LLINT: - send.customExtensions.put(kv.key(), kv.asLong()); - break; - case FLOAT: - send.customExtensions.put(kv.key(), kv.asFloat()); - break; - case DOUBLE: - send.customExtensions.put(kv.key(), kv.asDouble()); - break; - case STRING: - send.customExtensions.put(kv.key(), kv.asString()); - break; - case JSON_STRING: - send.customExtensions.put(kv.key(), kv.asString()); - break; - } - } - return send; - } - } - - - static class Dimensions { - @JsonProperty("width") - private Double width; - @JsonProperty("height") - private Double height; - - @JsonCreator - public Dimensions(@JsonProperty("width") Double width, - @JsonProperty("height") Double height) { - this.width = width; - this.height = height; - } - - public Double getWidth() { - return this.width; - } - - public Double getHeight() { - return this.height; - } - } -} diff --git a/im-sdk-core/src/main/java/com/easemob/im/server/api/message/send/SendMessage.java b/im-sdk-core/src/main/java/com/easemob/im/server/api/message/send/SendMessage.java deleted file mode 100644 index ac11e5e90..000000000 --- a/im-sdk-core/src/main/java/com/easemob/im/server/api/message/send/SendMessage.java +++ /dev/null @@ -1,447 +0,0 @@ -package com.easemob.im.server.api.message.send; - -import com.easemob.im.server.api.Context; -import com.easemob.im.server.api.DefaultErrorMapper; -import com.easemob.im.server.api.ErrorMapper; -import com.easemob.im.server.exception.EMUnknownException; -import com.easemob.im.server.model.*; -import io.github.resilience4j.core.StringUtils; -import reactor.core.publisher.Mono; - -import java.util.*; -import java.util.function.Consumer; - -public class SendMessage { - private final Context context; - - public SendMessage(Context context) { - this.context = context; - } - - public RouteSpec fromUser(String username) { - return new RouteSpec(username); - } - - public Mono send(String from, String toType, Set tos, - EMMessage message, Set extensions) { - return this.context.getHttpClient() - .flatMap(httpClient -> httpClient.post() - .uri("/messages?useMsgId=true") - .send(Mono.create(sink -> sink.success(context.getCodec() - .encode(new SendMessageRequest(from, toType, tos, message, - SendMessageRequest.parseExtensions(extensions)))))) - .responseSingle((rsp, buf) -> { - return buf.switchIfEmpty( - Mono.error(new EMUnknownException("response is null"))) - .flatMap(byteBuf -> { - ErrorMapper mapper = new DefaultErrorMapper(); - mapper.statusCode(rsp); - mapper.checkError(byteBuf); - return Mono.just(byteBuf); - }); - })) - .map(byteBuf -> { - SendMessageResponse sendMessageResponse = - context.getCodec().decode(byteBuf, SendMessageResponse.class); - return sendMessageResponse.toEMSentMessages(); - }); - } - - public Mono sendWithoutMsgId(String from, String toType, Set tos, - EMMessage message, Set extensions) { - return this.context.getHttpClient() - .flatMap(httpClient -> httpClient.post() - .uri("/messages") - .send(Mono.create(sink -> sink.success(context.getCodec() - .encode(new SendMessageRequest(from, toType, tos, message, - SendMessageRequest.parseExtensions(extensions)))))) - .responseSingle((rsp, buf) -> { - return buf.switchIfEmpty( - Mono.error(new EMUnknownException("response is null"))) - .flatMap(byteBuf -> { - ErrorMapper mapper = new DefaultErrorMapper(); - mapper.statusCode(rsp); - mapper.checkError(byteBuf); - return Mono.just(byteBuf); - }); - })) - .map(byteBuf -> { - SendMessageResultResponse sendMessageResultResponse = - context.getCodec().decode(byteBuf, SendMessageResultResponse.class); - return sendMessageResultResponse.toEMSentMessages(); - }); - } - - public Mono send(String from, String toType, Set tos, - EMMessage message, Set extensions, String routeType) { - return this.context.getHttpClient() - .flatMap(httpClient -> httpClient.post() - .uri("/messages?useMsgId=true") - .send(Mono.create(sink -> sink.success(context.getCodec() - .encode(new SendMessageRequest(from, toType, tos, message, - SendMessageRequest.parseExtensions(extensions), - routeType))))) - .responseSingle((rsp, buf) -> { - return buf.switchIfEmpty( - Mono.error(new EMUnknownException("response is null"))) - .flatMap(byteBuf -> { - ErrorMapper mapper = new DefaultErrorMapper(); - mapper.statusCode(rsp); - mapper.checkError(byteBuf); - return Mono.just(byteBuf); - }); - })) - .map(byteBuf -> { - SendMessageResponse sendMessageResponse = context.getCodec() - .decode(byteBuf, SendMessageResponse.class); - return sendMessageResponse.toEMSentMessages(); - }); - } - - public Mono sendWithoutMsgId(String from, String toType, Set tos, - EMMessage message, Set extensions, String routeType) { - return this.context.getHttpClient() - .flatMap(httpClient -> httpClient.post() - .uri("/messages") - .send(Mono.create(sink -> sink.success(context.getCodec() - .encode(new SendMessageRequest(from, toType, tos, message, - SendMessageRequest.parseExtensions(extensions), - routeType))))) - .responseSingle((rsp, buf) -> { - return buf.switchIfEmpty( - Mono.error(new EMUnknownException("response is null"))) - .flatMap(byteBuf -> { - ErrorMapper mapper = new DefaultErrorMapper(); - mapper.statusCode(rsp); - mapper.checkError(byteBuf); - return Mono.just(byteBuf); - }); - })) - .map(byteBuf -> { - SendMessageResultResponse sendMessageResultResponse = - context.getCodec() - .decode(byteBuf, SendMessageResultResponse.class); - return sendMessageResultResponse.toEMSentMessages(); - }); - } - - public Mono send(String from, String toType, Set tos, - EMMessage message, Set extensions, Boolean syncDevice) { - return this.context.getHttpClient() - .flatMap(httpClient -> httpClient.post() - .uri("/messages?useMsgId=true") - .send(Mono.create(sink -> sink.success(context.getCodec() - .encode(new SendMessageRequest(from, toType, tos, message, - SendMessageRequest.parseExtensions(extensions), - syncDevice))))) - .responseSingle((rsp, buf) -> { - return buf.switchIfEmpty( - Mono.error(new EMUnknownException("response is null"))) - .flatMap(byteBuf -> { - ErrorMapper mapper = new DefaultErrorMapper(); - mapper.statusCode(rsp); - mapper.checkError(byteBuf); - return Mono.just(byteBuf); - }); - })) - .map(byteBuf -> { - SendMessageResponse sendMessageResponse = context.getCodec() - .decode(byteBuf, SendMessageResponse.class); - return sendMessageResponse.toEMSentMessages(); - }); - } - - public Mono sendWithoutMsgId(String from, String toType, Set tos, - EMMessage message, Set extensions, Boolean syncDevice) { - return this.context.getHttpClient() - .flatMap(httpClient -> httpClient.post() - .uri("/messages") - .send(Mono.create(sink -> sink.success(context.getCodec() - .encode(new SendMessageRequest(from, toType, tos, message, - SendMessageRequest.parseExtensions(extensions), - syncDevice))))) - .responseSingle((rsp, buf) -> { - return buf.switchIfEmpty( - Mono.error(new EMUnknownException("response is null"))) - .flatMap(byteBuf -> { - ErrorMapper mapper = new DefaultErrorMapper(); - mapper.statusCode(rsp); - mapper.checkError(byteBuf); - return Mono.just(byteBuf); - }); - })) - .map(byteBuf -> { - SendMessageResultResponse sendMessageResultResponse = - context.getCodec() - .decode(byteBuf, SendMessageResultResponse.class); - return sendMessageResultResponse.toEMSentMessages(); - }); - } - - public Mono send(String from, String toType, Set tos, - EMMessage message, Set extensions, String routeType, Boolean syncDevice) { - return this.context.getHttpClient() - .flatMap(httpClient -> httpClient.post() - .uri("/messages?useMsgId=true") - .send(Mono.create(sink -> sink.success(context.getCodec() - .encode(new SendMessageRequest(from, toType, tos, message, - SendMessageRequest.parseExtensions(extensions), routeType, - syncDevice))))) - .responseSingle((rsp, buf) -> { - return buf.switchIfEmpty( - Mono.error(new EMUnknownException("response is null"))) - .flatMap(byteBuf -> { - ErrorMapper mapper = new DefaultErrorMapper(); - mapper.statusCode(rsp); - mapper.checkError(byteBuf); - return Mono.just(byteBuf); - }); - })) - .map(byteBuf -> { - SendMessageResponse sendMessageResponse = context.getCodec() - .decode(byteBuf, SendMessageResponse.class); - return sendMessageResponse.toEMSentMessages(); - }); - } - - public Mono sendWithoutMsgId(String from, String toType, Set tos, - EMMessage message, Set extensions, String routeType, Boolean syncDevice) { - return this.context.getHttpClient() - .flatMap(httpClient -> httpClient.post() - .uri("/messages") - .send(Mono.create(sink -> sink.success(context.getCodec() - .encode(new SendMessageRequest(from, toType, tos, message, - SendMessageRequest.parseExtensions(extensions), routeType, - syncDevice))))) - .responseSingle((rsp, buf) -> { - return buf.switchIfEmpty( - Mono.error(new EMUnknownException("response is null"))) - .flatMap(byteBuf -> { - ErrorMapper mapper = new DefaultErrorMapper(); - mapper.statusCode(rsp); - mapper.checkError(byteBuf); - return Mono.just(byteBuf); - }); - })) - .map(byteBuf -> { - SendMessageResultResponse sendMessageResultResponse = - context.getCodec() - .decode(byteBuf, SendMessageResultResponse.class); - return sendMessageResultResponse.toEMSentMessages(); - }); - } - - public class RouteSpec { - - private String from; - - public RouteSpec(String from) { - this.from = from; - } - - public MessageSpec toUser(String username) { - Set tos = new HashSet<>(); - tos.add(username); - return new MessageSpec(from, "users", tos); - } - - public MessageSpec toUsers(Set usernames) { - return new MessageSpec(from, "users", usernames); - } - - public MessageSpec toGroup(String groupId) { - Set tos = new HashSet<>(); - tos.add(groupId); - return new MessageSpec(from, "chatgroups", tos); - } - - public MessageSpec toGroups(Set groupIds) { - return new MessageSpec(from, "chatgroups", groupIds); - } - - public MessageSpec toRoom(String roomId) { - Set tos = new HashSet<>(); - tos.add(roomId); - return new MessageSpec(from, "chatrooms", tos); - } - - public MessageSpec toRooms(Set roomIds) { - return new MessageSpec(from, "chatrooms", roomIds); - } - } - - - public class MessageSpec { - - private String from; - - private String toType; - - private Set tos; - - public MessageSpec(String from, String toType, Set tos) { - this.from = from; - this.toType = toType; - this.tos = tos; - } - - public SendSpec text(Consumer customizer) { - EMTextMessage message = new EMTextMessage(); - customizer.accept(message); - return new SendSpec(this.from, this.toType, this.tos, message); - } - - public SendSpec image(Consumer customizer) { - EMImageMessage message = new EMImageMessage(); - customizer.accept(message); - return new SendSpec(this.from, this.toType, this.tos, message); - } - - public SendSpec voice(Consumer customizer) { - EMVoiceMessage message = new EMVoiceMessage(); - customizer.accept(message); - return new SendSpec(this.from, this.toType, this.tos, message); - } - - public SendSpec video(Consumer customizer) { - EMVideoMessage message = new EMVideoMessage(); - customizer.accept(message); - return new SendSpec(this.from, this.toType, this.tos, message); - } - - public SendSpec location(Consumer customizer) { - EMLocationMessage message = new EMLocationMessage(); - customizer.accept(message); - return new SendSpec(this.from, this.toType, this.tos, message); - } - - public SendSpec file(Consumer customizer) { - EMFileMessage message = new EMFileMessage(); - customizer.accept(message); - return new SendSpec(this.from, this.toType, this.tos, message); - } - - public SendSpec command(Consumer customizer) { - EMCommandMessage message = new EMCommandMessage(); - customizer.accept(message); - return new SendSpec(this.from, this.toType, this.tos, message); - } - - public SendSpec custom(Consumer customizer) { - EMCustomMessage message = new EMCustomMessage(); - customizer.accept(message); - return new SendSpec(this.from, this.toType, this.tos, message); - } - } - - - public class SendSpec { - - private String from; - - private String toType; - - private Set tos; - - private EMMessage message; - - private Set extensions; - - private String routeType; - - private Boolean syncDevice; - - SendSpec(String from, String toType, Set tos, EMMessage message) { - this.from = from; - this.toType = toType; - this.tos = tos; - this.message = message; - } - - SendSpec(String from, String toType, Set tos, EMMessage message, String routeType) { - this.from = from; - this.toType = toType; - this.tos = tos; - this.message = message; - this.routeType = routeType; - } - - SendSpec(String from, String toType, Set tos, EMMessage message, - Boolean syncDevice) { - this.from = from; - this.toType = toType; - this.tos = tos; - this.message = message; - this.syncDevice = syncDevice; - } - - SendSpec(String from, String toType, Set tos, EMMessage message, String routeType, - Boolean syncDevice) { - this.from = from; - this.toType = toType; - this.tos = tos; - this.message = message; - this.routeType = routeType; - this.syncDevice = syncDevice; - } - - public SendSpec extension(Consumer> customizer) { - if (this.extensions == null) { - this.extensions = new HashSet<>(); - } - customizer.accept(this.extensions); - return this; - } - - public SendSpec routeType(String type) { - this.routeType = type; - return this; - } - - public SendSpec syncDevice(Boolean syncDevice) { - this.syncDevice = syncDevice; - return this; - } - - public Mono send() { - if (StringUtils.isNotEmpty(routeType) && syncDevice != null) { - return SendMessage.this - .send(this.from, this.toType, this.tos, this.message, this.extensions, - this.routeType, this.syncDevice); - } else if (StringUtils.isNotEmpty(routeType)) { - return SendMessage.this - .send(this.from, this.toType, this.tos, this.message, this.extensions, - this.routeType); - } else if (syncDevice != null) { - return SendMessage.this - .send(this.from, this.toType, this.tos, this.message, this.extensions, - this.syncDevice); - } else { - return SendMessage.this - .send(this.from, this.toType, this.tos, this.message, this.extensions); - } - } - - public Mono sendWithoutMsgId() { - if (StringUtils.isNotEmpty(routeType) && syncDevice != null) { - return SendMessage.this - .sendWithoutMsgId(this.from, this.toType, this.tos, this.message, - this.extensions, this.routeType, this.syncDevice); - } else if (StringUtils.isNotEmpty(routeType)) { - return SendMessage.this - .sendWithoutMsgId(this.from, this.toType, this.tos, this.message, - this.extensions, this.routeType); - } else if (syncDevice != null) { - return SendMessage.this - .sendWithoutMsgId(this.from, this.toType, this.tos, this.message, - this.extensions, this.syncDevice); - } else { - return SendMessage.this - .sendWithoutMsgId(this.from, this.toType, this.tos, this.message, - this.extensions); - } - } - - } - -} diff --git a/im-sdk-core/src/main/java/com/easemob/im/server/api/message/send/SendMessageRequest.java b/im-sdk-core/src/main/java/com/easemob/im/server/api/message/send/SendMessageRequest.java deleted file mode 100644 index adec8579f..000000000 --- a/im-sdk-core/src/main/java/com/easemob/im/server/api/message/send/SendMessageRequest.java +++ /dev/null @@ -1,480 +0,0 @@ -package com.easemob.im.server.api.message.send; - -import com.easemob.im.server.api.message.ChatroomMsgLevel; -import com.easemob.im.server.model.*; -import com.fasterxml.jackson.annotation.JsonAutoDetect; -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonProperty; - -import java.util.HashMap; -import java.util.HashSet; -import java.util.Map; -import java.util.Set; - -@JsonAutoDetect(getterVisibility = JsonAutoDetect.Visibility.NONE) -public class SendMessageRequest { - @JsonProperty("from") - private String from; - - @JsonProperty("target_type") - private String targetType; - - /* the server side does not preserve order of targets */ - @JsonProperty("target") - private Set targets; - - @JsonProperty("msg") - private Message message; - - @JsonProperty("ext") - private Map extensions; - - @JsonProperty("routetype") - private String routeType; - - @JsonProperty("sync_device") - private Boolean syncDevice; - - @JsonProperty("chatroom_msg_level") - private String chatroomMsgLevel; - - @JsonCreator - public SendMessageRequest(@JsonProperty("from") String from, - @JsonProperty("target_type") String targetType, - @JsonProperty("target") Set targets, - @JsonProperty("msg") EMMessage message, - @JsonProperty("ext") Map extensions) { - this.from = from; - this.targetType = targetType; - this.targets = targets; - this.message = Message.of(message); - this.extensions = extensions; - } - - @JsonCreator - public SendMessageRequest(@JsonProperty("from") String from, - @JsonProperty("target_type") String targetType, - @JsonProperty("target") Set targets, - @JsonProperty("msg") EMMessage message, - @JsonProperty("ext") Map extensions, - @JsonProperty("routetype") String routeType) { - this.from = from; - this.targetType = targetType; - this.targets = targets; - this.message = Message.of(message); - this.extensions = extensions; - this.routeType = routeType; - } - - @JsonCreator - public SendMessageRequest(@JsonProperty("from") String from, - @JsonProperty("target_type") String targetType, - @JsonProperty("target") Set targets, - @JsonProperty("msg") EMMessage message, - @JsonProperty("ext") Map extensions, - @JsonProperty("sync_device") Boolean syncDevice) { - this.from = from; - this.targetType = targetType; - this.targets = targets; - this.message = Message.of(message); - this.extensions = extensions; - this.syncDevice = syncDevice; - } - - @JsonCreator - public SendMessageRequest(@JsonProperty("from") String from, - @JsonProperty("target_type") String targetType, - @JsonProperty("target") Set targets, - @JsonProperty("msg") EMMessage message, - @JsonProperty("ext") Map extensions, - @JsonProperty("routetype") String routeType, - @JsonProperty("sync_device") Boolean syncDevice) { - this.from = from; - this.targetType = targetType; - this.targets = targets; - this.message = Message.of(message); - this.extensions = extensions; - this.routeType = routeType; - this.syncDevice = syncDevice; - } - - @JsonCreator - public SendMessageRequest(@JsonProperty("from") String from, - @JsonProperty("msg") EMMessage message, - @JsonProperty("ext") Map extensions, - @JsonProperty("sync_device") Boolean syncDevice, - @JsonProperty("chatroom_msg_level") ChatroomMsgLevel chatroomMsgLevel) { - this.from = from; - this.message = Message.of(message); - this.extensions = extensions; - this.syncDevice = syncDevice; - this.chatroomMsgLevel = chatroomMsgLevel.getLevel(); - } - - public static Map parseExtensions(Set extensions) { - if (extensions == null || extensions.isEmpty()) { - return null; - } - Map mapped = new HashMap<>(); - for (EMKeyValue keyValue : extensions) { - switch (keyValue.type()) { - case BOOL: - mapped.put(keyValue.key(), keyValue.asBoolean()); - break; - case INT: - mapped.put(keyValue.key(), keyValue.asInt()); - break; - case UINT: - mapped.put(keyValue.key(), keyValue.asLong()); - break; - case LLINT: - mapped.put(keyValue.key(), keyValue.asLong()); - break; - case FLOAT: - mapped.put(keyValue.key(), keyValue.asFloat()); - break; - case DOUBLE: - mapped.put(keyValue.key(), keyValue.asDouble()); - break; - case STRING: - mapped.put(keyValue.key(), keyValue.asString()); - break; - case JSON_STRING: - mapped.put(keyValue.key(), keyValue.asString()); - break; - case OBJECT: - mapped.put(keyValue.key(), keyValue.asObject()); - break; - } - } - return mapped; - } - - public String getFrom() { - return this.from; - } - - public String getTargetType() { - return this.targetType; - } - - public Set getTargets() { - return this.targets; - } - - public Message getMessage() { - return this.message; - } - - public Set getExtensions() { - return populateExtensions(this.extensions); - } - - public String getRouteType() { - return routeType; - } - - public Boolean getSyncDevice() { - return syncDevice; - } - - public String getChatroomMsgLevel() { - return chatroomMsgLevel; - } - - @SuppressWarnings("unchecked") - public Set populateExtensions(Map extensions) { - if (extensions == null || extensions.isEmpty()) { - return null; - } - Set mapped = new HashSet<>(); - for (String key : extensions.keySet()) { - Object value = extensions.get(key); - if (value instanceof Boolean) { - mapped.add(EMKeyValue.of(key, (boolean) value)); - } else if (value instanceof Integer) { - mapped.add(EMKeyValue.of(key, (int) value)); - } else if (value instanceof Long) { - mapped.add(EMKeyValue.of(key, (long) value)); - } else if (value instanceof Float) { - mapped.add(EMKeyValue.of(key, (float) value)); - } else if (value instanceof Double) { - mapped.add(EMKeyValue.of(key, (double) value)); - } else if (value instanceof String) { - mapped.add(EMKeyValue.of(key, (String) value)); - } - } - return mapped; - } - - static class Message { - @JsonProperty("type") - private String type; - - @JsonProperty("msg") - private String text; - - @JsonProperty("lng") - private Double longitude; - - @JsonProperty("lat") - private Double latitude; - - @JsonProperty("addr") - private String address; - - @JsonProperty("filename") - private String displayName; - - @JsonProperty("url") - private String uri; - - @JsonProperty("secret") - private String secret; - - @JsonProperty("file_length") - private Integer bytes; - - @JsonProperty("action") - private String action; - - @JsonProperty("param") - private Map params; - - @JsonProperty("length") - private Integer duration; - - @JsonProperty("size") - private Dimensions dimensions; - - @JsonProperty("thumb") - private String thumb; - - @JsonProperty("thumb_secret") - private String thumbSecret; - - @JsonProperty("customEvent") - private String customEvent; - - @JsonProperty("customExts") - private Map customExtensions; - - @JsonCreator - public Message(@JsonProperty("type") String type, - @JsonProperty("msg") String text, - @JsonProperty("lng") Double longitude, - @JsonProperty("lat") Double latitude, - @JsonProperty("addr") String address, - @JsonProperty("filename") String displayName, - @JsonProperty("url") String uri, - @JsonProperty("secret") String secretKey, - @JsonProperty("file_length") Integer bytes, - @JsonProperty("action") String action, - @JsonProperty("param") Map params, - @JsonProperty("length") Integer duration, - @JsonProperty("size") Dimensions dimensions, - @JsonProperty("customEvent") String customEvent, - @JsonProperty("customExts") Map customExtensions) { - this.type = type; - this.text = text; - this.longitude = longitude; - this.latitude = latitude; - this.address = address; - this.displayName = displayName; - this.uri = uri; - this.secret = secretKey; - this.bytes = bytes; - this.action = action; - this.params = params; - this.duration = duration; - this.dimensions = dimensions; - this.customEvent = customEvent; - this.customExtensions = customExtensions; - } - - public Message(String type) { - this.type = type; - } - - @SuppressWarnings("unchecked") - public static Message of(EMMessage msg) { - switch (msg.messageType()) { - case TEXT: - return Message.of((EMTextMessage) msg); - case IMAGE: - return Message.of((EMImageMessage) msg); - case AUDIO: - return Message.of((EMVoiceMessage) msg); - case VIDEO: - return Message.of((EMVideoMessage) msg); - case LOCATION: - return Message.of((EMLocationMessage) msg); - case FILE: - return Message.of((EMFileMessage) msg); - case COMMAND: - return Message.of((EMCommandMessage) msg); - case CUSTOM: - return Message.of((EMCustomMessage) msg); - default: - throw new IllegalArgumentException( - String.format("message type %s not supported", msg.messageType())); - } - } - - public static Message of(EMTextMessage msg) { - Message send = new Message("txt"); - send.text = msg.text(); - return send; - } - - public static Message of(EMImageMessage msg) { - Message send = new Message("img"); - send.uri = msg.uri() == null ? null : msg.uri().toString(); - send.displayName = msg.displayName(); - send.bytes = msg.bytes(); - send.secret = msg.secret(); - if (msg.width() != null || msg.height() != null) { - send.dimensions = new Dimensions(msg.width(), msg.height()); - } - return send; - } - - public static Message of(EMVoiceMessage msg) { - Message send = new Message("audio"); - send.uri = msg.uri() == null ? null : msg.uri().toString(); - send.displayName = msg.displayName(); - send.bytes = msg.bytes(); - send.secret = msg.secret(); - send.duration = msg.duration(); - return send; - } - - public static Message of(EMVideoMessage msg) { - Message send = new Message("video"); - send.uri = msg.uri() == null ? null : msg.uri().toString(); - send.displayName = msg.displayName(); - send.bytes = msg.bytes(); - send.secret = msg.secret(); - send.duration = msg.duration(); - send.thumb = msg.thumb(); - send.thumbSecret = msg.thumbSecret(); - return send; - } - - public static Message of(EMLocationMessage msg) { - Message send = new Message("loc"); - send.longitude = msg.longitude(); - send.latitude = msg.latitude(); - send.address = msg.address(); - return send; - } - - public static Message of(EMFileMessage msg) { - Message send = new Message("file"); - send.uri = msg.uri() == null ? null : msg.uri().toString(); - send.displayName = msg.displayName(); - send.bytes = msg.bytes(); - send.secret = msg.secret(); - return send; - } - - public static Message of(EMCommandMessage msg) { - Message send = new Message("cmd"); - send.action = msg.action(); - if (msg.params() == null) { - return send; - } - send.params = new HashMap<>(); - for (EMKeyValue kv : msg.params()) { - switch (kv.type()) { - case BOOL: - send.params.put(kv.key(), kv.asBoolean()); - break; - case INT: - send.params.put(kv.key(), kv.asInt()); - break; - case UINT: - send.params.put(kv.key(), kv.asLong()); - break; - case LLINT: - send.params.put(kv.key(), kv.asLong()); - break; - case FLOAT: - send.params.put(kv.key(), kv.asFloat()); - break; - case DOUBLE: - send.params.put(kv.key(), kv.asDouble()); - break; - case STRING: - send.params.put(kv.key(), kv.asString()); - break; - case JSON_STRING: - send.params.put(kv.key(), kv.asString()); - break; - } - } - return send; - } - - public static Message of(EMCustomMessage msg) { - Message send = new Message("custom"); - send.customEvent = msg.customEvent(); - if (msg.customExtensions() == null) { - return send; - } - send.customExtensions = new HashMap<>(); - for (EMKeyValue kv : msg.customExtensions()) { - switch (kv.type()) { - case BOOL: - send.customExtensions.put(kv.key(), kv.asBoolean()); - break; - case INT: - send.customExtensions.put(kv.key(), kv.asInt()); - break; - case UINT: - send.customExtensions.put(kv.key(), kv.asLong()); - break; - case LLINT: - send.customExtensions.put(kv.key(), kv.asLong()); - break; - case FLOAT: - send.customExtensions.put(kv.key(), kv.asFloat()); - break; - case DOUBLE: - send.customExtensions.put(kv.key(), kv.asDouble()); - break; - case STRING: - send.customExtensions.put(kv.key(), kv.asString()); - break; - case JSON_STRING: - send.customExtensions.put(kv.key(), kv.asString()); - break; - } - } - return send; - } - } - - - static class Dimensions { - @JsonProperty("width") - private Double width; - @JsonProperty("height") - private Double height; - - @JsonCreator - public Dimensions(@JsonProperty("width") Double width, - @JsonProperty("height") Double height) { - this.width = width; - this.height = height; - } - - public Double getWidth() { - return this.width; - } - - public Double getHeight() { - return this.height; - } - } -} diff --git a/im-sdk-core/src/main/java/com/easemob/im/server/api/message/send/SendMessageResponse.java b/im-sdk-core/src/main/java/com/easemob/im/server/api/message/send/SendMessageResponse.java deleted file mode 100644 index 5bc87c294..000000000 --- a/im-sdk-core/src/main/java/com/easemob/im/server/api/message/send/SendMessageResponse.java +++ /dev/null @@ -1,44 +0,0 @@ -package com.easemob.im.server.api.message.send; - -import com.easemob.im.server.model.EMSentMessageIds; -import com.fasterxml.jackson.annotation.JsonProperty; - -import java.util.Map; - -public class SendMessageResponse { - /** - * messageIdsByReceiverId contains mapping from receiver id to message id - */ - @JsonProperty("data") - private Map messageIdsByReceiverId; - - public SendMessageResponse(@JsonProperty("data") Map messageIdsByReceiverId) { - this.messageIdsByReceiverId = messageIdsByReceiverId; - } - - /** - * Get message id sent to given receiver. - * - * @param receiverId the receiver's id - * @return the message id, null if absent - */ - public String getMessageIdByReceiverId(String receiverId) { - if (this.messageIdsByReceiverId == null) { - return null; - } - return this.messageIdsByReceiverId.get(receiverId); - } - - public EMSentMessageIds toEMSentMessages() { - return new EMSentMessageIds(this.messageIdsByReceiverId); - } - - /** - * Get all message ids mapped by receiver id. - * - * @return message ids mapped by receiver id - */ - public Map getAllMessageIdsByReceiver() { - return this.messageIdsByReceiverId; - } -} diff --git a/im-sdk-core/src/main/java/com/easemob/im/server/api/message/send/SendMessageResultResponse.java b/im-sdk-core/src/main/java/com/easemob/im/server/api/message/send/SendMessageResultResponse.java deleted file mode 100644 index 91d8005ba..000000000 --- a/im-sdk-core/src/main/java/com/easemob/im/server/api/message/send/SendMessageResultResponse.java +++ /dev/null @@ -1,44 +0,0 @@ -package com.easemob.im.server.api.message.send; - -import com.easemob.im.server.model.EMSentMessageResults; -import com.fasterxml.jackson.annotation.JsonProperty; - -import java.util.Map; - -public class SendMessageResultResponse { - /** - * messageSendResults contains mapping from receiver id to message send reuslt - */ - @JsonProperty("data") - private Map messageSendResults; - - public SendMessageResultResponse(@JsonProperty("data") Map messageSendResults) { - this.messageSendResults = messageSendResults; - } - - /** - * Get message result sent to given receiver. - * - * @param receiverId the receiver's id - * @return the message send result, null if absent - */ - public String getMessageSendResult(String receiverId) { - if (this.messageSendResults == null) { - return null; - } - return this.messageSendResults.get(receiverId); - } - - public EMSentMessageResults toEMSentMessages() { - return new EMSentMessageResults(this.messageSendResults); - } - - /** - * Get all message send results mapped by receiver id. - * - * @return message send results mapped by receiver id - */ - public Map getAllMessageSendResultsByReceiver() { - return this.messageSendResults; - } -} diff --git a/im-sdk-core/src/main/java/com/easemob/im/server/api/message/send/message/MessageSend.java b/im-sdk-core/src/main/java/com/easemob/im/server/api/message/send/message/MessageSend.java deleted file mode 100644 index bd698323b..000000000 --- a/im-sdk-core/src/main/java/com/easemob/im/server/api/message/send/message/MessageSend.java +++ /dev/null @@ -1,604 +0,0 @@ -package com.easemob.im.server.api.message.send.message; - -import com.easemob.im.server.api.Context; -import com.easemob.im.server.api.DefaultErrorMapper; -import com.easemob.im.server.api.ErrorMapper; -import com.easemob.im.server.api.message.ChatroomMsgLevel; -import com.easemob.im.server.api.message.send.SendMessageRequest; -import com.easemob.im.server.api.message.send.SendMessageResponse; -import com.easemob.im.server.exception.EMUnknownException; -import com.easemob.im.server.model.*; -import io.github.resilience4j.core.StringUtils; -import reactor.core.publisher.Mono; - -import java.util.HashSet; -import java.util.Set; -import java.util.function.Consumer; - -public class MessageSend { - private final Context context; - - private final static String CHAT_ROOMS = "chatrooms"; - - public MessageSend(Context context) { - this.context = context; - } - - public MessageSend.RouteSpec fromUser(String username) { - return new MessageSend.RouteSpec(username); - } - - public Mono send(String from, String toType, Set tos, - EMMessage message, Set extensions) { - return this.context.getHttpClient() - .flatMap(httpClient -> httpClient.post() - .uri("/messages/" + toType) - .send(Mono.create(sink -> sink.success(context.getCodec() - .encode(new MessageSendRequest(from, tos, message, - MessageSendRequest.parseExtensions(extensions)))))) - .responseSingle((rsp, buf) -> { - return buf.switchIfEmpty( - Mono.error(new EMUnknownException("response is null"))) - .flatMap(byteBuf -> { - ErrorMapper mapper = new DefaultErrorMapper(); - mapper.statusCode(rsp); - mapper.checkError(byteBuf); - return Mono.just(byteBuf); - }); - })) - .map(byteBuf -> { - SendMessageResponse sendMessageResponse = - context.getCodec().decode(byteBuf, SendMessageResponse.class); - return sendMessageResponse.toEMSentMessages(); - }); - } - - public Mono send(String from, String toType, Set tos, - EMMessage message, Set extensions, ChatroomMsgLevel level) { - return this.context.getHttpClient() - .flatMap(httpClient -> httpClient.post() - .uri("/messages/" + toType) - .send(Mono.create(sink -> sink.success(context.getCodec() - .encode(new MessageSendRequest(from, tos, message, - MessageSendRequest.parseExtensions(extensions), level))))) - .responseSingle((rsp, buf) -> { - return buf.switchIfEmpty( - Mono.error(new EMUnknownException("response is null"))) - .flatMap(byteBuf -> { - ErrorMapper mapper = new DefaultErrorMapper(); - mapper.statusCode(rsp); - mapper.checkError(byteBuf); - return Mono.just(byteBuf); - }); - })) - .map(byteBuf -> { - SendMessageResponse sendMessageResponse = - context.getCodec().decode(byteBuf, SendMessageResponse.class); - return sendMessageResponse.toEMSentMessages(); - }); - } - - public Mono send(String from, String toType, Set tos, - EMMessage message, Set extensions, String routeType) { - return this.context.getHttpClient() - .flatMap(httpClient -> httpClient.post() - .uri("/messages/" + toType) - .send(Mono.create(sink -> sink.success(context.getCodec() - .encode(new MessageSendRequest(from, tos, message, - SendMessageRequest.parseExtensions(extensions), - routeType))))) - .responseSingle((rsp, buf) -> { - return buf.switchIfEmpty( - Mono.error(new EMUnknownException("response is null"))) - .flatMap(byteBuf -> { - ErrorMapper mapper = new DefaultErrorMapper(); - mapper.statusCode(rsp); - mapper.checkError(byteBuf); - return Mono.just(byteBuf); - }); - })) - .map(byteBuf -> { - SendMessageResponse sendMessageResponse = context.getCodec() - .decode(byteBuf, SendMessageResponse.class); - return sendMessageResponse.toEMSentMessages(); - }); - } - - public Mono send(String from, String toType, Set tos, - EMMessage message, Set extensions, String routeType, ChatroomMsgLevel level) { - return this.context.getHttpClient() - .flatMap(httpClient -> httpClient.post() - .uri("/messages/" + toType) - .send(Mono.create(sink -> sink.success(context.getCodec() - .encode(new MessageSendRequest(from, tos, message, - SendMessageRequest.parseExtensions(extensions), - routeType, level))))) - .responseSingle((rsp, buf) -> { - return buf.switchIfEmpty( - Mono.error(new EMUnknownException("response is null"))) - .flatMap(byteBuf -> { - ErrorMapper mapper = new DefaultErrorMapper(); - mapper.statusCode(rsp); - mapper.checkError(byteBuf); - return Mono.just(byteBuf); - }); - })) - .map(byteBuf -> { - SendMessageResponse sendMessageResponse = context.getCodec() - .decode(byteBuf, SendMessageResponse.class); - return sendMessageResponse.toEMSentMessages(); - }); - } - - public Mono send(String from, String toType, Set tos, - EMMessage message, Set extensions, Boolean syncDevice) { - return this.context.getHttpClient() - .flatMap(httpClient -> httpClient.post() - .uri("/messages/" + toType) - .send(Mono.create(sink -> sink.success(context.getCodec() - .encode(new MessageSendRequest(from, tos, message, - SendMessageRequest.parseExtensions(extensions), - syncDevice))))) - .responseSingle((rsp, buf) -> { - return buf.switchIfEmpty( - Mono.error(new EMUnknownException("response is null"))) - .flatMap(byteBuf -> { - ErrorMapper mapper = new DefaultErrorMapper(); - mapper.statusCode(rsp); - mapper.checkError(byteBuf); - return Mono.just(byteBuf); - }); - })) - .map(byteBuf -> { - SendMessageResponse sendMessageResponse = context.getCodec() - .decode(byteBuf, SendMessageResponse.class); - return sendMessageResponse.toEMSentMessages(); - }); - } - - public Mono send(String from, String toType, Set tos, - EMMessage message, Set extensions, Boolean syncDevice, ChatroomMsgLevel level) { - return this.context.getHttpClient() - .flatMap(httpClient -> httpClient.post() - .uri("/messages/" + toType) - .send(Mono.create(sink -> sink.success(context.getCodec() - .encode(new MessageSendRequest(from, tos, message, - SendMessageRequest.parseExtensions(extensions), - syncDevice, level))))) - .responseSingle((rsp, buf) -> { - return buf.switchIfEmpty( - Mono.error(new EMUnknownException("response is null"))) - .flatMap(byteBuf -> { - ErrorMapper mapper = new DefaultErrorMapper(); - mapper.statusCode(rsp); - mapper.checkError(byteBuf); - return Mono.just(byteBuf); - }); - })) - .map(byteBuf -> { - SendMessageResponse sendMessageResponse = context.getCodec() - .decode(byteBuf, SendMessageResponse.class); - return sendMessageResponse.toEMSentMessages(); - }); - } - - public Mono send(String from, String toType, Set tos, - EMMessage message, Set extensions, String routeType, Boolean syncDevice) { - return this.context.getHttpClient() - .flatMap(httpClient -> httpClient.post() - .uri("/messages/" + toType) - .send(Mono.create(sink -> sink.success(context.getCodec() - .encode(new MessageSendRequest(from, tos, message, - MessageSendRequest.parseExtensions(extensions), routeType, - syncDevice))))) - .responseSingle((rsp, buf) -> { - return buf.switchIfEmpty( - Mono.error(new EMUnknownException("response is null"))) - .flatMap(byteBuf -> { - ErrorMapper mapper = new DefaultErrorMapper(); - mapper.statusCode(rsp); - mapper.checkError(byteBuf); - return Mono.just(byteBuf); - }); - })) - .map(byteBuf -> { - SendMessageResponse sendMessageResponse = context.getCodec() - .decode(byteBuf, SendMessageResponse.class); - return sendMessageResponse.toEMSentMessages(); - }); - } - - public Mono send(String from, String toType, Set tos, - EMMessage message, Set extensions, String routeType, Boolean syncDevice, ChatroomMsgLevel level) { - return this.context.getHttpClient() - .flatMap(httpClient -> httpClient.post() - .uri("/messages/" + toType) - .send(Mono.create(sink -> { - if (CHAT_ROOMS.equalsIgnoreCase(toType)) { - sink.success(context.getCodec() - .encode(new MessageSendRequest(from, tos, message, - MessageSendRequest.parseExtensions(extensions), routeType, - syncDevice, level))); - } - - sink.success(context.getCodec() - .encode(new MessageSendRequest(from, tos, message, - MessageSendRequest.parseExtensions(extensions), routeType, - syncDevice))); - })) - .responseSingle((rsp, buf) -> { - return buf.switchIfEmpty( - Mono.error(new EMUnknownException("response is null"))) - .flatMap(byteBuf -> { - ErrorMapper mapper = new DefaultErrorMapper(); - mapper.statusCode(rsp); - mapper.checkError(byteBuf); - return Mono.just(byteBuf); - }); - })) - .map(byteBuf -> { - SendMessageResponse sendMessageResponse = context.getCodec() - .decode(byteBuf, SendMessageResponse.class); - return sendMessageResponse.toEMSentMessages(); - }); - } - - public Mono send(String from, Set tos, EMMessage message, Set toGroupUsers, - Set extensions, Boolean syncDevice) { - return this.context.getHttpClient() - .flatMap(httpClient -> httpClient.post() - .uri("/messages/chatgroups/users") - .send(Mono.create(sink -> { - sink.success(context.getCodec() - .encode(new MessageSendRequest(from, tos, message, toGroupUsers, - MessageSendRequest.parseExtensions(extensions), - syncDevice))); - })) - .responseSingle((rsp, buf) -> { - return buf.switchIfEmpty( - Mono.error(new EMUnknownException("response is null"))) - .flatMap(byteBuf -> { - ErrorMapper mapper = new DefaultErrorMapper(); - mapper.statusCode(rsp); - mapper.checkError(byteBuf); - return Mono.just(byteBuf); - }); - })) - .map(byteBuf -> { - SendMessageResponse sendMessageResponse = context.getCodec() - .decode(byteBuf, SendMessageResponse.class); - return sendMessageResponse.toEMSentMessages(); - }); - } - - public Mono send(String from, Set tos, EMMessage message, Set toRoomUsers, - Set extensions, Boolean syncDevice, ChatroomMsgLevel chatroomMsgLevel) { - return this.context.getHttpClient() - .flatMap(httpClient -> httpClient.post() - .uri("/messages/chatrooms/users") - .send(Mono.create(sink -> { - sink.success(context.getCodec() - .encode(new MessageSendRequest(from, tos, message, toRoomUsers, - MessageSendRequest.parseExtensions(extensions), - syncDevice, chatroomMsgLevel))); - })) - .responseSingle((rsp, buf) -> { - return buf.switchIfEmpty( - Mono.error(new EMUnknownException("response is null"))) - .flatMap(byteBuf -> { - ErrorMapper mapper = new DefaultErrorMapper(); - mapper.statusCode(rsp); - mapper.checkError(byteBuf); - return Mono.just(byteBuf); - }); - })) - .map(byteBuf -> { - SendMessageResponse sendMessageResponse = context.getCodec() - .decode(byteBuf, SendMessageResponse.class); - return sendMessageResponse.toEMSentMessages(); - }); - } - - public Mono sendRoomBroadcast(String from, - EMMessage message, Set extensions, Boolean syncDevice, ChatroomMsgLevel level) { - return this.context.getHttpClient() - .flatMap(httpClient -> httpClient.post() - .uri("/messages/chatrooms/broadcast") - .send(Mono.create(sink -> { - sink.success(context.getCodec() - .encode(new SendMessageRequest(from, message, - MessageSendRequest.parseExtensions(extensions), syncDevice, level))); - })) - .responseSingle((rsp, buf) -> { - return buf.switchIfEmpty( - Mono.error(new EMUnknownException("response is null"))) - .flatMap(byteBuf -> { - ErrorMapper mapper = new DefaultErrorMapper(); - mapper.statusCode(rsp); - mapper.checkError(byteBuf); - return Mono.just(byteBuf); - }); - })) - .map(byteBuf -> { - SendMessageResponse sendMessageResponse = context.getCodec() - .decode(byteBuf, SendMessageResponse.class); - return sendMessageResponse.toEMSentMessages(); - }); - } - - public class RouteSpec { - - private String from; - - public RouteSpec(String from) { - this.from = from; - } - - public MessageSend.MessageSpec toUser(String username) { - Set tos = new HashSet<>(); - tos.add(username); - return new MessageSend.MessageSpec(from, "users", tos); - } - - public MessageSend.MessageSpec toUsers(Set usernames) { - return new MessageSend.MessageSpec(from, "users", usernames); - } - - public MessageSend.MessageSpec toGroup(String groupId) { - Set tos = new HashSet<>(); - tos.add(groupId); - return new MessageSend.MessageSpec(from, "chatgroups", tos); - } - - public MessageSend.MessageSpec toGroups(Set groupIds) { - return new MessageSend.MessageSpec(from, "chatgroups", groupIds); - } - - public MessageSend.MessageSpec toRoom(String roomId) { - Set tos = new HashSet<>(); - tos.add(roomId); - return new MessageSend.MessageSpec(from, "chatrooms", tos); - } - - public MessageSend.MessageSpec toRooms(Set roomIds) { - return new MessageSend.MessageSpec(from, "chatrooms", roomIds); - } - } - - - public class MessageSpec { - - private String from; - - private String toType; - - private Set tos; - - private Set toGroupUsers; - - public MessageSpec(String from, String toType, Set tos) { - this.from = from; - this.toType = toType; - this.tos = tos; - } - - public MessageSend.SendSpec text(Consumer customizer) { - EMTextMessage message = new EMTextMessage(); - customizer.accept(message); - return new MessageSend.SendSpec(this.from, this.toType, this.tos, message); - } - - public MessageSend.SendSpec image(Consumer customizer) { - EMImageMessage message = new EMImageMessage(); - customizer.accept(message); - return new MessageSend.SendSpec(this.from, this.toType, this.tos, message); - } - - public MessageSend.SendSpec voice(Consumer customizer) { - EMVoiceMessage message = new EMVoiceMessage(); - customizer.accept(message); - return new MessageSend.SendSpec(this.from, this.toType, this.tos, message); - } - - public MessageSend.SendSpec video(Consumer customizer) { - EMVideoMessage message = new EMVideoMessage(); - customizer.accept(message); - return new MessageSend.SendSpec(this.from, this.toType, this.tos, message); - } - - public MessageSend.SendSpec location(Consumer customizer) { - EMLocationMessage message = new EMLocationMessage(); - customizer.accept(message); - return new MessageSend.SendSpec(this.from, this.toType, this.tos, message); - } - - public MessageSend.SendSpec file(Consumer customizer) { - EMFileMessage message = new EMFileMessage(); - customizer.accept(message); - return new MessageSend.SendSpec(this.from, this.toType, this.tos, message); - } - - public MessageSend.SendSpec command(Consumer customizer) { - EMCommandMessage message = new EMCommandMessage(); - customizer.accept(message); - return new MessageSend.SendSpec(this.from, this.toType, this.tos, message); - } - - public MessageSend.SendSpec custom(Consumer customizer) { - EMCustomMessage message = new EMCustomMessage(); - customizer.accept(message); - return new MessageSend.SendSpec(this.from, this.toType, this.tos, message); - } - } - - - public class SendSpec { - - private String from; - - private String toType; - - private Set tos; - - private EMMessage message; - - private Set toGroupUsers; - - private Set toRoomUsers; - - private Set extensions; - - private String routeType; - - private Boolean syncDevice; - - private ChatroomMsgLevel chatroomMsgLevel; - - SendSpec(String from, String toType, Set tos, EMMessage message) { - this.from = from; - this.toType = toType; - this.tos = tos; - this.message = message; - } - - SendSpec(String from, String toType, Set tos, EMMessage message, String routeType) { - this.from = from; - this.toType = toType; - this.tos = tos; - this.message = message; - this.routeType = routeType; - } - - SendSpec(String from, String toType, Set tos, EMMessage message, - Boolean syncDevice) { - this.from = from; - this.toType = toType; - this.tos = tos; - this.message = message; - this.syncDevice = syncDevice; - } - - SendSpec(String from, String toType, Set tos, EMMessage message, String routeType, - Boolean syncDevice) { - this.from = from; - this.toType = toType; - this.tos = tos; - this.message = message; - this.routeType = routeType; - this.syncDevice = syncDevice; - } - - SendSpec(String from, String toType, Set tos, EMMessage message, String routeType, - Boolean syncDevice, ChatroomMsgLevel chatroomMsgLevel) { - this.from = from; - this.toType = toType; - this.tos = tos; - this.message = message; - this.routeType = routeType; - this.syncDevice = syncDevice; - this.chatroomMsgLevel = chatroomMsgLevel; - } - - SendSpec(String from, String toType, Set tos, EMMessage message, Set toGroupUsers, - Boolean syncDevice) { - this.from = from; - this.toType = toType; - this.tos = tos; - this.message = message; - this.toGroupUsers = toGroupUsers; - this.syncDevice = syncDevice; - } - - SendSpec(String from, String toType, Set tos, EMMessage message, Set toRoomUsers, - Boolean syncDevice, ChatroomMsgLevel chatroomMsgLevel) { - this.from = from; - this.toType = toType; - this.tos = tos; - this.message = message; - this.toRoomUsers = toRoomUsers; - this.syncDevice = syncDevice; - this.chatroomMsgLevel = chatroomMsgLevel; - } - - public MessageSend.SendSpec extension(Consumer> customizer) { - if (this.extensions == null) { - this.extensions = new HashSet<>(); - } - customizer.accept(this.extensions); - return this; - } - - public MessageSend.SendSpec routeType(String type) { - this.routeType = type; - return this; - } - - public MessageSend.SendSpec syncDevice(Boolean syncDevice) { - this.syncDevice = syncDevice; - return this; - } - - public MessageSend.SendSpec chatroomMsgLevel(ChatroomMsgLevel chatroomMsgLevel) { - this.chatroomMsgLevel = chatroomMsgLevel; - return this; - } - - public MessageSend.SendSpec toGroupUsers(Set toGroupUsers) { - this.toGroupUsers = toGroupUsers; - return this; - } - - public MessageSend.SendSpec toRoomUsers(Set toRoomUsers) { - this.toRoomUsers = toRoomUsers; - return this; - } - - public Mono send() { - if (CHAT_ROOMS.equalsIgnoreCase(this.toType)) { - if (StringUtils.isNotEmpty(routeType) && syncDevice != null) { - return MessageSend.this - .send(this.from, this.toType, this.tos, this.message, this.extensions, - this.routeType, this.syncDevice, this.chatroomMsgLevel); - } else if (StringUtils.isNotEmpty(routeType)) { - return MessageSend.this - .send(this.from, this.toType, this.tos, this.message, this.extensions, - this.routeType, this.chatroomMsgLevel); - } else if (syncDevice != null) { - if (toRoomUsers != null) { - return MessageSend.this.send(this.from, this.tos, this.message, - this.toRoomUsers, this.extensions, this.syncDevice, this.chatroomMsgLevel); - } - return MessageSend.this - .send(this.from, this.toType, this.tos, this.message, this.extensions, - this.syncDevice, this.chatroomMsgLevel); - } else { - return MessageSend.this - .send(this.from, this.toType, this.tos, this.message, this.extensions, this.chatroomMsgLevel); - } - } - - if (StringUtils.isNotEmpty(routeType) && syncDevice != null) { - return MessageSend.this - .send(this.from, this.toType, this.tos, this.message, this.extensions, - this.routeType, this.syncDevice); - } else if (StringUtils.isNotEmpty(routeType)) { - return MessageSend.this - .send(this.from, this.toType, this.tos, this.message, this.extensions, - this.routeType); - } else if (syncDevice != null) { - if (toGroupUsers != null) { - return MessageSend.this.send(this.from, this.tos, this.message, - this.toGroupUsers, this.extensions, this.syncDevice); - } - return MessageSend.this - .send(this.from, this.toType, this.tos, this.message, this.extensions, - this.syncDevice); - } else { - return MessageSend.this - .send(this.from, this.toType, this.tos, this.message, this.extensions); - } - } - - } - -} diff --git a/im-sdk-core/src/main/java/com/easemob/im/server/api/message/send/message/MessageSendRequest.java b/im-sdk-core/src/main/java/com/easemob/im/server/api/message/send/message/MessageSendRequest.java deleted file mode 100644 index 0157bef4c..000000000 --- a/im-sdk-core/src/main/java/com/easemob/im/server/api/message/send/message/MessageSendRequest.java +++ /dev/null @@ -1,582 +0,0 @@ -package com.easemob.im.server.api.message.send.message; - -import com.easemob.im.server.api.message.ChatroomMsgLevel; -import com.easemob.im.server.model.*; -import com.fasterxml.jackson.annotation.JsonAutoDetect; -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonIgnore; -import com.fasterxml.jackson.annotation.JsonProperty; - -import java.util.HashMap; -import java.util.HashSet; -import java.util.Map; -import java.util.Set; - -@JsonAutoDetect(getterVisibility = JsonAutoDetect.Visibility.NONE) -public class MessageSendRequest { - - @JsonProperty("from") - private String from; - - @JsonProperty("type") - private String msgType; - - /* the server side does not preserve order of targets */ - @JsonProperty("to") - private Set tos; - - @JsonProperty("users") - private Set toGroupUsers; - - @JsonProperty("body") - private MessageSendRequest.Message body; - - @JsonProperty("ext") - private Map extensions; - - @JsonProperty("routetype") - private String routeType; - - @JsonProperty("sync_device") - private Boolean syncDevice; - - @JsonProperty("chatroom_msg_level") - private String chatroomMsgLevel; - - @JsonCreator - public MessageSendRequest(@JsonProperty("from") String from, - @JsonProperty("to") Set toSet, - @JsonProperty("msg") EMMessage message, - @JsonProperty("ext") Map extensions) { - this.from = from; - this.tos = toSet; - Message send = Message.of(message); - this.msgType = send.type; - this.body = send; - this.extensions = extensions; - } - - @JsonCreator - public MessageSendRequest(@JsonProperty("from") String from, - @JsonProperty("to") Set toSet, - @JsonProperty("msg") EMMessage message, - @JsonProperty("ext") Map extensions, - @JsonProperty("chatroom_msg_level") ChatroomMsgLevel chatroomMsgLevel) { - this.from = from; - this.tos = toSet; - Message send = Message.of(message); - this.msgType = send.type; - this.body = send; - this.extensions = extensions; - this.chatroomMsgLevel = chatroomMsgLevel.getLevel(); - } - - @JsonCreator - public MessageSendRequest(@JsonProperty("from") String from, - @JsonProperty("to") Set toSet, - @JsonProperty("msg") EMMessage message, - @JsonProperty("ext") Map extensions, - @JsonProperty("routetype") String routeType) { - this.from = from; - this.tos = toSet; - Message send = Message.of(message); - this.msgType = send.type; - this.body = send; - this.extensions = extensions; - this.routeType = routeType; - } - - @JsonCreator - public MessageSendRequest(@JsonProperty("from") String from, - @JsonProperty("to") Set toSet, - @JsonProperty("msg") EMMessage message, - @JsonProperty("ext") Map extensions, - @JsonProperty("routetype") String routeType, - @JsonProperty("chatroom_msg_level") ChatroomMsgLevel chatroomMsgLevel) { - this.from = from; - this.tos = toSet; - Message send = Message.of(message); - this.msgType = send.type; - this.body = send; - this.extensions = extensions; - this.routeType = routeType; - this.chatroomMsgLevel = chatroomMsgLevel.getLevel(); - } - - @JsonCreator - public MessageSendRequest(@JsonProperty("from") String from, - @JsonProperty("to") Set toSet, - @JsonProperty("msg") EMMessage message, - @JsonProperty("ext") Map extensions, - @JsonProperty("sync_device") Boolean syncDevice) { - this.from = from; - this.tos = toSet; - Message send = Message.of(message); - this.msgType = send.type; - this.body = send; - this.extensions = extensions; - this.syncDevice = syncDevice; - } - - @JsonCreator - public MessageSendRequest(@JsonProperty("from") String from, - @JsonProperty("to") Set toSet, - @JsonProperty("msg") EMMessage message, - @JsonProperty("ext") Map extensions, - @JsonProperty("sync_device") Boolean syncDevice, - @JsonProperty("chatroom_msg_level") ChatroomMsgLevel chatroomMsgLevel) { - this.from = from; - this.tos = toSet; - Message send = Message.of(message); - this.msgType = send.type; - this.body = send; - this.extensions = extensions; - this.syncDevice = syncDevice; - this.chatroomMsgLevel = chatroomMsgLevel.getLevel(); - } - - @JsonCreator - public MessageSendRequest(@JsonProperty("from") String from, - @JsonProperty("to") Set toSet, - @JsonProperty("msg") EMMessage message, - @JsonProperty("ext") Map extensions, - @JsonProperty("routetype") String routeType, - @JsonProperty("sync_device") Boolean syncDevice) { - this.from = from; - this.tos = toSet; - Message send = Message.of(message); - this.msgType = send.type; - this.body = send; - this.extensions = extensions; - this.routeType = routeType; - this.syncDevice = syncDevice; - } - - @JsonCreator - public MessageSendRequest(@JsonProperty("from") String from, - @JsonProperty("to") Set toSet, - @JsonProperty("msg") EMMessage message, - @JsonProperty("ext") Map extensions, - @JsonProperty("routetype") String routeType, - @JsonProperty("sync_device") Boolean syncDevice, - @JsonProperty("chatroom_msg_level") ChatroomMsgLevel chatroomMsgLevel) { - this.from = from; - this.tos = toSet; - Message send = Message.of(message); - this.msgType = send.type; - this.body = send; - this.extensions = extensions; - this.routeType = routeType; - this.syncDevice = syncDevice; - this.chatroomMsgLevel = chatroomMsgLevel.getLevel(); - } - - @JsonCreator - public MessageSendRequest(@JsonProperty("from") String from, - @JsonProperty("to") Set toSet, - @JsonProperty("msg") EMMessage message, - @JsonProperty("users") Set toGroupUsers, - @JsonProperty("ext") Map extensions, - @JsonProperty("sync_device") Boolean syncDevice) { - this.from = from; - this.tos = toSet; - this.toGroupUsers = toGroupUsers; - Message send = Message.of(message); - this.msgType = send.type; - this.body = send; - this.extensions = extensions; - this.syncDevice = syncDevice; - } - - @JsonCreator - public MessageSendRequest(@JsonProperty("from") String from, - @JsonProperty("to") Set toSet, - @JsonProperty("msg") EMMessage message, - @JsonProperty("users") Set toRoomUsers, - @JsonProperty("ext") Map extensions, - @JsonProperty("sync_device") Boolean syncDevice, - @JsonProperty("chatroom_msg_level") ChatroomMsgLevel chatroomMsgLevel) { - this.from = from; - this.tos = toSet; - this.toGroupUsers = toRoomUsers; - Message send = Message.of(message); - this.msgType = send.type; - this.body = send; - this.extensions = extensions; - this.syncDevice = syncDevice; - this.chatroomMsgLevel = chatroomMsgLevel.getLevel(); - } - - public static Map parseExtensions(Set extensions) { - if (extensions == null || extensions.isEmpty()) { - return null; - } - Map mapped = new HashMap<>(); - for (EMKeyValue keyValue : extensions) { - switch (keyValue.type()) { - case BOOL: - mapped.put(keyValue.key(), keyValue.asBoolean()); - break; - case INT: - mapped.put(keyValue.key(), keyValue.asInt()); - break; - case UINT: - mapped.put(keyValue.key(), keyValue.asLong()); - break; - case LLINT: - mapped.put(keyValue.key(), keyValue.asLong()); - break; - case FLOAT: - mapped.put(keyValue.key(), keyValue.asFloat()); - break; - case DOUBLE: - mapped.put(keyValue.key(), keyValue.asDouble()); - break; - case STRING: - mapped.put(keyValue.key(), keyValue.asString()); - break; - case JSON_STRING: - mapped.put(keyValue.key(), keyValue.asString()); - break; - case OBJECT: - mapped.put(keyValue.key(), keyValue.asObject()); - break; - } - } - return mapped; - } - - public String getFrom() { - return this.from; - } - - public Set getTos() { - return this.tos; - } - - public String getMsgType(){ - return this.msgType; - } - - public Message getBody() { - return this.body; - } - - public Set getExtensions() { - return populateExtensions(this.extensions); - } - - public String getRouteType() { - return routeType; - } - - public Boolean getSyncDevice() { - return syncDevice; - } - - public String getChatroomMsgLevel() { - return chatroomMsgLevel; - } - - public Set getToGroupUsers() { - return toGroupUsers; - } - - @SuppressWarnings("unchecked") - public Set populateExtensions(Map extensions) { - if (extensions == null || extensions.isEmpty()) { - return null; - } - Set mapped = new HashSet<>(); - for (String key : extensions.keySet()) { - Object value = extensions.get(key); - if (value instanceof Boolean) { - mapped.add(EMKeyValue.of(key, (boolean) value)); - } else if (value instanceof Integer) { - mapped.add(EMKeyValue.of(key, (int) value)); - } else if (value instanceof Long) { - mapped.add(EMKeyValue.of(key, (long) value)); - } else if (value instanceof Float) { - mapped.add(EMKeyValue.of(key, (float) value)); - } else if (value instanceof Double) { - mapped.add(EMKeyValue.of(key, (double) value)); - } else if (value instanceof String) { - mapped.add(EMKeyValue.of(key, (String) value)); - } - } - return mapped; - } - - static class Message { - - @JsonIgnore - private String type; - - @JsonProperty("msg") - private String text; - - @JsonProperty("lng") - private Double longitude; - - @JsonProperty("lat") - private Double latitude; - - @JsonProperty("addr") - private String address; - - @JsonProperty("filename") - private String displayName; - - @JsonProperty("url") - private String uri; - - @JsonProperty("secret") - private String secret; - - @JsonProperty("file_length") - private Integer bytes; - - @JsonProperty("action") - private String action; - - @JsonProperty("param") - private Map params; - - @JsonProperty("length") - private Integer duration; - - @JsonProperty("size") - private MessageSendRequest.Dimensions dimensions; - - @JsonProperty("thumb") - private String thumb; - - @JsonProperty("thumb_secret") - private String thumbSecret; - - @JsonProperty("customEvent") - private String customEvent; - - @JsonProperty("customExts") - private Map customExtensions; - - @JsonCreator - public Message(@JsonProperty("type") String type, - @JsonProperty("msg") String text, - @JsonProperty("lng") Double longitude, - @JsonProperty("lat") Double latitude, - @JsonProperty("addr") String address, - @JsonProperty("filename") String displayName, - @JsonProperty("url") String uri, - @JsonProperty("secret") String secretKey, - @JsonProperty("file_length") Integer bytes, - @JsonProperty("action") String action, - @JsonProperty("param") Map params, - @JsonProperty("length") Integer duration, - @JsonProperty("size") MessageSendRequest.Dimensions dimensions, - @JsonProperty("customEvent") String customEvent, - @JsonProperty("customExts") Map customExtensions) { - this.type = type; - this.text = text; - this.longitude = longitude; - this.latitude = latitude; - this.address = address; - this.displayName = displayName; - this.uri = uri; - this.secret = secretKey; - this.bytes = bytes; - this.action = action; - this.params = params; - this.duration = duration; - this.dimensions = dimensions; - this.customEvent = customEvent; - this.customExtensions = customExtensions; - } - - public Message(String type) { - this.type = type; - } - - @SuppressWarnings("unchecked") - public static MessageSendRequest.Message of(EMMessage msg) { - switch (msg.messageType()) { - case TEXT: - return MessageSendRequest.Message.of((EMTextMessage) msg); - case IMAGE: - return MessageSendRequest.Message.of((EMImageMessage) msg); - case AUDIO: - return MessageSendRequest.Message.of((EMVoiceMessage) msg); - case VIDEO: - return MessageSendRequest.Message.of((EMVideoMessage) msg); - case LOCATION: - return MessageSendRequest.Message.of((EMLocationMessage) msg); - case FILE: - return MessageSendRequest.Message.of((EMFileMessage) msg); - case COMMAND: - return MessageSendRequest.Message.of((EMCommandMessage) msg); - case CUSTOM: - return MessageSendRequest.Message.of((EMCustomMessage) msg); - default: - throw new IllegalArgumentException( - String.format("message type %s not supported", msg.messageType())); - } - } - - public static MessageSendRequest.Message of(EMTextMessage msg) { - MessageSendRequest.Message send = new MessageSendRequest.Message("txt"); - send.text = msg.text(); - return send; - } - - public static MessageSendRequest.Message of(EMImageMessage msg) { - MessageSendRequest.Message send = new MessageSendRequest.Message("img"); - send.uri = msg.uri() == null ? null : msg.uri().toString(); - send.displayName = msg.displayName(); - send.bytes = msg.bytes(); - send.secret = msg.secret(); - if (msg.width() != null || msg.height() != null) { - send.dimensions = new MessageSendRequest.Dimensions(msg.width(), msg.height()); - } - return send; - } - - public static MessageSendRequest.Message of(EMVoiceMessage msg) { - MessageSendRequest.Message send = new MessageSendRequest.Message("audio"); - send.uri = msg.uri() == null ? null : msg.uri().toString(); - send.displayName = msg.displayName(); - send.bytes = msg.bytes(); - send.secret = msg.secret(); - send.duration = msg.duration(); - return send; - } - - public static MessageSendRequest.Message of(EMVideoMessage msg) { - MessageSendRequest.Message send = new MessageSendRequest.Message("video"); - send.uri = msg.uri() == null ? null : msg.uri().toString(); - send.displayName = msg.displayName(); - send.bytes = msg.bytes(); - send.secret = msg.secret(); - send.duration = msg.duration(); - send.thumb = msg.thumb(); - send.thumbSecret = msg.thumbSecret(); - return send; - } - - public static MessageSendRequest.Message of(EMLocationMessage msg) { - MessageSendRequest.Message send = new MessageSendRequest.Message("loc"); - send.longitude = msg.longitude(); - send.latitude = msg.latitude(); - send.address = msg.address(); - return send; - } - - public static MessageSendRequest.Message of(EMFileMessage msg) { - MessageSendRequest.Message send = new MessageSendRequest.Message("file"); - send.uri = msg.uri() == null ? null : msg.uri().toString(); - send.displayName = msg.displayName(); - send.bytes = msg.bytes(); - send.secret = msg.secret(); - return send; - } - - public static MessageSendRequest.Message of(EMCommandMessage msg) { - MessageSendRequest.Message send = new MessageSendRequest.Message("cmd"); - send.action = msg.action(); - if (msg.params() == null) { - return send; - } - send.params = new HashMap<>(); - for (EMKeyValue kv : msg.params()) { - switch (kv.type()) { - case BOOL: - send.params.put(kv.key(), kv.asBoolean()); - break; - case INT: - send.params.put(kv.key(), kv.asInt()); - break; - case UINT: - send.params.put(kv.key(), kv.asLong()); - break; - case LLINT: - send.params.put(kv.key(), kv.asLong()); - break; - case FLOAT: - send.params.put(kv.key(), kv.asFloat()); - break; - case DOUBLE: - send.params.put(kv.key(), kv.asDouble()); - break; - case STRING: - send.params.put(kv.key(), kv.asString()); - break; - case JSON_STRING: - send.params.put(kv.key(), kv.asString()); - break; - } - } - return send; - } - - public static MessageSendRequest.Message of(EMCustomMessage msg) { - MessageSendRequest.Message send = new MessageSendRequest.Message("custom"); - send.customEvent = msg.customEvent(); - if (msg.customExtensions() == null) { - return send; - } - send.customExtensions = new HashMap<>(); - for (EMKeyValue kv : msg.customExtensions()) { - switch (kv.type()) { - case BOOL: - send.customExtensions.put(kv.key(), kv.asBoolean()); - break; - case INT: - send.customExtensions.put(kv.key(), kv.asInt()); - break; - case UINT: - send.customExtensions.put(kv.key(), kv.asLong()); - break; - case LLINT: - send.customExtensions.put(kv.key(), kv.asLong()); - break; - case FLOAT: - send.customExtensions.put(kv.key(), kv.asFloat()); - break; - case DOUBLE: - send.customExtensions.put(kv.key(), kv.asDouble()); - break; - case STRING: - send.customExtensions.put(kv.key(), kv.asString()); - break; - case JSON_STRING: - send.customExtensions.put(kv.key(), kv.asString()); - break; - } - } - return send; - } - } - - - static class Dimensions { - @JsonProperty("width") - private Double width; - @JsonProperty("height") - private Double height; - - @JsonCreator - public Dimensions(@JsonProperty("width") Double width, - @JsonProperty("height") Double height) { - this.width = width; - this.height = height; - } - - public Double getWidth() { - return this.width; - } - - public Double getHeight() { - return this.height; - } - } - -} diff --git a/im-sdk-core/src/main/java/com/easemob/im/server/api/message/status/MessageStatus.java b/im-sdk-core/src/main/java/com/easemob/im/server/api/message/status/MessageStatus.java deleted file mode 100644 index 9f230c0cc..000000000 --- a/im-sdk-core/src/main/java/com/easemob/im/server/api/message/status/MessageStatus.java +++ /dev/null @@ -1,34 +0,0 @@ -package com.easemob.im.server.api.message.status; - -import com.easemob.im.server.api.Context; -import com.easemob.im.server.api.DefaultErrorMapper; -import com.easemob.im.server.api.ErrorMapper; -import com.easemob.im.server.exception.EMUnknownException; -import reactor.core.publisher.Mono; - -public class MessageStatus { - - private Context context; - - public MessageStatus(Context context) { - this.context = context; - } - - public Mono isMessageDeliveredToUser(String messageId, String username) { - return this.context.getHttpClient() - .flatMap(httpClient -> httpClient.get() - .uri(String.format("/users/%s/offline_msg_status/%s", username, messageId)) - .responseSingle((rsp, buf) -> { - return buf.switchIfEmpty( - Mono.error(new EMUnknownException("response is null"))) - .flatMap(byteBuf -> { - ErrorMapper mapper = new DefaultErrorMapper(); - mapper.statusCode(rsp); - mapper.checkError(byteBuf); - return Mono.just(byteBuf); - }); - })) - .map(buf -> this.context.getCodec().decode(buf, MessageStatusResponse.class)) - .map(rsp -> rsp.isMessageDelivered(messageId)); - } -} diff --git a/im-sdk-core/src/main/java/com/easemob/im/server/api/message/status/MessageStatusResponse.java b/im-sdk-core/src/main/java/com/easemob/im/server/api/message/status/MessageStatusResponse.java deleted file mode 100644 index 636ce98c6..000000000 --- a/im-sdk-core/src/main/java/com/easemob/im/server/api/message/status/MessageStatusResponse.java +++ /dev/null @@ -1,22 +0,0 @@ -package com.easemob.im.server.api.message.status; - -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonProperty; - -import java.util.Map; - -public class MessageStatusResponse { - @JsonProperty("data") - private Map statusByMessageId; - - @JsonCreator - public MessageStatusResponse(@JsonProperty("data") Map statusByMessageId) { - this.statusByMessageId = statusByMessageId; - } - - public boolean isMessageDelivered(String messageId) { - String delivered = this.statusByMessageId.get(messageId); - return delivered != null && delivered.equals("delivered"); - } - -} diff --git a/im-sdk-core/src/main/java/com/easemob/im/server/api/message/upload/ImportMessage.java b/im-sdk-core/src/main/java/com/easemob/im/server/api/message/upload/ImportMessage.java deleted file mode 100644 index b505b4cf6..000000000 --- a/im-sdk-core/src/main/java/com/easemob/im/server/api/message/upload/ImportMessage.java +++ /dev/null @@ -1,207 +0,0 @@ -package com.easemob.im.server.api.message.upload; - -import com.easemob.im.server.api.Context; -import com.easemob.im.server.api.DefaultErrorMapper; -import com.easemob.im.server.api.ErrorMapper; -import com.easemob.im.server.exception.EMUnknownException; -import com.easemob.im.server.model.*; -import reactor.core.publisher.Mono; - -import java.util.HashSet; -import java.util.Set; -import java.util.function.Consumer; - -public class ImportMessage { - private final Context context; - - public ImportMessage(Context context) { - this.context = context; - } - - public class RouteSpec { - - private String from; - - public RouteSpec(String from) { - this.from = from; - } - - public ImportMessage.MessageSpec toUser(String username) { - return new ImportMessage.MessageSpec(from, "users", username); - } - - public ImportMessage.MessageSpec toGroup(String groupId) { - return new ImportMessage.MessageSpec(from, "chatgroups", groupId); - } - - } - - public class MessageSpec { - - private String from; - - private String toType; - - private String to; - - public MessageSpec(String from, String toType, String to) { - this.from = from; - this.toType = toType; - this.to = to; - } - - public ImportSpec text(Consumer customizer) { - EMTextMessage message = new EMTextMessage(); - customizer.accept(message); - return new ImportSpec(this.from, this.toType, this.to, message); - } - - public ImportSpec image(Consumer customizer) { - EMImageMessage message = new EMImageMessage(); - customizer.accept(message); - return new ImportSpec(this.from, this.toType, this.to, message); - } - - public ImportSpec voice(Consumer customizer) { - EMVoiceMessage message = new EMVoiceMessage(); - customizer.accept(message); - return new ImportSpec(this.from, this.toType, this.to, message); - } - - public ImportSpec video(Consumer customizer) { - EMVideoMessage message = new EMVideoMessage(); - customizer.accept(message); - return new ImportSpec(this.from, this.toType, this.to, message); - } - - public ImportSpec location(Consumer customizer) { - EMLocationMessage message = new EMLocationMessage(); - customizer.accept(message); - return new ImportSpec(this.from, this.toType, this.to, message); - } - - public ImportSpec file(Consumer customizer) { - EMFileMessage message = new EMFileMessage(); - customizer.accept(message); - return new ImportSpec(this.from, this.toType, this.to, message); - } - - public ImportSpec command(Consumer customizer) { - EMCommandMessage message = new EMCommandMessage(); - customizer.accept(message); - return new ImportSpec(this.from, this.toType, this.to, message); - } - - public ImportSpec custom(Consumer customizer) { - EMCustomMessage message = new EMCustomMessage(); - customizer.accept(message); - return new ImportSpec(this.from, this.toType, this.to, message); - } - } - - public class ImportSpec { - - private String from; - - private String toType; - - private String to; - - private EMMessage message; - - private Set extensions; - - private Boolean isAckRead; - - private Long msgTimestamp; - - private Boolean needDownload; - - ImportSpec(String from, String toType, String to, EMMessage message) { - this.from = from; - this.toType = toType; - this.to = to; - this.message = message; - } - - public ImportSpec extension(Consumer> customizer) { - if (this.extensions == null) { - this.extensions = new HashSet<>(); - } - customizer.accept(this.extensions); - return this; - } - - public ImportSpec isAckRead(Boolean isAckRead) { - this.isAckRead = isAckRead; - return this; - } - - public ImportSpec msgTimestamp(Long msgTimestamp) { - this.msgTimestamp = msgTimestamp; - return this; - } - - public ImportSpec needDownload(Boolean needDownload) { - this.needDownload = needDownload; - return this; - } - - public Mono importChatMessage() { - if ("users".equalsIgnoreCase(toType)) { - return ImportMessage.this - .importChatMessage(this.from, this.to, this.message, this.extensions, - this.isAckRead, this.msgTimestamp, this.needDownload); - } else { - return ImportMessage.this - .importChatGroupMessage(this.from, this.to, this.message, this.extensions, - this.isAckRead, this.msgTimestamp, this.needDownload); - } - } - } - - public RouteSpec from(String from) { - return new RouteSpec(from); - } - - public Mono importChatMessage(String from, String to, - EMMessage message, Set extensions, Boolean isAckRead, - Long msgTimestamp, Boolean needDownload) { - String toType = "users"; - return importMessage(from, to, message, extensions, isAckRead, msgTimestamp, - needDownload, toType); - } - - public Mono importChatGroupMessage(String from, String to, - EMMessage message, Set extensions, Boolean isAckRead, - Long msgTimestamp, Boolean needDownload) { - String toType = "chatgroups"; - return importMessage(from, to, message, extensions, isAckRead, msgTimestamp, - needDownload, toType); - } - - public Mono importMessage(String from, String to, - EMMessage message, Set extensions, Boolean isAckRead, - Long msgTimestamp, Boolean needDownload, String toType) { - ImportMessageRequest importMessageRequest = new ImportMessageRequest(from, to, message, - ImportMessageRequest.parseExtensions(extensions), isAckRead, msgTimestamp, - needDownload); - return this.context.getHttpClient() - .flatMap(httpClient -> httpClient.post() - .uri(String.format("/messages/%s/import", toType)) - .send(Mono.create(sink -> sink.success(context.getCodec() - .encode(importMessageRequest)))) - .responseSingle((rsp, buf) -> { - return buf.switchIfEmpty( - Mono.error(new EMUnknownException("response is null"))) - .flatMap(byteBuf -> { - ErrorMapper mapper = new DefaultErrorMapper(); - mapper.statusCode(rsp); - mapper.checkError(byteBuf); - return Mono.just(byteBuf); - }); - })) - .map(buf -> context.getCodec().decode(buf, ImportMessageResponse.class)) - .map(ImportMessageResponse::getMessageId); - } -} diff --git a/im-sdk-core/src/main/java/com/easemob/im/server/api/message/upload/ImportMessageRequest.java b/im-sdk-core/src/main/java/com/easemob/im/server/api/message/upload/ImportMessageRequest.java deleted file mode 100644 index 3571f36fd..000000000 --- a/im-sdk-core/src/main/java/com/easemob/im/server/api/message/upload/ImportMessageRequest.java +++ /dev/null @@ -1,419 +0,0 @@ -package com.easemob.im.server.api.message.upload; - -import com.easemob.im.server.model.*; -import com.fasterxml.jackson.annotation.JsonAutoDetect; -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; - -import java.util.HashMap; -import java.util.HashSet; -import java.util.Map; -import java.util.Set; - -@JsonAutoDetect(getterVisibility = JsonAutoDetect.Visibility.NONE) -@JsonInclude(JsonInclude.Include.NON_NULL) -public class ImportMessageRequest { - - @JsonProperty("from") - private String from; - - /* the server side does not preserve order of targets */ - @JsonProperty("target") - private String target; - - @JsonProperty("msg") - private Message message; - - @JsonProperty("ext") - private Map extensions; - - @JsonProperty("is_ack_read") - private Boolean isAckRead; - - @JsonProperty("msg_timestamp") - private Long msgTimestamp; - - @JsonProperty("need_download") - private Boolean needDownload; - - @JsonCreator - public ImportMessageRequest(@JsonProperty("from") String from, - @JsonProperty("target") String target, - @JsonProperty("msg") EMMessage message, - @JsonProperty("ext") Map extensions, - @JsonProperty("is_ack_read") Boolean isAckRead, - @JsonProperty("msg_timestamp") Long msgTimestamp, - @JsonProperty("need_download") Boolean needDownload) { - this.from = from; - this.target = target; - this.message = Message.of(message); - this.extensions = extensions; - this.isAckRead = isAckRead; - this.msgTimestamp = msgTimestamp; - this.needDownload = needDownload; - } - - public static Map parseExtensions(Set extensions) { - if (extensions == null || extensions.isEmpty()) { - return null; - } - Map mapped = new HashMap<>(); - for (EMKeyValue keyValue : extensions) { - switch (keyValue.type()) { - case BOOL: - mapped.put(keyValue.key(), keyValue.asBoolean()); - break; - case INT: - mapped.put(keyValue.key(), keyValue.asInt()); - break; - case UINT: - mapped.put(keyValue.key(), keyValue.asLong()); - break; - case LLINT: - mapped.put(keyValue.key(), keyValue.asLong()); - break; - case FLOAT: - mapped.put(keyValue.key(), keyValue.asFloat()); - break; - case DOUBLE: - mapped.put(keyValue.key(), keyValue.asDouble()); - break; - case STRING: - mapped.put(keyValue.key(), keyValue.asString()); - break; - case JSON_STRING: - mapped.put(keyValue.key(), keyValue.asString()); - break; - case OBJECT: - mapped.put(keyValue.key(), keyValue.asObject()); - break; - } - } - return mapped; - } - - public String getFrom() { - return this.from; - } - - public String getTarget() { - return this.target; - } - - public Message getMessage() { - return this.message; - } - - public Set getExtensions() { - return populateExtensions(this.extensions); - } - - public Boolean isIsAckRead() { - return this.isAckRead; - } - - public Long getMsgTimestamp() { - return this.msgTimestamp; - } - - public Boolean isNeedDownload() { - return this.needDownload; - } - - @SuppressWarnings("unchecked") - public Set populateExtensions(Map extensions) { - if (extensions == null || extensions.isEmpty()) { - return null; - } - Set mapped = new HashSet<>(); - for (String key : extensions.keySet()) { - Object value = extensions.get(key); - if (value instanceof Boolean) { - mapped.add(EMKeyValue.of(key, (boolean) value)); - } else if (value instanceof Integer) { - mapped.add(EMKeyValue.of(key, (int) value)); - } else if (value instanceof Long) { - mapped.add(EMKeyValue.of(key, (long) value)); - } else if (value instanceof Float) { - mapped.add(EMKeyValue.of(key, (float) value)); - } else if (value instanceof Double) { - mapped.add(EMKeyValue.of(key, (double) value)); - } else if (value instanceof String) { - mapped.add(EMKeyValue.of(key, (String) value)); - } - } - return mapped; - } - - static class Message { - @JsonProperty("type") - private String type; - - @JsonProperty("msg") - private String text; - - @JsonProperty("lng") - private Double longitude; - - @JsonProperty("lat") - private Double latitude; - - @JsonProperty("addr") - private String address; - - @JsonProperty("filename") - private String displayName; - - @JsonProperty("url") - private String uri; - - @JsonProperty("secret") - private String secret; - - @JsonProperty("file_length") - private Integer bytes; - - @JsonProperty("action") - private String action; - - @JsonProperty("param") - private Map params; - - @JsonProperty("length") - private Integer duration; - - @JsonProperty("size") - private Dimensions dimensions; - - @JsonProperty("thumb") - private String thumb; - - @JsonProperty("thumb_secret") - private String thumbSecret; - - @JsonProperty("customEvent") - private String customEvent; - - @JsonProperty("customExts") - private Map customExtensions; - - @JsonCreator - public Message(@JsonProperty("type") String type, - @JsonProperty("msg") String text, - @JsonProperty("lng") Double longitude, - @JsonProperty("lat") Double latitude, - @JsonProperty("addr") String address, - @JsonProperty("filename") String displayName, - @JsonProperty("url") String uri, - @JsonProperty("secret") String secretKey, - @JsonProperty("file_length") Integer bytes, - @JsonProperty("action") String action, - @JsonProperty("param") Map params, - @JsonProperty("length") Integer duration, - @JsonProperty("size") Dimensions dimensions, - @JsonProperty("customEvent") String customEvent, - @JsonProperty("customExts") Map customExtensions) { - this.type = type; - this.text = text; - this.longitude = longitude; - this.latitude = latitude; - this.address = address; - this.displayName = displayName; - this.uri = uri; - this.secret = secretKey; - this.bytes = bytes; - this.action = action; - this.params = params; - this.duration = duration; - this.dimensions = dimensions; - this.customEvent = customEvent; - this.customExtensions = customExtensions; - } - - public Message(String type) { - this.type = type; - } - - @SuppressWarnings("unchecked") - public static Message of(EMMessage msg) { - switch (msg.messageType()) { - case TEXT: - return Message.of((EMTextMessage) msg); - case IMAGE: - return Message.of((EMImageMessage) msg); - case AUDIO: - return Message.of((EMVoiceMessage) msg); - case VIDEO: - return Message.of((EMVideoMessage) msg); - case LOCATION: - return Message.of((EMLocationMessage) msg); - case FILE: - return Message.of((EMFileMessage) msg); - case COMMAND: - return Message.of((EMCommandMessage) msg); - case CUSTOM: - return Message.of((EMCustomMessage) msg); - default: - throw new IllegalArgumentException( - String.format("message type %s not supported", msg.messageType())); - } - } - - public static Message of(EMTextMessage msg) { - Message send = new Message("text"); - send.text = msg.text(); - return send; - } - - public static Message of(EMImageMessage msg) { - Message send = new Message("img"); - send.uri = msg.uri() == null ? null : msg.uri().toString(); - send.displayName = msg.displayName(); - send.bytes = msg.bytes(); - send.secret = msg.secret(); - if (msg.width() != null || msg.height() != null) { - send.dimensions = new Dimensions(msg.width(), msg.height()); - } - return send; - } - - public static Message of(EMVoiceMessage msg) { - Message send = new Message("audio"); - send.uri = msg.uri() == null ? null : msg.uri().toString(); - send.displayName = msg.displayName(); - send.bytes = msg.bytes(); - send.secret = msg.secret(); - send.duration = msg.duration(); - return send; - } - - public static Message of(EMVideoMessage msg) { - Message send = new Message("video"); - send.uri = msg.uri() == null ? null : msg.uri().toString(); - send.displayName = msg.displayName(); - send.bytes = msg.bytes(); - send.secret = msg.secret(); - send.duration = msg.duration(); - send.thumb = msg.thumb(); - send.thumbSecret = msg.thumbSecret(); - return send; - } - - public static Message of(EMLocationMessage msg) { - Message send = new Message("loc"); - send.longitude = msg.longitude(); - send.latitude = msg.latitude(); - send.address = msg.address(); - return send; - } - - public static Message of(EMFileMessage msg) { - Message send = new Message("file"); - send.uri = msg.uri() == null ? null : msg.uri().toString(); - send.displayName = msg.displayName(); - send.bytes = msg.bytes(); - send.secret = msg.secret(); - return send; - } - - public static Message of(EMCommandMessage msg) { - Message send = new Message("cmd"); - send.action = msg.action(); - if (msg.params() == null) { - return send; - } - send.params = new HashMap<>(); - for (EMKeyValue kv : msg.params()) { - switch (kv.type()) { - case BOOL: - send.params.put(kv.key(), kv.asBoolean()); - break; - case INT: - send.params.put(kv.key(), kv.asInt()); - break; - case UINT: - send.params.put(kv.key(), kv.asLong()); - break; - case LLINT: - send.params.put(kv.key(), kv.asLong()); - break; - case FLOAT: - send.params.put(kv.key(), kv.asFloat()); - break; - case DOUBLE: - send.params.put(kv.key(), kv.asDouble()); - break; - case STRING: - send.params.put(kv.key(), kv.asString()); - break; - case JSON_STRING: - send.params.put(kv.key(), kv.asString()); - break; - } - } - return send; - } - - public static Message of(EMCustomMessage msg) { - Message send = new Message("custom"); - send.customEvent = msg.customEvent(); - if (msg.customExtensions() == null) { - return send; - } - send.customExtensions = new HashMap<>(); - for (EMKeyValue kv : msg.customExtensions()) { - switch (kv.type()) { - case BOOL: - send.customExtensions.put(kv.key(), kv.asBoolean()); - break; - case INT: - send.customExtensions.put(kv.key(), kv.asInt()); - break; - case UINT: - send.customExtensions.put(kv.key(), kv.asLong()); - break; - case LLINT: - send.customExtensions.put(kv.key(), kv.asLong()); - break; - case FLOAT: - send.customExtensions.put(kv.key(), kv.asFloat()); - break; - case DOUBLE: - send.customExtensions.put(kv.key(), kv.asDouble()); - break; - case STRING: - send.customExtensions.put(kv.key(), kv.asString()); - break; - case JSON_STRING: - send.customExtensions.put(kv.key(), kv.asString()); - break; - } - } - return send; - } - } - - - static class Dimensions { - @JsonProperty("width") - private Double width; - @JsonProperty("height") - private Double height; - - @JsonCreator - public Dimensions(@JsonProperty("width") Double width, - @JsonProperty("height") Double height) { - this.width = width; - this.height = height; - } - - public Double getWidth() { - return this.width; - } - - public Double getHeight() { - return this.height; - } - } -} diff --git a/im-sdk-core/src/main/java/com/easemob/im/server/api/message/upload/ImportMessageResponse.java b/im-sdk-core/src/main/java/com/easemob/im/server/api/message/upload/ImportMessageResponse.java deleted file mode 100644 index 90e94c2c4..000000000 --- a/im-sdk-core/src/main/java/com/easemob/im/server/api/message/upload/ImportMessageResponse.java +++ /dev/null @@ -1,35 +0,0 @@ -package com.easemob.im.server.api.message.upload; - -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonProperty; - -import java.util.Map; - -public class ImportMessageResponse { - - private final String fieldName = "msg_id"; - /** - * Import message successfully returns data. - */ - @JsonProperty("data") - private Map messageIdsByReceiverId; - - @JsonCreator - public ImportMessageResponse(@JsonProperty("data") Map messageIdsByReceiverId) { - this.messageIdsByReceiverId = messageIdsByReceiverId; - } - - /** - * Get the message id of the imported message. - * - * @return the message id, null if absent - */ - public String getMessageId() { - if (this.messageIdsByReceiverId == null || !this.messageIdsByReceiverId.containsKey( - fieldName)) { - return null; - } - return this.messageIdsByReceiverId.get(fieldName); - } - -} diff --git a/im-sdk-core/src/main/java/com/easemob/im/server/api/metadata/MetadataApi.java b/im-sdk-core/src/main/java/com/easemob/im/server/api/metadata/MetadataApi.java deleted file mode 100644 index 95cf709a5..000000000 --- a/im-sdk-core/src/main/java/com/easemob/im/server/api/metadata/MetadataApi.java +++ /dev/null @@ -1,460 +0,0 @@ -package com.easemob.im.server.api.metadata; - -import com.easemob.im.server.api.Context; -import com.easemob.im.server.api.metadata.chatgroup.get.ChatGroupMetadataBatchGet; -import com.easemob.im.server.api.metadata.chatgroup.get.ChatGroupMetadataGet; -import com.easemob.im.server.api.metadata.chatgroup.set.ChatGroupMetadataSet; -import com.easemob.im.server.api.metadata.chatroom.AutoDelete; -import com.easemob.im.server.api.metadata.chatroom.delete.ChatRoomMetadataDelete; -import com.easemob.im.server.api.metadata.chatroom.delete.ChatRoomMetadataDeleteResponse; -import com.easemob.im.server.api.metadata.chatroom.get.ChatRoomMetadataGet; -import com.easemob.im.server.api.metadata.chatroom.get.ChatRoomMetadataGetResponse; -import com.easemob.im.server.api.metadata.chatroom.set.ChatRoomMetadataSet; -import com.easemob.im.server.api.metadata.chatroom.set.ChatRoomMetadataSetResponse; -import com.easemob.im.server.api.metadata.user.delete.MetadataDelete; -import com.easemob.im.server.api.metadata.user.get.MetadataBatchGet; -import com.easemob.im.server.api.metadata.user.get.MetadataGet; -import com.easemob.im.server.api.metadata.user.set.MetadataSet; -import com.easemob.im.server.api.metadata.user.usage.MetadataUsage; -import com.easemob.im.server.exception.EMInvalidArgumentException; -import com.easemob.im.server.model.EMMetadata; -import com.easemob.im.server.model.EMMetadataBatch; -import com.easemob.im.server.model.EMMetadataUsage; -import reactor.core.publisher.Mono; - -import java.util.List; -import java.util.Map; - -/** - * 用户、群组、聊天室属性API。 - */ -public class MetadataApi { - - private MetadataSet metadataSet; - - private MetadataGet metadataGet; - - private MetadataBatchGet metadataBatchGet; - - private MetadataUsage metadataUsage; - - private MetadataDelete metadataDelete; - - private ChatGroupMetadataGet chatGroupMetadataGet; - - private ChatGroupMetadataBatchGet chatGroupMetadataBatchGet; - - private ChatGroupMetadataSet chatGroupMetadataSet; - - private ChatRoomMetadataSet chatRoomMetadataSet; - - private ChatRoomMetadataGet chatRoomMetadataGet; - - private ChatRoomMetadataDelete chatRoomMetadataDelete; - - public MetadataApi(Context context) { - this.metadataSet = new MetadataSet(context); - this.metadataGet = new MetadataGet(context); - this.metadataBatchGet = new MetadataBatchGet(context); - this.metadataUsage = new MetadataUsage(context); - this.chatGroupMetadataGet = new ChatGroupMetadataGet(context); - this.chatGroupMetadataBatchGet = new ChatGroupMetadataBatchGet(context); - this.chatGroupMetadataSet = new ChatGroupMetadataSet(context); - this.metadataDelete = new MetadataDelete(context); - this.chatRoomMetadataSet=new ChatRoomMetadataSet(context); - this.chatRoomMetadataGet=new ChatRoomMetadataGet(context); - this.chatRoomMetadataDelete=new ChatRoomMetadataDelete(context); - } - - /** - * 设置用户属性 - *

- * API使用示例: - *

 {@code
-     * EMService service;
-     * Map map = new HashMap<>();
-     * map.put("nickname", "昵称");
-     * map.put("avatarurl", "http://www.easemob.com/avatar.png");
-     * map.put("phone", "159");
-     *
-     * try {
-     *     service.metadata().setMetadataToUser("username", map).block();
-     * } catch (EMException e) {
-     *     e.getErrorCode();
-     *     e.getMessage();
-     * }
-     * }
- * - * @param username 要被设置用户属性的用户名 - * @param metadata 要设置的属性 - * @return 成功或错误 - * @see 设置用户属性 - */ - public Mono setMetadataToUser(String username, Map metadata) { - return this.metadataSet.toUser(username, metadata); - } - - /** - * 获取用户属性 - *

- * API使用示例: - *

 {@code
-     * EMService service;
-     *
-     * try {
-     *     EMMetadata userMetadata = service.metadata().getMetadataFromUser("username").block();
-     * } catch (EMException e) {
-     *     e.getErrorCode();
-     *     e.getMessage();
-     * }
-     * }
- * - * @param username 要获取的用户名 - * @return 返回获取到的用户属性 - * @see 获取用户属性 - */ - public Mono getMetadataFromUser(String username) { - return this.metadataGet.fromUser(username); - } - - /** - * 批量获取用户属性 - *

- * API使用示例: - *

 {@code
-     * EMService service;
-     * List targets = new ArrayList<>();
-     * targets.add("user1");
-     * targets.add("user2");
-     *
-     * List properties = new ArrayList<>();
-     * properties.add("nickname");
-     *
-     * try {
-     *     EMMetadataBatch metadataBatch = service.metadata().getMetadataFromUsers(targets, properties).block();
-     *     metadataBatch.getData();
-     * } catch (EMException e) {
-     *     e.getErrorCode();
-     *     e.getMessage();
-     * }
-     * }
- * - * @param targets 需要获取用户属性的用户名列表,最多 100 个用户名。 - * @param properties 属性名列表,查询结果只返回该列表中包含的属性,不在该列表中的属性将被忽略。 - * @return 返回获取到的用户属性列表 - * @see 批量获取用户属性 - */ - public Mono getMetadataFromUsers(List targets, List properties) { - if (targets == null || targets.isEmpty() || targets.size() > 100) { - return Mono.error(new EMInvalidArgumentException("targets is illegal")); - } - - if (properties == null || properties.isEmpty()) { - return Mono.error(new EMInvalidArgumentException("properties is illegal")); - } - - return this.metadataBatchGet.fromUsers(targets, properties); - } - - /** - * 获取app用户属性当前所占空间。 - *

- * API使用示例: - *

 {@code
-     * EMService service;
-     *
-     * try {
-     *     EMMetadataUsage metadataUsage = service.metadata().getUsage().block();
-     * } catch (EMException e) {
-     *     e.getErrorCode();
-     *     e.getMessage();
-     * }
-     * }
- * - * @return 返回占用空间大小,单位Bytes - * @see 获取app用户属性总量大小 - */ - public Mono getUsage() { - return this.metadataUsage.getUsage(); - } - - /** - * 删除用户属性。 - *

- * API使用示例: - *

 {@code
-     * EMService service;
-     *
-     * try {
-     *     Boolean isSuc = service.metadata().deleteMetadataFromUser("username").block();
-     * } catch (EMException e) {
-     *     e.getErrorCode();
-     *     e.getMessage();
-     * }
-     * }
- * - * @param username 要被删除用户属性的用户名 - * @return 返回删除是否成功的结果 - * @see 删除用户属性 - */ - public Mono deleteMetadataFromUser(String username) { - return this.metadataDelete.fromUser(username); - } - - /** - * 设置聊天室属性 - *

- * API使用示例: - *

 {@code
-     * EMService service;
-     * Map map = new HashMap<>();
-     * map.put("nickname", "昵称");
-     * map.put("avatarurl", "http://www.easemob.com/avatar.png");
-     * map.put("phone", "159");
-     *
-     * try {
-     *     service.metadata().setChatRoomMetadata("username", "roomId", map, AutoDelete.NO_DELETE).block();
-     * } catch (EMException e) {
-     *     e.getErrorCode();
-     *     e.getMessage();
-     * }
-     * }
- * - * @param operator 设置聊天室属性的操作人 - * @param chatroomId 聊天室id - * @param metadata 要设置的属性 - * @param autoDelete 用户退出是否删除属性 - * @return 成功或错误 - */ - public Mono setChatRoomMetadata(String operator, String chatroomId, - Map metadata, - AutoDelete autoDelete) { - return this.chatRoomMetadataSet.toChatRoom(operator, chatroomId, metadata, autoDelete); - } - - /** - * 强制设置聊天室属性 - *

- * API使用示例: - *

 {@code
-     * EMService service;
-     * Map map = new HashMap<>();
-     * map.put("nickname", "昵称");
-     * map.put("avatarurl", "http://www.easemob.com/avatar.png");
-     * map.put("phone", "159");
-     *
-     * try {
-     *     service.metadata().setChatRoomMetadataToUserForced("username", "roomId", map, AutoDelete.NO_DELETE).block();
-     * } catch (EMException e) {
-     *     e.getErrorCode();
-     *     e.getMessage();
-     * }
-     * }
- * - * @param chatroomId 聊天室id - * @param operator 强制设置聊天室属性的操作人 - * @param metadata 要设强制设置的属性 - * @param autoDelete 用户退出是否删除属性 - * @return 成功或错误 - */ - public Mono setChatRoomMetadataForced(String operator, - String chatroomId, Map metadata, - AutoDelete autoDelete) { - return this.chatRoomMetadataSet.toChatRoomForced(operator, chatroomId, metadata, autoDelete); - } - - /** - * 获取聊天室属性 - *

- * API使用示例: - *

 {@code
-     * EMService service;
-     * List keys = new ArrayList<>();
-     * keys.add("nickname");
-     *
-     * try {
-     *     service.metadata().listChatRoomMetadata("roomId", keys).block();
-     * } catch (EMException e) {
-     *     e.getErrorCode();
-     *     e.getMessage();
-     * }
-     * }
- * - * @param chatroomId 聊天室id - * @param keys 要获取的属性key列表 - * @return 成功或错误 - */ - public Mono listChatRoomMetadata(String chatroomId, - List keys) { - return this.chatRoomMetadataGet.listChatRoomMetadata(chatroomId, keys); - } - - /** - * 获取所有的聊天室属性 - *

- * API使用示例: - *

 {@code
-     * EMService service;
-     *
-     * try {
-     *     service.metadata().listChatRoomMetadataAll("roomId").block();
-     * } catch (EMException e) {
-     *     e.getErrorCode();
-     *     e.getMessage();
-     * }
-     * }
- * - * @param chatroomId 聊天室id - * @return 成功或错误 - */ - public Mono listChatRoomMetadataAll(String chatroomId) { - return this.chatRoomMetadataGet.listChatRoomMetadataAll(chatroomId); - } - - /** - * 删除聊天室属性 - *

- * API使用示例: - *

 {@code
-     * EMService service;
-     * List keys = new ArrayList<>();
-     * keys.add("nickname");
-     *
-     * try {
-     *     service.metadata().deleteChatRoomMetadata("operator", "roomId", map, keys).block();
-     * } catch (EMException e) {
-     *     e.getErrorCode();
-     *     e.getMessage();
-     * }
-     * }
- * - * @param operator 执行删除的操作人 - * @param chatroomId 聊天室id - * @param keys 要删除的属性key列表 - * @return 成功或错误 - */ - public Mono deleteChatRoomMetadata(String operator, - String chatroomId, List keys) { - return this.chatRoomMetadataDelete.fromChatRoom(operator, chatroomId, keys); - } - - /** - * 强制删除聊天室属性 - *

- * API使用示例: - *

 {@code
-     * EMService service;
-     * List keys = new ArrayList<>();
-     * keys.add("nickname");
-     *
-     * try {
-     *     service.metadata().deleteChatRoomMetadataForced("roomId", map, keys).block();
-     * } catch (EMException e) {
-     *     e.getErrorCode();
-     *     e.getMessage();
-     * }
-     * }
- * - * @param chatroomId 聊天室id - * @param keys 要强制删除的属性key列表 - * @return 成功或错误 - */ - public Mono deleteChatRoomMetadataForced(String chatroomId, - List keys) { - return this.chatRoomMetadataDelete.fromChatRoomForced(chatroomId, keys); - } - - /** - * 设置群成员自定义属性 - *

- * API使用示例: - *

 {@code
-     * EMService service;
-     * Map map = new HashMap<>();
-     * map.put("nickname", "昵称");
-     * map.put("avatarurl", "http://www.easemob.com/avatar.png");
-     * map.put("phone", "159");
-     *
-     * try {
-     *     service.metadata().setMetadataToChatGroup("username", "groupId", map).block();
-     * } catch (EMException e) {
-     *     e.getErrorCode();
-     *     e.getMessage();
-     * }
-     * }
- * - * @param username 要被设置群组属性的用户名 - * @param groupId 要被设置群组属性的群组id - * @param metadata 要设置的属性 - * @return 成功或错误 - * @see 设置群成员自定义属性 - */ - public Mono setMetadataToChatGroupUser(String username, String groupId, Map metadata) { - return this.chatGroupMetadataSet.toChatGroupUser(username, groupId, metadata); - } - - /** - * 获取单个群成员的所有自定义属性 - *

- * API使用示例: - *

 {@code
-     * EMService service;
-     *
-     * try {
-     *     EMMetadata userMetadata = service.metadata().getMetadataFromChatGroup("username", "groupId").block();
-     * } catch (EMException e) {
-     *     e.getErrorCode();
-     *     e.getMessage();
-     * }
-     * }
- * - * @param username 要获取的用户名 - * @param groupId 要获取的群组id - * @return 返回获取到的群组用户属性 - * @see 获取单个群成员的所有自定义属性 - */ - public Mono getMetadataFromChatGroupUser(String username, String groupId) { - return this.chatGroupMetadataGet.fromChatGroupUser(username, groupId); - } - - /** - * 根据属性 key 获取多个群成员的自定义属性 - *

- * API使用示例: - *

 {@code
-     * EMService service;
-     * List targets = new ArrayList<>();
-     * targets.add("user1");
-     * targets.add("user2");
-     *
-     * List properties = new ArrayList<>();
-     * properties.add("nickname");
-     *
-     * try {
-     *     EMMetadataBatch metadataBatch = service.metadata().getMetadataFromUsers("groupId", targets, properties).block();
-     *     metadataBatch.getData();
-     * } catch (EMException e) {
-     *     e.getErrorCode();
-     *     e.getMessage();
-     * }
-     * }
- * - * @param groupId 群组id - * @param targets 要获取自定义属性的群成员的用户 ID。一次最多可传 10 个用户 ID。 - * @param properties 要获取自定义属性的 key 的数组。若该参数设置为空数组或不传,则获取这些群成员的所有自定义属性。 - * @return 返回获取到的用户属性列表 - * @see 根据属性 key 获取多个群成员的自定义属性 - */ - public Mono getMetadataFromChatGroupUsers(String groupId, List targets, List properties) { - if (targets == null || targets.isEmpty() || targets.size() > 10) { - return Mono.error(new EMInvalidArgumentException("targets is illegal")); - } - - if (properties == null || properties.isEmpty()) { - return Mono.error(new EMInvalidArgumentException("properties is illegal")); - } - - return this.chatGroupMetadataBatchGet.fromChatGroupUsers(groupId, targets, properties); - } - -} diff --git a/im-sdk-core/src/main/java/com/easemob/im/server/api/metadata/chatgroup/get/ChatGroupMetadataBatchGet.java b/im-sdk-core/src/main/java/com/easemob/im/server/api/metadata/chatgroup/get/ChatGroupMetadataBatchGet.java deleted file mode 100644 index 804ad0c7d..000000000 --- a/im-sdk-core/src/main/java/com/easemob/im/server/api/metadata/chatgroup/get/ChatGroupMetadataBatchGet.java +++ /dev/null @@ -1,40 +0,0 @@ -package com.easemob.im.server.api.metadata.chatgroup.get; - -import com.easemob.im.server.api.Context; -import com.easemob.im.server.api.DefaultErrorMapper; -import com.easemob.im.server.api.ErrorMapper; -import com.easemob.im.server.exception.EMUnknownException; -import com.easemob.im.server.model.EMMetadataBatch; -import reactor.core.publisher.Mono; - -import java.util.List; - -public class ChatGroupMetadataBatchGet { - private Context context; - - public ChatGroupMetadataBatchGet(Context context) { - this.context = context; - } - - public Mono fromChatGroupUsers(String groupId, List targets, List properties) { - return this.context.getHttpClient() - .flatMap(httpClient -> httpClient - .headers(header -> header.add("Content-Type", "application/json")) - .post() - .uri(String.format("/metadata/chatgroup/%s/get", groupId)) - .send(Mono.create(sink -> sink.success(this.context.getCodec() - .encode(new ChatGroupMetadataBatchGetRequest(targets, properties))))) - .responseSingle((rsp, buf) -> { - return buf.switchIfEmpty( - Mono.error(new EMUnknownException("response is null"))) - .flatMap(byteBuf -> { - ErrorMapper mapper = new DefaultErrorMapper(); - mapper.statusCode(rsp); - mapper.checkError(byteBuf); - return Mono.just(byteBuf); - }); - })) - .map(buf -> this.context.getCodec().decode(buf, ChatGroupMetadataBatchGetResponse.class)) - .map(ChatGroupMetadataBatchGetResponse::toMetadataBatch); - } -} diff --git a/im-sdk-core/src/main/java/com/easemob/im/server/api/metadata/chatgroup/get/ChatGroupMetadataBatchGetRequest.java b/im-sdk-core/src/main/java/com/easemob/im/server/api/metadata/chatgroup/get/ChatGroupMetadataBatchGetRequest.java deleted file mode 100644 index 6f934ecba..000000000 --- a/im-sdk-core/src/main/java/com/easemob/im/server/api/metadata/chatgroup/get/ChatGroupMetadataBatchGetRequest.java +++ /dev/null @@ -1,31 +0,0 @@ -package com.easemob.im.server.api.metadata.chatgroup.get; - - -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonProperty; - -import java.util.List; - -public class ChatGroupMetadataBatchGetRequest { - - @JsonProperty("targets") - private List targets; - - @JsonProperty("properties") - private List properties; - - @JsonCreator - public ChatGroupMetadataBatchGetRequest(@JsonProperty("targets") List targets, - @JsonProperty("properties") List properties) { - this.targets = targets; - this.properties = properties; - } - - public List getTargets() { - return targets; - } - - public List getProperties() { - return properties; - } -} diff --git a/im-sdk-core/src/main/java/com/easemob/im/server/api/metadata/chatgroup/get/ChatGroupMetadataBatchGetResponse.java b/im-sdk-core/src/main/java/com/easemob/im/server/api/metadata/chatgroup/get/ChatGroupMetadataBatchGetResponse.java deleted file mode 100644 index d9f516d2f..000000000 --- a/im-sdk-core/src/main/java/com/easemob/im/server/api/metadata/chatgroup/get/ChatGroupMetadataBatchGetResponse.java +++ /dev/null @@ -1,31 +0,0 @@ -package com.easemob.im.server.api.metadata.chatgroup.get; - -import com.easemob.im.server.model.EMMetadataBatch; -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonProperty; - -import java.util.Map; - -public class ChatGroupMetadataBatchGetResponse { - @JsonProperty("data") - private Map> data; - - @JsonCreator - public ChatGroupMetadataBatchGetResponse(@JsonProperty("data") Map> data) { - this.data = data; - } - - public Map> getData() { - return data; - } - - public EMMetadataBatch toMetadataBatch() { - return new EMMetadataBatch(this.data); - } - - @Override public String toString() { - return "ChatGroupMetadataBatchGetResponse{" + - "data=" + data + - '}'; - } -} diff --git a/im-sdk-core/src/main/java/com/easemob/im/server/api/metadata/chatgroup/get/ChatGroupMetadataGet.java b/im-sdk-core/src/main/java/com/easemob/im/server/api/metadata/chatgroup/get/ChatGroupMetadataGet.java deleted file mode 100644 index 14841dfde..000000000 --- a/im-sdk-core/src/main/java/com/easemob/im/server/api/metadata/chatgroup/get/ChatGroupMetadataGet.java +++ /dev/null @@ -1,36 +0,0 @@ -package com.easemob.im.server.api.metadata.chatgroup.get; - -import com.easemob.im.server.api.Context; -import com.easemob.im.server.api.DefaultErrorMapper; -import com.easemob.im.server.api.ErrorMapper; -import com.easemob.im.server.exception.EMUnknownException; -import com.easemob.im.server.model.EMMetadata; -import reactor.core.publisher.Mono; - -public class ChatGroupMetadataGet { - private Context context; - - public ChatGroupMetadataGet(Context context) { - this.context = context; - } - - public Mono fromChatGroupUser(String username, String groupId) { - return this.context.getHttpClient() - .flatMap(httpClient -> httpClient - .headers(header -> header.add("Content-Type", "application/json")) - .get() - .uri(String.format("/metadata/chatgroup/%s/user/%s", groupId, username)) - .responseSingle((rsp, buf) -> { - return buf.switchIfEmpty( - Mono.error(new EMUnknownException("response is null"))) - .flatMap(byteBuf -> { - ErrorMapper mapper = new DefaultErrorMapper(); - mapper.statusCode(rsp); - mapper.checkError(byteBuf); - return Mono.just(byteBuf); - }); - })) - .map(buf -> this.context.getCodec().decode(buf, ChatGroupMetadataGetResponse.class)) - .map(ChatGroupMetadataGetResponse::toMetadata); - } -} diff --git a/im-sdk-core/src/main/java/com/easemob/im/server/api/metadata/chatgroup/get/ChatGroupMetadataGetResponse.java b/im-sdk-core/src/main/java/com/easemob/im/server/api/metadata/chatgroup/get/ChatGroupMetadataGetResponse.java deleted file mode 100644 index c333d794d..000000000 --- a/im-sdk-core/src/main/java/com/easemob/im/server/api/metadata/chatgroup/get/ChatGroupMetadataGetResponse.java +++ /dev/null @@ -1,31 +0,0 @@ -package com.easemob.im.server.api.metadata.chatgroup.get; - -import com.easemob.im.server.model.EMMetadata; -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonProperty; - -import java.util.Map; - -public class ChatGroupMetadataGetResponse { - @JsonProperty("data") - private Map data; - - @JsonCreator - public ChatGroupMetadataGetResponse(@JsonProperty("data") Map data) { - this.data = data; - } - - public Map getData() { - return data; - } - - public EMMetadata toMetadata() { - return new EMMetadata(this.data); - } - - @Override public String toString() { - return "ChatGroupMetadataGetResponse{" + - "data=" + data + - '}'; - } -} diff --git a/im-sdk-core/src/main/java/com/easemob/im/server/api/metadata/chatgroup/set/ChatGroupMetadataSet.java b/im-sdk-core/src/main/java/com/easemob/im/server/api/metadata/chatgroup/set/ChatGroupMetadataSet.java deleted file mode 100644 index d087e663b..000000000 --- a/im-sdk-core/src/main/java/com/easemob/im/server/api/metadata/chatgroup/set/ChatGroupMetadataSet.java +++ /dev/null @@ -1,39 +0,0 @@ -package com.easemob.im.server.api.metadata.chatgroup.set; - -import com.easemob.im.server.api.Context; -import com.easemob.im.server.api.DefaultErrorMapper; -import com.easemob.im.server.api.ErrorMapper; -import com.easemob.im.server.exception.EMUnknownException; -import reactor.core.publisher.Mono; - -import java.util.Map; - -public class ChatGroupMetadataSet { - private Context context; - - public ChatGroupMetadataSet(Context context) { - this.context = context; - } - - public Mono toChatGroupUser(String username, String groupId, - Map metadata) { - return this.context.getHttpClient() - .flatMap(httpClient -> httpClient - .headers(header -> header.add("Content-Type", "application/json")) - .put() - .uri(String.format("/metadata/chatgroup/%s/user/%s", groupId, username)) - .send(Mono.create(sink -> sink.success(this.context.getCodec() - .encode(new ChatGroupMetadataSetRequest(metadata))))) - .responseSingle((rsp, buf) -> { - return buf.switchIfEmpty( - Mono.error(new EMUnknownException("response is null"))) - .flatMap(byteBuf -> { - ErrorMapper mapper = new DefaultErrorMapper(); - mapper.statusCode(rsp); - mapper.checkError(byteBuf); - return Mono.just(byteBuf); - }); - })) - .then(); - } -} diff --git a/im-sdk-core/src/main/java/com/easemob/im/server/api/metadata/chatgroup/set/ChatGroupMetadataSetRequest.java b/im-sdk-core/src/main/java/com/easemob/im/server/api/metadata/chatgroup/set/ChatGroupMetadataSetRequest.java deleted file mode 100644 index 39a280695..000000000 --- a/im-sdk-core/src/main/java/com/easemob/im/server/api/metadata/chatgroup/set/ChatGroupMetadataSetRequest.java +++ /dev/null @@ -1,21 +0,0 @@ -package com.easemob.im.server.api.metadata.chatgroup.set; - -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonProperty; - -import java.util.Map; - -public class ChatGroupMetadataSetRequest { - - @JsonProperty("metaData") - private Map metaData; - - @JsonCreator - public ChatGroupMetadataSetRequest(@JsonProperty("metaData") Map metaData) { - this.metaData = metaData; - } - - public Map getMetaData() { - return metaData; - } -} diff --git a/im-sdk-core/src/main/java/com/easemob/im/server/api/metadata/chatroom/AutoDelete.java b/im-sdk-core/src/main/java/com/easemob/im/server/api/metadata/chatroom/AutoDelete.java deleted file mode 100644 index e26e8e1f6..000000000 --- a/im-sdk-core/src/main/java/com/easemob/im/server/api/metadata/chatroom/AutoDelete.java +++ /dev/null @@ -1,29 +0,0 @@ -package com.easemob.im.server.api.metadata.chatroom; - -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonValue; - -public enum AutoDelete { - - NO_DELETE, - DELETE; - - @JsonCreator - public static AutoDelete parse(String deleteType) { - if (deleteType == null || deleteType.equals("")) { - return NO_DELETE; - } - for (AutoDelete type : values()) { - if (type.toString().equalsIgnoreCase(deleteType)) { - return type; - } - } - return NO_DELETE; - } - - @JsonValue - public String toString() { - return name().toUpperCase(); - } - -} diff --git a/im-sdk-core/src/main/java/com/easemob/im/server/api/metadata/chatroom/ChatRoomMetadataRequest.java b/im-sdk-core/src/main/java/com/easemob/im/server/api/metadata/chatroom/ChatRoomMetadataRequest.java deleted file mode 100644 index 435e66de6..000000000 --- a/im-sdk-core/src/main/java/com/easemob/im/server/api/metadata/chatroom/ChatRoomMetadataRequest.java +++ /dev/null @@ -1,32 +0,0 @@ -package com.easemob.im.server.api.metadata.chatroom; - -import com.fasterxml.jackson.annotation.JsonProperty; - -import java.util.List; -import java.util.Map; - -public class ChatRoomMetadataRequest { - - @JsonProperty("metaData") - private Map metaData; - - @JsonProperty("autoDelete") - private AutoDelete autoDelete = AutoDelete.DELETE; - - @JsonProperty("notificationExt") - private String notificationExt; - - @JsonProperty("keys") - private List keys; - - public ChatRoomMetadataRequest(Map metaData, - AutoDelete autoDelete) { - this.autoDelete = autoDelete; - this.metaData = metaData; - } - - public ChatRoomMetadataRequest(List keys) { - this.keys = keys; - } - -} diff --git a/im-sdk-core/src/main/java/com/easemob/im/server/api/metadata/chatroom/delete/ChatRoomMetadataDelete.java b/im-sdk-core/src/main/java/com/easemob/im/server/api/metadata/chatroom/delete/ChatRoomMetadataDelete.java deleted file mode 100644 index 01aca702f..000000000 --- a/im-sdk-core/src/main/java/com/easemob/im/server/api/metadata/chatroom/delete/ChatRoomMetadataDelete.java +++ /dev/null @@ -1,69 +0,0 @@ -package com.easemob.im.server.api.metadata.chatroom.delete; - -import com.easemob.im.server.EMException; -import com.easemob.im.server.api.Context; -import com.easemob.im.server.api.DefaultErrorMapper; -import com.easemob.im.server.api.ErrorMapper; -import com.easemob.im.server.api.metadata.chatroom.ChatRoomMetadataRequest; -import com.easemob.im.server.exception.EMUnknownException; -import reactor.core.publisher.Mono; -import reactor.netty.http.client.HttpClientResponse; - -import java.util.List; - -public class ChatRoomMetadataDelete { - - private Context context; - - public ChatRoomMetadataDelete(Context context) { - this.context = context; - } - - public Mono fromChatRoom(String operator, String chatroomId, - List keys) { - return this.context.getHttpClient() - .flatMap(httpClient -> httpClient - .headers(header -> header.add("Content-Type", "application/json")).delete() - .uri(String.format("/metadata/chatroom/%s/user/%s", chatroomId, operator)) - .send(Mono.create(sink -> sink.success(this.context.getCodec() - .encode(new ChatRoomMetadataRequest(keys))))) - .responseSingle((rsp, buf) -> { - return buf.switchIfEmpty( - Mono.error(new EMUnknownException("response is null"))) - .flatMap(byteBuf -> { - ErrorMapper mapper = new DefaultErrorMapper(); - mapper.statusCode(rsp); - mapper.checkError(byteBuf); - return Mono.just(byteBuf); - }); - })) - .map(byteBuf -> { - return this.context.getCodec() - .decode(byteBuf, ChatRoomMetadataDeleteResponse.class); - }); - } - - public Mono fromChatRoomForced(String chatroomId, - List keys) { - return this.context.getHttpClient() - .flatMap(httpClient -> httpClient - .headers(header -> header.add("Content-Type", "application/json")).delete() - .uri(String.format("/metadata/chatroom/%s/user/admin/forced", chatroomId)) - .send(Mono.create(sink -> sink.success(this.context.getCodec() - .encode(new ChatRoomMetadataRequest(keys))))) - .responseSingle((rsp, buf) -> { - return buf.switchIfEmpty( - Mono.error(new EMUnknownException("response is null"))) - .flatMap(byteBuf -> { - ErrorMapper mapper = new DefaultErrorMapper(); - mapper.statusCode(rsp); - mapper.checkError(byteBuf); - return Mono.just(byteBuf); - }); - })) - .map(byteBuf -> { - return this.context.getCodec() - .decode(byteBuf, ChatRoomMetadataDeleteResponse.class); - }); - } -} diff --git a/im-sdk-core/src/main/java/com/easemob/im/server/api/metadata/chatroom/delete/ChatRoomMetadataDeleteResponse.java b/im-sdk-core/src/main/java/com/easemob/im/server/api/metadata/chatroom/delete/ChatRoomMetadataDeleteResponse.java deleted file mode 100644 index 6ce48ab44..000000000 --- a/im-sdk-core/src/main/java/com/easemob/im/server/api/metadata/chatroom/delete/ChatRoomMetadataDeleteResponse.java +++ /dev/null @@ -1,35 +0,0 @@ -package com.easemob.im.server.api.metadata.chatroom.delete; - -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonProperty; - -import java.util.List; -import java.util.Map; - -public class ChatRoomMetadataDeleteResponse { - - private List successKeys; - - private Map errorKeys; - - @JsonCreator - public ChatRoomMetadataDeleteResponse(@JsonProperty("data") Map result) { - if (result != null) { - if (result.containsKey("successKeys")) { - successKeys = (List) result.get("successKeys"); - } - if (result.containsKey("errorKeys")) { - errorKeys = (Map) result.get("errorKeys"); - } - } - } - - public List getSuccessKeys() { - return successKeys; - } - - public Map getErrorKeys() { - return errorKeys; - } - -} diff --git a/im-sdk-core/src/main/java/com/easemob/im/server/api/metadata/chatroom/get/ChatRoomMetadataGet.java b/im-sdk-core/src/main/java/com/easemob/im/server/api/metadata/chatroom/get/ChatRoomMetadataGet.java deleted file mode 100644 index 086380825..000000000 --- a/im-sdk-core/src/main/java/com/easemob/im/server/api/metadata/chatroom/get/ChatRoomMetadataGet.java +++ /dev/null @@ -1,66 +0,0 @@ -package com.easemob.im.server.api.metadata.chatroom.get; - -import com.easemob.im.server.EMException; -import com.easemob.im.server.api.Context; -import com.easemob.im.server.api.DefaultErrorMapper; -import com.easemob.im.server.api.ErrorMapper; -import com.easemob.im.server.api.metadata.chatroom.ChatRoomMetadataRequest; -import com.easemob.im.server.exception.EMUnknownException; -import reactor.core.publisher.Mono; -import reactor.netty.http.client.HttpClientResponse; - -import java.util.List; - -public class ChatRoomMetadataGet { - - private Context context; - - public ChatRoomMetadataGet(Context context) { - this.context = context; - } - - public Mono listChatRoomMetadata(String chatroomId, - List keys) { - return this.context.getHttpClient() - .flatMap(httpClient -> httpClient - .headers(header -> header.add("Content-Type", "application/json")).post() - .uri(String.format("/metadata/chatroom/%s", chatroomId)) - .send(Mono.create(sink -> sink.success(this.context.getCodec() - .encode(new ChatRoomMetadataRequest(keys))))) - .responseSingle((rsp, buf) -> { - return buf.switchIfEmpty( - Mono.error(new EMUnknownException("response is null"))) - .flatMap(byteBuf -> { - ErrorMapper mapper = new DefaultErrorMapper(); - mapper.statusCode(rsp); - mapper.checkError(byteBuf); - return Mono.just(byteBuf); - }); - })) - .map(byteBuf -> { - return this.context.getCodec() - .decode(byteBuf, ChatRoomMetadataGetResponse.class); - }); - } - - public Mono listChatRoomMetadataAll(String chatroomId) { - return this.context.getHttpClient() - .flatMap(httpClient -> httpClient - .headers(header -> header.add("Content-Type", "application/json")).post() - .uri(String.format("/metadata/chatroom/%s", chatroomId)) - .responseSingle((rsp, buf) -> { - return buf.switchIfEmpty( - Mono.error(new EMUnknownException("response is null"))) - .flatMap(byteBuf -> { - ErrorMapper mapper = new DefaultErrorMapper(); - mapper.statusCode(rsp); - mapper.checkError(byteBuf); - return Mono.just(byteBuf); - }); - })) - .map(byteBuf -> { - return this.context.getCodec() - .decode(byteBuf, ChatRoomMetadataGetResponse.class); - }); - } -} diff --git a/im-sdk-core/src/main/java/com/easemob/im/server/api/metadata/chatroom/get/ChatRoomMetadataGetResponse.java b/im-sdk-core/src/main/java/com/easemob/im/server/api/metadata/chatroom/get/ChatRoomMetadataGetResponse.java deleted file mode 100644 index f876d647d..000000000 --- a/im-sdk-core/src/main/java/com/easemob/im/server/api/metadata/chatroom/get/ChatRoomMetadataGetResponse.java +++ /dev/null @@ -1,21 +0,0 @@ -package com.easemob.im.server.api.metadata.chatroom.get; - -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonProperty; - -import java.util.Map; - -public class ChatRoomMetadataGetResponse { - - private Map metadata; - - @JsonCreator - public ChatRoomMetadataGetResponse(@JsonProperty("data") Map result) { - this.metadata = result; - } - - public Map getMetadata() { - return metadata; - } - -} diff --git a/im-sdk-core/src/main/java/com/easemob/im/server/api/metadata/chatroom/set/ChatRoomMetadataSet.java b/im-sdk-core/src/main/java/com/easemob/im/server/api/metadata/chatroom/set/ChatRoomMetadataSet.java deleted file mode 100644 index e4a655a76..000000000 --- a/im-sdk-core/src/main/java/com/easemob/im/server/api/metadata/chatroom/set/ChatRoomMetadataSet.java +++ /dev/null @@ -1,74 +0,0 @@ -package com.easemob.im.server.api.metadata.chatroom.set; - -import com.easemob.im.server.EMException; -import com.easemob.im.server.api.Context; -import com.easemob.im.server.api.DefaultErrorMapper; -import com.easemob.im.server.api.ErrorMapper; -import com.easemob.im.server.api.metadata.chatroom.AutoDelete; -import com.easemob.im.server.api.metadata.chatroom.ChatRoomMetadataRequest; -import com.easemob.im.server.api.user.get.UserGetResponse; -import com.easemob.im.server.exception.EMUnknownException; -import reactor.core.publisher.Mono; -import reactor.netty.http.client.HttpClientResponse; - -import java.util.Map; - -public class ChatRoomMetadataSet { - - private Context context; - - public ChatRoomMetadataSet(Context context) { - this.context = context; - } - - public Mono toChatRoom(String operator, String chatroomId, - Map metadata, - AutoDelete autoDelete) { - return this.context.getHttpClient() - .flatMap(httpClient -> httpClient - .headers(header -> header.add("Content-Type", "application/json")).put() - .uri(String.format("/metadata/chatroom/%s/user/%s", chatroomId, operator)) - .send(Mono.create(sink -> sink.success(this.context.getCodec() - .encode(new ChatRoomMetadataRequest(metadata, autoDelete))))) - .responseSingle((rsp, buf) -> { - return buf.switchIfEmpty( - Mono.error(new EMUnknownException("response is null"))) - .flatMap(byteBuf -> { - ErrorMapper mapper = new DefaultErrorMapper(); - mapper.statusCode(rsp); - mapper.checkError(byteBuf); - return Mono.just(byteBuf); - }); - })) - .map(byteBuf -> { - return this.context.getCodec() - .decode(byteBuf, ChatRoomMetadataSetResponse.class); - }); - } - - public Mono toChatRoomForced(String operator,String chatroomId, - Map metadata, - AutoDelete autoDelete) { - return this.context.getHttpClient() - .flatMap(httpClient -> httpClient - .headers(header -> header.add("Content-Type", "application/json")).put() - .uri(String.format("/metadata/chatroom/%s/user/%s/forced", chatroomId, - operator)) - .send(Mono.create(sink -> sink.success(this.context.getCodec() - .encode(new ChatRoomMetadataRequest(metadata, autoDelete))))) - .responseSingle((rsp, buf) -> { - return buf.switchIfEmpty( - Mono.error(new EMUnknownException("response is null"))) - .flatMap(byteBuf -> { - ErrorMapper mapper = new DefaultErrorMapper(); - mapper.statusCode(rsp); - mapper.checkError(byteBuf); - return Mono.just(byteBuf); - }); - })) - .map(byteBuf -> { - return this.context.getCodec() - .decode(byteBuf, ChatRoomMetadataSetResponse.class); - }); - } -} diff --git a/im-sdk-core/src/main/java/com/easemob/im/server/api/metadata/chatroom/set/ChatRoomMetadataSetResponse.java b/im-sdk-core/src/main/java/com/easemob/im/server/api/metadata/chatroom/set/ChatRoomMetadataSetResponse.java deleted file mode 100644 index 830c609bf..000000000 --- a/im-sdk-core/src/main/java/com/easemob/im/server/api/metadata/chatroom/set/ChatRoomMetadataSetResponse.java +++ /dev/null @@ -1,36 +0,0 @@ -package com.easemob.im.server.api.metadata.chatroom.set; - -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonProperty; - -import java.util.List; -import java.util.Map; - -public class ChatRoomMetadataSetResponse { - - private List successKeys; - - private Map errorKeys; - - @JsonCreator - public ChatRoomMetadataSetResponse(@JsonProperty("data") Map result) { - if (result != null) { - if (result.containsKey("successKeys")) { - successKeys = (List) result.get("successKeys"); - } - if (result.containsKey("errorKeys")) { - errorKeys = (Map) result.get("errorKeys"); - } - } - } - - - public List getSuccessKeys() { - return successKeys; - } - - public Map getErrorKeys() { - return errorKeys; - } - -} diff --git a/im-sdk-core/src/main/java/com/easemob/im/server/api/metadata/user/delete/MetadataDelete.java b/im-sdk-core/src/main/java/com/easemob/im/server/api/metadata/user/delete/MetadataDelete.java deleted file mode 100644 index f097b9699..000000000 --- a/im-sdk-core/src/main/java/com/easemob/im/server/api/metadata/user/delete/MetadataDelete.java +++ /dev/null @@ -1,34 +0,0 @@ -package com.easemob.im.server.api.metadata.user.delete; - -import com.easemob.im.server.api.Context; -import com.easemob.im.server.api.DefaultErrorMapper; -import com.easemob.im.server.api.ErrorMapper; -import com.easemob.im.server.exception.EMUnknownException; -import reactor.core.publisher.Mono; - -public class MetadataDelete { - private Context context; - - public MetadataDelete(Context context) { - this.context = context; - } - - public Mono fromUser(String username) { - return this.context.getHttpClient() - .flatMap(httpClient -> httpClient.delete() - .uri(String.format("/metadata/user/%s", username)) - .responseSingle((rsp, buf) -> { - return buf.switchIfEmpty( - Mono.error(new EMUnknownException("response is null"))) - .flatMap(byteBuf -> { - ErrorMapper mapper = new DefaultErrorMapper(); - mapper.statusCode(rsp); - mapper.checkError(byteBuf); - return Mono.just(byteBuf); - }); - })) - .map(buf -> this.context.getCodec().decode(buf, MetadataDeleteResponse.class)) - .map(MetadataDeleteResponse::getSuccess); - } - -} diff --git a/im-sdk-core/src/main/java/com/easemob/im/server/api/metadata/user/delete/MetadataDeleteResponse.java b/im-sdk-core/src/main/java/com/easemob/im/server/api/metadata/user/delete/MetadataDeleteResponse.java deleted file mode 100644 index 82879c149..000000000 --- a/im-sdk-core/src/main/java/com/easemob/im/server/api/metadata/user/delete/MetadataDeleteResponse.java +++ /dev/null @@ -1,22 +0,0 @@ -package com.easemob.im.server.api.metadata.user.delete; - -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonProperty; - -public class MetadataDeleteResponse { - @JsonProperty("data") - private boolean success; - - @JsonCreator - public MetadataDeleteResponse(@JsonProperty("data") Boolean success) { - if (success == null) { - this.success = false; - } else { - this.success = success; - } - } - - public boolean getSuccess() { - return success; - } -} diff --git a/im-sdk-core/src/main/java/com/easemob/im/server/api/metadata/user/get/MetadataBatchGet.java b/im-sdk-core/src/main/java/com/easemob/im/server/api/metadata/user/get/MetadataBatchGet.java deleted file mode 100644 index e73167785..000000000 --- a/im-sdk-core/src/main/java/com/easemob/im/server/api/metadata/user/get/MetadataBatchGet.java +++ /dev/null @@ -1,39 +0,0 @@ -package com.easemob.im.server.api.metadata.user.get; - -import com.easemob.im.server.api.Context; -import com.easemob.im.server.api.DefaultErrorMapper; -import com.easemob.im.server.api.ErrorMapper; -import com.easemob.im.server.exception.EMUnknownException; -import com.easemob.im.server.model.EMMetadataBatch; -import reactor.core.publisher.Mono; - -import java.util.List; - -public class MetadataBatchGet { - private Context context; - - public MetadataBatchGet(Context context) { - this.context = context; - } - - public Mono fromUsers(List targets, List properties) { - return this.context.getHttpClient() - .flatMap(httpClient -> httpClient.headers(header -> header.add("Content-Type", "application/json")) - .post() - .uri("/metadata/user/get") - .send(Mono.create(sink -> sink.success(this.context.getCodec() - .encode(new MetadataBatchGetRequest(targets, properties))))) - .responseSingle((rsp, buf) -> { - return buf.switchIfEmpty( - Mono.error(new EMUnknownException("response is null"))) - .flatMap(byteBuf -> { - ErrorMapper mapper = new DefaultErrorMapper(); - mapper.statusCode(rsp); - mapper.checkError(byteBuf); - return Mono.just(byteBuf); - }); - })) - .map(buf -> this.context.getCodec().decode(buf, MetadataBatchGetResponse.class)) - .map(MetadataBatchGetResponse::toMetadataBatch); - } -} diff --git a/im-sdk-core/src/main/java/com/easemob/im/server/api/metadata/user/get/MetadataBatchGetRequest.java b/im-sdk-core/src/main/java/com/easemob/im/server/api/metadata/user/get/MetadataBatchGetRequest.java deleted file mode 100644 index e2a13fb6c..000000000 --- a/im-sdk-core/src/main/java/com/easemob/im/server/api/metadata/user/get/MetadataBatchGetRequest.java +++ /dev/null @@ -1,31 +0,0 @@ -package com.easemob.im.server.api.metadata.user.get; - - -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonProperty; - -import java.util.List; - -public class MetadataBatchGetRequest { - - @JsonProperty("targets") - private List targets; - - @JsonProperty("properties") - private List properties; - - @JsonCreator - public MetadataBatchGetRequest(@JsonProperty("targets") List targets, - @JsonProperty("properties") List properties) { - this.targets = targets; - this.properties = properties; - } - - public List getTargets() { - return targets; - } - - public List getProperties() { - return properties; - } -} diff --git a/im-sdk-core/src/main/java/com/easemob/im/server/api/metadata/user/get/MetadataBatchGetResponse.java b/im-sdk-core/src/main/java/com/easemob/im/server/api/metadata/user/get/MetadataBatchGetResponse.java deleted file mode 100644 index ccbd223a8..000000000 --- a/im-sdk-core/src/main/java/com/easemob/im/server/api/metadata/user/get/MetadataBatchGetResponse.java +++ /dev/null @@ -1,31 +0,0 @@ -package com.easemob.im.server.api.metadata.user.get; - -import com.easemob.im.server.model.EMMetadataBatch; -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonProperty; - -import java.util.Map; - -public class MetadataBatchGetResponse { - @JsonProperty("data") - private Map> data; - - @JsonCreator - public MetadataBatchGetResponse(@JsonProperty("data") Map> data) { - this.data = data; - } - - public Map> getData() { - return data; - } - - public EMMetadataBatch toMetadataBatch() { - return new EMMetadataBatch(this.data); - } - - @Override public String toString() { - return "MetadataBatchGetResponse{" + - "data=" + data + - '}'; - } -} diff --git a/im-sdk-core/src/main/java/com/easemob/im/server/api/metadata/user/get/MetadataGet.java b/im-sdk-core/src/main/java/com/easemob/im/server/api/metadata/user/get/MetadataGet.java deleted file mode 100644 index 3f2b40440..000000000 --- a/im-sdk-core/src/main/java/com/easemob/im/server/api/metadata/user/get/MetadataGet.java +++ /dev/null @@ -1,34 +0,0 @@ -package com.easemob.im.server.api.metadata.user.get; - -import com.easemob.im.server.api.Context; -import com.easemob.im.server.api.DefaultErrorMapper; -import com.easemob.im.server.api.ErrorMapper; -import com.easemob.im.server.exception.EMUnknownException; -import com.easemob.im.server.model.EMMetadata; -import reactor.core.publisher.Mono; - -public class MetadataGet { - private Context context; - - public MetadataGet(Context context) { - this.context = context; - } - - public Mono fromUser(String username) { - return this.context.getHttpClient() - .flatMap(httpClient -> httpClient.get() - .uri(String.format("/metadata/user/%s", username)) - .responseSingle((rsp, buf) -> { - return buf.switchIfEmpty( - Mono.error(new EMUnknownException("response is null"))) - .flatMap(byteBuf -> { - ErrorMapper mapper = new DefaultErrorMapper(); - mapper.statusCode(rsp); - mapper.checkError(byteBuf); - return Mono.just(byteBuf); - }); - })) - .map(buf -> this.context.getCodec().decode(buf, MetadataGetUserResponse.class)) - .map(MetadataGetUserResponse::toMetadata); - } -} diff --git a/im-sdk-core/src/main/java/com/easemob/im/server/api/metadata/user/get/MetadataGetUserResponse.java b/im-sdk-core/src/main/java/com/easemob/im/server/api/metadata/user/get/MetadataGetUserResponse.java deleted file mode 100644 index c83767b43..000000000 --- a/im-sdk-core/src/main/java/com/easemob/im/server/api/metadata/user/get/MetadataGetUserResponse.java +++ /dev/null @@ -1,32 +0,0 @@ -package com.easemob.im.server.api.metadata.user.get; - -import com.easemob.im.server.model.EMMetadata; -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonProperty; - -import java.util.Map; - -public class MetadataGetUserResponse { - @JsonProperty("data") - private Map data; - - @JsonCreator - public MetadataGetUserResponse(@JsonProperty("data") Map data) { - this.data = data; - } - - public Map getData() { - return data; - } - - public EMMetadata toMetadata() { - return new EMMetadata(this.data); - } - - @Override - public String toString() { - return "MetadataGetUserResponse{" + - "data=" + data + - '}'; - } -} diff --git a/im-sdk-core/src/main/java/com/easemob/im/server/api/metadata/user/set/MetadataSet.java b/im-sdk-core/src/main/java/com/easemob/im/server/api/metadata/user/set/MetadataSet.java deleted file mode 100644 index 49dd89851..000000000 --- a/im-sdk-core/src/main/java/com/easemob/im/server/api/metadata/user/set/MetadataSet.java +++ /dev/null @@ -1,41 +0,0 @@ -package com.easemob.im.server.api.metadata.user.set; - -import com.easemob.im.server.api.Context; -import com.easemob.im.server.api.DefaultErrorMapper; -import com.easemob.im.server.api.ErrorMapper; -import com.easemob.im.server.exception.EMUnknownException; -import reactor.core.publisher.Mono; -import reactor.netty.http.client.HttpClientForm; - -import java.nio.charset.StandardCharsets; -import java.util.Map; - -public class MetadataSet { - private Context context; - - public MetadataSet(Context context) { - this.context = context; - } - - public Mono toUser(String username, Map metadata) { - return this.context.getHttpClient() - .flatMap(httpClient -> httpClient.put() - .uri(String.format("/metadata/user/%s", username)) - .sendForm((req, form) -> { - HttpClientForm clientForm = - form.multipart(false).charset(StandardCharsets.UTF_8); - metadata.forEach(clientForm::attr); - }) - .responseSingle((rsp, buf) -> { - return buf.switchIfEmpty( - Mono.error(new EMUnknownException("response is null"))) - .flatMap(byteBuf -> { - ErrorMapper mapper = new DefaultErrorMapper(); - mapper.statusCode(rsp); - mapper.checkError(byteBuf); - return Mono.just(byteBuf); - }); - })) - .then(); - } -} diff --git a/im-sdk-core/src/main/java/com/easemob/im/server/api/metadata/user/usage/MetadataUsage.java b/im-sdk-core/src/main/java/com/easemob/im/server/api/metadata/user/usage/MetadataUsage.java deleted file mode 100644 index 14d654e6e..000000000 --- a/im-sdk-core/src/main/java/com/easemob/im/server/api/metadata/user/usage/MetadataUsage.java +++ /dev/null @@ -1,35 +0,0 @@ -package com.easemob.im.server.api.metadata.user.usage; - -import com.easemob.im.server.api.Context; -import com.easemob.im.server.api.DefaultErrorMapper; -import com.easemob.im.server.api.ErrorMapper; -import com.easemob.im.server.exception.EMUnknownException; -import com.easemob.im.server.model.EMMetadataUsage; -import reactor.core.publisher.Mono; - -public class MetadataUsage { - private Context context; - - public MetadataUsage(Context context) { - this.context = context; - } - - public Mono getUsage() { - return this.context.getHttpClient() - .flatMap(httpClient -> httpClient.get() - .uri("/metadata/user/capacity") - .responseSingle((rsp, buf) -> { - return buf.switchIfEmpty( - Mono.error(new EMUnknownException("response is null"))) - .flatMap(byteBuf -> { - ErrorMapper mapper = new DefaultErrorMapper(); - mapper.statusCode(rsp); - mapper.checkError(byteBuf); - return Mono.just(byteBuf); - }); - })) - .map(buf -> this.context.getCodec().decode(buf, MetadataUsageResponse.class)) - .map(MetadataUsageResponse::getBytesUsed) - .map(EMMetadataUsage::new); - } -} diff --git a/im-sdk-core/src/main/java/com/easemob/im/server/api/metadata/user/usage/MetadataUsageResponse.java b/im-sdk-core/src/main/java/com/easemob/im/server/api/metadata/user/usage/MetadataUsageResponse.java deleted file mode 100644 index c32a67696..000000000 --- a/im-sdk-core/src/main/java/com/easemob/im/server/api/metadata/user/usage/MetadataUsageResponse.java +++ /dev/null @@ -1,18 +0,0 @@ -package com.easemob.im.server.api.metadata.user.usage; - -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonProperty; - -public class MetadataUsageResponse { - @JsonProperty("data") - private Long bytesUsed; - - @JsonCreator - public MetadataUsageResponse(@JsonProperty("data") Long bytesUsed) { - this.bytesUsed = bytesUsed; - } - - public Long getBytesUsed() { - return bytesUsed; - } -} diff --git a/im-sdk-core/src/main/java/com/easemob/im/server/api/moderation/ExportResource.java b/im-sdk-core/src/main/java/com/easemob/im/server/api/moderation/ExportResource.java deleted file mode 100644 index 3d90ee930..000000000 --- a/im-sdk-core/src/main/java/com/easemob/im/server/api/moderation/ExportResource.java +++ /dev/null @@ -1,136 +0,0 @@ -package com.easemob.im.server.api.moderation; - -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonProperty; - -public class ExportResource { - - @JsonProperty("id") - private String id; - - @JsonProperty("uuid") - private String uuid; - - /** - * 文件名 - */ - @JsonProperty("fileName") - private String fileName; - - /** - * 导出任务状态,('Creating':生成中,'Failed':导出失败,'Abort':任务终止,'Finished':文件已生成) - */ - @JsonProperty("status") - private String status; - - /** - * 导出查询条件 - */ - @JsonProperty("cond") - private String cond; - - /** - * 导出详情 - */ - @JsonProperty("detail") - private String detail; - - /** - * 文件大小 - */ - @JsonProperty("size") - private Long size; - - /** - * 过期时间 - */ - @JsonProperty("expiredAt") - private String expiredTime; - - /** - * 任务创建时间 - */ - @JsonProperty("createdAt") - private String createdTime; - - /** - * 任务数据更新时间 - */ - @JsonProperty("updatedAt") - private String updatedTime; - - @JsonCreator - public ExportResource(@JsonProperty("id") String id, @JsonProperty("uuid") String uuid, - @JsonProperty("fileName") String fileName, @JsonProperty("status") String status, - @JsonProperty("cond") String cond, - @JsonProperty("detail") String detail, @JsonProperty("size") Long size, - @JsonProperty("expiredAt") String expiredTime, - @JsonProperty("createdAt") String createdTime, - @JsonProperty("updatedAt") String updatedTime) { - this.id = id; - this.uuid = uuid; - this.fileName = fileName; - this.status = status; - this.cond = cond; - this.detail = detail; - this.size = size; - this.expiredTime = expiredTime; - this.createdTime = createdTime; - this.updatedTime = updatedTime; - } - - public String getId() { - return id; - } - - public String getUuid() { - return uuid; - } - - public String getFileName() { - return fileName; - } - - public String getStatus() { - return status; - } - - public String getCond() { - return cond; - } - - public String getDetail() { - return detail; - } - - public Long getSize() { - return size; - } - - public String getExpiredTime() { - return expiredTime; - } - - public String getCreatedTime() { - return createdTime; - } - - public String getUpdatedTime() { - return updatedTime; - } - - @Override public String toString() { - return "ExportResource{" + - "id='" + id + '\'' + - ", uuid='" + uuid + '\'' + - ", fileName='" + fileName + '\'' + - ", status='" + status + '\'' + - ", cond='" + cond + '\'' + - ", detail='" + detail + '\'' + - ", size=" + size + - ", expiredTime='" + expiredTime + '\'' + - ", createdTime='" + createdTime + '\'' + - ", updatedTime='" + updatedTime + '\'' + - '}'; - } -} diff --git a/im-sdk-core/src/main/java/com/easemob/im/server/api/moderation/ModerationApi.java b/im-sdk-core/src/main/java/com/easemob/im/server/api/moderation/ModerationApi.java deleted file mode 100644 index e0178caa3..000000000 --- a/im-sdk-core/src/main/java/com/easemob/im/server/api/moderation/ModerationApi.java +++ /dev/null @@ -1,119 +0,0 @@ -package com.easemob.im.server.api.moderation; - -import com.easemob.im.server.api.Context; -import com.easemob.im.server.api.moderation.download.RecordFileDownload; -import com.easemob.im.server.api.moderation.export.ExportMessageRecord; -import com.easemob.im.server.api.moderation.export.ExportMessageRecordResponse; -import com.easemob.im.server.api.moderation.list.ExportDetailsList; -import com.easemob.im.server.api.moderation.list.ExportDetailsListResponse; -import com.easemob.im.server.exception.EMInvalidArgumentException; -import reactor.core.publisher.Mono; - -import java.nio.file.Path; -import java.util.Map; - -/** - * 开通内容审核(高级版)服务后,过内容审核的消息会有审核记录,可以通过以下 API 导出这块数据记录 - */ -public class ModerationApi { - - private ExportMessageRecord exportMessageRecord; - - private ExportDetailsList exportDetailsList; - - private RecordFileDownload recordFileDownload; - - public ModerationApi(Context context) { - this.exportMessageRecord = new ExportMessageRecord(context); - this.exportDetailsList = new ExportDetailsList(context); - this.recordFileDownload = new RecordFileDownload(context); - } - - /** - * 按查询条件导出文件。 - *

- * - * API使用示例: - *

 {@code
-     * EMService service;
-     *
-     * try {
-     *     String uuid = service.moderation().export(1646723027000, 1646733127000, "chat", "txt", "PASS", "PASS").block();
-     * } catch (EMException e) {
-     *     e.getErrorCode();
-     *     e.getMessage();
-     * }
-     * }
- * - * @param beginTimestamp 查询起始时间,毫秒时间戳 - * @param endTimestamp 查询截止时间,毫秒时间戳 - * @param targetType 用判断单聊、群聊还是聊天室,chat: 单聊;groupchat: 群聊;chatroom: 聊天室 - * @param messageType 消息类型,txt: 文本;img: 图片;video: 视频;audio: 音频 - * @param moderationResult 处置结果,PASS: 通过;REJECT: 拒绝;EXCHANGE: 替换;RECALL: 撤回 - * @param providerResult 审核结果,PASS: 正常内容;REVIEWED: 需要审核;REJECT: 违规内容;UNKNOWN: 异常 - * @return uuid - */ - public Mono export(long beginTimestamp, long endTimestamp, String targetType, String messageType, String moderationResult, String providerResult) { - - if (beginTimestamp == 0 || endTimestamp == 0) { - throw new EMInvalidArgumentException("beginTimestamp or endTimestamp Cannot be 0"); - } - - if (beginTimestamp > endTimestamp) { - throw new EMInvalidArgumentException("beginTimestamp cannot be greater than endTimestamp"); - } - - return this.exportMessageRecord.export(beginTimestamp, endTimestamp, targetType, messageType, moderationResult, providerResult); - } - - /** - * 获取导出详情列表。 - *

- * - * API使用示例: - *

 {@code
-     * EMService service;
-     *
-     * try {
-     *     String uuid = service.moderation().get(1, 10, "287c0730-9e97-11ec-ba62-139a925bb42e").block();
-     * } catch (EMException e) {
-     *     e.getErrorCode();
-     *     e.getMessage();
-     * }
-     * }
- * - * @param page 导出哪页的详情 - * @param pageSize 每页详情的数量 - * @param uuid 导出文件的uuid,通过 "按查询条件导出文件" 的 api 获取 - * @return 详情列表 - */ - public Mono get(int page, int pageSize, String uuid) { - return this.exportDetailsList.get(page, pageSize, uuid); - } - - /** - * 下载文件。 - *

- * - * API使用示例: - *

 {@code
-     * EMService service;
-     *
-     * try {
-     *     Path path = FileSystems.getDefault().getPath("/Users/xxx/");
-     *     Path path = service.moderation().download("287c0730-9e97-11ec-ba62-139a925bb42e", path, "record.txt").block();
-     * } catch (EMException e) {
-     *     e.getErrorCode();
-     *     e.getMessage();
-     * }
-     * }
- * - * @param uuid 文件的uuid,通过 "按查询条件导出文件" 的 api 获取 - * @param dir 下载到哪个目录,如果不存在会自动创建 - * @param filename 下载到哪个文件,可以理解为带后缀的文件名,建议使用 .txt为后缀 - * @return path - */ - public Mono download(String uuid, Path dir, String filename) { - return this.recordFileDownload.toLocalFile(uuid, dir, filename); - } -} diff --git a/im-sdk-core/src/main/java/com/easemob/im/server/api/moderation/download/RecordFileDownload.java b/im-sdk-core/src/main/java/com/easemob/im/server/api/moderation/download/RecordFileDownload.java deleted file mode 100644 index 34128239d..000000000 --- a/im-sdk-core/src/main/java/com/easemob/im/server/api/moderation/download/RecordFileDownload.java +++ /dev/null @@ -1,45 +0,0 @@ -package com.easemob.im.server.api.moderation.download; - -import com.easemob.im.server.api.Context; -import com.easemob.im.server.api.DefaultErrorMapper; -import com.easemob.im.server.api.ErrorMapper; -import com.easemob.im.server.api.util.FileSystem; -import com.easemob.im.server.exception.EMUnknownException; -import reactor.core.publisher.Flux; -import reactor.core.publisher.Mono; - -import java.io.OutputStream; -import java.nio.file.Path; -import java.util.Map; - -public class RecordFileDownload { - - private Context context; - - public RecordFileDownload(Context context) { - this.context = context; - } - - public Mono toLocalFile(String uuid, Path dir, String filename) { - Path local = FileSystem.choosePath(dir, filename); - - return Mono.create(sink -> sink.success(FileSystem.open(local))) - .flatMap(out -> this.context.getHttpClient() - .flatMap(httpClient -> httpClient.get() - .uri(String.format("/moderationfiles/%s?type=record", uuid)) - .response((rsp, buf) -> { - return buf.switchIfEmpty( - Mono.error(new EMUnknownException("response is null"))) - .flatMap(byteBuf -> { - ErrorMapper mapper = new DefaultErrorMapper(); - mapper.statusCode(rsp); - mapper.checkError(byteBuf); - return Mono.just(byteBuf); - }); - }) - .doOnNext(buf -> FileSystem.append(out, buf)) - .doFinally(sig -> FileSystem.close(out)) - .then())) - .thenReturn(local); - } -} diff --git a/im-sdk-core/src/main/java/com/easemob/im/server/api/moderation/export/ExportMessageRecord.java b/im-sdk-core/src/main/java/com/easemob/im/server/api/moderation/export/ExportMessageRecord.java deleted file mode 100644 index 54bd1115b..000000000 --- a/im-sdk-core/src/main/java/com/easemob/im/server/api/moderation/export/ExportMessageRecord.java +++ /dev/null @@ -1,43 +0,0 @@ -package com.easemob.im.server.api.moderation.export; - -import com.easemob.im.server.api.Context; -import com.easemob.im.server.api.DefaultErrorMapper; -import com.easemob.im.server.api.ErrorMapper; -import com.easemob.im.server.api.user.create.CreateUserRequest; -import com.easemob.im.server.api.user.get.UserGetResponse; -import com.easemob.im.server.exception.EMUnknownException; -import reactor.core.publisher.Mono; - -public class ExportMessageRecord { - - private Context context; - - public ExportMessageRecord(Context context) { - this.context = context; - } - - public Mono export(Long beginTimestamp, Long endTimestamp, - String targetType, String messageType, String moderationResult, String providerResult) { - return this.context.getHttpClient() - .flatMap(httpClient -> httpClient.headers( - header -> header.add("Content-Type", "application/json")) - .post() - .uri("/moderation/record/message/export") - .send(Mono.create(sink -> sink.success(this.context.getCodec() - .encode(new ExportMessageRecordRequest(beginTimestamp, endTimestamp, - targetType, messageType, moderationResult, - providerResult))))) - .responseSingle((rsp, buf) -> { - return buf.switchIfEmpty( - Mono.error(new EMUnknownException("response is null"))) - .flatMap(byteBuf -> { - ErrorMapper mapper = new DefaultErrorMapper(); - mapper.statusCode(rsp); - mapper.checkError(byteBuf); - return Mono.just(byteBuf); - }); - })) - .map(buf -> this.context.getCodec().decode(buf, ExportMessageRecordResponse.class) - .getFileUuid()); - } -} diff --git a/im-sdk-core/src/main/java/com/easemob/im/server/api/moderation/export/ExportMessageRecordRequest.java b/im-sdk-core/src/main/java/com/easemob/im/server/api/moderation/export/ExportMessageRecordRequest.java deleted file mode 100644 index 2d9bd10b7..000000000 --- a/im-sdk-core/src/main/java/com/easemob/im/server/api/moderation/export/ExportMessageRecordRequest.java +++ /dev/null @@ -1,41 +0,0 @@ -package com.easemob.im.server.api.moderation.export; - -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonProperty; - -public class ExportMessageRecordRequest { - - @JsonProperty("dateFrom") - private Long dateFrom; - - @JsonProperty("dateTo") - private Long dateTo; - - @JsonProperty("targetType") - private String targetType; - - @JsonProperty("msgType") - private String msgType; - - @JsonProperty("moderationResult") - private String moderationResult; - - @JsonProperty("providerResult") - private String providerResult; - - @JsonCreator - public ExportMessageRecordRequest(@JsonProperty("dateFrom") Long dateFrom, - @JsonProperty("dateTo") Long dateTo, - @JsonProperty("targetType") String targetType, - @JsonProperty("msgType") String msgType, - @JsonProperty("moderationResult") String moderationResult, - @JsonProperty("providerResult") String providerResult) { - - this.dateFrom = dateFrom; - this.dateTo = dateTo; - this.targetType = targetType; - this.msgType = msgType; - this.moderationResult = moderationResult; - this.providerResult = providerResult; - } -} diff --git a/im-sdk-core/src/main/java/com/easemob/im/server/api/moderation/export/ExportMessageRecordResponse.java b/im-sdk-core/src/main/java/com/easemob/im/server/api/moderation/export/ExportMessageRecordResponse.java deleted file mode 100644 index dfa2193d3..000000000 --- a/im-sdk-core/src/main/java/com/easemob/im/server/api/moderation/export/ExportMessageRecordResponse.java +++ /dev/null @@ -1,21 +0,0 @@ -package com.easemob.im.server.api.moderation.export; - -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonProperty; - -import java.util.Map; - -public class ExportMessageRecordResponse { - - @JsonProperty("entity") - private Map entity; - - @JsonCreator - public ExportMessageRecordResponse(@JsonProperty("entity") Map entity) { - this.entity = entity; - } - - public String getFileUuid() { - return entity.get("uuid"); - } -} diff --git a/im-sdk-core/src/main/java/com/easemob/im/server/api/moderation/list/ExportDetailsList.java b/im-sdk-core/src/main/java/com/easemob/im/server/api/moderation/list/ExportDetailsList.java deleted file mode 100644 index b3dfffbc1..000000000 --- a/im-sdk-core/src/main/java/com/easemob/im/server/api/moderation/list/ExportDetailsList.java +++ /dev/null @@ -1,33 +0,0 @@ -package com.easemob.im.server.api.moderation.list; - -import com.easemob.im.server.api.Context; -import com.easemob.im.server.api.DefaultErrorMapper; -import com.easemob.im.server.api.ErrorMapper; -import com.easemob.im.server.exception.EMUnknownException; -import reactor.core.publisher.Mono; - -public class ExportDetailsList { - - private Context context; - - public ExportDetailsList(Context context) { - this.context = context; - } - - public Mono get(int page, int pageSize, String uuid) { - return this.context.getHttpClient() - .flatMap(httpClient -> httpClient.get() - .uri(String.format("/moderation/export/files?page=%d&size=%d&uuid=%s", page, pageSize, uuid)) - .responseSingle((rsp, buf) -> { - return buf.switchIfEmpty( - Mono.error(new EMUnknownException("response is null"))) - .flatMap(byteBuf -> { - ErrorMapper mapper = new DefaultErrorMapper(); - mapper.statusCode(rsp); - mapper.checkError(byteBuf); - return Mono.just(byteBuf); - }); - })) - .map(buf -> this.context.getCodec().decode(buf, ExportDetailsListResponse.class)); - } -} diff --git a/im-sdk-core/src/main/java/com/easemob/im/server/api/moderation/list/ExportDetailsListResponse.java b/im-sdk-core/src/main/java/com/easemob/im/server/api/moderation/list/ExportDetailsListResponse.java deleted file mode 100644 index 7b2faa221..000000000 --- a/im-sdk-core/src/main/java/com/easemob/im/server/api/moderation/list/ExportDetailsListResponse.java +++ /dev/null @@ -1,119 +0,0 @@ -package com.easemob.im.server.api.moderation.list; - -import com.easemob.im.server.api.moderation.ExportResource; -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonProperty; - -import java.util.List; - -public class ExportDetailsListResponse { - - @JsonProperty("entities") - private List entities; - - /** - * 是否为第一页 - */ - @JsonProperty("first") - private Boolean first; - - /** - * 是否为最后一页 - */ - @JsonProperty("last") - private Boolean last; - - /** - * 页大小 - */ - @JsonProperty("size") - private Long size; - - /** - * 页码 - */ - @JsonProperty("number") - private Long number; - - /** - * 页中元素个数 - */ - @JsonProperty("numberOfElements") - private Long numberOfElements; - - /** - * 总页码数 - */ - @JsonProperty("totalPages") - private Long totalPages; - - /** - * 总元素数 - */ - @JsonProperty("totalElements") - private Long totalElements; - - @JsonCreator - public ExportDetailsListResponse( - @JsonProperty("entities") List entities, - @JsonProperty("first") Boolean first, @JsonProperty("last") Boolean last, - @JsonProperty("size") Long size, - @JsonProperty("number") Long number, - @JsonProperty("numberOfElements") Long numberOfElements, - @JsonProperty("totalPages") Long totalPages, - @JsonProperty("totalElements") Long totalElements) { - this.entities = entities; - this.first = first; - this.last = last; - this.size = size; - this.number = number; - this.numberOfElements = numberOfElements; - this.totalPages = totalPages; - this.totalElements = totalElements; - } - - public List getEntities() { - return entities; - } - - public Boolean getFirst() { - return first; - } - - public Boolean getLast() { - return last; - } - - public Long getSize() { - return size; - } - - public Long getNumber() { - return number; - } - - public Long getNumberOfElements() { - return numberOfElements; - } - - public Long getTotalPages() { - return totalPages; - } - - public Long getTotalElements() { - return totalElements; - } - - @Override public String toString() { - return "ExportDetailsListResponse{" + - "entities=" + entities + - ", first=" + first + - ", last=" + last + - ", size=" + size + - ", number=" + number + - ", numberOfElements=" + numberOfElements + - ", totalPages=" + totalPages + - ", totalElements=" + totalElements + - '}'; - } -} diff --git a/im-sdk-core/src/main/java/com/easemob/im/server/api/mute/MuteApi.java b/im-sdk-core/src/main/java/com/easemob/im/server/api/mute/MuteApi.java deleted file mode 100644 index eff506d32..000000000 --- a/im-sdk-core/src/main/java/com/easemob/im/server/api/mute/MuteApi.java +++ /dev/null @@ -1,93 +0,0 @@ -package com.easemob.im.server.api.mute; - -import com.easemob.im.server.api.Context; -import com.easemob.im.server.api.mute.detail.MuteDetail; -import com.easemob.im.server.api.mute.list.GetMuteListResponse; -import com.easemob.im.server.api.mute.list.MuteList; -import com.easemob.im.server.api.mute.mute.MuteUser; -import com.easemob.im.server.api.mute.mute.MuteUserRequest; -import com.easemob.im.server.model.EMMute; -import reactor.core.publisher.Mono; - -import java.util.List; - -public class MuteApi { - - private MuteUser muteUser; - - private MuteDetail muteDetail; - - private MuteList muteList; - - public MuteApi(Context context) { - this.muteUser = new MuteUser(context); - this.muteDetail = new MuteDetail(context); - this.muteList = new MuteList(context); - } - - /** - * 设置用户全局禁言。 - *

- * API使用示例: - *

 {@code
-     * EMService service;
-     * try {
-     *     MuteUserRequest request = MuteUserRequest.builder().username("test_user").chat(0).build();
-     *     service.mute().muteUser(request).block();
-     * } catch (EMException e) {
-     *     e.getErrorCode();
-     *     e.getMessage();
-     * }
-     * }
- * - * @param request 用户全局禁言请求体 - * @return 成功或错误 - * @see 设置用户全局禁言 - */ - public Mono muteUser(MuteUserRequest request) { - return this.muteUser.execute(request); - } - - /** - * 查询单个用户全局禁言剩余时间。 - *

- * API使用示例: - *

 {@code
-     * EMService service;
-     * try {
-     *     service.mute().detail("test_user").block();
-     * } catch (EMException e) {
-     *     e.getErrorCode();
-     *     e.getMessage();
-     * }
-     * }
- * - * @param username 查询禁言信息的用户名 - * @return 成功或错误 - * @see 查询单个用户全局禁言剩余时间 - */ - public Mono detail(String username) { - return this.muteDetail.execute(username); - } - - /** - * 查询所有用户全局禁言剩余时间。 - *

- * API使用示例: - *

 {@code
-     * EMService service;
-     * try {
-     *     service.mute().muteList().block();
-     * } catch (EMException e) {
-     *     e.getErrorCode();
-     *     e.getMessage();
-     * }
-     * }
- * - * @return 成功或错误 - * @see 查询所有用户全局禁言剩余时间 - */ - public Mono muteList() { - return this.muteList.execute(); - } -} diff --git a/im-sdk-core/src/main/java/com/easemob/im/server/api/mute/detail/GetMuteDetailResponse.java b/im-sdk-core/src/main/java/com/easemob/im/server/api/mute/detail/GetMuteDetailResponse.java deleted file mode 100644 index 476db2be3..000000000 --- a/im-sdk-core/src/main/java/com/easemob/im/server/api/mute/detail/GetMuteDetailResponse.java +++ /dev/null @@ -1,43 +0,0 @@ -package com.easemob.im.server.api.mute.detail; - -import com.easemob.im.server.model.EMMute; -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonProperty; - -public class GetMuteDetailResponse { - - @JsonProperty("data") - private MuteDetail muteDetail; - - @JsonCreator - public GetMuteDetailResponse(@JsonProperty("data") - MuteDetail muteDetail) { - this.muteDetail = muteDetail; - } - - public EMMute toEMMute() { - return this.muteDetail.toEMMute(); - } - - private static class MuteDetail { - - @JsonProperty("userid") - private String username; - - @JsonProperty("chat") - private Integer chat; - - @JsonProperty("groupchat") - private Integer groupChat; - - @JsonProperty("chatroom") - private Integer chatroom; - - @JsonProperty("unixtime") - private Integer unixTime; - - public EMMute toEMMute() { - return new EMMute(this.username, this.chat, this.groupChat, this.chatroom, this.unixTime); - } - } -} diff --git a/im-sdk-core/src/main/java/com/easemob/im/server/api/mute/detail/MuteDetail.java b/im-sdk-core/src/main/java/com/easemob/im/server/api/mute/detail/MuteDetail.java deleted file mode 100644 index 72e9ebe5d..000000000 --- a/im-sdk-core/src/main/java/com/easemob/im/server/api/mute/detail/MuteDetail.java +++ /dev/null @@ -1,36 +0,0 @@ -package com.easemob.im.server.api.mute.detail; - -import com.easemob.im.server.api.Context; -import com.easemob.im.server.api.DefaultErrorMapper; -import com.easemob.im.server.api.ErrorMapper; -import com.easemob.im.server.exception.EMUnknownException; -import com.easemob.im.server.model.EMMute; -import reactor.core.publisher.Mono; - -public class MuteDetail { - - private Context context; - - public MuteDetail(Context context) { - this.context = context; - } - - public Mono execute(String username) { - return this.context.getHttpClient() - .flatMap(httpClient -> httpClient.get() - .uri(String.format("/mutes/%s", username)) - .responseSingle((rsp, buf) -> { - return buf.switchIfEmpty( - Mono.error(new EMUnknownException("response is null"))) - .flatMap(byteBuf -> { - ErrorMapper mapper = new DefaultErrorMapper(); - mapper.statusCode(rsp); - mapper.checkError(byteBuf); - return Mono.just(byteBuf); - }); - })) - .map(buf -> this.context.getCodec().decode(buf, GetMuteDetailResponse.class)) - .map(GetMuteDetailResponse::toEMMute); - } - -} diff --git a/im-sdk-core/src/main/java/com/easemob/im/server/api/mute/list/GetMuteListResponse.java b/im-sdk-core/src/main/java/com/easemob/im/server/api/mute/list/GetMuteListResponse.java deleted file mode 100644 index bf425a121..000000000 --- a/im-sdk-core/src/main/java/com/easemob/im/server/api/mute/list/GetMuteListResponse.java +++ /dev/null @@ -1,19 +0,0 @@ -package com.easemob.im.server.api.mute.list; - -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonProperty; - -public class GetMuteListResponse { - - @JsonProperty("data") - private Object muteData; - - @JsonCreator - public GetMuteListResponse(@JsonProperty("data") Object muteData) { - this.muteData = muteData; - } - - public Object getMuteData() { - return muteData; - } -} diff --git a/im-sdk-core/src/main/java/com/easemob/im/server/api/mute/list/MuteList.java b/im-sdk-core/src/main/java/com/easemob/im/server/api/mute/list/MuteList.java deleted file mode 100644 index 660865616..000000000 --- a/im-sdk-core/src/main/java/com/easemob/im/server/api/mute/list/MuteList.java +++ /dev/null @@ -1,41 +0,0 @@ -package com.easemob.im.server.api.mute.list; - -import com.easemob.im.server.api.Context; -import com.easemob.im.server.api.DefaultErrorMapper; -import com.easemob.im.server.api.ErrorMapper; -import com.easemob.im.server.api.token.allocate.AgoraTokenProvider; -import com.easemob.im.server.exception.EMUnknownException; -import com.easemob.im.server.model.EMMute; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import reactor.core.publisher.Mono; - -import java.util.List; - -public class MuteList { - private static final Logger log = LoggerFactory.getLogger(MuteList.class); - - private Context context; - - public MuteList(Context context) { - this.context = context; - } - - public Mono execute() { - log.debug("mute list -------------"); - return this.context.getHttpClient() - .flatMap(httpClient -> httpClient.get() - .uri("/mutes") - .responseSingle((rsp, buf) -> { - return buf.switchIfEmpty( - Mono.error(new EMUnknownException("response is null"))) - .flatMap(byteBuf -> { - ErrorMapper mapper = new DefaultErrorMapper(); - mapper.statusCode(rsp); - mapper.checkError(byteBuf); - return Mono.just(byteBuf); - }); - })) - .map(buf -> this.context.getCodec().decode(buf, GetMuteListResponse.class)); - } -} diff --git a/im-sdk-core/src/main/java/com/easemob/im/server/api/mute/mute/MuteUser.java b/im-sdk-core/src/main/java/com/easemob/im/server/api/mute/mute/MuteUser.java deleted file mode 100644 index 19a35ce31..000000000 --- a/im-sdk-core/src/main/java/com/easemob/im/server/api/mute/mute/MuteUser.java +++ /dev/null @@ -1,37 +0,0 @@ -package com.easemob.im.server.api.mute.mute; - -import com.easemob.im.server.api.Context; -import com.easemob.im.server.api.DefaultErrorMapper; -import com.easemob.im.server.api.ErrorMapper; -import com.easemob.im.server.exception.EMNotFoundException; -import com.easemob.im.server.exception.EMUnknownException; -import reactor.core.publisher.Mono; - -public class MuteUser { - - private Context context; - - public MuteUser(Context context) { - this.context = context; - } - - public Mono execute(MuteUserRequest request) { - return this.context.getHttpClient() - .flatMap(httpClient -> httpClient.post() - .uri("/mutes") - .send(Mono.create(sink -> sink.success(this.context.getCodec().encode(request)))) - .responseSingle((rsp, buf) -> { - return buf.switchIfEmpty( - Mono.error(new EMUnknownException("response is null"))) - .flatMap(byteBuf -> { - ErrorMapper mapper = new DefaultErrorMapper(); - mapper.statusCode(rsp); - mapper.checkError(byteBuf); - return Mono.just(byteBuf); - }); - })) - .onErrorResume(EMNotFoundException.class, errorIgnored -> Mono.empty()) - .then(); - } - -} diff --git a/im-sdk-core/src/main/java/com/easemob/im/server/api/mute/mute/MuteUserRequest.java b/im-sdk-core/src/main/java/com/easemob/im/server/api/mute/mute/MuteUserRequest.java deleted file mode 100644 index c34d7b3df..000000000 --- a/im-sdk-core/src/main/java/com/easemob/im/server/api/mute/mute/MuteUserRequest.java +++ /dev/null @@ -1,74 +0,0 @@ -package com.easemob.im.server.api.mute.mute; - -import com.fasterxml.jackson.annotation.JsonProperty; - -public class MuteUserRequest { - - @JsonProperty("username") - private String username; - - @JsonProperty("chat") - private Integer chat; - - @JsonProperty("groupchat") - private Integer groupChat; - - @JsonProperty("chatroom") - private Integer chatroom; - - private MuteUserRequest() { - - } - - public static Builder builder() { - return new Builder(); - } - - public static class Builder { - - private String username; - private Integer chat; - private Integer groupChat; - private Integer chatroom; - - public Builder username(String username) { - this.username = username; - return this; - } - - public Builder chat(Integer chat) { - this.chat = chat; - return this; - } - - public Builder groupChat(Integer groupChat) { - this.groupChat = groupChat; - return this; - } - - public Builder chatroom(Integer chatroom) { - this.chatroom = chatroom; - return this; - } - - public MuteUserRequest build() { - MuteUserRequest muteUserRequest = new MuteUserRequest(); - muteUserRequest.username = this.username; - muteUserRequest.chat = this.chat; - muteUserRequest.groupChat = this.groupChat; - muteUserRequest.chatroom = this.chatroom; - return muteUserRequest; - } - - @Override - public String toString() { - return "Builder{" + - "username=" + username + - ", chat=" + chat + - ", groupChat=" + groupChat + - ", chatroom=" + chatroom + - '}'; - } - - } -} diff --git a/im-sdk-core/src/main/java/com/easemob/im/server/api/push/PushApi.java b/im-sdk-core/src/main/java/com/easemob/im/server/api/push/PushApi.java deleted file mode 100644 index 59da98cab..000000000 --- a/im-sdk-core/src/main/java/com/easemob/im/server/api/push/PushApi.java +++ /dev/null @@ -1,214 +0,0 @@ -package com.easemob.im.server.api.push; - -import com.easemob.im.server.api.Context; -import com.easemob.im.server.api.push.displaystyle.set.DisplayStyle; -import com.easemob.im.server.api.push.displaystyle.set.NotificationDisplayStyle; -import com.easemob.im.server.api.push.nickname.UpdateUserNickname; -import com.easemob.im.server.api.push.nodisturbing.NotificationNoDisturbing; -import com.easemob.im.server.api.push.offline.Setting; -import com.easemob.im.server.exception.EMInvalidArgumentException; -import com.easemob.im.server.model.EMConversationType; -import com.easemob.im.server.model.EMNotificationType; -import com.easemob.im.server.model.EMUser; -import reactor.core.publisher.Mono; - -/** - * 推送API。 - */ -public class PushApi { - - private Context context; - - private UpdateUserNickname updateUserNickname; - - private NotificationDisplayStyle notificationDisplayStyle; - - private NotificationNoDisturbing notificationNoDisturbing; - - private Setting setting; - - public PushApi(Context context) { - this.updateUserNickname = new UpdateUserNickname(context); - this.notificationDisplayStyle = new NotificationDisplayStyle(context); - this.notificationNoDisturbing = new NotificationNoDisturbing(context); - this.setting = new Setting(context); - this.context = context; - } - - /** - * 设置推送昵称。 - *

- * API使用示例: - *

 {@code
-     * EMService service;
-     *
-     * try {
-     *     service.push().updateUserNickname("username", "nickname").block();
-     * } catch (EMException e) {
-     *     e.getErrorCode();
-     *     e.getMessage();
-     * }
-     * }
- * - * @param username 用户名 - * @param nickname 推送昵称 - * @return {@code Mono} - * @see 设置推送昵称 - */ - public Mono updateUserNickname(String username, String nickname) { - try { - if (context.getProperties().getValidateUserName()) { - EMUser.validateUsername(username); - } - } catch (EMInvalidArgumentException e) { - return Mono.error(e); - } - return this.updateUserNickname.update(username, nickname); - } - - /** - * 设置推送消息展示方式,指客户端的推送通知栏展示消息的样式。 - *

- * API使用示例: - *

 {@code
-     * EMService service;
-     *
-     * try {
-     *     service.push().setNotificationDisplayStyle("username", DisplayStyle.DETAILS).block();
-     * } catch (EMException e) {
-     *     e.getErrorCode();
-     *     e.getMessage();
-     * }
-     * }
- * - * @param username 用户名 - * @param style 展示方式,DEFAULT 仅通知,DETAILS 通知以及消息详情 - * @return {@code Mono} - * @see 设置推送消息展示方式 - */ - public Mono setNotificationDisplayStyle(String username, DisplayStyle style) { - try { - if (context.getProperties().getValidateUserName()) { - EMUser.validateUsername(username); - } - } catch (EMInvalidArgumentException e) { - return Mono.error(e); - } - - if (style == DisplayStyle.DEFAULT) { - return this.notificationDisplayStyle.set(username, "0"); - } else { - return this.notificationDisplayStyle.set(username, "1"); - } - } - - /** - * 设置推送免打扰。 - *

- * 设置 IM 用户免打扰,在免打扰期间,用户将不会收到离线消息推送。 - *

- * API使用示例: - *

 {@code
-     * EMService service;
-     *
-     * try {
-     *     service.push().openNotificationNoDisturbing("username", 10, 13).block();
-     * } catch (EMException e) {
-     *     e.getErrorCode();
-     *     e.getMessage();
-     * }
-     * }
- * - * @param username 用户名 - * @param startTime 免打扰起始时间,单位是小时 - * @param endTime 免打扰结束时间,单位是小时 - * @return {@code Mono} - * @see 设置推送免打扰 - */ - public Mono openNotificationNoDisturbing(String username, int startTime, int endTime) { - try { - if (context.getProperties().getValidateUserName()) { - EMUser.validateUsername(username); - } - } catch (EMInvalidArgumentException e) { - return Mono.error(e); - } - - validateTime(startTime); - - validateTime(endTime); - - return this.notificationNoDisturbing - .open(username, String.valueOf(startTime), String.valueOf(endTime)); - } - - /** - * 取消推送免打扰。 - *

- * 设置 IM 用户免打扰,在免打扰期间,用户将不会收到离线消息推送。 - *

- * API使用示例: - *

 {@code
-     * EMService service;
-     *
-     * try {
-     *     service.push().closeNotificationNoDisturbing("username").block();
-     * } catch (EMException e) {
-     *     e.getErrorCode();
-     *     e.getMessage();
-     * }
-     * }
- * - * @param username 用户名 - * @return {@code Mono} - * @see 设置推送免打扰 - */ - public Mono closeNotificationNoDisturbing(String username) { - try { - if (context.getProperties().getValidateUserName()) { - EMUser.validateUsername(username); - } - } catch (EMInvalidArgumentException e) { - return Mono.error(e); - } - - return this.notificationNoDisturbing.close(username); - } - - /** - * 设置离线推送设置 - * - * @param username 用户名 - * @param conversationType 会话类型 - * @param conversationId 会话Id,单聊时为对端用户的用户 ID,群聊时为群组 ID - * @param notificationType 离线推送通知方式 - * @param ignoreInterval 离线推送免打扰时间段,精确到分钟,格式为 HH:MM-HH:MM,例如 08:30-10:00。 - * 该时间为 24 小时制,免打扰时间段的开始时间和结束时间中的小时数和分钟数的取值范围分别为 [00,23] 和 [00,59]。 - * 免打扰时段的设置仅针对 app 生效,对单聊或群聊不生效。如需设置 app 的免打扰时段,type 指定为 user,key 指定为当前用户 ID - * @param ignoreDuration 离线推送免打扰时长,单位为毫秒。该参数的取值范围为 [0,604800000],0 表示该参数无效,604800000 表示免打扰模式持续 7 天 - * @return {@code Mono} - * @see 设置离线推送设置 - */ - public Mono offlineSetting(String username, EMConversationType conversationType, - String conversationId, EMNotificationType notificationType, String ignoreInterval, - long ignoreDuration) { - - try { - if (context.getProperties().getValidateUserName()) { - EMUser.validateUsername(username); - } - } catch (EMInvalidArgumentException e) { - return Mono.error(e); - } - - return setting.execute(username, conversationType, conversationId, notificationType, - ignoreInterval, ignoreDuration); - } - - private void validateTime(int time) { - if (!(time >= 0 && time <= 23)) { - throw new EMInvalidArgumentException("no disturbing time should be between 0 and 23"); - } - } - -} diff --git a/im-sdk-core/src/main/java/com/easemob/im/server/api/push/displaystyle/set/DisplayStyle.java b/im-sdk-core/src/main/java/com/easemob/im/server/api/push/displaystyle/set/DisplayStyle.java deleted file mode 100644 index fc12777b7..000000000 --- a/im-sdk-core/src/main/java/com/easemob/im/server/api/push/displaystyle/set/DisplayStyle.java +++ /dev/null @@ -1,6 +0,0 @@ -package com.easemob.im.server.api.push.displaystyle.set; - -public enum DisplayStyle { - DEFAULT, - DETAILS -} diff --git a/im-sdk-core/src/main/java/com/easemob/im/server/api/push/displaystyle/set/NotificationDisplayStyle.java b/im-sdk-core/src/main/java/com/easemob/im/server/api/push/displaystyle/set/NotificationDisplayStyle.java deleted file mode 100644 index 58249beaf..000000000 --- a/im-sdk-core/src/main/java/com/easemob/im/server/api/push/displaystyle/set/NotificationDisplayStyle.java +++ /dev/null @@ -1,35 +0,0 @@ -package com.easemob.im.server.api.push.displaystyle.set; - -import com.easemob.im.server.api.Context; - -import com.easemob.im.server.api.DefaultErrorMapper; -import com.easemob.im.server.api.ErrorMapper; -import com.easemob.im.server.exception.EMUnknownException; -import reactor.core.publisher.Mono; - -public class NotificationDisplayStyle { - private Context context; - - public NotificationDisplayStyle(Context context) { - this.context = context; - } - - public Mono set(String username, String style) { - return this.context.getHttpClient() - .flatMap(httpClient -> httpClient.put() - .uri(String.format("/users/%s", username)) - .send(Mono.create(sink -> sink.success(this.context.getCodec() - .encode(new NotificationDisplayStyleRequest(style))))) - .responseSingle((rsp, buf) -> { - return buf.switchIfEmpty( - Mono.error(new EMUnknownException("response is null"))) - .flatMap(byteBuf -> { - ErrorMapper mapper = new DefaultErrorMapper(); - mapper.statusCode(rsp); - mapper.checkError(byteBuf); - return Mono.just(byteBuf); - }); - })) - .then(); - } -} diff --git a/im-sdk-core/src/main/java/com/easemob/im/server/api/push/displaystyle/set/NotificationDisplayStyleRequest.java b/im-sdk-core/src/main/java/com/easemob/im/server/api/push/displaystyle/set/NotificationDisplayStyleRequest.java deleted file mode 100644 index 29fcbbd77..000000000 --- a/im-sdk-core/src/main/java/com/easemob/im/server/api/push/displaystyle/set/NotificationDisplayStyleRequest.java +++ /dev/null @@ -1,15 +0,0 @@ -package com.easemob.im.server.api.push.displaystyle.set; - -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonProperty; - -public class NotificationDisplayStyleRequest { - - @JsonProperty("notification_display_style") - private String displayStyle; - - @JsonCreator - public NotificationDisplayStyleRequest(@JsonProperty("notification_display_style") String displayStyle) { - this.displayStyle = displayStyle; - } -} diff --git a/im-sdk-core/src/main/java/com/easemob/im/server/api/push/nickname/UpdateUserNickname.java b/im-sdk-core/src/main/java/com/easemob/im/server/api/push/nickname/UpdateUserNickname.java deleted file mode 100644 index e526ceca5..000000000 --- a/im-sdk-core/src/main/java/com/easemob/im/server/api/push/nickname/UpdateUserNickname.java +++ /dev/null @@ -1,36 +0,0 @@ -package com.easemob.im.server.api.push.nickname; - -import com.easemob.im.server.api.Context; -import com.easemob.im.server.api.DefaultErrorMapper; -import com.easemob.im.server.api.ErrorMapper; -import com.easemob.im.server.exception.EMUnknownException; -import reactor.core.publisher.Mono; - -public class UpdateUserNickname { - - private Context context; - - public UpdateUserNickname(Context context) { - this.context = context; - } - - public Mono update(String username, String nickname) { - return this.context.getHttpClient() - .flatMap(httpClient -> httpClient.put() - .uri(String.format("/users/%s", username)) - .send(Mono.create(sink -> sink.success(this.context.getCodec() - .encode(new UpdateUserNicknameRequest(nickname))))) - .responseSingle((rsp, buf) -> { - return buf.switchIfEmpty( - Mono.error(new EMUnknownException("response is null"))) - .flatMap(byteBuf -> { - ErrorMapper mapper = new DefaultErrorMapper(); - mapper.statusCode(rsp); - mapper.checkError(byteBuf); - return Mono.just(byteBuf); - }); - })) - .then(); - } - -} diff --git a/im-sdk-core/src/main/java/com/easemob/im/server/api/push/nickname/UpdateUserNicknameRequest.java b/im-sdk-core/src/main/java/com/easemob/im/server/api/push/nickname/UpdateUserNicknameRequest.java deleted file mode 100644 index 272e106ad..000000000 --- a/im-sdk-core/src/main/java/com/easemob/im/server/api/push/nickname/UpdateUserNicknameRequest.java +++ /dev/null @@ -1,20 +0,0 @@ -package com.easemob.im.server.api.push.nickname; - - -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonProperty; - -public class UpdateUserNicknameRequest { - - @JsonProperty("nickname") - private String nickname; - - @JsonCreator - public UpdateUserNicknameRequest(@JsonProperty("nickname") String nickname) { - this.nickname = nickname; - } - - public String getNickname() { - return nickname; - } -} diff --git a/im-sdk-core/src/main/java/com/easemob/im/server/api/push/nodisturbing/NotificationNoDisturbing.java b/im-sdk-core/src/main/java/com/easemob/im/server/api/push/nodisturbing/NotificationNoDisturbing.java deleted file mode 100644 index 74761e895..000000000 --- a/im-sdk-core/src/main/java/com/easemob/im/server/api/push/nodisturbing/NotificationNoDisturbing.java +++ /dev/null @@ -1,55 +0,0 @@ -package com.easemob.im.server.api.push.nodisturbing; - -import com.easemob.im.server.api.Context; -import com.easemob.im.server.api.DefaultErrorMapper; -import com.easemob.im.server.api.ErrorMapper; -import com.easemob.im.server.api.push.nodisturbing.close.CloseNotificationNoDisturbingRequest; -import com.easemob.im.server.api.push.nodisturbing.open.OpenNotificationNoDisturbingRequest; -import com.easemob.im.server.exception.EMUnknownException; -import reactor.core.publisher.Mono; - -public class NotificationNoDisturbing { - private Context context; - - public NotificationNoDisturbing(Context context) { - this.context = context; - } - - public Mono open(String username, String startTime, String endTime) { - return this.context.getHttpClient() - .flatMap(httpClient -> httpClient.put() - .uri(String.format("/users/%s", username)) - .send(Mono.create(sink -> sink.success(this.context.getCodec() - .encode(new OpenNotificationNoDisturbingRequest(startTime, endTime))))) - .responseSingle((rsp, buf) -> { - return buf.switchIfEmpty( - Mono.error(new EMUnknownException("response is null"))) - .flatMap(byteBuf -> { - ErrorMapper mapper = new DefaultErrorMapper(); - mapper.statusCode(rsp); - mapper.checkError(byteBuf); - return Mono.just(byteBuf); - }); - })) - .then(); - } - - public Mono close(String username) { - return this.context.getHttpClient() - .flatMap(httpClient -> httpClient.put() - .uri(String.format("/users/%s", username)) - .send(Mono.create(sink -> sink.success(this.context.getCodec() - .encode(new CloseNotificationNoDisturbingRequest())))) - .responseSingle((rsp, buf) -> { - return buf.switchIfEmpty( - Mono.error(new EMUnknownException("response is null"))) - .flatMap(byteBuf -> { - ErrorMapper mapper = new DefaultErrorMapper(); - mapper.statusCode(rsp); - mapper.checkError(byteBuf); - return Mono.just(byteBuf); - }); - })) - .then(); - } -} diff --git a/im-sdk-core/src/main/java/com/easemob/im/server/api/push/nodisturbing/close/CloseNotificationNoDisturbingRequest.java b/im-sdk-core/src/main/java/com/easemob/im/server/api/push/nodisturbing/close/CloseNotificationNoDisturbingRequest.java deleted file mode 100644 index a5b1332fb..000000000 --- a/im-sdk-core/src/main/java/com/easemob/im/server/api/push/nodisturbing/close/CloseNotificationNoDisturbingRequest.java +++ /dev/null @@ -1,14 +0,0 @@ -package com.easemob.im.server.api.push.nodisturbing.close; - -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonProperty; - -public class CloseNotificationNoDisturbingRequest { - @JsonProperty("notification_no_disturbing") - private Boolean noDisturbing; - - @JsonCreator - public CloseNotificationNoDisturbingRequest() { - this.noDisturbing = false; - } -} diff --git a/im-sdk-core/src/main/java/com/easemob/im/server/api/push/nodisturbing/open/OpenNotificationNoDisturbingRequest.java b/im-sdk-core/src/main/java/com/easemob/im/server/api/push/nodisturbing/open/OpenNotificationNoDisturbingRequest.java deleted file mode 100644 index d6e0d4552..000000000 --- a/im-sdk-core/src/main/java/com/easemob/im/server/api/push/nodisturbing/open/OpenNotificationNoDisturbingRequest.java +++ /dev/null @@ -1,25 +0,0 @@ -package com.easemob.im.server.api.push.nodisturbing.open; - -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonProperty; - -public class OpenNotificationNoDisturbingRequest { - - @JsonProperty("notification_no_disturbing") - private Boolean noDisturbing; - - @JsonProperty("notification_no_disturbing_start") - private String startTime; - - @JsonProperty("notification_no_disturbing_end") - private String endTime; - - @JsonCreator - public OpenNotificationNoDisturbingRequest( - @JsonProperty("notification_no_disturbing_start") String startTime, - @JsonProperty("notification_no_disturbing_end") String endTime) { - this.noDisturbing = true; - this.startTime = startTime; - this.endTime = endTime; - } -} diff --git a/im-sdk-core/src/main/java/com/easemob/im/server/api/push/offline/Setting.java b/im-sdk-core/src/main/java/com/easemob/im/server/api/push/offline/Setting.java deleted file mode 100644 index f8c4ed40c..000000000 --- a/im-sdk-core/src/main/java/com/easemob/im/server/api/push/offline/Setting.java +++ /dev/null @@ -1,40 +0,0 @@ -package com.easemob.im.server.api.push.offline; - -import com.easemob.im.server.api.Context; -import com.easemob.im.server.api.DefaultErrorMapper; -import com.easemob.im.server.api.ErrorMapper; -import com.easemob.im.server.exception.EMUnknownException; -import com.easemob.im.server.model.EMConversationType; -import com.easemob.im.server.model.EMNotificationType; -import reactor.core.publisher.Mono; - -public class Setting { - private Context context; - - public Setting(Context context) { - this.context = context; - } - - public Mono execute(String username, EMConversationType conversationType, - String conversationId, EMNotificationType notificationType, String ignoreInterval, - long ignoreDuration) { - return this.context.getHttpClient() - .flatMap(httpClient -> httpClient.put() - .uri(String.format("/users/%s/notification/%s/%s", username, - conversationType.getConversationType(), conversationId)) - .send(Mono.create(sink -> sink.success(this.context.getCodec() - .encode(new SettingRequest(notificationType.getNotificationType(), - ignoreInterval, ignoreDuration))))) - .responseSingle((rsp, buf) -> { - return buf.switchIfEmpty( - Mono.error(new EMUnknownException("response is null"))) - .flatMap(byteBuf -> { - ErrorMapper mapper = new DefaultErrorMapper(); - mapper.statusCode(rsp); - mapper.checkError(byteBuf); - return Mono.just(byteBuf); - }); - })) - .then(); - } -} diff --git a/im-sdk-core/src/main/java/com/easemob/im/server/api/push/offline/SettingRequest.java b/im-sdk-core/src/main/java/com/easemob/im/server/api/push/offline/SettingRequest.java deleted file mode 100644 index 7ef729921..000000000 --- a/im-sdk-core/src/main/java/com/easemob/im/server/api/push/offline/SettingRequest.java +++ /dev/null @@ -1,38 +0,0 @@ -package com.easemob.im.server.api.push.offline; - - -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonProperty; - -public class SettingRequest { - - @JsonProperty("type") - private String type; - - @JsonProperty("ignoreInterval") - private String ignoreInterval; - - @JsonProperty("ignoreDuration") - private long ignoreDuration; - - @JsonCreator - public SettingRequest(@JsonProperty("type") String type, - @JsonProperty("ignoreInterval") String ignoreInterval, - @JsonProperty("ignoreDuration") long ignoreDuration) { - this.type = type; - this.ignoreInterval = ignoreInterval; - this.ignoreDuration = ignoreDuration; - } - - public String getType() { - return type; - } - - public String getIgnoreInterval() { - return ignoreInterval; - } - - public long getIgnoreDuration() { - return ignoreDuration; - } -} diff --git a/im-sdk-core/src/main/java/com/easemob/im/server/api/room/RoomApi.java b/im-sdk-core/src/main/java/com/easemob/im/server/api/room/RoomApi.java deleted file mode 100644 index 2d6db7f72..000000000 --- a/im-sdk-core/src/main/java/com/easemob/im/server/api/room/RoomApi.java +++ /dev/null @@ -1,796 +0,0 @@ -package com.easemob.im.server.api.room; - -import com.easemob.im.server.api.Context; -import com.easemob.im.server.api.room.admin.demote.DemoteRoomAdmin; -import com.easemob.im.server.api.room.admin.list.ListRoomAdmins; -import com.easemob.im.server.api.room.admin.promote.PromoteRoomAdmin; -import com.easemob.im.server.api.room.announcement.RoomAnnouncement; -import com.easemob.im.server.api.room.assign.AssignRoom; -import com.easemob.im.server.api.room.create.CreateRoom; -import com.easemob.im.server.api.room.delete.DeleteRoom; -import com.easemob.im.server.api.room.detail.GetRoomDetail; -import com.easemob.im.server.api.room.list.ListRooms; -import com.easemob.im.server.api.room.member.add.AddRoomMember; -import com.easemob.im.server.api.room.member.list.ListRoomMembers; -import com.easemob.im.server.api.room.member.list.ListRoomMembersResponseV1; -import com.easemob.im.server.api.room.member.remove.RemoveRoomMember; -import com.easemob.im.server.api.room.superadmin.demote.DemoteRoomSuperAdmin; -import com.easemob.im.server.api.room.superadmin.list.ListRoomSuperAdmins; -import com.easemob.im.server.api.room.superadmin.promote.PromoteRoomSuperAdmin; -import com.easemob.im.server.api.room.update.UpdateRoom; -import com.easemob.im.server.api.room.update.UpdateRoomRequest; -import com.easemob.im.server.model.EMGroup; -import com.easemob.im.server.model.EMPage; -import com.easemob.im.server.model.EMRoom; -import reactor.core.publisher.Flux; -import reactor.core.publisher.Mono; - -import java.util.List; -import java.util.Map; -import java.util.function.Consumer; - -/** - * 聊天室API。 - */ -public class RoomApi { - - private CreateRoom createRoom; - - private GetRoomDetail getRoomDetail; - - private UpdateRoom updateRoom; - - private ListRooms listRooms; - - private ListRoomMembers listRoomMembers; - - private AddRoomMember addRoomMember; - - private RemoveRoomMember removeRoomMember; - - private ListRoomAdmins listRoomAdmins; - - private PromoteRoomAdmin promoteRoomAdmin; - - private DemoteRoomAdmin demoteRoomAdmin; - - private ListRoomSuperAdmins listRoomSuperAdmins; - - private PromoteRoomSuperAdmin promoteRoomSuperAdmin; - - private DemoteRoomSuperAdmin demoteRoomSuperAdmin; - - private DeleteRoom deleteRoom; - - private AssignRoom assignRoom; - - private RoomAnnouncement roomAnnouncement; - - public RoomApi(Context context) { - this.createRoom = new CreateRoom(context); - this.getRoomDetail = new GetRoomDetail(context); - this.updateRoom = new UpdateRoom(context); - this.listRooms = new ListRooms(context); - this.listRoomMembers = new ListRoomMembers(context); - this.addRoomMember = new AddRoomMember(context); - this.removeRoomMember = new RemoveRoomMember(context); - this.listRoomAdmins = new ListRoomAdmins(context); - this.promoteRoomAdmin = new PromoteRoomAdmin(context); - this.demoteRoomAdmin = new DemoteRoomAdmin(context); - this.listRoomSuperAdmins = new ListRoomSuperAdmins(context); - this.promoteRoomSuperAdmin = new PromoteRoomSuperAdmin(context); - this.demoteRoomSuperAdmin = new DemoteRoomSuperAdmin(context); - this.deleteRoom = new DeleteRoom(context); - this.assignRoom = new AssignRoom(context); - this.roomAnnouncement=new RoomAnnouncement(context); - } - - /** - * 创建聊天室。 - *

- * API使用示例: - *

 {@code
-     * EMService service;
-     * List members = new ArrayList<>();
-     * members.add("userA");
-     *
-     * try {
-     *     String roomId = service.room().createRoom("name", "description", "owner", members, 200).block();
-     * } catch (EMException e) {
-     *     e.getErrorCode();
-     *     e.getMessage();
-     * }
-     * }
- * - * @param name 聊天室名称 - * @param description 聊天室描述 - * @param owner 聊天室主 - * @param members 聊天室初始成员的用户名列表 - * @param maxMembers 聊天室最大成员数 - * @return 聊天室id或错误 - * @see 创建聊天室 - */ - public Mono createRoom(String name, String description, String owner, - List members, int maxMembers) { - return this.createRoom.createRoom(name, description, owner, members, maxMembers); - } - - /** - * 创建聊天室。 - *

- * API使用示例: - *

 {@code
-     * EMService service;
-     * List members = new ArrayList<>();
-     * members.add("userA");
-     *
-     * try {
-     *     String roomId = service.room().createRoom("name", "description", "owner", members, 200).block();
-     * } catch (EMException e) {
-     *     e.getErrorCode();
-     *     e.getMessage();
-     * }
-     * }
- * - * @param name 聊天室名称 - * @param description 聊天室描述 - * @param owner 聊天室主 - * @param members 聊天室初始成员的用户名列表 - * @param maxMembers 聊天室最大成员数 - * @param custom 聊天室扩展信息,例如可以给聊天室添加业务相关的标记 - * @return 聊天室id或错误 - * @see 创建聊天室 - */ - public Mono createRoom(String name, String description, String owner, - List members, int maxMembers, String custom) { - return this.createRoom.createRoom(name, description, owner, members, maxMembers, custom); - } - - /** - * 创建聊天室。 - *

- * API使用示例: - *

 {@code
-     * EMService service;
-     * List members = new ArrayList<>();
-     * members.add("userA");
-     *
-     * try {
-     *     String roomId = service.room().createRoom("name", "description", "owner", members, 200, "custom", true).block();
-     * } catch (EMException e) {
-     *     e.getErrorCode();
-     *     e.getMessage();
-     * }
-     * }
- * - * @param name 聊天室名称 - * @param description 聊天室描述 - * @param owner 聊天室主 - * @param members 聊天室初始成员的用户名列表 - * @param maxMembers 聊天室最大成员数 - * @param custom 聊天室扩展信息,例如可以给聊天室添加业务相关的标记 - * @param needVerify 是否审核聊天室名称(付费功能,需联系商务开通) - * @return 聊天室id或错误 - * @see 创建聊天室 - */ - public Mono createRoom(String name, String description, String owner, - List members, int maxMembers, String custom, Boolean needVerify) { - return this.createRoom.createRoom(name, description, owner, members, maxMembers, custom, needVerify); - } - - /** - * 获取聊天室详情。 - *

- * API使用示例: - *

 {@code
-     * EMService service;
-     * try {
-     *     EMRoom room = service.room().getRoom(roomId).block();
-     *     String roomName = room.name();
-     *     String roomDescription = room.description();
-     * } catch (EMException e) {
-     *     e.getErrorCode();
-     *     e.getMessage();
-     * }
-     * }
- * - * @param id 聊天室id - * @return 聊天室详情或错误. - * @see 获取聊天室详情 - */ - public Mono getRoom(String id) { - return this.getRoomDetail.byId(id); - } - - /** - * 获取多个聊天室详情。 - *

- * API使用示例: - *

 {@code
-     * EMService service;
-     * try {
-     *     List roomIdList = new ArrayList<>();
-     *     roomIdList.add("193100825821185");
-     *     roomIdList.add("193100825821186");
-     *
-     *     List roomList = service.group().getRoomList(roomIdList).block();
-     * } catch (EMException e) {
-     *     e.getErrorCode();
-     *     e.getMessage();
-     * }
-     * }
- * - * @param roomIdList 聊天室id列表 - * @return 聊天室情或错误 - * @see 获取聊天室详情 - */ - public Mono> getRoomList(List roomIdList) { - return this.getRoomDetail.byIds(roomIdList); - } - - /** - * 修改聊天室。 - *

- * 可修改的字段参考 {@link com.easemob.im.server.api.room.update.UpdateRoomRequest UpdateRoomRequest} - *

- * API使用示例: - *

- * 比如,要更新聊天室名称,可以这么做: - *

{@code
-     * EMService service;
-     * try {
-     *     service.updateRoom(roomId, request -> request.withName("some cool name")).block();
-     * } catch (EMException e) {
-     *     e.getErrorCode();
-     *     e.getMessage();
-     * }
-     * }
- * - * @param id 聊天室id - * @param customizer 更新请求定制函数 - * @return 成功或错误 - * @see com.easemob.im.server.api.room.update.UpdateRoomRequest - * @see 修改聊天室 - */ - public Mono updateRoom(String id, Consumer customizer) { - return this.updateRoom.byId(id, customizer); - } - - /** - * 获取全部聊天室列表 - *

- * API使用示例: - *

 {@code
-     * EMService service;
-     * try {
-     *     List rooms = service.room().listRoomsAll().collectList().block();
-     * } catch (EMException e) {
-     *     e.getErrorCode();
-     *     e.getMessage();
-     * }
-     * }
- * - * @return 每个聊天室的id或错误 - * @see 获取聊天室列表 - */ - public Flux listRoomsAll() { - return this.listRooms.all(10); - } - - /** - * 分页获取聊天室列表 - *

- * API使用示例: - *

 {@code
-     * EMService service;
-     * EMPage page = null;
-     * try {
-     *     service.room().listRooms(10, null).block();
-     *     List roomIds = page.getValues();
-     *     System.out.println("聊天室列表:" + roomIds);
-     * } catch (EMException e) {
-     *     e.getErrorCode();
-     *     e.getMessage();
-     * }
-     *
-     * // ... do something with the roomIds ...
-     * if (page != null) {
-     *      String cursor = page.getCursor();
-     *      // cursor == null indicates the end of the list
-     *      while (cursor != null) {
-     *              try {
-     *                  page = service.room().listRooms(10, cursor).block();
-     *                  System.out.println("聊天室列表:" + page.getValues());
-     *                  // ... do something to the roomIds ...
-     *                  cursor = page.getCursor();
-     *              } catch (EMException e) {
-     *                  e.getErrorCode();
-     *                  e.getMessage();
-     *              }
-     *      }
-     * }
-     * }
- * - * @param limit 返回多少个聊天室id - * @param cursor 开始位置 - * @return 获取聊天室响应或错误 - * @see 获取聊天室列表 - */ - public Mono> listRooms(int limit, String cursor) { - return this.listRooms.next(limit, cursor); - } - - /** - * 获取用户加入的聊天室列表。 - *

- * API使用示例: - *

 {@code
-     * EMService service;
-     * try {
-     *     List rooms = service.room().listRoomsUserJoined("username").collectList().block();
-     * } catch (EMException e) {
-     *     e.getErrorCode();
-     *     e.getMessage();
-     * }
-     * }
- * - * @param username 用户名 - * @return 每个聊天室的id或错误 - * @see 获取用户加入的聊天室 - */ - public Flux listRoomsUserJoined(String username) { - return this.listRooms.userJoined(username); - } - - /** - * 获取聊天室全部成员列表。 - *

- * API使用示例: - *

 {@code
-     * EMService service;
-     * try {
-     *     List members = service.room().listRoomMembersAll("roomId").collectList().block();
-     * } catch (EMException e) {
-     *     e.getErrorCode();
-     *     e.getMessage();
-     * }
-     * }
- * - * @param roomId 聊天室id - * @return 每个聊天室成员或者错误 - * @see 获取聊天室成员 - */ - public Flux listRoomMembersAll(String roomId) { - return this.listRoomMembers.all(roomId, 10, null); - } - - /** - * 获取聊天室全部成员列表。 - *

- * API使用示例: - *

 {@code
-     * EMService service;
-     * try {
-     *     List members = service.room().listRoomMembersAll("roomId", "asc").collectList().block();
-     * } catch (EMException e) {
-     *     e.getErrorCode();
-     *     e.getMessage();
-     * }
-     * }
- * - * @param roomId 聊天室id - * @param sort 聊天室成员排序方法 asc:根据加入顺序升序排序 desc:根据加入顺序降序排序 - * @return 每个聊天室成员或者错误 - * @see 获取聊天室成员 - */ - public Flux listRoomMembersAll(String roomId, String sort) { - return this.listRoomMembers.all(roomId, 10, sort); - } - - /** - * 获取聊天室全部成员列表,包括聊天室的 Owner。 - *

- * API使用示例: - *

 {@code
-     * EMService service;
-     * try {
-     *     List> members = service.room().listRoomMembersAllWithOwner("roomId").collectList().block();
-     * } catch (EMException e) {
-     *     e.getErrorCode();
-     *     e.getMessage();
-     * }
-     * }
- * - * @param roomId 聊天室id - * @return 每个聊天室成员或者错误 - * @see 获取聊天室成员 - */ - public Flux> listRoomMembersAllWithOwner(String roomId) { - return this.listRoomMembers.all(roomId, 10); - } - - /** - * 分页获取聊天室成员列表。 - *

- * API使用示例: - *

 {@code
-     * EMService service;
-     * EMPage page = null;
-     * try {
-     *     EMPage page = service.room().listRoomMembers(roomId, 1, null).block();
-     *     List members = page.getValues();
-     *     System.out.println("聊天室成员列表:" + members);
-     * } catch (EMException e) {
-     *     e.getErrorCode();
-     *     e.getMessage();
-     * }
-     *
-     * // ... do something with the roomIds ...
-     * if (page != null) {
-     *      String cursor = page.getCursor();
-     *      // cursor == null indicates the end of the list
-     *      while (cursor != null) {
-     *              try {
-     *                  page = service.room().listRoomMembers(roomId, 1, cursor).block();
-     *                  System.out.println("聊天室成员列表:" + page.getValues());
-     *                  // ... do something to the members ...
-     *                  cursor = page.getCursor();
-     *              } catch (EMException e) {
-     *                  e.getErrorCode();
-     *                  e.getMessage();
-     *              }
-     *      }
-     * }
-     * }
- * - * @param roomId 聊天室id - * @param limit 返回多少个聊天室成员 - * @param cursor 开始位置 - * @return 获取聊天室成员响应或错误 - * @see 获取聊天室成员 - */ - public Mono> listRoomMembers(String roomId, int limit, String cursor) { - return this.listRoomMembers.next(roomId, limit, cursor, null); - } - - /** - * 分页获取聊天室成员列表,包括聊天室的 Owner。 - *

- * API使用示例: - *

 {@code
-     * EMService service;
-     * EMPage page = null;
-     * try {
-     *     List> members = service.room().listRoomMembers(roomId, 1, 10).block();
-     *     System.out.println("聊天室成员列表:" + members);
-     * } catch (EMException e) {
-     *     e.getErrorCode();
-     *     e.getMessage();
-     * }
-     *}
- * - * @param roomId 聊天室id - * @param pageNum 当前页码。默认从第 1 页开始获取 - * @param pageSize 每页期望返回的群组成员数量。取值范围为[1,100]。默认为 10。 - * @return 获取聊天室成员响应或错误 - * @see 获取聊天室成员 - */ - public Mono>> listRoomMembersWithOwner(String roomId, int pageNum, int pageSize) { - return this.listRoomMembers.next(roomId, pageNum, pageSize).map( - ListRoomMembersResponseV1::getMembers); - } - - /** - * 分页获取聊天室成员列表。 - *

- * API使用示例: - *

 {@code
-     * EMService service;
-     * EMPage page = null;
-     * try {
-     *     EMPage page = service.room().listRoomMembers(roomId, 1, null, "asc").block();
-     *     List members = page.getValues();
-     *     System.out.println("聊天室成员列表:" + members);
-     * } catch (EMException e) {
-     *     e.getErrorCode();
-     *     e.getMessage();
-     * }
-     *
-     * // ... do something with the roomIds ...
-     * if (page != null) {
-     *      String cursor = page.getCursor();
-     *      // cursor == null indicates the end of the list
-     *      while (cursor != null) {
-     *              try {
-     *                  page = service.room().listRoomMembers(roomId, 1, cursor, "asc").block();
-     *                  System.out.println("聊天室成员列表:" + page.getValues());
-     *                  // ... do something to the members ...
-     *                  cursor = page.getCursor();
-     *              } catch (EMException e) {
-     *                  e.getErrorCode();
-     *                  e.getMessage();
-     *              }
-     *      }
-     * }
-     * }
- * - * @param roomId 聊天室id - * @param limit 返回多少个聊天室成员 - * @param cursor 开始位置 - * @param sort 聊天室成员排序方法 asc:根据加入顺序升序排序 desc:根据加入顺序降序排序 - * @return 获取聊天室成员响应或错误 - * @see 获取聊天室成员 - */ - public Mono> listRoomMembers(String roomId, int limit, String cursor, String sort) { - return this.listRoomMembers.next(roomId, limit, cursor, sort); - } - - /**m - * 向聊天室添加成员。 - *

- * API使用示例: - *

 {@code
-     * EMService service;
-     * try {
-     *     service.room().addRoomMember("roomId", "username").block();
-     * } catch (EMException e) {
-     *     e.getErrorCode();
-     *     e.getMessage();
-     * }
-     * }
- * - * @param roomId 聊天室id - * @param username 要添加的用户的用户名 - * @return 成功或错误 - * @see 聊天室添加成员 - */ - public Mono addRoomMember(String roomId, String username) { - return this.addRoomMember.single(roomId, username); - } - - /** - * 从聊天室移除成员。 - *

- * API使用示例: - *

 {@code
-     * EMService service;
-     * try {
-     *     service.room().removeRoomMember("roomId", "username").block();
-     * } catch (EMException e) {
-     *     e.getErrorCode();
-     *     e.getMessage();
-     * }
-     * }
- * - * @param roomId 聊天室id - * @param username 要移除的成员的用户名 - * @return 成功或错误 - * @see 聊天室移除成员 - */ - public Mono removeRoomMember(String roomId, String username) { - return this.removeRoomMember.single(roomId, username); - } - - /** - * 获取聊天室管理员。 - *

- * API使用示例: - *

 {@code
-     * EMService service;
-     * try {
-     *     List admins = service.room().listRoomAdminsAll("roomId").collectList().block();
-     * } catch (EMException e) {
-     *     e.getErrorCode();
-     *     e.getMessage();
-     * }
-     * }
- * - * @param roomId 聊天室id - * @return 每个管理员的用户名或错误 - * @see 获取聊天室管理员 - */ - public Flux listRoomAdminsAll(String roomId) { - return this.listRoomAdmins.all(roomId); - } - - /** - * 升级聊天室成员至管理员。 - *

- * API使用示例: - *

 {@code
-     * EMService service;
-     * try {
-     *     service.room().promoteRoomAdmin("roomId", "username").block();
-     * } catch (EMException e) {
-     *     e.getErrorCode();
-     *     e.getMessage();
-     * }
-     * }
- * - * @param roomId 聊天室id - * @param username 要升级的成员的用户名 - * @return 成功或错误 - * @see 添加聊天室管理员 - */ - public Mono promoteRoomAdmin(String roomId, String username) { - return this.promoteRoomAdmin.single(roomId, username); - } - - /** - * 降级聊天室管理员至成员。 - *

- * API使用示例: - *

 {@code
-     * EMService service;
-     * try {
-     *     service.room().demoteRoomAdmin("roomId", "username").block();
-     * } catch (EMException e) {
-     *     e.getErrorCode();
-     *     e.getMessage();
-     * }
-     * }
- * - * @param roomId 聊天室id - * @param username 要降级的管理员的用户名 - * @return 成功或错误 - * @see 移除聊天室管理员 - */ - public Mono demoteRoomAdmin(String roomId, String username) { - return this.demoteRoomAdmin.single(roomId, username); - } - - /** - * 获取所有超级管理员列表。 - *

- * API使用示例: - *

 {@code
-     * EMService service;
-     * try {
-     *     List superAdmins = service.room().listRoomSuperAdminsAll().collectList().block();
-     * } catch (EMException e) {
-     *     e.getErrorCode();
-     *     e.getMessage();
-     * }
-     * }
- * - * @return 所有超级管理员的用户名 - * @see 分页获取聊天室超级管理员列表 - */ - public Flux listRoomSuperAdminsAll() { - return this.listRoomSuperAdmins.all(1); - } - - /** - * 升级用户为超级管理员,只有超级管理员有权限创建聊天室。 - *

- * API使用示例: - *

 {@code
-     * EMService service;
-     * try {
-     *     service.room().promoteRoomSuperAdmin("username").block();
-     * } catch (EMException e) {
-     *     e.getErrorCode();
-     *     e.getMessage();
-     * }
-     * }
- * - * @param username 要升级的用户的用户名 - * @return 成功或错误 - * @see 添加超级管理员 - */ - public Mono promoteRoomSuperAdmin(String username) { - return this.promoteRoomSuperAdmin.single(username); - } - - /** - * 降级超级管理员为普通用户 - *

- * API使用示例: - *

 {@code
-     * EMService service;
-     * try {
-     *     service.room().demoteRoomSuperAdmin("username").block();
-     * } catch (EMException e) {
-     *     e.getErrorCode();
-     *     e.getMessage();
-     * }
-     * }
- * - * @param username 要降级的超级管理员的用户名 - * @return 成功或错误 - * @see 移除超级管理员 - */ - public Mono demoteRoomSuperAdmin(String username) { - return this.demoteRoomSuperAdmin.single(username); - } - - /** - * 注销聊天室 - *

- * 请谨慎使用。 - *

- * API使用示例: - *

 {@code
-     * EMService service;
-     * try {
-     *     service.room().destroyRoom("roomId").block();
-     * } catch (EMException e) {
-     *     e.getErrorCode();
-     *     e.getMessage();
-     * }
-     * }
- * - * @param roomId 聊天室id - * @return 成功或错误 - * @see 删除聊天室 - */ - public Mono destroyRoom(String roomId) { - return this.deleteRoom.byId(roomId); - } - - /** - * 转让聊天室。 - *

- * API使用示例: - *

 {@code
-     * EMService service;
-     * try {
-     *     service.room().assignRoom("chatroomId", "newOwner").block();
-     * } catch (EMException e) {
-     *     e.getErrorCode();
-     *     e.getMessage();
-     * }
-     * }
- * - * @param chatroomId 聊天室id - * @param newOwner 被转让聊天室的用户名 - * @return 成功或错误 - */ - public Mono assignRoom(String chatroomId, String newOwner){ - return this.assignRoom.execute(chatroomId, newOwner); - } - - /** - * 获取聊天室公告。 - *

- * API使用示例: - *

 {@code
-     * EMService service;
-     * try {
-     *     String roomAnnouncement = service.room().getRoomAnnouncement("roomId").block();
-     * } catch (EMException e) {
-     *     e.getErrorCode();
-     *     e.getMessage();
-     * }
-     * }
- * - * @param chatroomId 聊天室id - * @return 聊天室公告或错误 - */ - public Mono getRoomAnnouncement(String chatroomId) { - return this.roomAnnouncement.get(chatroomId); - } - - /** - * 更新聊天室公告。 - *

- * API使用示例: - *

 {@code
-     * EMService service;
-     * try {
-     *     service.room().updateRoomAnnouncement("chatroomId", "announcement").block();
-     * } catch (EMException e) {
-     *     e.getErrorCode();
-     *     e.getMessage();
-     * }
-     * }
- * - * @param chatroomId 聊天室id - * @param announcement 聊天室公告 - * @return 成功或错误 - */ - public Mono updateRoomAnnouncement(String chatroomId, String announcement) { - return this.roomAnnouncement.set(chatroomId, announcement); - } - -} diff --git a/im-sdk-core/src/main/java/com/easemob/im/server/api/room/admin/demote/DemoteRoomAdmin.java b/im-sdk-core/src/main/java/com/easemob/im/server/api/room/admin/demote/DemoteRoomAdmin.java deleted file mode 100644 index 8cd749ef2..000000000 --- a/im-sdk-core/src/main/java/com/easemob/im/server/api/room/admin/demote/DemoteRoomAdmin.java +++ /dev/null @@ -1,40 +0,0 @@ -package com.easemob.im.server.api.room.admin.demote; - -import com.easemob.im.server.api.Context; -import com.easemob.im.server.api.DefaultErrorMapper; -import com.easemob.im.server.api.ErrorMapper; -import com.easemob.im.server.exception.EMUnknownException; -import reactor.core.publisher.Mono; - -public class DemoteRoomAdmin { - - private Context context; - - public DemoteRoomAdmin(Context context) { - this.context = context; - } - - public Mono single(String roomId, String username) { - return this.context.getHttpClient() - .flatMap(httpClient -> httpClient.delete() - .uri(String.format("/chatrooms/%s/admin/%s", roomId, username)) - .responseSingle((rsp, buf) -> { - return buf.switchIfEmpty( - Mono.error(new EMUnknownException("response is null"))) - .flatMap(byteBuf -> { - ErrorMapper mapper = new DefaultErrorMapper(); - mapper.statusCode(rsp); - mapper.checkError(byteBuf); - return Mono.just(byteBuf); - }); - })) - .map(buf -> this.context.getCodec().decode(buf, DemoteRoomAdminResponse.class)) - .handle((rsp, sink) -> { - if (!rsp.isSuccess()) { - sink.error(new EMUnknownException("unknown")); - return; - } - sink.complete(); - }); - } -} diff --git a/im-sdk-core/src/main/java/com/easemob/im/server/api/room/admin/demote/DemoteRoomAdminResponse.java b/im-sdk-core/src/main/java/com/easemob/im/server/api/room/admin/demote/DemoteRoomAdminResponse.java deleted file mode 100644 index 07a4f9bde..000000000 --- a/im-sdk-core/src/main/java/com/easemob/im/server/api/room/admin/demote/DemoteRoomAdminResponse.java +++ /dev/null @@ -1,36 +0,0 @@ -package com.easemob.im.server.api.room.admin.demote; - -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonProperty; - -public class DemoteRoomAdminResponse { - @JsonProperty("data") - private Wrapper wrapper; - - @JsonCreator - public DemoteRoomAdminResponse(@JsonProperty("data") Wrapper wrapper) { - this.wrapper = wrapper; - } - - public boolean isSuccess() { - return this.wrapper != null && "success".equals(this.wrapper.getResult()); - } - - public static class Wrapper { - @JsonProperty("result") - private String result; - @JsonProperty("oldadmin") - private String username; - - @JsonCreator - public Wrapper(@JsonProperty("result") String result, - @JsonProperty("oldadmin") String username) { - this.result = result; - this.username = username; - } - - public String getResult() { - return this.result; - } - } -} diff --git a/im-sdk-core/src/main/java/com/easemob/im/server/api/room/admin/list/ListRoomAdmins.java b/im-sdk-core/src/main/java/com/easemob/im/server/api/room/admin/list/ListRoomAdmins.java deleted file mode 100644 index fe66f7721..000000000 --- a/im-sdk-core/src/main/java/com/easemob/im/server/api/room/admin/list/ListRoomAdmins.java +++ /dev/null @@ -1,35 +0,0 @@ -package com.easemob.im.server.api.room.admin.list; - -import com.easemob.im.server.api.Context; -import com.easemob.im.server.api.DefaultErrorMapper; -import com.easemob.im.server.api.ErrorMapper; -import com.easemob.im.server.exception.EMUnknownException; -import reactor.core.publisher.Flux; -import reactor.core.publisher.Mono; - -public class ListRoomAdmins { - - private Context context; - - public ListRoomAdmins(Context context) { - this.context = context; - } - - public Flux all(String roomId) { - return this.context.getHttpClient() - .flatMap(httpClient -> httpClient.get() - .uri(String.format("/chatrooms/%s/admin", roomId)) - .responseSingle((rsp, buf) -> { - return buf.switchIfEmpty( - Mono.error(new EMUnknownException("response is null"))) - .flatMap(byteBuf -> { - ErrorMapper mapper = new DefaultErrorMapper(); - mapper.statusCode(rsp); - mapper.checkError(byteBuf); - return Mono.just(byteBuf); - }); - })) - .map(buf -> this.context.getCodec().decode(buf, ListRoomAdminsResponse.class)) - .flatMapIterable(ListRoomAdminsResponse::getAdmins); - } -} diff --git a/im-sdk-core/src/main/java/com/easemob/im/server/api/room/admin/list/ListRoomAdminsResponse.java b/im-sdk-core/src/main/java/com/easemob/im/server/api/room/admin/list/ListRoomAdminsResponse.java deleted file mode 100644 index 3c5d6381a..000000000 --- a/im-sdk-core/src/main/java/com/easemob/im/server/api/room/admin/list/ListRoomAdminsResponse.java +++ /dev/null @@ -1,20 +0,0 @@ -package com.easemob.im.server.api.room.admin.list; - -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonProperty; - -import java.util.List; - -public class ListRoomAdminsResponse { - @JsonProperty("data") - private List admins; - - @JsonCreator - public ListRoomAdminsResponse(@JsonProperty("data") List admins) { - this.admins = admins; - } - - public List getAdmins() { - return this.admins; - } -} diff --git a/im-sdk-core/src/main/java/com/easemob/im/server/api/room/admin/promote/PromoteRoomAdmin.java b/im-sdk-core/src/main/java/com/easemob/im/server/api/room/admin/promote/PromoteRoomAdmin.java deleted file mode 100644 index e68237091..000000000 --- a/im-sdk-core/src/main/java/com/easemob/im/server/api/room/admin/promote/PromoteRoomAdmin.java +++ /dev/null @@ -1,43 +0,0 @@ -package com.easemob.im.server.api.room.admin.promote; - -import com.easemob.im.server.api.Context; -import com.easemob.im.server.api.DefaultErrorMapper; -import com.easemob.im.server.api.ErrorMapper; -import com.easemob.im.server.exception.EMUnknownException; -import reactor.core.publisher.Mono; - -public class PromoteRoomAdmin { - - private Context context; - - public PromoteRoomAdmin(Context context) { - this.context = context; - } - - public Mono single(String roomId, String username) { - return this.context.getHttpClient() - .flatMap(httpClient -> httpClient.post() - .uri(String.format("/chatrooms/%s/admin", roomId)) - .send(Mono.create(sink -> sink.success(this.context.getCodec() - .encode(new PromoteRoomAdminRequest(username))))) - .responseSingle((rsp, buf) -> { - return buf.switchIfEmpty( - Mono.error(new EMUnknownException("response is null"))) - .flatMap(byteBuf -> { - ErrorMapper mapper = new DefaultErrorMapper(); - mapper.statusCode(rsp); - mapper.checkError(byteBuf); - return Mono.just(byteBuf); - }); - })) - .map(buf -> this.context.getCodec().decode(buf, PromoteRoomAdminResponse.class)) - .handle((rsp, sink) -> { - if (!rsp.isSuccess()) { - sink.error(new EMUnknownException("unknown")); - return; - } - sink.complete(); - }); - } - -} diff --git a/im-sdk-core/src/main/java/com/easemob/im/server/api/room/admin/promote/PromoteRoomAdminRequest.java b/im-sdk-core/src/main/java/com/easemob/im/server/api/room/admin/promote/PromoteRoomAdminRequest.java deleted file mode 100644 index e26d2d509..000000000 --- a/im-sdk-core/src/main/java/com/easemob/im/server/api/room/admin/promote/PromoteRoomAdminRequest.java +++ /dev/null @@ -1,15 +0,0 @@ -package com.easemob.im.server.api.room.admin.promote; - -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonProperty; - -public class PromoteRoomAdminRequest { - @JsonProperty("newadmin") - private String username; - - @JsonCreator - public PromoteRoomAdminRequest(@JsonProperty("newadmin") String username) { - this.username = username; - } - -} diff --git a/im-sdk-core/src/main/java/com/easemob/im/server/api/room/admin/promote/PromoteRoomAdminResponse.java b/im-sdk-core/src/main/java/com/easemob/im/server/api/room/admin/promote/PromoteRoomAdminResponse.java deleted file mode 100644 index aa53d4d50..000000000 --- a/im-sdk-core/src/main/java/com/easemob/im/server/api/room/admin/promote/PromoteRoomAdminResponse.java +++ /dev/null @@ -1,37 +0,0 @@ -package com.easemob.im.server.api.room.admin.promote; - -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonProperty; - -public class PromoteRoomAdminResponse { - @JsonProperty("data") - private Wrapper wrapper; - - @JsonCreator - public PromoteRoomAdminResponse(@JsonProperty("data") Wrapper wrapper) { - this.wrapper = wrapper; - } - - public boolean isSuccess() { - return this.wrapper != null && this.wrapper.getResult().equals("success"); - } - - public static class Wrapper { - @JsonProperty("result") - private String result; - - @JsonProperty("newadmin") - private String username; - - @JsonCreator - public Wrapper(@JsonProperty("result") String result, - @JsonProperty("newadmin") String username) { - this.result = result; - this.username = username; - } - - private String getResult() { - return this.result; - } - } -} diff --git a/im-sdk-core/src/main/java/com/easemob/im/server/api/room/announcement/RoomAnnouncement.java b/im-sdk-core/src/main/java/com/easemob/im/server/api/room/announcement/RoomAnnouncement.java deleted file mode 100644 index c3debd256..000000000 --- a/im-sdk-core/src/main/java/com/easemob/im/server/api/room/announcement/RoomAnnouncement.java +++ /dev/null @@ -1,59 +0,0 @@ -package com.easemob.im.server.api.room.announcement; - -import com.easemob.im.server.api.Context; -import com.easemob.im.server.api.DefaultErrorMapper; -import com.easemob.im.server.api.ErrorMapper; -import com.easemob.im.server.exception.EMInvalidArgumentException; -import com.easemob.im.server.exception.EMUnknownException; -import reactor.core.publisher.Mono; - -public class RoomAnnouncement { - - private Context context; - - public RoomAnnouncement(Context context) { - this.context = context; - } - - public Mono get(String roomId) { - return context.getHttpClient() - .flatMap(httpClient -> httpClient.get() - .uri(String.format("/chatrooms/%s/announcement", roomId)) - .responseSingle((rsp, buf) -> { - return buf.switchIfEmpty( - Mono.error(new EMUnknownException("response is null"))) - .flatMap(byteBuf -> { - ErrorMapper mapper = new DefaultErrorMapper(); - mapper.statusCode(rsp); - mapper.checkError(byteBuf); - return Mono.just(byteBuf); - }); - })) - .map(buf -> this.context.getCodec().decode(buf, RoomAnnouncementGetResponse.class)) - .map(RoomAnnouncementGetResponse::getAnnouncement); - } - - public Mono set(String groupId, String announcement) { - if (announcement.length() > 512) { - return Mono.error(new EMInvalidArgumentException( - "announcement must not be longer than 512 characters")); - } - return context.getHttpClient() - .flatMap(httpClient -> httpClient.post() - .uri(String.format("/chatrooms/%s/announcement", groupId)) - .send(Mono.create(sink -> sink.success(this.context.getCodec() - .encode(new RoomAnnouncementResource(announcement))))) - .responseSingle((rsp, buf) -> { - return buf.switchIfEmpty( - Mono.error(new EMUnknownException("response is null"))) - .flatMap(byteBuf -> { - ErrorMapper mapper = new DefaultErrorMapper(); - mapper.statusCode(rsp); - mapper.checkError(byteBuf); - return Mono.just(byteBuf); - }); - })) - .then(); - } -} - diff --git a/im-sdk-core/src/main/java/com/easemob/im/server/api/room/announcement/RoomAnnouncementGetResponse.java b/im-sdk-core/src/main/java/com/easemob/im/server/api/room/announcement/RoomAnnouncementGetResponse.java deleted file mode 100644 index eeff83c1b..000000000 --- a/im-sdk-core/src/main/java/com/easemob/im/server/api/room/announcement/RoomAnnouncementGetResponse.java +++ /dev/null @@ -1,19 +0,0 @@ -package com.easemob.im.server.api.room.announcement; - -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonProperty; - -public class RoomAnnouncementGetResponse { - @JsonProperty("data") - private RoomAnnouncementResource resource; - - @JsonCreator - public RoomAnnouncementGetResponse(@JsonProperty("data") RoomAnnouncementResource resource) { - this.resource = resource; - } - - public String getAnnouncement() { - return resource.getText(); - } - -} diff --git a/im-sdk-core/src/main/java/com/easemob/im/server/api/room/announcement/RoomAnnouncementResource.java b/im-sdk-core/src/main/java/com/easemob/im/server/api/room/announcement/RoomAnnouncementResource.java deleted file mode 100644 index ca2ac6177..000000000 --- a/im-sdk-core/src/main/java/com/easemob/im/server/api/room/announcement/RoomAnnouncementResource.java +++ /dev/null @@ -1,19 +0,0 @@ -package com.easemob.im.server.api.room.announcement; - -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonProperty; - -public class RoomAnnouncementResource { - @JsonProperty("announcement") - private String text; - - @JsonCreator - public RoomAnnouncementResource(@JsonProperty("announcement") String text) { - this.text = text; - } - - public String getText() { - return text; - } - -} diff --git a/im-sdk-core/src/main/java/com/easemob/im/server/api/room/assign/AssignRoom.java b/im-sdk-core/src/main/java/com/easemob/im/server/api/room/assign/AssignRoom.java deleted file mode 100644 index 89b254961..000000000 --- a/im-sdk-core/src/main/java/com/easemob/im/server/api/room/assign/AssignRoom.java +++ /dev/null @@ -1,43 +0,0 @@ -package com.easemob.im.server.api.room.assign; - -import com.easemob.im.server.api.Context; -import com.easemob.im.server.api.DefaultErrorMapper; -import com.easemob.im.server.api.ErrorMapper; -import com.easemob.im.server.exception.EMNotFoundException; -import com.easemob.im.server.exception.EMUnknownException; -import reactor.core.publisher.Mono; - -import java.util.HashMap; -import java.util.Map; - -public class AssignRoom { - - private Context context; - - public AssignRoom(Context context) { - this.context = context; - } - - public Mono execute(String chatroomId, String newOwner) { - return this.context.getHttpClient() - .flatMap(httpClient -> httpClient.put() - .uri(String.format("/chatrooms/%s", chatroomId)) - .send(Mono.create(sink -> { - Map paramsMap = new HashMap<>(); - paramsMap.put("newowner", newOwner); - sink.success(this.context.getCodec().encode(paramsMap)); - })) - .responseSingle((rsp, buf) -> { - return buf.switchIfEmpty( - Mono.error(new EMUnknownException("response is null"))) - .flatMap(byteBuf -> { - ErrorMapper mapper = new DefaultErrorMapper(); - mapper.statusCode(rsp); - mapper.checkError(byteBuf); - return Mono.just(byteBuf); - }); - })) - .onErrorResume(EMNotFoundException.class, errorIgnored -> Mono.empty()) - .then(); - } -} diff --git a/im-sdk-core/src/main/java/com/easemob/im/server/api/room/create/CreateRoom.java b/im-sdk-core/src/main/java/com/easemob/im/server/api/room/create/CreateRoom.java deleted file mode 100644 index e4df536fe..000000000 --- a/im-sdk-core/src/main/java/com/easemob/im/server/api/room/create/CreateRoom.java +++ /dev/null @@ -1,101 +0,0 @@ -package com.easemob.im.server.api.room.create; - -import com.easemob.im.server.EMException; -import com.easemob.im.server.api.Context; -import com.easemob.im.server.api.DefaultErrorMapper; -import com.easemob.im.server.api.ErrorMapper; -import com.easemob.im.server.exception.EMUnknownException; -import reactor.core.publisher.Mono; -import reactor.netty.http.client.HttpClientResponse; - -import java.util.List; - -public class CreateRoom { - - private Context context; - - public CreateRoom(Context context) { - this.context = context; - } - - public Mono createRoom(String name, String description, String owner, - List members, int maxMembers) { - return this.context.getHttpClient() - .flatMap(httpClient -> httpClient.post() - .uri("/chatrooms") - .send(Mono.create(sink -> sink.success(this.context.getCodec() - .encode(CreateRoomRequest - .of(name, description, owner, members, maxMembers))))) - .responseSingle((rsp, buf) -> { - return buf.switchIfEmpty( - Mono.error(new EMUnknownException("response is null"))) - .flatMap(byteBuf -> { - ErrorMapper mapper = new DefaultErrorMapper(); - mapper.statusCode(rsp); - mapper.checkError(byteBuf); - return Mono.just(byteBuf); - }); - })) - .map(byteBuf -> { - CreateRoomResponse - createRoomResponse = this.context.getCodec() - .decode(byteBuf, CreateRoomResponse.class); - return createRoomResponse.getRoomId(); - }); - } - - public Mono createRoom(String name, String description, String owner, - List members, int maxMembers, String custom) { - return this.context.getHttpClient() - .flatMap(httpClient -> httpClient.post() - .uri("/chatrooms") - .send(Mono.create(sink -> sink.success(this.context.getCodec() - .encode(CreateRoomRequest - .of(name, description, owner, members, maxMembers, - custom))))) - .responseSingle((rsp, buf) -> { - return buf.switchIfEmpty( - Mono.error(new EMUnknownException("response is null"))) - .flatMap(byteBuf -> { - ErrorMapper mapper = new DefaultErrorMapper(); - mapper.statusCode(rsp); - mapper.checkError(byteBuf); - return Mono.just(byteBuf); - }); - })) - .map(byteBuf -> { - CreateRoomResponse - createRoomResponse = this.context.getCodec() - .decode(byteBuf, CreateRoomResponse.class); - return createRoomResponse.getRoomId(); - }); - } - - public Mono createRoom(String name, String description, String owner, - List members, int maxMembers, String custom, Boolean needVerify) { - return this.context.getHttpClient() - .flatMap(httpClient -> httpClient.post() - .uri("/chatrooms") - .send(Mono.create(sink -> sink.success(this.context.getCodec() - .encode(CreateRoomRequest - .of(name, description, owner, members, maxMembers, custom, - needVerify))))) - .responseSingle((rsp, buf) -> { - return buf.switchIfEmpty( - Mono.error(new EMUnknownException("response is null"))) - .flatMap(byteBuf -> { - ErrorMapper mapper = new DefaultErrorMapper(); - mapper.statusCode(rsp); - mapper.checkError(byteBuf); - return Mono.just(byteBuf); - }); - })) - .map(byteBuf -> { - CreateRoomResponse - createRoomResponse = this.context.getCodec() - .decode(byteBuf, CreateRoomResponse.class); - return createRoomResponse.getRoomId(); - }); - } - -} diff --git a/im-sdk-core/src/main/java/com/easemob/im/server/api/room/create/CreateRoomRequest.java b/im-sdk-core/src/main/java/com/easemob/im/server/api/room/create/CreateRoomRequest.java deleted file mode 100644 index 0551dbeb7..000000000 --- a/im-sdk-core/src/main/java/com/easemob/im/server/api/room/create/CreateRoomRequest.java +++ /dev/null @@ -1,76 +0,0 @@ -package com.easemob.im.server.api.room.create; - -import com.fasterxml.jackson.annotation.JsonProperty; - -import java.util.List; - -public class CreateRoomRequest { - @JsonProperty("name") - private String name; - @JsonProperty("description") - private String description; - @JsonProperty("maxusers") - private int maxMembers; - @JsonProperty("owner") - private String owner; - @JsonProperty("members") - private List members; - @JsonProperty("scale") - private String scale; - @JsonProperty("custom") - private String custom; - @JsonProperty("need_verify") - private Boolean needVerify; - - { - needVerify = true; - } - - private CreateRoomRequest(String name, String description, String owner, List members, - int maxMembers) { - this.name = name; - this.description = description; - this.owner = owner; - this.members = members; - this.maxMembers = maxMembers; - this.scale = "large"; - } - - private CreateRoomRequest(String name, String description, String owner, List members, - int maxMembers, String custom) { - this.name = name; - this.description = description; - this.owner = owner; - this.members = members; - this.maxMembers = maxMembers; - this.scale = "large"; - this.custom = custom; - } - - private CreateRoomRequest(String name, String description, String owner, List members, - int maxMembers, String custom, Boolean needVerify) { - this.name = name; - this.description = description; - this.owner = owner; - this.members = members; - this.maxMembers = maxMembers; - this.scale = "large"; - this.custom = custom; - this.needVerify = needVerify; - } - - public static CreateRoomRequest of(String name, String description, String owner, - List members, int maxMembers) { - return new CreateRoomRequest(name, description, owner, members, maxMembers); - } - - public static CreateRoomRequest of(String name, String description, String owner, - List members, int maxMembers, String custom) { - return new CreateRoomRequest(name, description, owner, members, maxMembers, custom); - } - - public static CreateRoomRequest of(String name, String description, String owner, - List members, int maxMembers, String custom, Boolean needVerify) { - return new CreateRoomRequest(name, description, owner, members, maxMembers, custom, needVerify); - } -} diff --git a/im-sdk-core/src/main/java/com/easemob/im/server/api/room/create/CreateRoomResponse.java b/im-sdk-core/src/main/java/com/easemob/im/server/api/room/create/CreateRoomResponse.java deleted file mode 100644 index 722cd4243..000000000 --- a/im-sdk-core/src/main/java/com/easemob/im/server/api/room/create/CreateRoomResponse.java +++ /dev/null @@ -1,29 +0,0 @@ -package com.easemob.im.server.api.room.create; - -import com.fasterxml.jackson.annotation.JsonProperty; - -public class CreateRoomResponse { - @JsonProperty("data") - private Wrapper wrapper; - - public CreateRoomResponse(@JsonProperty("data") Wrapper wrapper) { - this.wrapper = wrapper; - } - - public String getRoomId() { - return this.wrapper != null ? this.wrapper.roomId : null; - } - - public static class Wrapper { - @JsonProperty("id") - private String roomId; - - public Wrapper(@JsonProperty("id") String roomId) { - this.roomId = roomId; - } - - public String getRoomId() { - return this.roomId; - } - } -} diff --git a/im-sdk-core/src/main/java/com/easemob/im/server/api/room/delete/DeleteRoom.java b/im-sdk-core/src/main/java/com/easemob/im/server/api/room/delete/DeleteRoom.java deleted file mode 100644 index fd8458ea9..000000000 --- a/im-sdk-core/src/main/java/com/easemob/im/server/api/room/delete/DeleteRoom.java +++ /dev/null @@ -1,41 +0,0 @@ -package com.easemob.im.server.api.room.delete; - -import com.easemob.im.server.api.Context; -import com.easemob.im.server.api.DefaultErrorMapper; -import com.easemob.im.server.api.ErrorMapper; -import com.easemob.im.server.exception.EMUnknownException; -import reactor.core.publisher.Mono; - -public class DeleteRoom { - - private Context context; - - public DeleteRoom(Context context) { - this.context = context; - } - - public Mono byId(String roomId) { - return this.context.getHttpClient() - .flatMap(httpClient -> httpClient.delete() - .uri(String.format("/chatrooms/%s", roomId)) - .responseSingle((rsp, buf) -> { - return buf.switchIfEmpty( - Mono.error(new EMUnknownException("response is null"))) - .flatMap(byteBuf -> { - ErrorMapper mapper = new DefaultErrorMapper(); - mapper.statusCode(rsp); - mapper.checkError(byteBuf); - return Mono.just(byteBuf); - }); - })) - .map(buf -> this.context.getCodec().decode(buf, DeleteRoomResponse.class)) - .handle((rsp, sink) -> { - if (!rsp.getSuccess()) { - sink.error(new EMUnknownException("unknown")); - return; - } - sink.complete(); - }); - } - -} diff --git a/im-sdk-core/src/main/java/com/easemob/im/server/api/room/delete/DeleteRoomResponse.java b/im-sdk-core/src/main/java/com/easemob/im/server/api/room/delete/DeleteRoomResponse.java deleted file mode 100644 index 49ae8c838..000000000 --- a/im-sdk-core/src/main/java/com/easemob/im/server/api/room/delete/DeleteRoomResponse.java +++ /dev/null @@ -1,40 +0,0 @@ -package com.easemob.im.server.api.room.delete; - -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonProperty; - -public class DeleteRoomResponse { - @JsonProperty("data") - private Wrapper wrapper; - - @JsonCreator - public DeleteRoomResponse(@JsonProperty("data") Wrapper wrapper) { - this.wrapper = wrapper; - } - - public boolean getSuccess() { - return this.wrapper != null && this.wrapper.getSuccess(); - } - - public static class Wrapper { - @JsonProperty("success") - private boolean success; - @JsonProperty("id") - private String id; - - @JsonCreator - public Wrapper(@JsonProperty("success") boolean success, - @JsonProperty("id") String id) { - this.success = success; - this.id = id; - } - - public boolean getSuccess() { - return this.success; - } - - public String getId() { - return this.id; - } - } -} diff --git a/im-sdk-core/src/main/java/com/easemob/im/server/api/room/detail/GetRoomDetail.java b/im-sdk-core/src/main/java/com/easemob/im/server/api/room/detail/GetRoomDetail.java deleted file mode 100644 index ca255ef50..000000000 --- a/im-sdk-core/src/main/java/com/easemob/im/server/api/room/detail/GetRoomDetail.java +++ /dev/null @@ -1,71 +0,0 @@ -package com.easemob.im.server.api.room.detail; - -import com.easemob.im.server.api.Context; -import com.easemob.im.server.api.DefaultErrorMapper; -import com.easemob.im.server.api.ErrorMapper; -import com.easemob.im.server.api.group.get.GetGroupResponse; -import com.easemob.im.server.exception.EMUnknownException; -import com.easemob.im.server.model.EMRoom; -import reactor.core.publisher.Mono; - -import java.util.Collection; -import java.util.Iterator; -import java.util.List; - -public class GetRoomDetail { - - private Context context; - - public GetRoomDetail(Context context) { - this.context = context; - } - - public Mono byId(String roomId) { - return this.context.getHttpClient() - .flatMap(httpClient -> httpClient.get() - .uri(String.format("/chatrooms/%s", roomId)) - .responseSingle((rsp, buf) -> { - return buf.switchIfEmpty( - Mono.error(new EMUnknownException("response is null"))) - .flatMap(byteBuf -> { - ErrorMapper mapper = new DefaultErrorMapper(); - mapper.statusCode(rsp); - mapper.checkError(byteBuf); - return Mono.just(byteBuf); - }); - })) - .map(buf -> this.context.getCodec().decode(buf, GetRoomDetailResponse.class) - .toRoomDetails().get(0)); - } - - public Mono> byIds(List roomIdList) { - return this.context.getHttpClient() - .flatMap(httpClient -> httpClient.get() - .uri(String.format("/chatrooms/%s", join(roomIdList, ","))) - .responseSingle((rsp, buf) -> { - return buf.switchIfEmpty( - Mono.error(new EMUnknownException("response is null"))) - .flatMap(byteBuf -> { - ErrorMapper mapper = new DefaultErrorMapper(); - mapper.statusCode(rsp); - mapper.checkError(byteBuf); - return Mono.just(byteBuf); - }); - })) - .map(buf -> this.context.getCodec().decode(buf, GetRoomDetailResponse.class)) - .map(GetRoomDetailResponse::toRoomDetails); - } - - public static String join(Collection var0, String var1) { - StringBuffer var2 = new StringBuffer(); - - for(Iterator var3 = var0.iterator(); var3.hasNext(); var2.append((String)var3.next())) { - if (var2.length() != 0) { - var2.append(var1); - } - } - - return var2.toString(); - } - -} diff --git a/im-sdk-core/src/main/java/com/easemob/im/server/api/room/detail/GetRoomDetailResponse.java b/im-sdk-core/src/main/java/com/easemob/im/server/api/room/detail/GetRoomDetailResponse.java deleted file mode 100644 index de0a1cf05..000000000 --- a/im-sdk-core/src/main/java/com/easemob/im/server/api/room/detail/GetRoomDetailResponse.java +++ /dev/null @@ -1,87 +0,0 @@ -package com.easemob.im.server.api.room.detail; - -import com.easemob.im.server.model.EMRoom; -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonProperty; - -import java.util.List; -import java.util.Map; -import java.util.stream.Collectors; - -public class GetRoomDetailResponse { - @JsonProperty("data") - private List rooms; - - public GetRoomDetailResponse(@JsonProperty("data") List rooms) { - this.rooms = rooms; - } - - public List toRoomDetails() { - return this.rooms.stream().map(Room::toRoom).collect(Collectors.toList()); - } - - private static class Room { - @JsonProperty("id") - private String id; - - @JsonProperty("name") - private String name; - - @JsonProperty("description") - private String description; - - @JsonProperty("membersonly") - private boolean needApprove; - - @JsonProperty("owner") - private String owner; - - @JsonProperty("maxusers") - private int maxMembers; - - @JsonProperty("mute") - private Boolean mute; - - @JsonProperty("affiliations") - private List> members; - - @JsonProperty("affiliations_count") - private Integer memberCount; - - @JsonProperty("custom") - private String custom; - - @JsonProperty("created") - private Long created; - - @JsonCreator - public Room(@JsonProperty("id") String id, - @JsonProperty("name") String name, - @JsonProperty("description") String description, - @JsonProperty("owner") String owner, - @JsonProperty("membersonly") boolean needApprove, - @JsonProperty("maxusers") int maxMembers, - @JsonProperty("mute") Boolean mute, - @JsonProperty("affiliations") List> members, - @JsonProperty("affiliations_count") Integer memberCount, - @JsonProperty("custom") String custom, - @JsonProperty("created") Long created) { - this.id = id; - this.name = name; - this.description = description; - this.owner = owner; - this.needApprove = needApprove; - this.maxMembers = maxMembers; - this.mute = mute; - this.members = members; - this.memberCount = memberCount; - this.custom = custom; - this.created = created; - } - - public EMRoom toRoom() { - return new EMRoom(this.id, this.name, this.description, this.needApprove, this.owner, - this.maxMembers, this.mute, this.members, this.memberCount, this.custom, this.created); - } - } -} diff --git a/im-sdk-core/src/main/java/com/easemob/im/server/api/room/list/ListRooms.java b/im-sdk-core/src/main/java/com/easemob/im/server/api/room/list/ListRooms.java deleted file mode 100644 index 0a3606f8e..000000000 --- a/im-sdk-core/src/main/java/com/easemob/im/server/api/room/list/ListRooms.java +++ /dev/null @@ -1,69 +0,0 @@ -package com.easemob.im.server.api.room.list; - -import com.easemob.im.server.api.Context; -import com.easemob.im.server.api.DefaultErrorMapper; -import com.easemob.im.server.api.ErrorMapper; -import com.easemob.im.server.exception.EMUnknownException; -import com.easemob.im.server.model.EMPage; -import io.netty.handler.codec.http.QueryStringEncoder; -import reactor.core.publisher.Flux; -import reactor.core.publisher.Mono; - -public class ListRooms { - - private Context context; - - public ListRooms(Context context) { - this.context = context; - } - - public Flux all(int limit) { - return next(limit, null) - .expand(rsp -> rsp.getCursor() == null ? - Mono.empty() : - next(limit, rsp.getCursor())) - .concatMapIterable(EMPage::getValues); - } - - public Mono> next(int limit, String cursor) { - QueryStringEncoder encoder = new QueryStringEncoder("/chatrooms"); - encoder.addParam("limit", String.valueOf(limit)); - if (cursor != null) { - encoder.addParam("cursor", cursor); - } - String uriString = encoder.toString(); - return this.context.getHttpClient() - .flatMap(httpClient -> httpClient.get() - .uri(uriString) - .responseSingle((rsp, buf) -> { - return buf.switchIfEmpty( - Mono.error(new EMUnknownException("response is null"))) - .flatMap(byteBuf -> { - ErrorMapper mapper = new DefaultErrorMapper(); - mapper.statusCode(rsp); - mapper.checkError(byteBuf); - return Mono.just(byteBuf); - }); - })) - .map(buf -> this.context.getCodec().decode(buf, ListRoomsResponse.class)) - .map(ListRoomsResponse::toEMPage); - } - - public Flux userJoined(String username) { - return this.context.getHttpClient() - .flatMap(httpClient -> httpClient.get() - .uri(String.format("/users/%s/joined_chatrooms", username)) - .responseSingle((rsp, buf) -> { - return buf.switchIfEmpty( - Mono.error(new EMUnknownException("response is null"))) - .flatMap(byteBuf -> { - ErrorMapper mapper = new DefaultErrorMapper(); - mapper.statusCode(rsp); - mapper.checkError(byteBuf); - return Mono.just(byteBuf); - }); - })) - .map(buf -> this.context.getCodec().decode(buf, ListRoomsResponse.class)) - .flatMapIterable(ListRoomsResponse::getRoomIds); - } -} diff --git a/im-sdk-core/src/main/java/com/easemob/im/server/api/room/list/ListRoomsResponse.java b/im-sdk-core/src/main/java/com/easemob/im/server/api/room/list/ListRoomsResponse.java deleted file mode 100644 index 46e76107d..000000000 --- a/im-sdk-core/src/main/java/com/easemob/im/server/api/room/list/ListRoomsResponse.java +++ /dev/null @@ -1,74 +0,0 @@ -package com.easemob.im.server.api.room.list; - -import com.easemob.im.server.model.EMPage; -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonProperty; - -import java.util.List; -import java.util.stream.Collectors; - -public class ListRoomsResponse { - - @JsonProperty("data") - private List rooms; - - @JsonProperty("cursor") - private String cursor; - - @JsonCreator - public ListRoomsResponse(@JsonProperty("data") List rooms) { - this.rooms = rooms; - } - - public List getRoomIds() { - return this.rooms.stream().map(Room::getId).collect(Collectors.toList()); - } - - public String getCursor() { - return this.cursor; - } - - public EMPage toEMPage() { - List roomIds = this.rooms.stream().map(Room::getId).collect(Collectors.toList()); - return new EMPage<>(roomIds, this.cursor); - } - - public static class Room { - @JsonProperty("id") - private String id; - @JsonProperty("name") - private String name; - @JsonProperty("owner") - private String owner; - @JsonProperty("affiliations_count") - private int members; - - @JsonCreator - public Room(@JsonProperty("id") String id, - @JsonProperty("name") String name, - @JsonProperty("owner") String owner, - @JsonProperty("affiliations_count") int members) { - this.id = id; - this.name = name; - this.owner = owner; - this.members = members; - } - - public String getId() { - return this.id; - } - - public String getName() { - return this.name; - } - - public String getOwner() { - return this.owner; - } - - public int getMembers() { - return this.members; - } - - } -} diff --git a/im-sdk-core/src/main/java/com/easemob/im/server/api/room/member/add/AddRoomMember.java b/im-sdk-core/src/main/java/com/easemob/im/server/api/room/member/add/AddRoomMember.java deleted file mode 100644 index a9fb386d3..000000000 --- a/im-sdk-core/src/main/java/com/easemob/im/server/api/room/member/add/AddRoomMember.java +++ /dev/null @@ -1,42 +0,0 @@ -package com.easemob.im.server.api.room.member.add; - -import com.easemob.im.server.api.Context; -import com.easemob.im.server.api.DefaultErrorMapper; -import com.easemob.im.server.api.ErrorMapper; -import com.easemob.im.server.exception.EMUnknownException; -import reactor.core.publisher.Mono; - -public class AddRoomMember { - - private Context context; - - public AddRoomMember(Context context) { - this.context = context; - } - - public Mono single(String roomId, String username) { - return this.context.getHttpClient() - .flatMap(httpClient -> httpClient.post() - .uri(String.format("/chatrooms/%s/users/%s", roomId, username)) - .responseSingle((rsp, buf) -> { - return buf.switchIfEmpty( - Mono.error(new EMUnknownException("response is null"))) - .flatMap(byteBuf -> { - ErrorMapper mapper = new DefaultErrorMapper(); - mapper.statusCode(rsp); - mapper.checkError(byteBuf); - return Mono.just(byteBuf); - }); - })) - .map(buf -> this.context.getCodec().decode(buf, AddRoomMemberResponse.class)) - .handle((rsp, sink) -> { - if (!rsp.isSuccess()) { - sink.error(new EMUnknownException("unknown")); - return; - } - sink.complete(); - }); - - } - -} diff --git a/im-sdk-core/src/main/java/com/easemob/im/server/api/room/member/add/AddRoomMemberResponse.java b/im-sdk-core/src/main/java/com/easemob/im/server/api/room/member/add/AddRoomMemberResponse.java deleted file mode 100644 index 999692a56..000000000 --- a/im-sdk-core/src/main/java/com/easemob/im/server/api/room/member/add/AddRoomMemberResponse.java +++ /dev/null @@ -1,33 +0,0 @@ -package com.easemob.im.server.api.room.member.add; - -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonProperty; - -public class AddRoomMemberResponse { - - @JsonProperty("data") - private Wrapper wrapper; - - @JsonCreator - public AddRoomMemberResponse(@JsonProperty("data") Wrapper wrapper) { - this.wrapper = wrapper; - } - - public boolean isSuccess() { - return this.wrapper != null && this.wrapper.getResult(); - } - - public static class Wrapper { - @JsonProperty("result") - private boolean result; - - @JsonCreator - public Wrapper(@JsonProperty("result") boolean result) { - this.result = result; - } - - public boolean getResult() { - return this.result; - } - } -} diff --git a/im-sdk-core/src/main/java/com/easemob/im/server/api/room/member/list/ListRoomMembers.java b/im-sdk-core/src/main/java/com/easemob/im/server/api/room/member/list/ListRoomMembers.java deleted file mode 100644 index df4a3af12..000000000 --- a/im-sdk-core/src/main/java/com/easemob/im/server/api/room/member/list/ListRoomMembers.java +++ /dev/null @@ -1,91 +0,0 @@ -package com.easemob.im.server.api.room.member.list; - -import com.easemob.im.server.api.Context; -import com.easemob.im.server.api.DefaultErrorMapper; -import com.easemob.im.server.api.ErrorMapper; -import com.easemob.im.server.exception.EMUnknownException; -import com.easemob.im.server.model.EMPage; -import io.netty.handler.codec.http.QueryStringEncoder; -import reactor.core.publisher.Flux; -import reactor.core.publisher.Mono; - -import java.util.Map; - -public class ListRoomMembers { - - private Context context; - - public ListRoomMembers(Context context) { - this.context = context; - } - - public Flux all(String roomId, int limit, String sort) { - return next(roomId, limit, null, sort) - .expand(rsp -> rsp.getCursor() == null ? - Mono.empty() : - next(roomId, limit, rsp.getCursor(), sort)) - .concatMapIterable(EMPage::getValues); - } - - public Mono> next(String roomId, int limit, String cursor, String sort) { - final String uriPath = String.format("/chatrooms/%s/users", roomId); - QueryStringEncoder encoder = new QueryStringEncoder(uriPath); - encoder.addParam("version", "v3"); - encoder.addParam("limit", String.valueOf(limit)); - if (cursor != null) { - encoder.addParam("cursor", cursor); - } - if (sort != null) { - encoder.addParam("sort", sort); - } - String uriString = encoder.toString(); - return this.context.getHttpClient() - .flatMap(httpClient -> httpClient.get() - .uri(uriString) - .responseSingle((rsp, buf) -> { - return buf.switchIfEmpty( - Mono.error(new EMUnknownException("response is null"))) - .flatMap(byteBuf -> { - ErrorMapper mapper = new DefaultErrorMapper(); - mapper.statusCode(rsp); - mapper.checkError(byteBuf); - return Mono.just(byteBuf); - }); - })) - .map(buf -> this.context.getCodec().decode(buf, ListRoomMembersResponse.class)) - .map(ListRoomMembersResponse::toEMPage); - } - - public Flux> all(String roomId, int pageSize) { - return next(roomId, 1, pageSize) - .expand(rsp -> { - return rsp.getMemberCount() < pageSize ? - Mono.empty() : - next(roomId, Integer.parseInt(rsp.getParamsInfo().getPageNum()) + 1, pageSize); - }) - .concatMapIterable(ListRoomMembersResponseV1::getMembers); - } - - public Mono next(String roomId, int pageNum, int pageSize) { - final String uriPath = String.format("/chatrooms/%s/users", roomId); - QueryStringEncoder encoder = new QueryStringEncoder(uriPath); - encoder.addParam("pagenum", String.valueOf(pageNum)); - encoder.addParam("pagesize", String.valueOf(pageSize)); - - String uriString = encoder.toString(); - return this.context.getHttpClient() - .flatMap(httpClient -> httpClient.get() - .uri(uriString) - .responseSingle((rsp, buf) -> { - return buf.switchIfEmpty( - Mono.error(new EMUnknownException("response is null"))) - .flatMap(byteBuf -> { - ErrorMapper mapper = new DefaultErrorMapper(); - mapper.statusCode(rsp); - mapper.checkError(byteBuf); - return Mono.just(byteBuf); - }); - })) - .map(buf -> this.context.getCodec().decode(buf, ListRoomMembersResponseV1.class)); - } -} diff --git a/im-sdk-core/src/main/java/com/easemob/im/server/api/room/member/list/ListRoomMembersResponse.java b/im-sdk-core/src/main/java/com/easemob/im/server/api/room/member/list/ListRoomMembersResponse.java deleted file mode 100644 index 951948a79..000000000 --- a/im-sdk-core/src/main/java/com/easemob/im/server/api/room/member/list/ListRoomMembersResponse.java +++ /dev/null @@ -1,19 +0,0 @@ -package com.easemob.im.server.api.room.member.list; - -import com.easemob.im.server.model.EMPage; -import com.fasterxml.jackson.annotation.JsonProperty; - -import java.util.List; - -// "data": ["username1", "username2"] -public class ListRoomMembersResponse { - @JsonProperty("data") - private List members; - - @JsonProperty("cursor") - private String cursor; - - public EMPage toEMPage() { - return new EMPage<>(this.members, this.cursor); - } -} diff --git a/im-sdk-core/src/main/java/com/easemob/im/server/api/room/member/list/ListRoomMembersResponseV1.java b/im-sdk-core/src/main/java/com/easemob/im/server/api/room/member/list/ListRoomMembersResponseV1.java deleted file mode 100644 index c3fa75440..000000000 --- a/im-sdk-core/src/main/java/com/easemob/im/server/api/room/member/list/ListRoomMembersResponseV1.java +++ /dev/null @@ -1,64 +0,0 @@ -package com.easemob.im.server.api.room.member.list; - -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonProperty; - -import java.util.List; -import java.util.Map; - -// "data": [{"member": "username1"}, {"owner": "username2"}] -public class ListRoomMembersResponseV1 { - @JsonProperty("data") - private List> members; - - @JsonProperty("count") - private Integer memberCount; - - @JsonProperty("params") - private ListRomParams paramsInfo; - - public Integer getMemberCount() { - return memberCount; - } - - public List> getMembers() { - return members; - } - - @JsonCreator - public ListRoomMembersResponseV1(@JsonProperty("data") List> members, - @JsonProperty("count") Integer memberCount, - @JsonProperty("params") ListRomParams paramsInfo) { - this.members = members; - this.memberCount = memberCount; - this.paramsInfo = paramsInfo; - } - - public ListRomParams getParamsInfo() { - return paramsInfo; - } - - public static class ListRomParams { - @JsonProperty("pagesize") - private List pageSize; - - @JsonProperty("pagenum") - private List pageNum; - - @JsonCreator - public ListRomParams(@JsonProperty("pagesize") List pageSize, - @JsonProperty("pagenum") List pageNum) { - this.pageSize = pageSize; - this.pageNum = pageNum; - } - - public String getPageSize() { - return pageSize.get(0); - } - - public String getPageNum() { - return pageNum.get(0); - } - } - -} diff --git a/im-sdk-core/src/main/java/com/easemob/im/server/api/room/member/remove/RemoveRoomMember.java b/im-sdk-core/src/main/java/com/easemob/im/server/api/room/member/remove/RemoveRoomMember.java deleted file mode 100644 index 3466b5c8f..000000000 --- a/im-sdk-core/src/main/java/com/easemob/im/server/api/room/member/remove/RemoveRoomMember.java +++ /dev/null @@ -1,41 +0,0 @@ -package com.easemob.im.server.api.room.member.remove; - -import com.easemob.im.server.api.Context; -import com.easemob.im.server.api.DefaultErrorMapper; -import com.easemob.im.server.api.ErrorMapper; -import com.easemob.im.server.exception.EMUnknownException; -import reactor.core.publisher.Mono; - -public class RemoveRoomMember { - - private Context context; - - public RemoveRoomMember(Context context) { - this.context = context; - } - - public Mono single(String roomId, String username) { - return this.context.getHttpClient() - .flatMap(httpClient -> httpClient.delete() - .uri(String.format("/chatrooms/%s/users/%s", roomId, username)) - .responseSingle((rsp, buf) -> { - return buf.switchIfEmpty( - Mono.error(new EMUnknownException("response is null"))) - .flatMap(byteBuf -> { - ErrorMapper mapper = new DefaultErrorMapper(); - mapper.statusCode(rsp); - mapper.checkError(byteBuf); - return Mono.just(byteBuf); - }); - })) - .map(buf -> this.context.getCodec().decode(buf, RemoveRoomMemberResponse.class)) - .handle((rsp, sink) -> { - if (!rsp.isSuccess()) { - sink.error(new EMUnknownException("unknown")); - return; - } - sink.complete(); - }); - } - -} diff --git a/im-sdk-core/src/main/java/com/easemob/im/server/api/room/member/remove/RemoveRoomMemberResponse.java b/im-sdk-core/src/main/java/com/easemob/im/server/api/room/member/remove/RemoveRoomMemberResponse.java deleted file mode 100644 index 742275efb..000000000 --- a/im-sdk-core/src/main/java/com/easemob/im/server/api/room/member/remove/RemoveRoomMemberResponse.java +++ /dev/null @@ -1,33 +0,0 @@ -package com.easemob.im.server.api.room.member.remove; - -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonProperty; - -public class RemoveRoomMemberResponse { - - @JsonProperty("data") - private Wrapper wrapper; - - @JsonCreator - public RemoveRoomMemberResponse(@JsonProperty("data") Wrapper wrapper) { - this.wrapper = wrapper; - } - - public boolean isSuccess() { - return this.wrapper != null && this.wrapper.getResult(); - } - - public static class Wrapper { - @JsonProperty("result") - private boolean result; - - @JsonCreator - public Wrapper(@JsonProperty("result") boolean result) { - this.result = result; - } - - public boolean getResult() { - return this.result; - } - } -} diff --git a/im-sdk-core/src/main/java/com/easemob/im/server/api/room/superadmin/demote/DemoteRoomSuperAdmin.java b/im-sdk-core/src/main/java/com/easemob/im/server/api/room/superadmin/demote/DemoteRoomSuperAdmin.java deleted file mode 100644 index 0271563bf..000000000 --- a/im-sdk-core/src/main/java/com/easemob/im/server/api/room/superadmin/demote/DemoteRoomSuperAdmin.java +++ /dev/null @@ -1,40 +0,0 @@ -package com.easemob.im.server.api.room.superadmin.demote; - -import com.easemob.im.server.api.Context; -import com.easemob.im.server.api.DefaultErrorMapper; -import com.easemob.im.server.api.ErrorMapper; -import com.easemob.im.server.exception.EMUnknownException; -import reactor.core.publisher.Mono; - -public class DemoteRoomSuperAdmin { - - private Context context; - - public DemoteRoomSuperAdmin(Context context) { - this.context = context; - } - - public Mono single(String username) { - return this.context.getHttpClient() - .flatMap(httpClient -> httpClient.delete() - .uri(String.format("/chatrooms/super_admin/%s", username)) - .responseSingle((rsp, buf) -> { - return buf.switchIfEmpty( - Mono.error(new EMUnknownException("response is null"))) - .flatMap(byteBuf -> { - ErrorMapper mapper = new DefaultErrorMapper(); - mapper.statusCode(rsp); - mapper.checkError(byteBuf); - return Mono.just(byteBuf); - }); - })) - .map(buf -> this.context.getCodec().decode(buf, DemoteRoomSuperAdminResponse.class)) - .handle((rsp, sink) -> { - if (!rsp.isSucess()) { - sink.error(new EMUnknownException("unknown")); - return; - } - sink.complete(); - }); - } -} diff --git a/im-sdk-core/src/main/java/com/easemob/im/server/api/room/superadmin/demote/DemoteRoomSuperAdminResponse.java b/im-sdk-core/src/main/java/com/easemob/im/server/api/room/superadmin/demote/DemoteRoomSuperAdminResponse.java deleted file mode 100644 index e82ce25d4..000000000 --- a/im-sdk-core/src/main/java/com/easemob/im/server/api/room/superadmin/demote/DemoteRoomSuperAdminResponse.java +++ /dev/null @@ -1,32 +0,0 @@ -package com.easemob.im.server.api.room.superadmin.demote; - -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonProperty; - -public class DemoteRoomSuperAdminResponse { - @JsonProperty("data") - private Wrapper wrapper; - - @JsonCreator - public DemoteRoomSuperAdminResponse(@JsonProperty("data") Wrapper wrapper) { - this.wrapper = wrapper; - } - - public boolean isSucess() { - return this.wrapper != null; - } - - public static class Wrapper { - @JsonProperty("newSuperAdmin") - private String username; - @JsonProperty("resource") - private String resource; - - @JsonCreator - public Wrapper(@JsonProperty("newSuperAdmin") String username, - @JsonProperty("resource") String resource) { - this.username = username; - this.resource = resource; - } - } -} diff --git a/im-sdk-core/src/main/java/com/easemob/im/server/api/room/superadmin/list/ListRoomSuperAdmins.java b/im-sdk-core/src/main/java/com/easemob/im/server/api/room/superadmin/list/ListRoomSuperAdmins.java deleted file mode 100644 index 6d06dbf39..000000000 --- a/im-sdk-core/src/main/java/com/easemob/im/server/api/room/superadmin/list/ListRoomSuperAdmins.java +++ /dev/null @@ -1,51 +0,0 @@ -package com.easemob.im.server.api.room.superadmin.list; - -import com.easemob.im.server.api.Context; -import com.easemob.im.server.api.DefaultErrorMapper; -import com.easemob.im.server.api.ErrorMapper; -import com.easemob.im.server.api.room.member.list.ListRoomMembersResponseV1; -import com.easemob.im.server.exception.EMUnknownException; -import reactor.core.publisher.Flux; -import reactor.core.publisher.Mono; - -import java.util.List; -import java.util.Map; - -public class ListRoomSuperAdmins { - - private Context context; - - public ListRoomSuperAdmins(Context context) { - this.context = context; - } - - public Mono next(int pageNum, int pageSize) { - String uri = - String.format("/chatrooms/super_admin?pagenum=%d&pagesize=%d", pageNum, pageSize); - - return this.context.getHttpClient() - .flatMap(httpClient -> httpClient.get() - .uri(uri) - .responseSingle((rsp, buf) -> { - return buf.switchIfEmpty( - Mono.error(new EMUnknownException("response is null"))) - .flatMap(byteBuf -> { - ErrorMapper mapper = new DefaultErrorMapper(); - mapper.statusCode(rsp); - mapper.checkError(byteBuf); - return Mono.just(byteBuf); - }); - })) - .map(buf -> this.context.getCodec().decode(buf, ListRoomSuperAdminsResponse.class)); - } - - public Flux all(int pageSize) { - return next(1, pageSize) - .expand(rsp -> { - return rsp.getAdmins().size() < pageSize ? - Mono.empty() : - next(Integer.parseInt(rsp.getParamsInfo().getPageNum()) + 1, pageSize); - }) - .concatMapIterable(ListRoomSuperAdminsResponse::getAdmins); - } -} diff --git a/im-sdk-core/src/main/java/com/easemob/im/server/api/room/superadmin/list/ListRoomSuperAdminsResponse.java b/im-sdk-core/src/main/java/com/easemob/im/server/api/room/superadmin/list/ListRoomSuperAdminsResponse.java deleted file mode 100644 index 7b079e24a..000000000 --- a/im-sdk-core/src/main/java/com/easemob/im/server/api/room/superadmin/list/ListRoomSuperAdminsResponse.java +++ /dev/null @@ -1,50 +0,0 @@ -package com.easemob.im.server.api.room.superadmin.list; - -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonProperty; - -import java.util.List; - -public class ListRoomSuperAdminsResponse { - @JsonProperty("data") - private List admins; - - @JsonProperty("params") - private ListRoomSuperAdminParams paramsInfo; - - @JsonCreator - public ListRoomSuperAdminsResponse(@JsonProperty("data") List admins) { - this.admins = admins; - } - - public List getAdmins() { - return admins; - } - - public ListRoomSuperAdminParams getParamsInfo() { - return paramsInfo; - } - - public static class ListRoomSuperAdminParams { - @JsonProperty("pagesize") - private List pageSize; - - @JsonProperty("pagenum") - private List pageNum; - - @JsonCreator - public ListRoomSuperAdminParams(@JsonProperty("pagesize") List pageSize, - @JsonProperty("pagenum") List pageNum) { - this.pageSize = pageSize; - this.pageNum = pageNum; - } - - public String getPageSize() { - return pageSize.get(0); - } - - public String getPageNum() { - return pageNum.get(0); - } - } -} diff --git a/im-sdk-core/src/main/java/com/easemob/im/server/api/room/superadmin/promote/PromoteRoomSuperAdmin.java b/im-sdk-core/src/main/java/com/easemob/im/server/api/room/superadmin/promote/PromoteRoomSuperAdmin.java deleted file mode 100644 index 16fbacfa8..000000000 --- a/im-sdk-core/src/main/java/com/easemob/im/server/api/room/superadmin/promote/PromoteRoomSuperAdmin.java +++ /dev/null @@ -1,43 +0,0 @@ -package com.easemob.im.server.api.room.superadmin.promote; - -import com.easemob.im.server.api.Context; -import com.easemob.im.server.api.DefaultErrorMapper; -import com.easemob.im.server.api.ErrorMapper; -import com.easemob.im.server.exception.EMUnknownException; -import reactor.core.publisher.Mono; - -public class PromoteRoomSuperAdmin { - - private Context context; - - public PromoteRoomSuperAdmin(Context context) { - this.context = context; - } - - public Mono single(String username) { - return this.context.getHttpClient() - .flatMap(httpClient -> httpClient.post() - .uri("/chatrooms/super_admin") - .send(Mono.create(sink -> sink.success(this.context.getCodec() - .encode(new PromoteRoomSuperAdminRequest(username))))) - .responseSingle((rsp, buf) -> { - return buf.switchIfEmpty( - Mono.error(new EMUnknownException("response is null"))) - .flatMap(byteBuf -> { - ErrorMapper mapper = new DefaultErrorMapper(); - mapper.statusCode(rsp); - mapper.checkError(byteBuf); - return Mono.just(byteBuf); - }); - })) - .map(buf -> this.context.getCodec() - .decode(buf, PromoteRoomSuperAdminResponse.class)) - .handle((rsp, sink) -> { - if (!rsp.isSuccess()) { - sink.error(new EMUnknownException("unknown")); - return; - } - sink.complete(); - }); - } -} diff --git a/im-sdk-core/src/main/java/com/easemob/im/server/api/room/superadmin/promote/PromoteRoomSuperAdminRequest.java b/im-sdk-core/src/main/java/com/easemob/im/server/api/room/superadmin/promote/PromoteRoomSuperAdminRequest.java deleted file mode 100644 index 6559a193a..000000000 --- a/im-sdk-core/src/main/java/com/easemob/im/server/api/room/superadmin/promote/PromoteRoomSuperAdminRequest.java +++ /dev/null @@ -1,14 +0,0 @@ -package com.easemob.im.server.api.room.superadmin.promote; - -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonProperty; - -public class PromoteRoomSuperAdminRequest { - @JsonProperty("superadmin") - private String username; - - @JsonCreator - public PromoteRoomSuperAdminRequest(@JsonProperty("superadmin") String username) { - this.username = username; - } -} diff --git a/im-sdk-core/src/main/java/com/easemob/im/server/api/room/superadmin/promote/PromoteRoomSuperAdminResponse.java b/im-sdk-core/src/main/java/com/easemob/im/server/api/room/superadmin/promote/PromoteRoomSuperAdminResponse.java deleted file mode 100644 index a73ed1a2e..000000000 --- a/im-sdk-core/src/main/java/com/easemob/im/server/api/room/superadmin/promote/PromoteRoomSuperAdminResponse.java +++ /dev/null @@ -1,36 +0,0 @@ -package com.easemob.im.server.api.room.superadmin.promote; - -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonProperty; - -public class PromoteRoomSuperAdminResponse { - @JsonProperty("data") - private Wrapper wrapper; - - @JsonCreator - public PromoteRoomSuperAdminResponse(@JsonProperty("data") Wrapper wrapper) { - this.wrapper = wrapper; - } - - public boolean isSuccess() { - return this.wrapper != null && "success".equals(this.wrapper.getResult()); - } - - public static class Wrapper { - @JsonProperty("result") - private String result; - @JsonProperty("resource") - private String resource; - - @JsonCreator - public Wrapper(@JsonProperty("result") String result, - @JsonProperty("resource") String resource) { - this.result = result; - this.resource = resource; - } - - private String getResult() { - return this.result; - } - } -} diff --git a/im-sdk-core/src/main/java/com/easemob/im/server/api/room/update/UpdateRoom.java b/im-sdk-core/src/main/java/com/easemob/im/server/api/room/update/UpdateRoom.java deleted file mode 100644 index 52059c514..000000000 --- a/im-sdk-core/src/main/java/com/easemob/im/server/api/room/update/UpdateRoom.java +++ /dev/null @@ -1,60 +0,0 @@ -package com.easemob.im.server.api.room.update; - -import com.easemob.im.server.api.Context; -import com.easemob.im.server.api.DefaultErrorMapper; -import com.easemob.im.server.api.ErrorMapper; -import com.easemob.im.server.exception.EMUnknownException; -import reactor.core.publisher.Mono; - -import java.util.ArrayList; -import java.util.List; -import java.util.function.Consumer; - -public class UpdateRoom { - - private Context context; - - public UpdateRoom(Context context) { - this.context = context; - } - - public Mono byId(String id, Consumer customizer) { - UpdateRoomRequest request = new UpdateRoomRequest(); - customizer.accept(request); - - return this.context.getHttpClient() - .flatMap(httpClient -> httpClient.put() - .uri(String.format("/chatrooms/%s", id)) - .send(Mono.create(sink -> sink - .success(this.context.getCodec().encode(request)))) - .responseSingle((rsp, buf) -> { - return buf.switchIfEmpty( - Mono.error(new EMUnknownException("response is null"))) - .flatMap(byteBuf -> { - ErrorMapper mapper = new DefaultErrorMapper(); - mapper.statusCode(rsp); - mapper.checkError(byteBuf); - return Mono.just(byteBuf); - }); - })) - .map(buf -> this.context.getCodec().decode(buf, UpdateRoomResponse.class)) - .handle((rsp, sink) -> { - List notUpdated = new ArrayList<>(); - if (request.hasName() && !rsp.nameUpdated()) { - notUpdated.add("name"); - } - if (request.hasDescription() && !rsp.descriptionUpdated()) { - notUpdated.add("description"); - } - if (request.hasMaxMembers() && !rsp.maxMembersUpdated()) { - notUpdated.add("maxMembers"); - } - if (!notUpdated.isEmpty()) { - sink.error(new EMUnknownException( - String.format("%s not updated", String.join(",", notUpdated)))); - return; - } - sink.complete(); - }); - } -} diff --git a/im-sdk-core/src/main/java/com/easemob/im/server/api/room/update/UpdateRoomRequest.java b/im-sdk-core/src/main/java/com/easemob/im/server/api/room/update/UpdateRoomRequest.java deleted file mode 100644 index c0b672685..000000000 --- a/im-sdk-core/src/main/java/com/easemob/im/server/api/room/update/UpdateRoomRequest.java +++ /dev/null @@ -1,105 +0,0 @@ -package com.easemob.im.server.api.room.update; - -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; - -// TODO: add other mutable properties -public class UpdateRoomRequest { - @JsonProperty("name") - private String name; - - @JsonProperty("description") - private String description; - - @JsonProperty("maxusers") - private Integer maxMembers; - - @JsonProperty("custom") - private String custom; - - @JsonProperty("need_verify") - @JsonInclude(JsonInclude.Include.NON_NULL) - private Boolean needVerify; - - public UpdateRoomRequest() { - this.name = null; - this.description = null; - this.maxMembers = null; - this.custom = null; - } - - @JsonCreator - public UpdateRoomRequest(@JsonProperty("name") String name, - @JsonProperty("description") String description, - @JsonProperty("maxusers") Integer maxMembers) { - this.name = name; - this.description = description; - this.maxMembers = maxMembers; - } - - @JsonCreator - public UpdateRoomRequest(@JsonProperty("name") String name, - @JsonProperty("description") String description, - @JsonProperty("maxusers") Integer maxMembers, - @JsonProperty("custom") String custom) { - this.name = name; - this.description = description; - this.maxMembers = maxMembers; - this.custom = custom; - } - - @JsonCreator - public UpdateRoomRequest(@JsonProperty("name") String name, - @JsonProperty("description") String description, - @JsonProperty("maxusers") Integer maxMembers, - @JsonProperty("custom") String custom, - @JsonProperty("need_verify") Boolean needVerify) { - this.name = name; - this.description = description; - this.maxMembers = maxMembers; - this.custom = custom; - this.needVerify = needVerify; - } - - public UpdateRoomRequest withName(String name) { - this.name = name; - return this; - } - - public UpdateRoomRequest withDescription(String description) { - this.description = description; - return this; - } - - public UpdateRoomRequest withMaxMembers(Integer maxMembers) { - this.maxMembers = maxMembers; - return this; - } - - public UpdateRoomRequest withCustom(String custom) { - this.custom = custom; - return this; - } - - public UpdateRoomRequest withNeedVerify(Boolean needVerify){ - this.needVerify = needVerify; - return this; - } - - public boolean hasName() { - return this.name != null; - } - - public boolean hasDescription() { - return this.description != null; - } - - public boolean hasMaxMembers() { - return this.maxMembers != null; - } - - public boolean hasCustom() { - return this.custom != null; - } -} diff --git a/im-sdk-core/src/main/java/com/easemob/im/server/api/room/update/UpdateRoomResponse.java b/im-sdk-core/src/main/java/com/easemob/im/server/api/room/update/UpdateRoomResponse.java deleted file mode 100644 index 53dd8c137..000000000 --- a/im-sdk-core/src/main/java/com/easemob/im/server/api/room/update/UpdateRoomResponse.java +++ /dev/null @@ -1,56 +0,0 @@ -package com.easemob.im.server.api.room.update; - -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonProperty; - -public class UpdateRoomResponse { - - @JsonProperty("data") - private Wrapper wrapper; - - @JsonCreator - public UpdateRoomResponse(@JsonProperty("data") Wrapper wrapper) { - this.wrapper = wrapper; - } - - public boolean nameUpdated() { - return this.wrapper.getName() != null && this.wrapper.getName(); - } - - public boolean descriptionUpdated() { - return this.wrapper.getDescription() != null && this.wrapper.getDescription(); - } - - public boolean maxMembersUpdated() { - return this.wrapper.getMaxMembers() != null && this.wrapper.getMaxMembers(); - } - - public static class Wrapper { - @JsonProperty("description") - private Boolean description; - @JsonProperty("maxusers") - private Boolean maxMembers; - @JsonProperty("groupname") - private Boolean name; - - public Wrapper(@JsonProperty("description") Boolean description, - @JsonProperty("maxusers") Boolean maxMembers, - @JsonProperty("groupname") Boolean name) { - this.description = description; - this.maxMembers = maxMembers; - this.name = name; - } - - public Boolean getDescription() { - return this.description; - } - - public Boolean getMaxMembers() { - return this.maxMembers; - } - - public Boolean getName() { - return this.name; - } - } -} diff --git a/im-sdk-core/src/main/java/com/easemob/im/server/api/token/Token.java b/im-sdk-core/src/main/java/com/easemob/im/server/api/token/Token.java deleted file mode 100644 index d1d76a80c..000000000 --- a/im-sdk-core/src/main/java/com/easemob/im/server/api/token/Token.java +++ /dev/null @@ -1,37 +0,0 @@ -package com.easemob.im.server.api.token; - -import com.easemob.im.server.api.util.Utilities; - -import java.time.Instant; - -public class Token { - - private String value; - - private Instant expireAt; - - public Token(String value, Instant expireAt) { - this.value = value; - this.expireAt = expireAt; - } - - public boolean isValid() { - return Instant.now().isBefore(this.expireAt); - } - - public String getValue() { - return this.value; - } - - public Instant getExpireAt() { - return this.expireAt; - } - - @Override - public String toString() { - return "Token{" + - "value='" + Utilities.mask(value) + '\'' + - ", expireAt=" + expireAt + - '}'; - } -} diff --git a/im-sdk-core/src/main/java/com/easemob/im/server/api/token/TokenApi.java b/im-sdk-core/src/main/java/com/easemob/im/server/api/token/TokenApi.java deleted file mode 100644 index 452d33ea7..000000000 --- a/im-sdk-core/src/main/java/com/easemob/im/server/api/token/TokenApi.java +++ /dev/null @@ -1,293 +0,0 @@ -package com.easemob.im.server.api.token; - -import com.easemob.im.server.EMProperties; -import com.easemob.im.server.api.Context; -import com.easemob.im.server.api.DefaultErrorMapper; -import com.easemob.im.server.api.ErrorMapper; -import com.easemob.im.server.api.token.agora.AccessToken2; -import com.easemob.im.server.api.token.allocate.*; -import com.easemob.im.server.api.util.Utilities; -import com.easemob.im.server.exception.*; -import com.easemob.im.server.model.EMUser; -import io.netty.util.internal.StringUtil; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import reactor.core.publisher.Mono; - -import java.util.Map; -import java.util.function.Consumer; - -// TODO: need tests UT/IT -public class TokenApi { - - private static final String ERROR_MSG = "failed to build AccessToken2"; - private static final Logger log = LoggerFactory.getLogger(TokenApi.class); - - private final Context context; - - public TokenApi(Context context) { - this.context = context; - } - - public static Mono fetchUserTokenWithEasemobRealm(Context context, - TokenRequest tokenRequest) { - return context.getHttpClient() - .flatMap(httpClient -> httpClient.post() - .uri("/token") - .send(Mono.create(sink -> sink.success(context.getCodec() - .encode(tokenRequest)))) - .responseSingle((rsp, buf) -> { - return buf.switchIfEmpty( - Mono.error(new EMUnknownException("response is null"))) - .flatMap(byteBuf -> { - ErrorMapper mapper = new DefaultErrorMapper(); - mapper.statusCode(rsp); - mapper.checkError(byteBuf); - return Mono.just(byteBuf); - }); - })) - .map(buf -> context.getCodec().decode(buf, TokenResponse.class)) - .map(TokenResponse::asToken); - } - - /** - * 获取 App Token - * @return token - */ - public Mono getAppToken() { - return this.context.getTokenProvider().fetchAppToken(); - } - - /** - * 获取 User Token,expireInSeconds 仅对生成 Agora userToken 生效 - *

- * 可获取 Easemob userToken 或 Agora userToken. - *

- * 如果您在初始化 EMProperties 时使用的是 ClientId 与 ClientSecret,那么无需关注 Agora userToken,直接使用以下示例获取 Easemob userToken 即可。 - * 为用户 Cat 获取 Easemob userToken - *

{@code
-     * EMUser cathy = new EMUser("cathy", "da920000-ecf9-11eb-9af3-296ff79acb67", true);
-     * String cathyEasemobToken = service.token().getUserToken(cathy, null, null, "passwordOfUserCat");
-     * }
- *

- * 如果您在初始化 EMProperties 时使用的是 AppId 与 AppCert,那么需要关注 Agora userToken。 - * 其中 Agora userToken 的结构请参考 {@link AccessToken2} - *

- * Agora userToken 中除了 AgoraChat 权限以外, 还可以自定义添加其他 Agora 服务(比如RTC)的权限, - * 对每个服务的权限可以单独设置不同的过期时间. - *

- * 为用户 Alice 生成仅含 AgoraChat 权限的 Agora userToken, 有效期为3600秒: - *

{@code
-     * EMUser alice = new EMUser("alice", "da920000-ecf9-11eb-9af3-296ff79acb67", true);
-     * String aliceAgoraChatToken = service.token().getUserToken(alice, 3600, null, null);
-     * }
- *

- * 为用户 Bob 生成包含 AgoraChat 权限和 AgoraRTC (JOIN_CHANNEL) 权限的 Agora userToken, 有效期为600秒: - *

{@code
-     *
-     * EMUser bob = new EMUser("bob", "da921111-ecf9-11eb-9af3-296ff79acb67", true);
-     * String bobAgoraChatRtcToken = service.token().getUserToken(bob, 600, token -> {
-     *     AccessToken2.ServiceRtc serviceRtc = new AccessToken2.ServiceRtc("dummyRtcChannelName", "dummyUid");
-     *     serviceRtc.addPrivilegeRtc(AccessToken2.PrivilegeRtc.PRIVILEGE_JOIN_CHANNEL, 600);
-     *     token.addService(serviceRtc);
-     * }, null);
-     * }
- * - * @param user 用户 - * @param expireInSeconds token 过期时间 TTL in seconds,该参数仅对 Agora userToken 生效 - * @param tokenConfigurer 用来自定义添加其他 Agora 服务的 lambda function - * @param password 用户密码 - * @return Easemob userToken 或 Agora userToken - */ - public String getUserToken(EMUser user, Integer expireInSeconds, - Consumer tokenConfigurer, String password) { - - if (user == null) { - throw new EMInvalidArgumentException("user cannot be null"); - } - EMProperties properties = context.getProperties(); - EMProperties.Realm realm = properties.getRealm(); - if (realm.equals(EMProperties.Realm.AGORA_REALM)) { - if (expireInSeconds == null) { - throw new EMInvalidArgumentException("expireInSeconds cannot be null"); - } - String userId = user.getUuid(); - String appId = properties.getAppId(); - String appCert = properties.getAppCert(); - - AccessToken2 accessToken = new AccessToken2(appId, appCert, expireInSeconds); - AccessToken2.Service serviceChat = new AccessToken2.ServiceChat(userId); - serviceChat.addPrivilegeChat(AccessToken2.PrivilegeChat.PRIVILEGE_CHAT_USER, - expireInSeconds); - accessToken.addService(serviceChat); - - if (tokenConfigurer != null) { - tokenConfigurer.accept(accessToken); - } - validateUserChatToken(accessToken); - - try { - return accessToken.build(); - } catch (Exception e) { - log.error(ERROR_MSG, e); - throw new EMInvalidStateException(ERROR_MSG); - } - } else if (realm.equals(EMProperties.Realm.EASEMOB_REALM)) { - if (StringUtil.isNullOrEmpty(password)) { - throw new EMInvalidArgumentException("password cannot be blank"); - } - String userName = user.getUsername(); - return fetchUserTokenWithEasemobRealm(this.context, - UserTokenRequest.of(userName, password)) - .map(Token::getValue).block(Utilities.IT_TIMEOUT); - } else { - throw new EMInvalidStateException(String.format("invalid realm value %s", realm)); - } - } - - /** - * 获取 User Token,expireInSeconds 对生成 Easemob userToken 和 Agora userToken 都会生效 - *

- * 可获取 Easemob userToken 或 Agora userToken. - *

- * 如果您在初始化 EMProperties 时使用的是 ClientId 与 ClientSecret,那么无需关注 Agora userToken,直接使用以下示例获取 Easemob userToken 即可。 - * 为用户 Cat 获取 Easemob userToken - *

{@code
-     * EMUser cathy = new EMUser("cathy", "da920000-ecf9-11eb-9af3-296ff79acb67", true);
-     * String cathyEasemobToken = service.token().getUserTokenWithTtl(cathy, 86400, null, "passwordOfUserCat");
-     * }
- *

- * 如果您在初始化 EMProperties 时使用的是 AppId 与 AppCert,那么需要关注 Agora userToken。 - * 其中 Agora userToken 的结构请参考 {@link AccessToken2} - *

- * Agora userToken 中除了 AgoraChat 权限以外, 还可以自定义添加其他 Agora 服务(比如RTC)的权限, - * 对每个服务的权限可以单独设置不同的过期时间. - *

- * 为用户 Alice 生成仅含 AgoraChat 权限的 Agora userToken, 有效期为3600秒: - *

{@code
-     * EMUser alice = new EMUser("alice", "da920000-ecf9-11eb-9af3-296ff79acb67", true);
-     * String aliceAgoraChatToken = service.token().getUserTokenWithTtl(alice, 3600, null, null);
-     * }
- *

- * 为用户 Bob 生成包含 AgoraChat 权限和 AgoraRTC (JOIN_CHANNEL) 权限的 Agora userToken, 有效期为600秒: - *

{@code
-     *
-     * EMUser bob = new EMUser("bob", "da921111-ecf9-11eb-9af3-296ff79acb67", true);
-     * String bobAgoraChatRtcToken = service.token().getUserTokenWithTtl(bob, 600, token -> {
-     *     AccessToken2.ServiceRtc serviceRtc = new AccessToken2.ServiceRtc("dummyRtcChannelName", "dummyUid");
-     *     serviceRtc.addPrivilegeRtc(AccessToken2.PrivilegeRtc.PRIVILEGE_JOIN_CHANNEL, 600);
-     *     token.addService(serviceRtc);
-     * }, null);
-     * }
- * - * @param user 用户 - * @param expireInSeconds token 过期时间 TTL in seconds - * @param tokenConfigurer 用来自定义添加其他 Agora 服务的 lambda function - * @param password 用户密码 - * @return Easemob userToken 或 Agora userToken - */ - public String getUserTokenWithTtl(EMUser user, Integer expireInSeconds, - Consumer tokenConfigurer, String password) { - - if (user == null) { - throw new EMInvalidArgumentException("user cannot be null"); - } - EMProperties properties = context.getProperties(); - EMProperties.Realm realm = properties.getRealm(); - if (realm.equals(EMProperties.Realm.AGORA_REALM)) { - if (expireInSeconds == null) { - throw new EMInvalidArgumentException("expireInSeconds cannot be null"); - } - String userId = user.getUuid(); - String appId = properties.getAppId(); - String appCert = properties.getAppCert(); - - AccessToken2 accessToken = new AccessToken2(appId, appCert, expireInSeconds); - AccessToken2.Service serviceChat = new AccessToken2.ServiceChat(userId); - serviceChat.addPrivilegeChat(AccessToken2.PrivilegeChat.PRIVILEGE_CHAT_USER, - expireInSeconds); - accessToken.addService(serviceChat); - - if (tokenConfigurer != null) { - tokenConfigurer.accept(accessToken); - } - validateUserChatToken(accessToken); - - try { - return accessToken.build(); - } catch (Exception e) { - log.error(ERROR_MSG, e); - throw new EMInvalidStateException(ERROR_MSG); - } - } else if (realm.equals(EMProperties.Realm.EASEMOB_REALM)) { - if (StringUtil.isNullOrEmpty(password)) { - throw new EMInvalidArgumentException("password cannot be blank"); - } - String userName = user.getUsername(); - return fetchUserTokenWithEasemobRealm(this.context, - UserTokenTtlRequest.of(userName, password, Long.valueOf(expireInSeconds))) - .map(Token::getValue).block(Utilities.IT_TIMEOUT); - } else { - throw new EMInvalidStateException(String.format("invalid realm value %s", realm)); - } - } - - public String getUserTokenWithInherit(String username) { - if (username == null || username.isEmpty()) { - throw new EMInvalidArgumentException("user cannot be null"); - } - EMProperties properties = context.getProperties(); - EMProperties.Realm realm = properties.getRealm(); - if (realm.equals(EMProperties.Realm.AGORA_REALM)) { - throw new EMNotImplementedException("get user token with agora realm not implemented"); - } else if (realm.equals(EMProperties.Realm.EASEMOB_REALM)) { - return fetchUserTokenWithEasemobRealm(this.context, - InheritTokenRequest.of(username, true)) - .map(Token::getValue).block(Utilities.IT_TIMEOUT); - } else { - throw new EMInvalidStateException(String.format("invalid realm value %s", realm)); - } - } - - public String getUserTokenWithInherit(String username, Integer expireInSeconds) { - if (username == null || username.isEmpty()) { - throw new EMInvalidArgumentException("user cannot be null"); - } - EMProperties properties = context.getProperties(); - EMProperties.Realm realm = properties.getRealm(); - if (realm.equals(EMProperties.Realm.AGORA_REALM)) { - throw new EMNotImplementedException("get user token with agora realm not implemented"); - } else if (realm.equals(EMProperties.Realm.EASEMOB_REALM)) { - return fetchUserTokenWithEasemobRealm(this.context, - InheritTokenTtlRequest.of(username, true, Long.valueOf(expireInSeconds))) - .map(Token::getValue).block(Utilities.IT_TIMEOUT); - } else { - throw new EMInvalidStateException(String.format("invalid realm value %s", realm)); - } - } - - // must include userId if it has the chat.user privilege - // must not have chat.app privilege - private void validateUserChatToken(AccessToken2 token) { - AccessToken2.Service service = token.services.get(AccessToken2.SERVICE_TYPE_CHAT); - if (service == null) { - return; - } - AccessToken2.ServiceChat serviceChat = (AccessToken2.ServiceChat) service; - String userId = serviceChat.getUserId(); - Map chatPrivileges = serviceChat.getPrivileges(); - boolean hasUserId = StringUtil.isNullOrEmpty(userId); - boolean hasAppPrivilege = - chatPrivileges.get(AccessToken2.PrivilegeChat.PRIVILEGE_CHAT_APP.intValue) != null; - boolean hasUserPrivilege = - chatPrivileges.get(AccessToken2.PrivilegeChat.PRIVILEGE_CHAT_USER.intValue) != null; - if (hasAppPrivilege) { - throw new EMForbiddenException("userToken must not have chat app privilege"); - } - if (hasUserPrivilege && !hasUserId) { - throw new EMForbiddenException( - "accessToken with the chatUser privilege must include an userId"); - } - } - -} diff --git a/im-sdk-core/src/main/java/com/easemob/im/server/api/token/agora/Packable.java b/im-sdk-core/src/main/java/com/easemob/im/server/api/token/agora/Packable.java deleted file mode 100644 index 645a398ea..000000000 --- a/im-sdk-core/src/main/java/com/easemob/im/server/api/token/agora/Packable.java +++ /dev/null @@ -1,8 +0,0 @@ -package com.easemob.im.server.api.token.agora; - -/** - * Created by Li on 10/1/2016. - */ -public interface Packable { - ByteBuf marshal(ByteBuf out); -} diff --git a/im-sdk-core/src/main/java/com/easemob/im/server/api/token/allocate/AgoraTokenProvider.java b/im-sdk-core/src/main/java/com/easemob/im/server/api/token/allocate/AgoraTokenProvider.java deleted file mode 100644 index 6b3a42721..000000000 --- a/im-sdk-core/src/main/java/com/easemob/im/server/api/token/allocate/AgoraTokenProvider.java +++ /dev/null @@ -1,108 +0,0 @@ -package com.easemob.im.server.api.token.allocate; - -import com.easemob.im.server.EMProperties; -import com.easemob.im.server.api.Codec; -import com.easemob.im.server.api.DefaultErrorMapper; -import com.easemob.im.server.api.ErrorMapper; -import com.easemob.im.server.api.loadbalance.EndpointRegistry; -import com.easemob.im.server.api.loadbalance.LoadBalancer; -import com.easemob.im.server.api.token.Token; -import com.easemob.im.server.api.token.agora.AccessToken2; -import com.easemob.im.server.exception.EMInvalidStateException; -import com.easemob.im.server.exception.EMUnknownException; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import reactor.core.publisher.Mono; -import reactor.netty.http.client.HttpClient; - -import java.time.Duration; -import java.time.Instant; - -public class AgoraTokenProvider implements TokenProvider { - - private static final Logger log = LoggerFactory.getLogger(AgoraTokenProvider.class); - private final EMProperties properties; - - private final HttpClient httpClient; - - private final EndpointRegistry endpointRegistry; - - private final LoadBalancer loadBalancer; - - private final Codec codec; - - private final ErrorMapper errorMapper; - - private final Mono appToken; - - public AgoraTokenProvider(EMProperties properties, HttpClient httpClient, - EndpointRegistry endpointRegistry, LoadBalancer loadBalancer, Codec codec, - ErrorMapper errorMapper) { - this.properties = properties; - this.httpClient = httpClient; - this.endpointRegistry = endpointRegistry; - this.loadBalancer = loadBalancer; - this.codec = codec; - this.errorMapper = errorMapper; - this.appToken = fetchEasemobToken(properties.getAppId(), properties.getAppCert(), - properties.getAgoraTokenExpireInSeconds()) - .cache(token -> Duration.between(Instant.now(), token.getExpireAt()).dividedBy(2), - error -> Duration.ofSeconds(10), - () -> Duration.ofSeconds(10)); - } - - // exchangeForEasemobToken(httpClient, baseUrl, agoraToken, codec, errorMapper) - public static Mono exchangeForEasemobToken(HttpClient httpClient, String baseUrl, - Mono agoraToken, Codec codec, ErrorMapper errorMapper){ - return httpClient.baseUrl(baseUrl) - .headersWhen(headers -> agoraToken - .map(token -> headers.set("Authorization", String.format("Bearer %s", token)))) - .post().uri("/token") - .send(Mono.create(sink -> sink - .success(codec.encode(ExchangeTokenRequest.getInstance())))) - .responseSingle((rsp, buf) -> { - return buf.switchIfEmpty( - Mono.error(new EMUnknownException("response is null"))) - .flatMap(byteBuf -> { - ErrorMapper mapper = new DefaultErrorMapper(); - mapper.statusCode(rsp); - mapper.checkError(byteBuf); - return Mono.just(byteBuf); - }); - }) - .map(buf -> codec.decode(buf, ExchangeTokenResponse.class)) - .map(ExchangeTokenResponse::asToken); - } - - @Override - public Mono fetchAppToken() { - return this.appToken; - } - - private Mono fetchEasemobToken(String appId, String appCert, int expireInSeconds) { - return endpointRegistry.endpoints().map(this.loadBalancer::loadBalance) - .flatMap(endpoint -> - exchangeForEasemobToken( - this.httpClient, - String.format("%s/%s", endpoint.getUri(), this.properties.getAppkeySlashDelimited()), - buildAppToken(appId, appCert, expireInSeconds), this.codec, this.errorMapper - ) - ); - } - - private Mono buildAppToken(String appId, String appCert, int expireInSeconds) { - return Mono.fromCallable(() -> { - AccessToken2 accessToken = new AccessToken2(appId, appCert, expireInSeconds); - AccessToken2.Service serviceChat = new AccessToken2.ServiceChat(); - serviceChat.addPrivilegeChat(AccessToken2.PrivilegeChat.PRIVILEGE_CHAT_APP, expireInSeconds); - accessToken.addService(serviceChat); - try { - log.debug("building agoraAppToken upon expiration, with expireInSeconds = {}", expireInSeconds); - return accessToken.build(); - } catch (Exception e) { - log.error("building accessToken2 failed", e); - throw new EMInvalidStateException("building accessToken2 failed"); - } - }); - } -} diff --git a/im-sdk-core/src/main/java/com/easemob/im/server/api/token/allocate/AppTokenRequest.java b/im-sdk-core/src/main/java/com/easemob/im/server/api/token/allocate/AppTokenRequest.java deleted file mode 100644 index 31fc52613..000000000 --- a/im-sdk-core/src/main/java/com/easemob/im/server/api/token/allocate/AppTokenRequest.java +++ /dev/null @@ -1,28 +0,0 @@ -package com.easemob.im.server.api.token.allocate; - -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonProperty; - -public class AppTokenRequest implements TokenRequest { - @SuppressWarnings("java:S1170") - @JsonProperty("grant_type") - private final String grantType = "client_credentials"; - - @JsonProperty("client_id") - private final String clientId; - - @JsonProperty("client_secret") - private final String clientSecret; - - private AppTokenRequest(String clientId, String clientSecret) { - this.clientId = clientId; - this.clientSecret = clientSecret; - } - - @JsonCreator - public static AppTokenRequest of(@JsonProperty("client_id") String clientId, - @JsonProperty("client_secret") String clientSecret) { - return new AppTokenRequest(clientId, clientSecret); - } - -} diff --git a/im-sdk-core/src/main/java/com/easemob/im/server/api/token/allocate/DefaultTokenProvider.java b/im-sdk-core/src/main/java/com/easemob/im/server/api/token/allocate/DefaultTokenProvider.java deleted file mode 100644 index 52f97b294..000000000 --- a/im-sdk-core/src/main/java/com/easemob/im/server/api/token/allocate/DefaultTokenProvider.java +++ /dev/null @@ -1,79 +0,0 @@ -package com.easemob.im.server.api.token.allocate; - -import com.easemob.im.server.EMProperties; -import com.easemob.im.server.api.Codec; -import com.easemob.im.server.api.DefaultErrorMapper; -import com.easemob.im.server.api.ErrorMapper; -import com.easemob.im.server.api.loadbalance.EndpointRegistry; -import com.easemob.im.server.api.loadbalance.LoadBalancer; -import com.easemob.im.server.api.token.Token; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import reactor.core.publisher.Mono; -import reactor.netty.http.client.HttpClient; - -import java.time.Duration; -import java.time.Instant; - -public class DefaultTokenProvider implements TokenProvider { - - private static final Logger log = LoggerFactory.getLogger(DefaultTokenProvider.class); - - private final EMProperties properties; - - private final HttpClient httpClient; - - private final EndpointRegistry endpointRegistry; - - private final LoadBalancer loadBalancer; - - private final Codec codec; - - private final ErrorMapper errorMapper; - - private final Mono appToken; - - public DefaultTokenProvider(EMProperties properties, HttpClient httpClient, - EndpointRegistry endpointRegistry, LoadBalancer loadBalancer, Codec codec, - ErrorMapper errorMapper) { - this.properties = properties; - this.httpClient = httpClient; - this.endpointRegistry = endpointRegistry; - this.loadBalancer = loadBalancer; - this.codec = codec; - this.errorMapper = errorMapper; - AppTokenRequest appTokenRequest = AppTokenRequest - .of(this.properties.getClientId(), this.properties.getClientSecret()); - this.appToken = fetchToken(appTokenRequest) - .cache(token -> Duration.between(Instant.now(), token.getExpireAt()) - .dividedBy(2), - error -> Duration.ofSeconds(10), - () -> Duration.ofSeconds(10)); - } - - @Override - public Mono fetchAppToken() { - return this.appToken; - } - - private Mono fetchToken(TokenRequest tokenRequest) { - return endpointRegistry.endpoints() - .map(this.loadBalancer::loadBalance) - .flatMap(endpoint -> this.httpClient - .baseUrl(String.format("%s/%s", endpoint.getUri(), - this.properties.getAppkeySlashDelimited())) - .post() - .uri("/token") - .send(Mono.create(sink -> sink.success(this.codec.encode(tokenRequest)))) - .responseSingle((rsp, buf) -> Mono.zip(Mono.just(rsp), buf))) - .map(tuple2 -> { - ErrorMapper mapper = new DefaultErrorMapper(); - mapper.statusCode(tuple2.getT1()); - mapper.checkError(tuple2.getT2()); - - return tuple2.getT2(); - }) - .map(buf -> this.codec.decode(buf, TokenResponse.class)) - .map(TokenResponse::asToken); - } -} diff --git a/im-sdk-core/src/main/java/com/easemob/im/server/api/token/allocate/ExchangeTokenRequest.java b/im-sdk-core/src/main/java/com/easemob/im/server/api/token/allocate/ExchangeTokenRequest.java deleted file mode 100644 index 91099755d..000000000 --- a/im-sdk-core/src/main/java/com/easemob/im/server/api/token/allocate/ExchangeTokenRequest.java +++ /dev/null @@ -1,18 +0,0 @@ -package com.easemob.im.server.api.token.allocate; - -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonProperty; - -public class ExchangeTokenRequest implements TokenRequest { - @SuppressWarnings("java:S1170") - @JsonProperty("grant_type") - private final String grantType = "agora"; - - @JsonCreator - public ExchangeTokenRequest() { - } - - public static ExchangeTokenRequest getInstance() { - return new ExchangeTokenRequest(); - } -} diff --git a/im-sdk-core/src/main/java/com/easemob/im/server/api/token/allocate/ExchangeTokenResponse.java b/im-sdk-core/src/main/java/com/easemob/im/server/api/token/allocate/ExchangeTokenResponse.java deleted file mode 100644 index bdbd8aad0..000000000 --- a/im-sdk-core/src/main/java/com/easemob/im/server/api/token/allocate/ExchangeTokenResponse.java +++ /dev/null @@ -1,38 +0,0 @@ -package com.easemob.im.server.api.token.allocate; - -import com.easemob.im.server.api.token.Token; -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonProperty; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import java.time.Instant; - -public class ExchangeTokenResponse { - - private static final Logger log = LoggerFactory.getLogger(ExchangeTokenResponse.class); - - // easemob token - @JsonProperty("access_token") - private final String accessToken; - - @JsonProperty("expire_timestamp") - private final Long expireEpochMilli; - - private ExchangeTokenResponse(String accessToken, Long expireEpochMilli) { - this.accessToken = accessToken; - this.expireEpochMilli = expireEpochMilli; - } - - @JsonCreator - public static ExchangeTokenResponse of( - @JsonProperty("access_token") String accessToken, - @JsonProperty("expire_timestamp") Long expireEpochMilli) { - return new ExchangeTokenResponse(accessToken, expireEpochMilli); - } - - public Token asToken() { - Instant expireAt = Instant.ofEpochMilli(expireEpochMilli); - return new Token(this.accessToken, expireAt); - } -} diff --git a/im-sdk-core/src/main/java/com/easemob/im/server/api/token/allocate/InheritTokenRequest.java b/im-sdk-core/src/main/java/com/easemob/im/server/api/token/allocate/InheritTokenRequest.java deleted file mode 100644 index c0f2ffe10..000000000 --- a/im-sdk-core/src/main/java/com/easemob/im/server/api/token/allocate/InheritTokenRequest.java +++ /dev/null @@ -1,45 +0,0 @@ -package com.easemob.im.server.api.token.allocate; - -import com.easemob.im.server.exception.EMInvalidArgumentException; -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonProperty; -import io.netty.util.internal.StringUtil; - -public class InheritTokenRequest implements TokenRequest { - - @SuppressWarnings("java:S1170") - @JsonProperty("grant_type") - private final String grantType = "inherit"; - - @JsonProperty("username") - private final String username; - - @JsonProperty("autoCreateUser") - private final Boolean autoCreateUser; - - public InheritTokenRequest(String username, Boolean autoCreateUser) { - this.username = username; - this.autoCreateUser = autoCreateUser; - } - - @JsonCreator - public static InheritTokenRequest of(@JsonProperty("username") String username, - @JsonProperty("autoCreateUser") Boolean autoCreateUser) { - if (StringUtil.isNullOrEmpty(username)) { - throw new EMInvalidArgumentException("username must not be null or blank"); - } - return new InheritTokenRequest(username, autoCreateUser); - } - - public String getGrantType() { - return grantType; - } - - public String getUsername() { - return username; - } - - public Boolean getAutoCreateUser() { - return autoCreateUser; - } -} diff --git a/im-sdk-core/src/main/java/com/easemob/im/server/api/token/allocate/InheritTokenTtlRequest.java b/im-sdk-core/src/main/java/com/easemob/im/server/api/token/allocate/InheritTokenTtlRequest.java deleted file mode 100644 index 591111909..000000000 --- a/im-sdk-core/src/main/java/com/easemob/im/server/api/token/allocate/InheritTokenTtlRequest.java +++ /dev/null @@ -1,53 +0,0 @@ -package com.easemob.im.server.api.token.allocate; - -import com.easemob.im.server.exception.EMInvalidArgumentException; -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonProperty; -import io.netty.util.internal.StringUtil; - -public class InheritTokenTtlRequest implements TokenRequest { - - @SuppressWarnings("java:S1170") - @JsonProperty("grant_type") - private final String grantType = "inherit"; - - @JsonProperty("username") - private final String username; - - @JsonProperty("autoCreateUser") - private final Boolean autoCreateUser; - - @JsonProperty("ttl") - private final Long ttl; - - public InheritTokenTtlRequest(String username, Boolean autoCreateUser, Long ttl) { - this.username = username; - this.autoCreateUser = autoCreateUser; - this.ttl = ttl; - } - - @JsonCreator - public static InheritTokenTtlRequest of(@JsonProperty("username") String username, - @JsonProperty("autoCreateUser") Boolean autoCreateUser, @JsonProperty("ttl") Long ttl) { - if (StringUtil.isNullOrEmpty(username)) { - throw new EMInvalidArgumentException("username must not be null or blank"); - } - return new InheritTokenTtlRequest(username, autoCreateUser, ttl); - } - - public String getGrantType() { - return grantType; - } - - public String getUsername() { - return username; - } - - public Boolean getAutoCreateUser() { - return autoCreateUser; - } - - public Long getTtl() { - return ttl; - } -} diff --git a/im-sdk-core/src/main/java/com/easemob/im/server/api/token/allocate/TokenProvider.java b/im-sdk-core/src/main/java/com/easemob/im/server/api/token/allocate/TokenProvider.java deleted file mode 100644 index 280effa44..000000000 --- a/im-sdk-core/src/main/java/com/easemob/im/server/api/token/allocate/TokenProvider.java +++ /dev/null @@ -1,14 +0,0 @@ -package com.easemob.im.server.api.token.allocate; - -import com.easemob.im.server.api.token.Token; -import com.easemob.im.server.api.token.agora.AccessToken2; -import com.easemob.im.server.exception.EMNotImplementedException; -import reactor.core.publisher.Mono; - -import java.util.function.Consumer; - -public interface TokenProvider { - - Mono fetchAppToken(); - -} diff --git a/im-sdk-core/src/main/java/com/easemob/im/server/api/token/allocate/TokenRequest.java b/im-sdk-core/src/main/java/com/easemob/im/server/api/token/allocate/TokenRequest.java deleted file mode 100644 index 2ed69c2bf..000000000 --- a/im-sdk-core/src/main/java/com/easemob/im/server/api/token/allocate/TokenRequest.java +++ /dev/null @@ -1,8 +0,0 @@ -package com.easemob.im.server.api.token.allocate; - -/** - * Marker interface - */ -public interface TokenRequest { - -} diff --git a/im-sdk-core/src/main/java/com/easemob/im/server/api/token/allocate/TokenResponse.java b/im-sdk-core/src/main/java/com/easemob/im/server/api/token/allocate/TokenResponse.java deleted file mode 100644 index 0ad966ecb..000000000 --- a/im-sdk-core/src/main/java/com/easemob/im/server/api/token/allocate/TokenResponse.java +++ /dev/null @@ -1,40 +0,0 @@ -package com.easemob.im.server.api.token.allocate; - -import com.easemob.im.server.api.token.Token; -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonProperty; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import java.time.Duration; -import java.time.Instant; - -public class TokenResponse { - - private static final Logger log = LoggerFactory.getLogger(TokenResponse.class); - - // easemob token - @JsonProperty("access_token") - private final String accessToken; - - // TTL in seconds - @JsonProperty("expires_in") - private final int expireInSeconds; - - private TokenResponse(String accessToken, int expireInSeconds) { - this.accessToken = accessToken; - this.expireInSeconds = expireInSeconds; - } - - @JsonCreator - public static TokenResponse of( - @JsonProperty("access_token") String accessToken, - @JsonProperty("expires_in") int expireInSeconds) { - return new TokenResponse(accessToken, expireInSeconds); - } - - public Token asToken() { - Instant expireAt = Instant.now().plus(Duration.ofSeconds(this.expireInSeconds)); - return new Token(this.accessToken, expireAt); - } -} diff --git a/im-sdk-core/src/main/java/com/easemob/im/server/api/token/allocate/UserTokenRequest.java b/im-sdk-core/src/main/java/com/easemob/im/server/api/token/allocate/UserTokenRequest.java deleted file mode 100644 index a2eef871c..000000000 --- a/im-sdk-core/src/main/java/com/easemob/im/server/api/token/allocate/UserTokenRequest.java +++ /dev/null @@ -1,48 +0,0 @@ -package com.easemob.im.server.api.token.allocate; - -import com.easemob.im.server.exception.EMInvalidArgumentException; -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonProperty; -import io.netty.util.internal.StringUtil; - -public class UserTokenRequest implements TokenRequest { - @SuppressWarnings("java:S1170") - @JsonProperty("grant_type") - private final String grantType = "password"; - - @JsonProperty("username") - private final String username; - - @JsonProperty("password") - private final String password; - - private UserTokenRequest(String username, String password) { - this.username = username; - this.password = password; - } - - @JsonCreator - public static UserTokenRequest of(@JsonProperty("username") String username, - @JsonProperty("password") String password) { - if (StringUtil.isNullOrEmpty(username)) { - throw new EMInvalidArgumentException("username must not be null or blank"); - } - if (StringUtil.isNullOrEmpty(password)) { - throw new EMInvalidArgumentException("password must not be null or blank"); - } - return new UserTokenRequest(username, password); - } - - public String getGrantType() { - return grantType; - } - - public String getUsername() { - return username; - } - - public String getPassword() { - return password; - } - -} diff --git a/im-sdk-core/src/main/java/com/easemob/im/server/api/token/allocate/UserTokenTtlRequest.java b/im-sdk-core/src/main/java/com/easemob/im/server/api/token/allocate/UserTokenTtlRequest.java deleted file mode 100644 index 780d1c813..000000000 --- a/im-sdk-core/src/main/java/com/easemob/im/server/api/token/allocate/UserTokenTtlRequest.java +++ /dev/null @@ -1,56 +0,0 @@ -package com.easemob.im.server.api.token.allocate; - -import com.easemob.im.server.exception.EMInvalidArgumentException; -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonProperty; -import io.netty.util.internal.StringUtil; - -public class UserTokenTtlRequest implements TokenRequest { - @SuppressWarnings("java:S1170") - @JsonProperty("grant_type") - private final String grantType = "password"; - - @JsonProperty("username") - private final String username; - - @JsonProperty("password") - private final String password; - - @JsonProperty("ttl") - private final Long ttl; - - public UserTokenTtlRequest(String username, String password, Long ttl) { - this.username = username; - this.password = password; - this.ttl = ttl; - } - - @JsonCreator - public static UserTokenTtlRequest of(@JsonProperty("username") String username, - @JsonProperty("password") String password, @JsonProperty("ttl") Long ttl) { - if (StringUtil.isNullOrEmpty(username)) { - throw new EMInvalidArgumentException("username must not be null or blank"); - } - if (StringUtil.isNullOrEmpty(password)) { - throw new EMInvalidArgumentException("password must not be null or blank"); - } - return new UserTokenTtlRequest(username, password, ttl); - } - - public String getGrantType() { - return grantType; - } - - public String getUsername() { - return username; - } - - public String getPassword() { - return password; - } - - public Long getTtl() { - return ttl; - } - -} diff --git a/im-sdk-core/src/main/java/com/easemob/im/server/api/user/PushResource.java b/im-sdk-core/src/main/java/com/easemob/im/server/api/user/PushResource.java deleted file mode 100644 index 9a2b873c6..000000000 --- a/im-sdk-core/src/main/java/com/easemob/im/server/api/user/PushResource.java +++ /dev/null @@ -1,42 +0,0 @@ -package com.easemob.im.server.api.user; - -import com.fasterxml.jackson.annotation.JsonProperty; - -public class PushResource { - @JsonProperty("device_Id") - private String deviceId; - - @JsonProperty("device_token") - private String deviceToken; - - @JsonProperty("notifier_name") - private String notifierName; - - public PushResource(@JsonProperty("device_Id") String deviceId, - @JsonProperty("device_token") String deviceToken, - @JsonProperty("notifier_name") String notifierName) { - this.deviceId = deviceId; - this.deviceToken = deviceToken; - this.notifierName = notifierName; - } - - public String getDeviceId() { - return deviceId; - } - - public String getDeviceToken() { - return deviceToken; - } - - public String getNotifierName() { - return notifierName; - } - - @Override public String toString() { - return "PushResource{" + - "deviceId='" + deviceId + '\'' + - ", deviceToken='" + deviceToken + '\'' + - ", notifierName='" + notifierName + '\'' + - '}'; - } -} diff --git a/im-sdk-core/src/main/java/com/easemob/im/server/api/user/UserApi.java b/im-sdk-core/src/main/java/com/easemob/im/server/api/user/UserApi.java deleted file mode 100644 index 29a8572c1..000000000 --- a/im-sdk-core/src/main/java/com/easemob/im/server/api/user/UserApi.java +++ /dev/null @@ -1,411 +0,0 @@ -package com.easemob.im.server.api.user; - -import com.easemob.im.server.api.Context; -import com.easemob.im.server.api.token.Token; -import com.easemob.im.server.api.token.TokenApi; -import com.easemob.im.server.api.token.allocate.UserTokenRequest; -import com.easemob.im.server.api.user.create.CreateUser; -import com.easemob.im.server.api.user.forcelogout.ForceLogoutUser; -import com.easemob.im.server.api.user.get.UserGet; -import com.easemob.im.server.api.user.list.ListUsers; -import com.easemob.im.server.api.user.password.UpdateUserPassword; -import com.easemob.im.server.api.user.status.UserStatus; -import com.easemob.im.server.api.user.unregister.DeleteUser; -import com.easemob.im.server.exception.EMInvalidArgumentException; -import com.easemob.im.server.model.EMCreateUser; -import com.easemob.im.server.model.EMPage; -import com.easemob.im.server.model.EMUser; -import com.easemob.im.server.model.EMUserStatus; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import reactor.core.publisher.Flux; -import reactor.core.publisher.Mono; - -import java.util.ArrayList; -import java.util.List; -import java.util.function.Consumer; - -/** - * 用户API。 - */ -public class UserApi { - - private static final Logger log = LoggerFactory.getLogger(UserApi.class); - - private CreateUser createUser; - private DeleteUser deleteUser; - private ListUsers listUsers; - private UpdateUserPassword updateUserPassword; - private ForceLogoutUser forceLogoutUser; - - private UserStatus userStatus; - - private UserGet userGet; - - private Context context; - - public UserApi(Context context) { - this.createUser = new CreateUser(context); - this.deleteUser = new DeleteUser(context); - this.listUsers = new ListUsers(context); - this.updateUserPassword = new UpdateUserPassword(context); - this.forceLogoutUser = new ForceLogoutUser(context); - this.userStatus = new UserStatus(context); - this.userGet = new UserGet(context); - this.context = context; - } - - /** - * 创建用户。 - *

- * Server SDK 对创建的用户名有自己的限制,如果不想使用该限制,请查看此文档: - * 用户名限制 - *

- * API使用示例: - *

 {@code
-     * EMService service;
-     * try {
-     *     EMUser user = service.user().create("username", "password").block();
-     * } catch (EMException e) {
-     *     e.getErrorCode();
-     *     e.getMessage();
-     * }
-     * }
- * - * @param username 用户名,可以包含小写字母、数字、减号,有效长度1至32个字节 - * @param password 密码,可以包含字母、数字、特殊符号(~!@#$%^&*-_=+<>;:,./?),有效长度1至32字节 - * @return EMUser - * @see 注册用户 - */ - public Mono create(String username, String password) { - try { - if (context.getProperties().getValidateUserName()) { - EMUser.validateUsername(username); - } - EMUser.validatePassword(password); - } catch (EMInvalidArgumentException e) { - return Mono.error(e); - } - return this.createUser.single(username, password); - } - - /** - * 批量创建用户。 - *

- * Server SDK 对创建的用户名有自己的限制,如果不想使用该限制,请查看此文档: - * 用户名限制 - *

- * API使用示例: - *

 {@code
-     * EMService service;
-     * try {
-     *     List createUsers = new ArrayList<>();
-     *     EMCreateUser createUser1 = new EMCreateUser("user1", "123456");
-     *     EMCreateUser createUser2 = new EMCreateUser("user2", "123456");
-     *     createUsers.add(createUser1);
-     *     createUsers.add(createUser2);
-     *
-     *     List users = service.user().create(createUsers).block();
-     * } catch (EMException e) {
-     *     e.getErrorCode();
-     *     e.getMessage();
-     * }
-     * }
- * - * @param createUsers 需要创建用户的列表,EMCreateUser中包含用户名以及密码,用户名可以包含小写字母、数字、减号,有效长度1至32个字节 - * 密码,可以包含字母、数字、特殊符号(~!@#$%^&*-_=+<>;:,./?),有效长度1至32字节 - * @return EMUser - * @see 批量注册用户 - */ - public Mono> create(List createUsers) { - return this.createUser.batch(createUsers); - } - - /** - * 删除用户。 - *

- * API使用示例: - *

 {@code
-     * EMService service;
-     * try {
-     *     service.user().delete("username").block();
-     * } catch (EMException e) {
-     *     e.getErrorCode();
-     *     e.getMessage();
-     * }
-     * }
- * - * @param username 要删除的用户的用户名 - * @return 成功或失败 - * @see 删除用户 - */ - public Mono delete(String username) { - return this.deleteUser.single(username); - } - - /** - * 获取全部用户。 - *

- * API使用示例: - *

 {@code
-     * EMService service;
-     * try {
-     *     List users = service.user().listAllUsers().collectList().block();
-     * } catch (EMException e) {
-     *     e.getErrorCode();
-     *     e.getMessage();
-     * }
-     * }
- * - * @return 用户名或错误 - * @see 获取用户列表 - */ - public Flux listAllUsers() { - return this.listUsers.all(20); - } - - /** - * 分页获取用户列表。 - *

- * API使用示例: - *

 {@code
-     * EMService service;
-     * EMPage page = null;
-     * try {
-     *     page = service.user().listUsers(10, null).block();
-     *     List users = page.getValues();
-     *     System.out.println("用户列表:" + users);
-     * } catch (EMException e) {
-     *     e.getErrorCode();
-     *     e.getMessage();
-     * }
-     *
-     * // ... do something with the users ...
-     * if (page != null) {
-     *      String cursor = page.getCursor();
-     *      // cursor == null indicates the end of the list
-     *      while (cursor != null) {
-     *          try {
-     *              page = service.user().listUsers(10, cursor).block();
-     *              System.out.println("用户列表:" + page.getValues());
-     *              // ... do something to the users ...
-     *              cursor = page.getCursor();
-     *          } catch (EMException e) {
-     *              e.getErrorCode();
-     *              e.getMessage();
-     *          }
-     *      }
-     * }
-     * }
- * - * @param limit 返回多少用户 - * @param cursor 开始位置 - * @return 获取用户响应或错误 - * @see 获取用户列表 - * @see com.easemob.im.server.model.EMPage - */ - public Mono> listUsers(int limit, String cursor) { - return this.listUsers.next(limit, cursor); - } - - /** - * 删除全部用户。 - *

- * 请谨慎使用。 - *

- * API使用示例: - *

 {@code
-     * EMService service;
-     * try {
-     *     List users = service.user().deleteAll().collectList().block();
-     * } catch (EMException e) {
-     *     e.getErrorCode();
-     *     e.getMessage();
-     * }
-     * }
- * - * @return 删除的每个用户名或错误 - * @see 删除全部用户 - */ - public Flux deleteAll() { - return this.deleteUser.all(20); - } - - /** - * 获取用户详情。 - *

- * API使用示例: - *

 {@code
-     * EMService service;
-     * try {
-     *     EMUser user = service.user().get("username").block();
-     *     String uuid = user.getUuid();
-     *     String username = user.getUsername();
-     *     Boolean canLogin = user.getCanLogin();
-     * } catch (EMException e) {
-     *     e.getErrorCode();
-     *     e.getMessage();
-     * }
-     * }
- * - * @param username 用户名 - * @return A {@code Mono} emits {@code EMUser} on success. - * @see 获取用户详情 - */ - public Mono get(String username) { - return this.userGet.single(username); - } - - /** - * 修改用户密码。 - *

- * API使用示例: - *

 {@code
-     * EMService service;
-     * try {
-     *     service.user().updateUserPassword("username", "password").block();
-     * } catch (EMException e) {
-     *     e.getErrorCode();
-     *     e.getMessage();
-     * }
-     * }
- * - * @param username 要修改的用户的用户名 - * @param password 新密码 - * @return 成功或错误 - * @see 修改用户密码 - */ - public Mono updateUserPassword(String username, String password) { - try { - EMUser.validatePassword(password); - } catch (EMInvalidArgumentException e) { - return Mono.error(e); - } - - return this.updateUserPassword.update(username, password); - } - - /** - * 强制指定用户所有设备下线。 - *

- * API使用示例: - *

 {@code
-     * EMService service;
-     * try {
-     *     service.user().forceLogoutAllDevices("username").block();
-     * } catch (EMException e) {
-     *     e.getErrorCode();
-     *     e.getMessage();
-     * }
-     * }
- * - * @param username 要强制下线的用户的用户名 - * @return 成功或错误 - * @see 强制下线 - */ - public Mono forceLogoutAllDevices(String username) { - return this.forceLogoutUser.byUsername(username); - } - - /** - * 强制指定用户指定设备下线。 - *

- * TODO: 增加查询用户在线设备id的API - * - * API使用示例: - *

 {@code
-     * EMService service;
-     * try {
-     *     service.user().forceLogoutOneDevice("username", "resource").block();
-     * } catch (EMException e) {
-     *     e.getErrorCode();
-     *     e.getMessage();
-     * }
-     * }
- * - * @param username 要强制下线的用户的用户名 - * @param resource 要强制下线的设备id,获取设备id的方法待补充 - * @return 成功或错误 - * @see 强制下线 - */ - public Mono forceLogoutOneDevice(String username, String resource) { - return this.forceLogoutUser.byUsernameAndResource(username, resource); - } - - /** - * 获取用户在线状态。 - *

- * API使用示例: - *

 {@code
-     * EMService service;
-     * try {
-     *     Boolean isOnline = service.user().isUserOnline("username").block();
-     * } catch (EMException e) {
-     *     e.getErrorCode();
-     *     e.getMessage();
-     * }
-     * }
- * - * @param username 要查询的用户的用户名 - * @return 是否在线或错误 - * @see 获取用户在线状态 - */ - public Mono isUserOnline(String username) { - return this.userStatus.isUserOnline(username); - } - - /** - * 批量获取用户在线状态 - *

- * API使用示例: - *

 {@code
-     * EMService service;
-     * List users = new ArrayList<>();
-     * users.add("user1");
-     * users.add("user2");
-     *
-     * try {
-     *     List userStatuses = service.user().isUsersOnline(users).block();
-     * } catch (EMException e) {
-     *     e.getErrorCode();
-     *     e.getMessage();
-     * }
-     * }
- * - * @param usernames 需要查询状态的用户名 - * @return 是否在线或错误 - * @see 批量获取用户在线状态 - */ - public Mono> isUsersOnline(List usernames) { - if (usernames == null || usernames.size() == 0) { - return Mono.error(new EMInvalidArgumentException("usernames must not be null or empty")); - } - return this.userStatus.isUsersOnline(usernames); - } - - /** - * 获取用户token。 - *

- * API使用示例: - *

 {@code
-     * EMService service;
-     * try {
-     *     Token token = service.user().getToken("u1", "123").block();
-     *     String userToken = token.getValue();
-     * } catch (EMException e) {
-     *     e.getErrorCode();
-     *     e.getMessage();
-     * }
-     * }
- * - * @param username 要获取token的用户名 - * @param password 要获取token的用户名密码 - * @return 返回token或失败 - * @deprecated use {@link TokenApi#getUserToken(EMUser, Integer, Consumer, String)} instead. - */ - @Deprecated - public Mono getToken(String username, String password) { - return TokenApi.fetchUserTokenWithEasemobRealm(this.context, - UserTokenRequest.of(username, password)); - } -} diff --git a/im-sdk-core/src/main/java/com/easemob/im/server/api/user/UserResource.java b/im-sdk-core/src/main/java/com/easemob/im/server/api/user/UserResource.java deleted file mode 100644 index 18a59c0b4..000000000 --- a/im-sdk-core/src/main/java/com/easemob/im/server/api/user/UserResource.java +++ /dev/null @@ -1,63 +0,0 @@ -package com.easemob.im.server.api.user; - -import com.easemob.im.server.model.EMUser; -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonProperty; - -import java.util.List; - -public class UserResource { - - @JsonProperty("username") - private String username; - - @JsonProperty("uuid") - private String uuid; - - @JsonProperty("activated") - private boolean activated; - - @JsonProperty("pushInfo") - private List pushResources; - - @JsonCreator - public UserResource( - @JsonProperty("username") String username, - @JsonProperty("uuid") String uuid, - @JsonProperty("activated") boolean activated, - @JsonProperty("pushInfo") List pushResources) { - this.username = username; - this.uuid = uuid; - this.activated = activated; - this.pushResources = pushResources; - } - - public String getUuid() { - return uuid; - } - - public String getUsername() { - return username; - } - - public List getPushResources() { - return pushResources; - } - - public boolean isActivated() { - return activated; - } - - public EMUser toEMUser() { - return new EMUser(this.username, this.uuid, this.activated, this.pushResources); - } - - @Override public String toString() { - return "UserResource{" + - "username='" + username + '\'' + - ", uuid='" + uuid + '\'' + - ", activated=" + activated + - ", pushResources=" + pushResources + - '}'; - } -} diff --git a/im-sdk-core/src/main/java/com/easemob/im/server/api/user/create/BatchCreateUserResponse.java b/im-sdk-core/src/main/java/com/easemob/im/server/api/user/create/BatchCreateUserResponse.java deleted file mode 100644 index 53531ecc9..000000000 --- a/im-sdk-core/src/main/java/com/easemob/im/server/api/user/create/BatchCreateUserResponse.java +++ /dev/null @@ -1,24 +0,0 @@ -package com.easemob.im.server.api.user.create; - -import com.easemob.im.server.api.user.UserResource; -import com.easemob.im.server.model.EMPage; -import com.easemob.im.server.model.EMUser; -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonProperty; - -import java.util.List; -import java.util.stream.Collectors; - -public class BatchCreateUserResponse { - @JsonProperty("entities") - private List entities; - - @JsonCreator - public BatchCreateUserResponse(@JsonProperty("entities") List entities) { - this.entities = entities; - } - - public List toEMUsers() { - return this.entities.stream().map(UserResource::toEMUser).collect(Collectors.toList()); - } -} diff --git a/im-sdk-core/src/main/java/com/easemob/im/server/api/user/create/CreateUser.java b/im-sdk-core/src/main/java/com/easemob/im/server/api/user/create/CreateUser.java deleted file mode 100644 index 6df1442bc..000000000 --- a/im-sdk-core/src/main/java/com/easemob/im/server/api/user/create/CreateUser.java +++ /dev/null @@ -1,70 +0,0 @@ -package com.easemob.im.server.api.user.create; - -import com.easemob.im.server.api.Context; -import com.easemob.im.server.api.DefaultErrorMapper; -import com.easemob.im.server.api.ErrorMapper; -import com.easemob.im.server.api.user.get.UserGetResponse; -import com.easemob.im.server.exception.EMUnknownException; -import com.easemob.im.server.model.EMCreateUser; -import com.easemob.im.server.model.EMUser; -import reactor.core.publisher.Mono; - -import java.util.List; - -public class CreateUser { - - private Context context; - - public CreateUser(Context context) { - this.context = context; - } - - public Mono single(String username, String password) { - return this.context.getHttpClient() - .flatMap(httpClient -> httpClient.post() - .uri("/users") - .send(Mono.create(sink -> sink.success(this.context.getCodec() - .encode(new CreateUserRequest(username, password))))) - .responseSingle( - (rsp, buf) -> { - return buf.switchIfEmpty( - Mono.error(new EMUnknownException("response is null"))) - .flatMap(byteBuf -> { - ErrorMapper mapper = new DefaultErrorMapper(); - mapper.statusCode(rsp); - mapper.checkError(byteBuf); - return Mono.just(byteBuf); - }); - })) - .map(byteBuf -> { - UserGetResponse userGetResponse = - this.context.getCodec().decode(byteBuf, UserGetResponse.class); - return userGetResponse.getEMUser(username.toLowerCase()); - }); - } - - public Mono> batch(List createUsers) { - return this.context.getHttpClient() - .flatMap(httpClient -> httpClient.post() - .uri("/users") - .send(Mono.create(sink -> sink.success(this.context.getCodec() - .encode(createUsers)))) - .responseSingle( - (rsp, buf) -> { - return buf.switchIfEmpty( - Mono.error(new EMUnknownException("response is null"))) - .flatMap(byteBuf -> { - ErrorMapper mapper = new DefaultErrorMapper(); - mapper.statusCode(rsp); - mapper.checkError(byteBuf); - return Mono.just(byteBuf); - }); - })) - .map(byteBuf -> { - BatchCreateUserResponse batchCreateUserResponse = - this.context.getCodec().decode(byteBuf, BatchCreateUserResponse.class); - return batchCreateUserResponse.toEMUsers(); - }); - } - -} diff --git a/im-sdk-core/src/main/java/com/easemob/im/server/api/user/create/CreateUserRequest.java b/im-sdk-core/src/main/java/com/easemob/im/server/api/user/create/CreateUserRequest.java deleted file mode 100644 index 033bf5a00..000000000 --- a/im-sdk-core/src/main/java/com/easemob/im/server/api/user/create/CreateUserRequest.java +++ /dev/null @@ -1,24 +0,0 @@ -package com.easemob.im.server.api.user.create; - -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonProperty; - -public class CreateUserRequest { - @JsonProperty("username") - private String username; - - @JsonProperty("password") - private String password; - - @JsonCreator - public CreateUserRequest(@JsonProperty("username") String username, - @JsonProperty("password") String password) { - this.username = username; - this.password = password; - } - - public String getUsername() { - return this.username; - } - -} diff --git a/im-sdk-core/src/main/java/com/easemob/im/server/api/user/create/CreateUserResponse.java b/im-sdk-core/src/main/java/com/easemob/im/server/api/user/create/CreateUserResponse.java deleted file mode 100644 index 64c05cfc1..000000000 --- a/im-sdk-core/src/main/java/com/easemob/im/server/api/user/create/CreateUserResponse.java +++ /dev/null @@ -1,18 +0,0 @@ -package com.easemob.im.server.api.user.create; - -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonProperty; - -public class CreateUserResponse { - @JsonProperty("error") - private String error; - - @JsonCreator - public CreateUserResponse(@JsonProperty("error") String error) { - this.error = error; - } - - public String getError() { - return this.error; - } -} diff --git a/im-sdk-core/src/main/java/com/easemob/im/server/api/user/forcelogout/ForceLogoutUser.java b/im-sdk-core/src/main/java/com/easemob/im/server/api/user/forcelogout/ForceLogoutUser.java deleted file mode 100644 index a0dbe1b0e..000000000 --- a/im-sdk-core/src/main/java/com/easemob/im/server/api/user/forcelogout/ForceLogoutUser.java +++ /dev/null @@ -1,54 +0,0 @@ -package com.easemob.im.server.api.user.forcelogout; - -import com.easemob.im.server.api.Context; -import com.easemob.im.server.api.DefaultErrorMapper; -import com.easemob.im.server.api.ErrorMapper; -import com.easemob.im.server.exception.EMInternalServerErrorException; -import com.easemob.im.server.exception.EMUnknownException; -import reactor.core.publisher.Mono; - -public class ForceLogoutUser { - - private Context context; - - public ForceLogoutUser(Context context) { - this.context = context; - } - - public Mono byUsername(String username) { - return byUsernameAndResource(username, null); - } - - public Mono byUsernameAndResource(String username, String resource) { - String path = String.format("/users/%s/disconnect", username); - if (resource != null) { - path = String.format("%s/%s", path, resource); - } - // immutable final uri path string - final String finalPath = String.valueOf(path); - return this.context.getHttpClient() - .flatMap(httpClient -> httpClient.get() - .uri(finalPath) - .responseSingle( - (rsp, buf) -> { - return buf.switchIfEmpty( - Mono.error(new EMUnknownException("response is null"))) - .flatMap(byteBuf -> { - ErrorMapper mapper = new DefaultErrorMapper(); - mapper.statusCode(rsp); - mapper.checkError(byteBuf); - return Mono.just(byteBuf); - }); - })) - .flatMap(byteBuf -> { - UserForceLogoutResponse userForceLogoutResponse = - this.context.getCodec().decode(byteBuf, UserForceLogoutResponse.class); - if (!userForceLogoutResponse.isSuccessful()) { - return Mono.error(new EMInternalServerErrorException("unknown")); - } - return Mono.just(userForceLogoutResponse); - }) - .then(); - - } -} diff --git a/im-sdk-core/src/main/java/com/easemob/im/server/api/user/forcelogout/UserForceLogoutResponse.java b/im-sdk-core/src/main/java/com/easemob/im/server/api/user/forcelogout/UserForceLogoutResponse.java deleted file mode 100644 index 578c26e6e..000000000 --- a/im-sdk-core/src/main/java/com/easemob/im/server/api/user/forcelogout/UserForceLogoutResponse.java +++ /dev/null @@ -1,29 +0,0 @@ -package com.easemob.im.server.api.user.forcelogout; - -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonProperty; - -public class UserForceLogoutResponse { - @JsonProperty("data") - private UserForceLogoutResultResource resultResource; - - @JsonCreator - public UserForceLogoutResponse( - @JsonProperty("data") UserForceLogoutResultResource resultResource) { - this.resultResource = resultResource; - } - - public boolean isSuccessful() { - return this.resultResource.result; - } - - private static class UserForceLogoutResultResource { - @JsonProperty("result") - private boolean result; - - @JsonCreator - public UserForceLogoutResultResource(@JsonProperty("result") boolean result) { - this.result = result; - } - } -} diff --git a/im-sdk-core/src/main/java/com/easemob/im/server/api/user/get/UserGet.java b/im-sdk-core/src/main/java/com/easemob/im/server/api/user/get/UserGet.java deleted file mode 100644 index 2fa540990..000000000 --- a/im-sdk-core/src/main/java/com/easemob/im/server/api/user/get/UserGet.java +++ /dev/null @@ -1,39 +0,0 @@ -package com.easemob.im.server.api.user.get; - -import com.easemob.im.server.api.Context; -import com.easemob.im.server.api.DefaultErrorMapper; -import com.easemob.im.server.api.ErrorMapper; -import com.easemob.im.server.exception.EMUnknownException; -import com.easemob.im.server.model.EMUser; -import reactor.core.publisher.Mono; - -public class UserGet { - - private Context context; - - public UserGet(Context context) { - this.context = context; - } - - public Mono single(String username) { - return this.context.getHttpClient() - .flatMap(httpClient -> httpClient.get() - .uri(String.format("/users/%s", username)) - .responseSingle( - (rsp, buf) -> { - return buf.switchIfEmpty( - Mono.error(new EMUnknownException("response is null"))) - .flatMap(byteBuf -> { - ErrorMapper mapper = new DefaultErrorMapper(); - mapper.statusCode(rsp); - mapper.checkError(byteBuf); - return Mono.just(byteBuf); - }); - })) - .map(byteBuf -> { - UserGetResponse userGetResponse = this.context.getCodec() - .decode(byteBuf, UserGetResponse.class); - return userGetResponse.getEMUser(username.toLowerCase()); - }); - } -} diff --git a/im-sdk-core/src/main/java/com/easemob/im/server/api/user/get/UserGetResponse.java b/im-sdk-core/src/main/java/com/easemob/im/server/api/user/get/UserGetResponse.java deleted file mode 100644 index 464319699..000000000 --- a/im-sdk-core/src/main/java/com/easemob/im/server/api/user/get/UserGetResponse.java +++ /dev/null @@ -1,37 +0,0 @@ -package com.easemob.im.server.api.user.get; - -import com.easemob.im.server.api.user.UserResource; -import com.easemob.im.server.model.EMUser; -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonProperty; - -import java.util.List; - -public class UserGetResponse { - - @JsonProperty("entities") - private List entities; - - @JsonProperty("cursor") - private String cursor; - - @JsonCreator - public UserGetResponse(@JsonProperty("entities") List entities, - @JsonProperty("cursor") String cursor) { - this.entities = entities; - this.cursor = cursor; - } - - public EMUser getEMUser(String username) { - return this.entities.stream() - .filter(user -> { - return user.getUsername().toLowerCase().equals(username); - }).findFirst() - .map(UserResource::toEMUser).orElse(null); - } - - public String getCursor() { - return this.cursor; - } - -} diff --git a/im-sdk-core/src/main/java/com/easemob/im/server/api/user/list/ListUsers.java b/im-sdk-core/src/main/java/com/easemob/im/server/api/user/list/ListUsers.java deleted file mode 100644 index 0417b34ff..000000000 --- a/im-sdk-core/src/main/java/com/easemob/im/server/api/user/list/ListUsers.java +++ /dev/null @@ -1,58 +0,0 @@ -package com.easemob.im.server.api.user.list; - -import com.easemob.im.server.api.Context; -import com.easemob.im.server.api.DefaultErrorMapper; -import com.easemob.im.server.api.ErrorMapper; -import com.easemob.im.server.exception.EMUnknownException; -import com.easemob.im.server.model.EMPage; -import io.netty.handler.codec.http.QueryStringEncoder; -import reactor.core.publisher.Flux; -import reactor.core.publisher.Mono; - -public class ListUsers { - - private Context context; - - public ListUsers(Context context) { - this.context = context; - } - - public Flux all(int limit) { - return next(limit, null) - .expand(rsp -> rsp.getCursor() == null ? - Mono.empty() : - next(limit, rsp.getCursor())) - .limitRate(1) - .concatMapIterable(EMPage::getValues) - .limitRate(limit); - } - - public Mono> next(int limit, String cursor) { - QueryStringEncoder encoder = new QueryStringEncoder("/users"); - encoder.addParam("limit", String.valueOf(limit)); - if (cursor != null) { - encoder.addParam("cursor", cursor); - } - final String uriString = encoder.toString(); - return this.context.getHttpClient() - .flatMap(httpClient -> httpClient.get() - .uri(uriString) - .responseSingle( - (rsp, buf) -> { - return buf.switchIfEmpty( - Mono.error(new EMUnknownException("response is null"))) - .flatMap(byteBuf -> { - ErrorMapper mapper = new DefaultErrorMapper(); - mapper.statusCode(rsp); - mapper.checkError(byteBuf); - return Mono.just(byteBuf); - }); - })) - .map(byteBuf -> { - UserListResponse userListResponse = - this.context.getCodec().decode(byteBuf, UserListResponse.class); - return userListResponse.toEMPage(); - }); - } - -} diff --git a/im-sdk-core/src/main/java/com/easemob/im/server/api/user/list/UserListResponse.java b/im-sdk-core/src/main/java/com/easemob/im/server/api/user/list/UserListResponse.java deleted file mode 100644 index 3ba78c71c..000000000 --- a/im-sdk-core/src/main/java/com/easemob/im/server/api/user/list/UserListResponse.java +++ /dev/null @@ -1,54 +0,0 @@ -package com.easemob.im.server.api.user.list; - -import com.easemob.im.server.api.user.UserResource; -import com.easemob.im.server.model.EMPage; -import com.easemob.im.server.model.EMUser; -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonProperty; - -import java.util.List; -import java.util.stream.Collectors; - -public class UserListResponse { - - @JsonProperty("entities") - private List entities; - - @JsonProperty("cursor") - private String cursor; - - @JsonCreator - public UserListResponse(@JsonProperty("entities") List entities, - @JsonProperty("cursor") String cursor) { - this.entities = entities; - this.cursor = cursor; - } - - public List getUsernames() { - return this.entities.stream().map(UserResource::getUsername).collect(Collectors.toList()); - } - - public EMUser getEMUser(String username) { - return this.entities.stream() - .filter(user -> user.getUsername().equals(username)).findFirst() - .map(UserResource::toEMUser).orElse(null); - } - - public EMPage toEMPage() { - List usernames = - this.entities.stream().map(UserResource::getUsername).collect(Collectors.toList()); - return new EMPage<>(usernames, this.cursor); - } - - public String getCursor() { - return this.cursor; - } - - @Override - public String toString() { - return "UserListResponse{" + - "entities=" + entities + - ", cursor='" + cursor + '\'' + - '}'; - } -} diff --git a/im-sdk-core/src/main/java/com/easemob/im/server/api/user/password/UpdateUserPassword.java b/im-sdk-core/src/main/java/com/easemob/im/server/api/user/password/UpdateUserPassword.java deleted file mode 100644 index 45d338d28..000000000 --- a/im-sdk-core/src/main/java/com/easemob/im/server/api/user/password/UpdateUserPassword.java +++ /dev/null @@ -1,35 +0,0 @@ -package com.easemob.im.server.api.user.password; - -import com.easemob.im.server.api.Context; -import com.easemob.im.server.api.DefaultErrorMapper; -import com.easemob.im.server.api.ErrorMapper; -import com.easemob.im.server.exception.EMUnknownException; -import reactor.core.publisher.Mono; - -public class UpdateUserPassword { - private Context context; - - public UpdateUserPassword(Context context) { - this.context = context; - } - - public Mono update(String username, String password) { - return this.context.getHttpClient() - .flatMap(httpClient -> httpClient.put() - .uri(String.format("/users/%s/password", username)) - .send(Mono.create(sink -> sink.success(this.context.getCodec() - .encode(new UserPasswordResetRequest(password))))) - .responseSingle( - (rsp, buf) -> { - return buf.switchIfEmpty( - Mono.error(new EMUnknownException("response is null"))) - .flatMap(byteBuf -> { - ErrorMapper mapper = new DefaultErrorMapper(); - mapper.statusCode(rsp); - mapper.checkError(byteBuf); - return Mono.just(byteBuf); - }); - })) - .then(); - } -} diff --git a/im-sdk-core/src/main/java/com/easemob/im/server/api/user/password/UserPasswordResetRequest.java b/im-sdk-core/src/main/java/com/easemob/im/server/api/user/password/UserPasswordResetRequest.java deleted file mode 100644 index 913b297b9..000000000 --- a/im-sdk-core/src/main/java/com/easemob/im/server/api/user/password/UserPasswordResetRequest.java +++ /dev/null @@ -1,21 +0,0 @@ -package com.easemob.im.server.api.user.password; - -import com.easemob.im.server.model.EMUser; -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonProperty; - -public class UserPasswordResetRequest { - @JsonProperty("newpassword") - private String password; - - @JsonCreator - public UserPasswordResetRequest(@JsonProperty("newpassword") String password) { - EMUser.validatePassword(password); - this.password = password; - } - - public String getPassword() { - return password; - } - -} diff --git a/im-sdk-core/src/main/java/com/easemob/im/server/api/user/status/UserStatus.java b/im-sdk-core/src/main/java/com/easemob/im/server/api/user/status/UserStatus.java deleted file mode 100644 index 8f85765db..000000000 --- a/im-sdk-core/src/main/java/com/easemob/im/server/api/user/status/UserStatus.java +++ /dev/null @@ -1,64 +0,0 @@ -package com.easemob.im.server.api.user.status; - -import com.easemob.im.server.api.Context; -import com.easemob.im.server.api.DefaultErrorMapper; -import com.easemob.im.server.api.ErrorMapper; -import com.easemob.im.server.exception.EMUnknownException; -import com.easemob.im.server.model.EMUserStatus; -import reactor.core.publisher.Mono; - -import java.util.List; - -public class UserStatus { - - private Context context; - - public UserStatus(Context context) { - this.context = context; - } - - public Mono isUserOnline(String username) { - return context.getHttpClient() - .flatMap(httpClient -> httpClient.get() - .uri(String.format("/users/%s/status", username)) - .responseSingle((rsp, buf) -> { - return buf.switchIfEmpty( - Mono.error(new EMUnknownException("response is null"))) - .flatMap(byteBuf -> { - ErrorMapper mapper = new DefaultErrorMapper(); - mapper.statusCode(rsp); - mapper.checkError(byteBuf); - return Mono.just(byteBuf); - }); - })) - .map(byteBuf -> { - UserStatusResponse userStatusResponse = - this.context.getCodec().decode(byteBuf, UserStatusResponse.class); - return userStatusResponse.isUserOnline(username); - }); - } - - public Mono> isUsersOnline(List usernames) { - return context.getHttpClient() - .flatMap(httpClient -> httpClient.post() - .uri("/users/batch/status") - .send(Mono.create(sink -> sink.success(this.context.getCodec() - .encode(new UserStatusBatchQueryRequest(usernames))))) - .responseSingle((rsp, buf) -> { - return buf.switchIfEmpty( - Mono.error(new EMUnknownException("response is null"))) - .flatMap(byteBuf -> { - ErrorMapper mapper = new DefaultErrorMapper(); - mapper.statusCode(rsp); - mapper.checkError(byteBuf); - return Mono.just(byteBuf); - }); - })) - .map(byteBuf -> { - UserStatusBatchQueryResponse userStatusBatchQueryResponse = - this.context.getCodec() - .decode(byteBuf, UserStatusBatchQueryResponse.class); - return userStatusBatchQueryResponse.getUsersOnline(); - }); - } -} diff --git a/im-sdk-core/src/main/java/com/easemob/im/server/api/user/status/UserStatusBatchQueryRequest.java b/im-sdk-core/src/main/java/com/easemob/im/server/api/user/status/UserStatusBatchQueryRequest.java deleted file mode 100644 index 1650970ef..000000000 --- a/im-sdk-core/src/main/java/com/easemob/im/server/api/user/status/UserStatusBatchQueryRequest.java +++ /dev/null @@ -1,20 +0,0 @@ -package com.easemob.im.server.api.user.status; - -import java.util.List; - -public class UserStatusBatchQueryRequest { - - private List usernames; - - public UserStatusBatchQueryRequest(List usernames) { - this.usernames = usernames; - } - - public List getUsernames() { - return this.usernames; - } - - public void setUsernames(List usernames) { - this.usernames = usernames; - } -} diff --git a/im-sdk-core/src/main/java/com/easemob/im/server/api/user/status/UserStatusBatchQueryResponse.java b/im-sdk-core/src/main/java/com/easemob/im/server/api/user/status/UserStatusBatchQueryResponse.java deleted file mode 100644 index 96c511781..000000000 --- a/im-sdk-core/src/main/java/com/easemob/im/server/api/user/status/UserStatusBatchQueryResponse.java +++ /dev/null @@ -1,36 +0,0 @@ -package com.easemob.im.server.api.user.status; - -import com.easemob.im.server.exception.EMUnknownException; -import com.easemob.im.server.model.EMUserStatus; -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonProperty; - -import java.util.ArrayList; -import java.util.List; -import java.util.Map; - -public class UserStatusBatchQueryResponse { - - @JsonProperty("data") - private List> userStatusList; - - @JsonCreator - public UserStatusBatchQueryResponse(@JsonProperty("data") List> userStatusList) { - this.userStatusList = userStatusList; - } - - public List getUsersOnline() { - if (this.userStatusList == null || this.userStatusList.size() <= 0) { - throw new EMUnknownException("isUsersOnline api return result is null or empty"); - } - List emUserStatusList = new ArrayList<>(); - for (Map map : this.userStatusList) { - map.forEach((username, status) -> { - Boolean isOnline = "online".equals(status); - EMUserStatus emUserStatus = new EMUserStatus(username, isOnline); - emUserStatusList.add(emUserStatus); - }); - } - return emUserStatusList; - } -} diff --git a/im-sdk-core/src/main/java/com/easemob/im/server/api/user/status/UserStatusRequest.java b/im-sdk-core/src/main/java/com/easemob/im/server/api/user/status/UserStatusRequest.java deleted file mode 100644 index e65371eed..000000000 --- a/im-sdk-core/src/main/java/com/easemob/im/server/api/user/status/UserStatusRequest.java +++ /dev/null @@ -1,16 +0,0 @@ -package com.easemob.im.server.api.user.status; - -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonProperty; - -import java.util.List; - -public class UserStatusRequest { - @JsonProperty("usernames") - private List usernames; - - @JsonCreator - public UserStatusRequest(@JsonProperty("usernames") List usernames) { - this.usernames = usernames; - } -} diff --git a/im-sdk-core/src/main/java/com/easemob/im/server/api/user/status/UserStatusResponse.java b/im-sdk-core/src/main/java/com/easemob/im/server/api/user/status/UserStatusResponse.java deleted file mode 100644 index f2b580790..000000000 --- a/im-sdk-core/src/main/java/com/easemob/im/server/api/user/status/UserStatusResponse.java +++ /dev/null @@ -1,22 +0,0 @@ -package com.easemob.im.server.api.user.status; - -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonProperty; - -import java.util.Map; - -public class UserStatusResponse { - @JsonProperty("data") - private Map statusByUsername; - - @JsonCreator - public UserStatusResponse(@JsonProperty("data") Map statusByUsername) { - this.statusByUsername = statusByUsername; - } - - public Boolean isUserOnline(String username) { - String status = this.statusByUsername.get(username); - return status != null && status.equals("online"); - } - -} diff --git a/im-sdk-core/src/main/java/com/easemob/im/server/api/user/unregister/DeleteUser.java b/im-sdk-core/src/main/java/com/easemob/im/server/api/user/unregister/DeleteUser.java deleted file mode 100644 index 997877582..000000000 --- a/im-sdk-core/src/main/java/com/easemob/im/server/api/user/unregister/DeleteUser.java +++ /dev/null @@ -1,76 +0,0 @@ -package com.easemob.im.server.api.user.unregister; - -import com.easemob.im.server.EMException; -import com.easemob.im.server.api.Context; -import com.easemob.im.server.api.DefaultErrorMapper; -import com.easemob.im.server.api.ErrorMapper; -import com.easemob.im.server.api.user.list.UserListResponse; -import com.easemob.im.server.exception.EMUnknownException; -import io.netty.handler.codec.http.QueryStringEncoder; -import reactor.core.publisher.Flux; -import reactor.core.publisher.Mono; -import reactor.netty.http.client.HttpClientResponse; - -public class DeleteUser { - - private Context context; - - public DeleteUser(Context context) { - this.context = context; - } - - public Mono single(String username) { - return this.context.getHttpClient() - .flatMap(httpClient -> httpClient.delete() - .uri(String.format("/users/%s", username)) - .responseSingle( - (rsp, buf) -> { - return buf.switchIfEmpty( - Mono.error(new EMUnknownException("response is null"))) - .flatMap(byteBuf -> { - ErrorMapper mapper = new DefaultErrorMapper(); - mapper.statusCode(rsp); - mapper.checkError(byteBuf); - return Mono.just(byteBuf); - }); - })) - .then(); - } - - public Flux all(int limit) { - return next(limit, null) - .expand(rsp -> rsp.getCursor() == null ? - Mono.empty() : - next(limit, rsp.getCursor())) - .concatMapIterable(UserUnregisterResponse::getUsernames); - } - - public Mono next(int limit, String cursor) { - // try to avoid manually assembling uri string - QueryStringEncoder encoder = new QueryStringEncoder("/users"); - encoder.addParam("limit", String.valueOf(limit)); - if (cursor != null) { - encoder.addParam("cursor", cursor); - } - String uirString = encoder.toString(); - return this.context.getHttpClient() - .flatMap(httpClient -> httpClient.delete() - .uri(uirString) - .responseSingle( - (rsp, buf) -> { - return buf.switchIfEmpty( - Mono.error(new EMUnknownException("response is null"))) - .flatMap(byteBuf -> { - ErrorMapper mapper = new DefaultErrorMapper(); - mapper.statusCode(rsp); - mapper.checkError(byteBuf); - return Mono.just(byteBuf); - }); - })) - .map(byteBuf -> { - UserUnregisterResponse userUnregisterResponse = - this.context.getCodec().decode(byteBuf, UserUnregisterResponse.class); - return userUnregisterResponse; - }); - } -} diff --git a/im-sdk-core/src/main/java/com/easemob/im/server/api/user/unregister/UserUnregisterResponse.java b/im-sdk-core/src/main/java/com/easemob/im/server/api/user/unregister/UserUnregisterResponse.java deleted file mode 100644 index 85f601edc..000000000 --- a/im-sdk-core/src/main/java/com/easemob/im/server/api/user/unregister/UserUnregisterResponse.java +++ /dev/null @@ -1,51 +0,0 @@ -package com.easemob.im.server.api.user.unregister; - -import com.easemob.im.server.api.user.UserResource; -import com.easemob.im.server.model.EMUser; -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonProperty; - -import java.util.List; -import java.util.stream.Collectors; - -public class UserUnregisterResponse { - @JsonProperty("entities") - private List entities; - - @JsonProperty("cursor") - private String cursor; - - @JsonProperty("error") - private String error; - - @JsonCreator - public UserUnregisterResponse(@JsonProperty("entities") List entities, - @JsonProperty("cursor") String cursor, - @JsonProperty("error") String error) { - this.entities = entities; - this.cursor = cursor; - this.error = error; - } - - public List getUsernames() { - return this.entities.stream() - .map(UserResource::getUsername) - .collect(Collectors.toList()); - } - - public EMUser getEMUser(String username) { - return this.entities.stream() - .filter(user -> user.getUsername().equals(username)) - .findFirst() - .map(UserResource::toEMUser) - .orElse(null); - } - - public String getCursor() { - return this.cursor; - } - - public String getError() { - return this.error; - } -} diff --git a/im-sdk-core/src/main/java/com/easemob/im/server/api/util/FileSystem.java b/im-sdk-core/src/main/java/com/easemob/im/server/api/util/FileSystem.java deleted file mode 100644 index 4b8c46f9c..000000000 --- a/im-sdk-core/src/main/java/com/easemob/im/server/api/util/FileSystem.java +++ /dev/null @@ -1,67 +0,0 @@ -package com.easemob.im.server.api.util; - -import com.easemob.im.server.exception.EMFileSystemException; -import io.netty.buffer.ByteBuf; -import io.netty.buffer.ByteBufUtil; - -import java.io.IOException; -import java.io.OutputStream; -import java.nio.file.Files; -import java.nio.file.Path; -import java.nio.file.StandardOpenOption; - -public class FileSystem { - - // avoid instantiate - private FileSystem() { - } - - public static Path choosePath(Path dir, String filename) { - if (!dir.toFile().exists()) { - dir.toFile().mkdirs(); - } - Path localFile = dir.resolve(filename); - int suffix = 0; - while (localFile.toFile().exists()) { - localFile = dir.resolve(filename + "." + suffix++); - } - return localFile; - } - - public static OutputStream open(Path path) { - try { - return Files - .newOutputStream(path, StandardOpenOption.CREATE_NEW, StandardOpenOption.WRITE); - } catch (IOException e) { - throw new EMFileSystemException(e.getMessage()); - } - } - - public static OutputStream append(OutputStream output, ByteBuf buf) { - byte[] array; - int offset; - if (buf.hasArray()) { - array = buf.array(); - offset = buf.arrayOffset(); - } else { - array = ByteBufUtil.getBytes(buf); - offset = 0; - } - - try { - output.write(array, offset, buf.readableBytes()); - } catch (IOException e) { - throw new EMFileSystemException(e.getMessage()); - } - - return output; - } - - public static void close(OutputStream out) { - try { - out.close(); - } catch (IOException e) { - throw new EMFileSystemException(e.getMessage()); - } - } -} diff --git a/im-sdk-core/src/main/java/com/easemob/im/server/api/util/Sensitive.java b/im-sdk-core/src/main/java/com/easemob/im/server/api/util/Sensitive.java deleted file mode 100644 index 91320b042..000000000 --- a/im-sdk-core/src/main/java/com/easemob/im/server/api/util/Sensitive.java +++ /dev/null @@ -1,8 +0,0 @@ -package com.easemob.im.server.api.util; - -public class Sensitive { - // avoid instantiate - private Sensitive() { - } - -} diff --git a/im-sdk-core/src/main/java/com/easemob/im/server/api/util/Utilities.java b/im-sdk-core/src/main/java/com/easemob/im/server/api/util/Utilities.java deleted file mode 100644 index 201fec96d..000000000 --- a/im-sdk-core/src/main/java/com/easemob/im/server/api/util/Utilities.java +++ /dev/null @@ -1,36 +0,0 @@ -package com.easemob.im.server.api.util; - -import io.netty.util.internal.StringUtil; - -import java.time.Duration; -import java.time.Instant; -import java.util.concurrent.ThreadLocalRandom; - -public class Utilities { - - public static final Duration IT_TIMEOUT = Duration.ofSeconds(60); - public static final Duration UT_TIMEOUT = Duration.ofSeconds(3); - public static final int DEFAULT_AGORA_TOKEN_EXPIRE_IN_SECONDS = 3600; - - public static String randomUserName() { - return String.format("it-%d-%d", - ThreadLocalRandom.current().nextInt(100000000), - Instant.now().toEpochMilli() - ); - } - - public static String randomPassword() { - return String.format("it-password-%d-%d", - ThreadLocalRandom.current().nextInt(10000), - Instant.now().getEpochSecond() - ); - } - - public static String mask(String text) { - if (StringUtil.isNullOrEmpty(text)) { - return text; - } else { - return text.replaceAll(".", "*"); - } - } -} diff --git a/im-sdk-core/src/main/java/com/easemob/im/server/exception/EMBadGatewayException.java b/im-sdk-core/src/main/java/com/easemob/im/server/exception/EMBadGatewayException.java deleted file mode 100644 index 666ef8611..000000000 --- a/im-sdk-core/src/main/java/com/easemob/im/server/exception/EMBadGatewayException.java +++ /dev/null @@ -1,11 +0,0 @@ -package com.easemob.im.server.exception; - -import com.easemob.im.server.EMException; - -public class EMBadGatewayException extends EMException { - - public EMBadGatewayException(String message) { - super(message); - } - -} diff --git a/im-sdk-core/src/main/java/com/easemob/im/server/exception/EMBadRequestException.java b/im-sdk-core/src/main/java/com/easemob/im/server/exception/EMBadRequestException.java deleted file mode 100644 index f20f65ebe..000000000 --- a/im-sdk-core/src/main/java/com/easemob/im/server/exception/EMBadRequestException.java +++ /dev/null @@ -1,11 +0,0 @@ -package com.easemob.im.server.exception; - -import com.easemob.im.server.EMException; - -public class EMBadRequestException extends EMException { - - public EMBadRequestException(String message) { - super(message); - } - -} diff --git a/im-sdk-core/src/main/java/com/easemob/im/server/exception/EMFileSystemException.java b/im-sdk-core/src/main/java/com/easemob/im/server/exception/EMFileSystemException.java deleted file mode 100644 index 956c62e02..000000000 --- a/im-sdk-core/src/main/java/com/easemob/im/server/exception/EMFileSystemException.java +++ /dev/null @@ -1,9 +0,0 @@ -package com.easemob.im.server.exception; - -import com.easemob.im.server.EMException; - -public class EMFileSystemException extends EMException { - public EMFileSystemException(String message) { - super(message); - } -} diff --git a/im-sdk-core/src/main/java/com/easemob/im/server/exception/EMForbiddenException.java b/im-sdk-core/src/main/java/com/easemob/im/server/exception/EMForbiddenException.java deleted file mode 100644 index ab4516d01..000000000 --- a/im-sdk-core/src/main/java/com/easemob/im/server/exception/EMForbiddenException.java +++ /dev/null @@ -1,11 +0,0 @@ -package com.easemob.im.server.exception; - -import com.easemob.im.server.EMException; - -public class EMForbiddenException extends EMException { - - public EMForbiddenException(String message) { - super(message); - } - -} diff --git a/im-sdk-core/src/main/java/com/easemob/im/server/exception/EMGatewayTimeoutException.java b/im-sdk-core/src/main/java/com/easemob/im/server/exception/EMGatewayTimeoutException.java deleted file mode 100644 index a031d852c..000000000 --- a/im-sdk-core/src/main/java/com/easemob/im/server/exception/EMGatewayTimeoutException.java +++ /dev/null @@ -1,11 +0,0 @@ -package com.easemob.im.server.exception; - -import com.easemob.im.server.EMException; - -public class EMGatewayTimeoutException extends EMException { - - public EMGatewayTimeoutException(String message) { - super(message); - } - -} diff --git a/im-sdk-core/src/main/java/com/easemob/im/server/exception/EMInternalServerErrorException.java b/im-sdk-core/src/main/java/com/easemob/im/server/exception/EMInternalServerErrorException.java deleted file mode 100644 index 02509a727..000000000 --- a/im-sdk-core/src/main/java/com/easemob/im/server/exception/EMInternalServerErrorException.java +++ /dev/null @@ -1,11 +0,0 @@ -package com.easemob.im.server.exception; - -import com.easemob.im.server.EMException; - -public class EMInternalServerErrorException extends EMException { - - public EMInternalServerErrorException(String message) { - super(message); - } - -} diff --git a/im-sdk-core/src/main/java/com/easemob/im/server/exception/EMInvalidArgumentException.java b/im-sdk-core/src/main/java/com/easemob/im/server/exception/EMInvalidArgumentException.java deleted file mode 100644 index 6410ed57d..000000000 --- a/im-sdk-core/src/main/java/com/easemob/im/server/exception/EMInvalidArgumentException.java +++ /dev/null @@ -1,9 +0,0 @@ -package com.easemob.im.server.exception; - -import com.easemob.im.server.EMException; - -public class EMInvalidArgumentException extends EMException { - public EMInvalidArgumentException(String message) { - super(message); - } -} diff --git a/im-sdk-core/src/main/java/com/easemob/im/server/exception/EMInvalidStateException.java b/im-sdk-core/src/main/java/com/easemob/im/server/exception/EMInvalidStateException.java deleted file mode 100644 index ce28020d8..000000000 --- a/im-sdk-core/src/main/java/com/easemob/im/server/exception/EMInvalidStateException.java +++ /dev/null @@ -1,9 +0,0 @@ -package com.easemob.im.server.exception; - -import com.easemob.im.server.EMException; - -public class EMInvalidStateException extends EMException { - public EMInvalidStateException(String message) { - super(message); - } -} diff --git a/im-sdk-core/src/main/java/com/easemob/im/server/exception/EMJsonException.java b/im-sdk-core/src/main/java/com/easemob/im/server/exception/EMJsonException.java deleted file mode 100644 index 32fb949b7..000000000 --- a/im-sdk-core/src/main/java/com/easemob/im/server/exception/EMJsonException.java +++ /dev/null @@ -1,14 +0,0 @@ -package com.easemob.im.server.exception; - -import com.easemob.im.server.EMException; - -public class EMJsonException extends EMException { - - public EMJsonException(String message) { - super(message); - } - - public EMJsonException(String message, Throwable cause) { - super(message, cause); - } -} diff --git a/im-sdk-core/src/main/java/com/easemob/im/server/exception/EMLoadBalanceException.java b/im-sdk-core/src/main/java/com/easemob/im/server/exception/EMLoadBalanceException.java deleted file mode 100644 index 8c1d9c22d..000000000 --- a/im-sdk-core/src/main/java/com/easemob/im/server/exception/EMLoadBalanceException.java +++ /dev/null @@ -1,9 +0,0 @@ -package com.easemob.im.server.exception; - -import com.easemob.im.server.EMException; - -public class EMLoadBalanceException extends EMException { - public EMLoadBalanceException(String message) { - super(message); - } -} diff --git a/im-sdk-core/src/main/java/com/easemob/im/server/exception/EMNotFoundException.java b/im-sdk-core/src/main/java/com/easemob/im/server/exception/EMNotFoundException.java deleted file mode 100644 index a906eb4f9..000000000 --- a/im-sdk-core/src/main/java/com/easemob/im/server/exception/EMNotFoundException.java +++ /dev/null @@ -1,11 +0,0 @@ -package com.easemob.im.server.exception; - -import com.easemob.im.server.EMException; - -public class EMNotFoundException extends EMException { - - public EMNotFoundException(String message) { - super(message); - } - -} diff --git a/im-sdk-core/src/main/java/com/easemob/im/server/exception/EMNotImplementedException.java b/im-sdk-core/src/main/java/com/easemob/im/server/exception/EMNotImplementedException.java deleted file mode 100644 index a70b5fa47..000000000 --- a/im-sdk-core/src/main/java/com/easemob/im/server/exception/EMNotImplementedException.java +++ /dev/null @@ -1,9 +0,0 @@ -package com.easemob.im.server.exception; - -import com.easemob.im.server.EMException; - -public class EMNotImplementedException extends EMException { - public EMNotImplementedException(String message) { - super(message); - } -} diff --git a/im-sdk-core/src/main/java/com/easemob/im/server/exception/EMServiceUnavailableException.java b/im-sdk-core/src/main/java/com/easemob/im/server/exception/EMServiceUnavailableException.java deleted file mode 100644 index 5abe5f14f..000000000 --- a/im-sdk-core/src/main/java/com/easemob/im/server/exception/EMServiceUnavailableException.java +++ /dev/null @@ -1,11 +0,0 @@ -package com.easemob.im.server.exception; - -import com.easemob.im.server.EMException; - -public class EMServiceUnavailableException extends EMException { - - public EMServiceUnavailableException(String message) { - super(message); - } - -} diff --git a/im-sdk-core/src/main/java/com/easemob/im/server/exception/EMTooManyRequestsException.java b/im-sdk-core/src/main/java/com/easemob/im/server/exception/EMTooManyRequestsException.java deleted file mode 100644 index 694f4b84b..000000000 --- a/im-sdk-core/src/main/java/com/easemob/im/server/exception/EMTooManyRequestsException.java +++ /dev/null @@ -1,11 +0,0 @@ -package com.easemob.im.server.exception; - -import com.easemob.im.server.EMException; - -public class EMTooManyRequestsException extends EMException { - - public EMTooManyRequestsException(String message) { - super(message); - } - -} diff --git a/im-sdk-core/src/main/java/com/easemob/im/server/exception/EMUnauthorizedException.java b/im-sdk-core/src/main/java/com/easemob/im/server/exception/EMUnauthorizedException.java deleted file mode 100644 index 69f6008cf..000000000 --- a/im-sdk-core/src/main/java/com/easemob/im/server/exception/EMUnauthorizedException.java +++ /dev/null @@ -1,9 +0,0 @@ -package com.easemob.im.server.exception; - -import com.easemob.im.server.EMException; - -public class EMUnauthorizedException extends EMException { - public EMUnauthorizedException(String message) { - super(message); - } -} diff --git a/im-sdk-core/src/main/java/com/easemob/im/server/exception/EMUnknownException.java b/im-sdk-core/src/main/java/com/easemob/im/server/exception/EMUnknownException.java deleted file mode 100644 index 119922062..000000000 --- a/im-sdk-core/src/main/java/com/easemob/im/server/exception/EMUnknownException.java +++ /dev/null @@ -1,11 +0,0 @@ -package com.easemob.im.server.exception; - -import com.easemob.im.server.EMException; - -public class EMUnknownException extends EMException { - - public EMUnknownException(String message) { - super(message); - } - -} diff --git a/im-sdk-core/src/main/java/com/easemob/im/server/exception/EMUnsupportedEncodingException.java b/im-sdk-core/src/main/java/com/easemob/im/server/exception/EMUnsupportedEncodingException.java deleted file mode 100644 index a68b4da48..000000000 --- a/im-sdk-core/src/main/java/com/easemob/im/server/exception/EMUnsupportedEncodingException.java +++ /dev/null @@ -1,9 +0,0 @@ -package com.easemob.im.server.exception; - -import com.easemob.im.server.EMException; - -public class EMUnsupportedEncodingException extends EMException { - public EMUnsupportedEncodingException(String message) { - super(message); - } -} diff --git a/im-sdk-core/src/main/java/com/easemob/im/server/model/EMAttachment.java b/im-sdk-core/src/main/java/com/easemob/im/server/model/EMAttachment.java deleted file mode 100644 index 068ae3658..000000000 --- a/im-sdk-core/src/main/java/com/easemob/im/server/model/EMAttachment.java +++ /dev/null @@ -1,57 +0,0 @@ -package com.easemob.im.server.model; - -import java.util.Objects; - -public class EMAttachment { - private String id; - private String url; - private String secret; - - public EMAttachment(String id, String secret) { - this.id = id; - this.secret = secret; - } - - public EMAttachment(String id, String url, String secret) { - this.id = id; - this.url = url; - this.secret = secret; - } - - public String getId() { - return id; - } - - public String getUrl() { - return url; - } - - public String getSecret() { - return secret; - } - - @Override - public boolean equals(Object o) { - if (this == o) - return true; - if (o == null || getClass() != o.getClass()) - return false; - EMAttachment that = (EMAttachment) o; - return Objects.equals(id, that.id) && - Objects.equals(secret, that.secret); - } - - @Override - public int hashCode() { - return Objects.hash(id, url, secret); - } - - @Override - public String toString() { - return "EMAttachment{" + - "id='" + id + '\'' + - ", url='" + url + '\'' + - ", secret='" + secret + '\'' + - '}'; - } -} diff --git a/im-sdk-core/src/main/java/com/easemob/im/server/model/EMBlock.java b/im-sdk-core/src/main/java/com/easemob/im/server/model/EMBlock.java deleted file mode 100644 index 9e5431f6b..000000000 --- a/im-sdk-core/src/main/java/com/easemob/im/server/model/EMBlock.java +++ /dev/null @@ -1,48 +0,0 @@ -package com.easemob.im.server.model; - -import java.time.Instant; -import java.util.Objects; - -public class EMBlock { - - private String username; - - private Instant expireAt; - - public EMBlock(String username, Instant expireAt) { - this.username = username; - this.expireAt = expireAt; - } - - public String getUsername() { - return this.username; - } - - public Instant getExpireAt() { - return this.expireAt; - } - - @Override - public boolean equals(Object o) { - if (this == o) - return true; - if (o == null || getClass() != o.getClass()) - return false; - EMBlock emBlock = (EMBlock) o; - return Objects.equals(username, emBlock.username) && Objects - .equals(expireAt, emBlock.expireAt); - } - - @Override - public int hashCode() { - return Objects.hash(username, expireAt); - } - - @Override - public String toString() { - return "EMBlock{" + - "username='" + username + '\'' + - ", expireAt=" + expireAt + - '}'; - } -} diff --git a/im-sdk-core/src/main/java/com/easemob/im/server/model/EMCommandMessage.java b/im-sdk-core/src/main/java/com/easemob/im/server/model/EMCommandMessage.java deleted file mode 100644 index 3c9a573d6..000000000 --- a/im-sdk-core/src/main/java/com/easemob/im/server/model/EMCommandMessage.java +++ /dev/null @@ -1,106 +0,0 @@ -package com.easemob.im.server.model; - -import java.util.HashSet; -import java.util.Objects; -import java.util.Set; - -public class EMCommandMessage extends EMMessage { - private String action; - - private Set params; - - public EMCommandMessage() { - super(MessageType.COMMAND); - } - - public String action() { - return this.action; - } - - public EMCommandMessage action(String action) { - this.action = action; - return this; - } - - public Set params() { - return this.params; - } - - public EMCommandMessage params(Set params) { - this.params = params; - return this; - } - - public EMCommandMessage param(String key, boolean value) { - if (this.params == null) { - this.params = new HashSet<>(); - } - this.params.add(EMKeyValue.of(key, value)); - return this; - } - - public EMCommandMessage param(String key, int value) { - if (this.params == null) { - this.params = new HashSet<>(); - } - this.params.add(EMKeyValue.of(key, value)); - return this; - } - - public EMCommandMessage param(String key, long value) { - if (this.params == null) { - this.params = new HashSet<>(); - } - this.params.add(EMKeyValue.of(key, value)); - return this; - } - - public EMCommandMessage param(String key, float value) { - if (this.params == null) { - this.params = new HashSet<>(); - } - this.params.add(EMKeyValue.of(key, value)); - return this; - } - - public EMCommandMessage param(String key, double value) { - if (this.params == null) { - this.params = new HashSet<>(); - } - this.params.add(EMKeyValue.of(key, value)); - return this; - } - - public EMCommandMessage param(String key, String value) { - if (this.params == null) { - this.params = new HashSet<>(); - } - this.params.add(EMKeyValue.of(key, value)); - return this; - } - - @Override - public boolean equals(Object o) { - if (this == o) - return true; - if (o == null || getClass() != o.getClass()) - return false; - if (!super.equals(o)) - return false; - EMCommandMessage that = (EMCommandMessage) o; - return Objects.equals(action, that.action) && Objects.equals(params, that.params); - } - - @Override - public int hashCode() { - return Objects.hash(super.hashCode(), action, params); - } - - @Override - public String toString() { - return "EMCommandMessage{" + - "action='" + action + '\'' + - ", params=" + params + - '}'; - } -} diff --git a/im-sdk-core/src/main/java/com/easemob/im/server/model/EMConversationType.java b/im-sdk-core/src/main/java/com/easemob/im/server/model/EMConversationType.java deleted file mode 100644 index da53b8b35..000000000 --- a/im-sdk-core/src/main/java/com/easemob/im/server/model/EMConversationType.java +++ /dev/null @@ -1,27 +0,0 @@ -package com.easemob.im.server.model; - -public enum EMConversationType { - /** - * 用户,表示单聊 - */ - USER("user"), - - /** - * 群组,表示群聊 - */ - CHAT_GROUP("chatgroup"); - - public String conversationType; - - EMConversationType(String conversationType) { - this.conversationType = conversationType; - } - - public String getConversationType() { - return conversationType; - } - - public void setConversationType(String conversationType) { - this.conversationType = conversationType; - } -} diff --git a/im-sdk-core/src/main/java/com/easemob/im/server/model/EMCreateUser.java b/im-sdk-core/src/main/java/com/easemob/im/server/model/EMCreateUser.java deleted file mode 100644 index ff7d9b5f8..000000000 --- a/im-sdk-core/src/main/java/com/easemob/im/server/model/EMCreateUser.java +++ /dev/null @@ -1,20 +0,0 @@ -package com.easemob.im.server.model; - -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonProperty; - -public class EMCreateUser { - - @JsonProperty("username") - private String username; - - @JsonProperty("password") - private String password; - - @JsonCreator - public EMCreateUser(@JsonProperty("username") String username, - @JsonProperty("password") String password) { - this.username = username; - this.password = password; - } -} diff --git a/im-sdk-core/src/main/java/com/easemob/im/server/model/EMCustomMessage.java b/im-sdk-core/src/main/java/com/easemob/im/server/model/EMCustomMessage.java deleted file mode 100644 index 22ea21e89..000000000 --- a/im-sdk-core/src/main/java/com/easemob/im/server/model/EMCustomMessage.java +++ /dev/null @@ -1,124 +0,0 @@ -package com.easemob.im.server.model; - -import com.easemob.im.server.exception.EMInvalidArgumentException; - -import java.util.*; - -public class EMCustomMessage extends EMMessage { - private String customEvent; - private Set customExtensions; - - public EMCustomMessage() { - super(MessageType.CUSTOM); - } - - public String customEvent() { - return this.customEvent; - } - - public EMCustomMessage customEvent(String customEvent) { - this.customEvent = customEvent; - return this; - } - - public Set customExtensions() { - return this.customExtensions; - } - - public EMCustomMessage customExtensions(Set customParams) { - if (customParams != null && !customParams.isEmpty()) { - long errorCount = customParams.stream().filter(kv -> kv.type() != EMKeyValue.Type.STRING).count(); - if (errorCount > 0) { - throw new EMInvalidArgumentException("customExtensions require key and value must be string"); - } - } - this.customExtensions = customParams; - return this; - } - - public EMKeyValue customExtension(String key) { - if (this.customExtensions == null) { - return null; - } - for (EMKeyValue keyValue : this.customExtensions) { - if (keyValue.key().equals(key)) { - return keyValue; - } - } - return null; - } - - public EMCustomMessage customExtension(String key, boolean value) { - if (this.customExtensions == null) { - this.customExtensions = new HashSet<>(); - } - this.customExtensions.add(EMKeyValue.of(key, value)); - return this; - } - - public EMCustomMessage customExtension(String key, int value) { - if (this.customExtensions == null) { - this.customExtensions = new HashSet<>(); - } - this.customExtensions.add(EMKeyValue.of(key, value)); - return this; - } - - public EMCustomMessage customExtension(String key, long value) { - if (this.customExtensions == null) { - this.customExtensions = new HashSet<>(); - } - this.customExtensions.add(EMKeyValue.of(key, value)); - return this; - } - - public EMCustomMessage customExtension(String key, float value) { - if (this.customExtensions == null) { - this.customExtensions = new HashSet<>(); - } - this.customExtensions.add(EMKeyValue.of(key, value)); - return this; - } - - public EMCustomMessage customExtension(String key, double value) { - if (this.customExtensions == null) { - this.customExtensions = new HashSet<>(); - } - this.customExtensions.add(EMKeyValue.of(key, value)); - return this; - } - - public EMCustomMessage customExtension(String key, String value) { - if (this.customExtensions == null) { - this.customExtensions = new HashSet<>(); - } - this.customExtensions.add(EMKeyValue.of(key, value)); - return this; - } - - @Override - public boolean equals(Object o) { - if (this == o) - return true; - if (o == null || getClass() != o.getClass()) - return false; - if (!super.equals(o)) - return false; - EMCustomMessage that = (EMCustomMessage) o; - return Objects.equals(customEvent, that.customEvent) && Objects - .equals(customExtensions, that.customExtensions); - } - - @Override - public int hashCode() { - return Objects.hash(super.hashCode(), customEvent, customExtensions); - } - - @Override - public String toString() { - return "EMCustomMessage{" + - "customEvent='" + customEvent + '\'' + - ", customParams=" + customExtensions + - '}'; - } -} diff --git a/im-sdk-core/src/main/java/com/easemob/im/server/model/EMEntity.java b/im-sdk-core/src/main/java/com/easemob/im/server/model/EMEntity.java deleted file mode 100644 index f22a76e44..000000000 --- a/im-sdk-core/src/main/java/com/easemob/im/server/model/EMEntity.java +++ /dev/null @@ -1,63 +0,0 @@ -package com.easemob.im.server.model; - -import java.util.Objects; - -public class EMEntity { - private EntityType entityType; - private String id; - - protected EMEntity(EntityType entityType) { - this.entityType = entityType; - } - - public static EMEntity user(String username) { - return new EMEntity(EntityType.USER).id(username); - } - - public static EMEntity group(String id) { - return new EMEntity(EntityType.GROUP).id(id); - } - - public static EMEntity room(String id) { - return new EMEntity(EntityType.ROOM).id(id); - } - - public static EMEntity message(String id) { - return new EMEntity(EntityType.MESSAGE).id(id); - } - - public EMEntity id(String id) { - this.id = id; - return this; - } - - public String id() { - return this.id; - } - - public EntityType entityType() { - return this.entityType; - } - - @Override - public boolean equals(Object o) { - if (this == o) - return true; - if (o == null || getClass() != o.getClass()) - return false; - EMEntity emEntity = (EMEntity) o; - return entityType == emEntity.entityType && Objects.equals(id, emEntity.id); - } - - @Override - public int hashCode() { - return Objects.hash(entityType, id); - } - - public enum EntityType { - USER, - GROUP, - ROOM, - MESSAGE, - } -} diff --git a/im-sdk-core/src/main/java/com/easemob/im/server/model/EMFileMessage.java b/im-sdk-core/src/main/java/com/easemob/im/server/model/EMFileMessage.java deleted file mode 100644 index 97d02072d..000000000 --- a/im-sdk-core/src/main/java/com/easemob/im/server/model/EMFileMessage.java +++ /dev/null @@ -1,65 +0,0 @@ -package com.easemob.im.server.model; - -import java.net.URI; - -@SuppressWarnings("java:S2160") -public class EMFileMessage extends EMMessage { - - private URI uri; - - private String displayName; - - private String secret; - - private Integer bytes; - - public EMFileMessage() { - super(MessageType.FILE); - } - - public URI uri() { - return this.uri; - } - - public EMFileMessage uri(URI uri) { - this.uri = uri; - return this; - } - - public String displayName() { - return this.displayName; - } - - public EMFileMessage displayName(String displayName) { - this.displayName = displayName; - return this; - } - - public String secret() { - return this.secret; - } - - public EMFileMessage secret(String secret) { - this.secret = secret; - return this; - } - - public Integer bytes() { - return this.bytes; - } - - public EMFileMessage bytes(int bytes) { - this.bytes = bytes; - return this; - } - - @Override - public String toString() { - return "EMFileMessage{" + - "uri=" + uri + - ", displayName='" + displayName + '\'' + - ", secret='" + secret + '\'' + - ", bytes=" + bytes + - '}'; - } -} diff --git a/im-sdk-core/src/main/java/com/easemob/im/server/model/EMGroup.java b/im-sdk-core/src/main/java/com/easemob/im/server/model/EMGroup.java deleted file mode 100644 index 54c4f60ac..000000000 --- a/im-sdk-core/src/main/java/com/easemob/im/server/model/EMGroup.java +++ /dev/null @@ -1,137 +0,0 @@ -package com.easemob.im.server.model; - -import com.easemob.im.server.exception.EMInvalidArgumentException; -import io.netty.util.internal.StringUtil; - -import java.util.regex.Pattern; - -public class EMGroup extends EMEntity { - - private static final Pattern GROUP_ID_PATTERN = Pattern.compile("^[1-9][0-9]{1,17}$"); - - private final String name; - - private final String description; - - private final boolean isPublic; - - private final boolean needApproveToJoin; - - private final boolean canMemberInviteOthers; - - private final String owner; - - private final int maxMembers; - - private final int affiliationsCount; - - private final Affiliation affiliations; - - private final boolean isMute; - - private final String custom; - - private final boolean isDisabled; - - public EMGroup(String groupId, String name, String description, boolean isPublic, - boolean needApproveToJoin, boolean canMemberInviteOthers, - String owner, int maxMembers, int affiliationsCount, String[] groupMembers, - boolean isMute, String custom, boolean isDisabled) { - super(EntityType.GROUP); - super.id(groupId); - this.name = name; - this.description = description; - this.isPublic = isPublic; - this.needApproveToJoin = needApproveToJoin; - this.canMemberInviteOthers = canMemberInviteOthers; - this.owner = owner; - this.maxMembers = maxMembers; - this.affiliationsCount = affiliationsCount; - this.affiliations = new Affiliation(owner, groupMembers); - this.isMute = isMute; - this.custom = custom; - this.isDisabled = isDisabled; - } - - public static void validateGroupId(String groupId) { - if (StringUtil.isNullOrEmpty(groupId)) { - throw new EMInvalidArgumentException("groupId must not be null or blank"); - } - if (!GROUP_ID_PATTERN.matcher(groupId).matches()) { - throw new EMInvalidArgumentException( - String.format("groupId '%s' should match regex %s", groupId, - GROUP_ID_PATTERN)); - } - } - - public String getGroupId() { - return super.id(); - } - - public String getName() { - return this.name; - } - - public String getDescription() { - return this.description; - } - - public boolean getIsPublic() { - return this.isPublic; - } - - public boolean getNeedApproveToJoin() { - return this.needApproveToJoin; - } - - public boolean getCanMemberInviteOthers() { - return this.canMemberInviteOthers; - } - - public String getOwner() { - return this.owner; - } - - public int getMaxMembers() { - return this.maxMembers; - } - - public int getAffiliationsCount() { - return this.affiliationsCount; - } - - public Affiliation getAffiliations() { - return this.affiliations; - } - - public class Affiliation { - private final String owner; - - private final String[] members; - - public Affiliation(String owner, String[] members) { - this.owner = owner; - this.members = members; - } - - public String getOwner() { - return this.owner; - } - - public String[] getMembers() { - return this.members; - } - } - - public boolean getIsMute() { - return this.isMute; - } - - public String getCustom() { - return this.custom; - } - - public boolean getIsDisabled() { - return this.isDisabled; - } -} diff --git a/im-sdk-core/src/main/java/com/easemob/im/server/model/EMImageMessage.java b/im-sdk-core/src/main/java/com/easemob/im/server/model/EMImageMessage.java deleted file mode 100644 index 80b89754d..000000000 --- a/im-sdk-core/src/main/java/com/easemob/im/server/model/EMImageMessage.java +++ /dev/null @@ -1,88 +0,0 @@ -package com.easemob.im.server.model; - -import java.net.URI; - -@SuppressWarnings("java:S2160") -public class EMImageMessage extends EMMessage { - private String displayName; - - private String secret; - - private URI uri; - - private int bytes; - - private Double width; - - private Double height; - - public EMImageMessage() { - super(MessageType.IMAGE); - } - - public URI uri() { - return this.uri; - } - - public EMImageMessage uri(URI uri) { - this.uri = uri; - return this; - } - - public EMImageMessage displayName(String displayName) { - this.displayName = displayName; - return this; - } - - public String displayName() { - return this.displayName; - } - - public EMImageMessage secret(String secret) { - this.secret = secret; - return this; - } - - public String secret() { - return this.secret; - } - - public Integer bytes() { - return this.bytes; - } - - public EMImageMessage bytes(int bytes) { - this.bytes = bytes; - return this; - } - - public Double width() { - return this.width; - } - - public EMImageMessage width(double pixels) { - this.width = pixels; - return this; - } - - public Double height() { - return this.height; - } - - public EMImageMessage height(double pixels) { - this.height = pixels; - return this; - } - - @Override - public String toString() { - return "EMImageMessage{" + - "displayName='" + displayName + '\'' + - ", secret='" + secret + '\'' + - ", uri=" + uri + - ", bytes=" + bytes + - ", width=" + width + - ", height=" + height + - '}'; - } -} diff --git a/im-sdk-core/src/main/java/com/easemob/im/server/model/EMKeyValue.java b/im-sdk-core/src/main/java/com/easemob/im/server/model/EMKeyValue.java deleted file mode 100644 index d2b028394..000000000 --- a/im-sdk-core/src/main/java/com/easemob/im/server/model/EMKeyValue.java +++ /dev/null @@ -1,125 +0,0 @@ -package com.easemob.im.server.model; - -import java.util.LinkedHashSet; -import java.util.Map; -import java.util.Set; - -public class EMKeyValue { - - private final String key; - - private final Type type; - - private final Object value; - - private EMKeyValue(String key, Type type, Object value) { - this.key = key; - this.type = type; - this.value = value; - } - - public static EMKeyValue of(String key, boolean value) { - return new EMKeyValue(key, Type.BOOL, value); - } - - public static EMKeyValue of(String key, int value) { - return new EMKeyValue(key, Type.INT, value); - } - - public static EMKeyValue of(String key, long value) { - return new EMKeyValue(key, Type.LLINT, value); - } - - public static EMKeyValue of(String key, float value) { - return new EMKeyValue(key, Type.FLOAT, value); - } - - public static EMKeyValue of(String key, double value) { - return new EMKeyValue(key, Type.DOUBLE, value); - } - - public static EMKeyValue of(String key, String value) { - return new EMKeyValue(key, Type.STRING, value); - } - - public static EMKeyValue of(String k, Object v) { - if (v instanceof Boolean) { - return EMKeyValue.of(k, (boolean) v); - } else if (v instanceof Integer) { - return EMKeyValue.of(k, (int) v); - } else if (v instanceof Long) { - return EMKeyValue.of(k, (long) v); - } else if (v instanceof Float) { - return EMKeyValue.of(k, (float) v); - } else if (v instanceof Double) { - return EMKeyValue.of(k, (double) v); - } else if (v instanceof String) { - return EMKeyValue.of(k, (String) v); - } else { - return new EMKeyValue(k, Type.OBJECT, v); - } - } - - public static Set of(Map map) { - if (map == null || map.isEmpty()) { - return new LinkedHashSet<>(); - } - Set emKeyValues = new LinkedHashSet<>(map.size()); - map.forEach((k, v) -> emKeyValues.add(EMKeyValue.of(k, v))); - return emKeyValues; - } - - public String key() { - return this.key; - } - - public Type type() { - return this.type; - } - - @SuppressWarnings("unchecked") - public boolean asBoolean() { - return (boolean) this.value; - } - - @SuppressWarnings("unchecked") - public int asInt() { - return (int) this.value; - } - - @SuppressWarnings("unchecked") - public long asLong() { - return (long) this.value; - } - - @SuppressWarnings("unchecked") - public long asFloat() { - return (long) this.value; - } - - @SuppressWarnings("unchecked") - public double asDouble() { - return (double) this.value; - } - - @SuppressWarnings("unchecked") - public String asString() { - return (String) this.value; - } - - public Object asObject() { - return this.value; - } - - public enum Type { - BOOL, - INT, - UINT, - LLINT, - FLOAT, - DOUBLE, - STRING, - JSON_STRING, - OBJECT, - } -} diff --git a/im-sdk-core/src/main/java/com/easemob/im/server/model/EMLocationMessage.java b/im-sdk-core/src/main/java/com/easemob/im/server/model/EMLocationMessage.java deleted file mode 100644 index 4dac2eaca..000000000 --- a/im-sdk-core/src/main/java/com/easemob/im/server/model/EMLocationMessage.java +++ /dev/null @@ -1,71 +0,0 @@ -package com.easemob.im.server.model; - -import java.util.Objects; - -public class EMLocationMessage extends EMMessage { - - private double longitude; - - private double latitude; - - private String address; - - public EMLocationMessage() { - super(MessageType.LOCATION); - } - - public double longitude() { - return this.longitude; - } - - public EMLocationMessage longitude(double longitude) { - this.longitude = longitude; - return this; - } - - public double latitude() { - return this.latitude; - } - - public EMLocationMessage latitude(double latitude) { - this.latitude = latitude; - return this; - } - - public String address() { - return this.address; - } - - public EMLocationMessage address(String address) { - this.address = address; - return this; - } - - @Override - public boolean equals(Object o) { - if (this == o) - return true; - if (o == null || getClass() != o.getClass()) - return false; - if (!super.equals(o)) - return false; - EMLocationMessage that = (EMLocationMessage) o; - return Double.compare(that.longitude, longitude) == 0 - && Double.compare(that.latitude, latitude) == 0 && Objects - .equals(address, that.address); - } - - @Override - public int hashCode() { - return Objects.hash(super.hashCode(), longitude, latitude, address); - } - - @Override - public String toString() { - return "EMLocationMessage{" + - "longitude=" + longitude + - ", latitude=" + latitude + - ", address='" + address + '\'' + - '}'; - } -} diff --git a/im-sdk-core/src/main/java/com/easemob/im/server/model/EMMessage.java b/im-sdk-core/src/main/java/com/easemob/im/server/model/EMMessage.java deleted file mode 100644 index c7264d463..000000000 --- a/im-sdk-core/src/main/java/com/easemob/im/server/model/EMMessage.java +++ /dev/null @@ -1,78 +0,0 @@ -package com.easemob.im.server.model; - -import java.util.Objects; - -public abstract class EMMessage extends EMEntity { - - private MessageType messageType; - - private EMEntity from; - - private EMEntity to; - - protected EMMessage(MessageType messageType) { - super(EntityType.MESSAGE); - this.messageType = messageType; - } - - public MessageType messageType() { - return this.messageType; - } - - public EMMessage fromUser(String username) { - this.from = EMEntity.user(username); - return this; - } - - public EMEntity from() { - return this.from; - } - - public EMMessage toUser(String username) { - this.to = EMEntity.user(username); - return this; - } - - public EMMessage toGroup(String groupId) { - this.to = EMEntity.group(groupId); - return this; - } - - public EMMessage toRoom(String roomId) { - this.to = EMEntity.room(roomId); - return this; - } - - public EMEntity to() { - return this.to; - } - - @Override - public boolean equals(Object o) { - if (this == o) - return true; - if (o == null || getClass() != o.getClass()) - return false; - if (!super.equals(o)) - return false; - EMMessage emMessage = (EMMessage) o; - return Objects.equals(from, emMessage.from) && Objects.equals(to, emMessage.to); - } - - @Override - public int hashCode() { - return Objects.hash(super.hashCode(), from, to); - } - - public enum MessageType { - TEXT, - IMAGE, - AUDIO, - VIDEO, - LOCATION, - FILE, - COMMAND, - CUSTOM, - } - -} diff --git a/im-sdk-core/src/main/java/com/easemob/im/server/model/EMMetadata.java b/im-sdk-core/src/main/java/com/easemob/im/server/model/EMMetadata.java deleted file mode 100644 index 6f1caf8ba..000000000 --- a/im-sdk-core/src/main/java/com/easemob/im/server/model/EMMetadata.java +++ /dev/null @@ -1,22 +0,0 @@ -package com.easemob.im.server.model; - -import java.util.Map; - -public class EMMetadata { - private Map data; - - public EMMetadata(Map data) { - this.data = data; - } - - public Map getData() { - return data; - } - - @Override - public String toString() { - return "EMMetadata{" + - "data=" + data + - '}'; - } -} diff --git a/im-sdk-core/src/main/java/com/easemob/im/server/model/EMMetadataBatch.java b/im-sdk-core/src/main/java/com/easemob/im/server/model/EMMetadataBatch.java deleted file mode 100644 index 5266e592d..000000000 --- a/im-sdk-core/src/main/java/com/easemob/im/server/model/EMMetadataBatch.java +++ /dev/null @@ -1,21 +0,0 @@ -package com.easemob.im.server.model; - -import java.util.Map; - -public class EMMetadataBatch { - private Map> data; - - public EMMetadataBatch(Map> data) { - this.data = data; - } - - public Map> getData() { - return data; - } - - @Override public String toString() { - return "EMMetadataBatch{" + - "data=" + data + - '}'; - } -} diff --git a/im-sdk-core/src/main/java/com/easemob/im/server/model/EMMetadataUsage.java b/im-sdk-core/src/main/java/com/easemob/im/server/model/EMMetadataUsage.java deleted file mode 100644 index c98255b42..000000000 --- a/im-sdk-core/src/main/java/com/easemob/im/server/model/EMMetadataUsage.java +++ /dev/null @@ -1,21 +0,0 @@ -package com.easemob.im.server.model; - -public class EMMetadataUsage { - - private Long bytesUsed; - - public EMMetadataUsage(Long bytesUsed) { - this.bytesUsed = bytesUsed; - } - - public Long getBytesUsed() { - return bytesUsed; - } - - @Override - public String toString() { - return "EMMetadataUsage{" + - "bytesUsed=" + bytesUsed + - '}'; - } -} diff --git a/im-sdk-core/src/main/java/com/easemob/im/server/model/EMMute.java b/im-sdk-core/src/main/java/com/easemob/im/server/model/EMMute.java deleted file mode 100644 index 66c1e070e..000000000 --- a/im-sdk-core/src/main/java/com/easemob/im/server/model/EMMute.java +++ /dev/null @@ -1,43 +0,0 @@ -package com.easemob.im.server.model; - -public class EMMute { - - private final String username; - - private final Integer chatMuteRemain; - - private final Integer groupChatMuteRemain; - - private final Integer chatroomMuteRemain; - - private final Integer unixTime; - - public EMMute(String username, Integer chatMuteRemain, Integer groupChatMuteRemain, - Integer chatroomMuteRemain, Integer unixTime) { - this.username = username; - this.chatMuteRemain = chatMuteRemain; - this.groupChatMuteRemain = groupChatMuteRemain; - this.chatroomMuteRemain = chatroomMuteRemain; - this.unixTime = unixTime; - } - - public String getUsername() { - return username; - } - - public Integer getChatMuteRemain() { - return chatMuteRemain; - } - - public Integer getGroupChatMuteRemain() { - return groupChatMuteRemain; - } - - public Integer getChatroomMuteRemain() { - return chatroomMuteRemain; - } - - public Integer getUnixTime() { - return unixTime; - } -} diff --git a/im-sdk-core/src/main/java/com/easemob/im/server/model/EMNotificationType.java b/im-sdk-core/src/main/java/com/easemob/im/server/model/EMNotificationType.java deleted file mode 100644 index 72edb3e44..000000000 --- a/im-sdk-core/src/main/java/com/easemob/im/server/model/EMNotificationType.java +++ /dev/null @@ -1,38 +0,0 @@ -package com.easemob.im.server.model; - -public enum EMNotificationType { - /** - * 默认值,采用全局配置 - */ - DEFAULT("DEFAULT"), - - /** - * 接收全部离线消息的推送通知 - */ - ALL("ALL"), - - /** - * 只接收提及当前用户的离线消息的推送通知 - */ - AT("AT"), - - /** - * 不接收离线消息的推送通知 - */ - NONE("NONE") - ; - - public String notificationType; - - EMNotificationType(String notificationType) { - this.notificationType = notificationType; - } - - public String getNotificationType() { - return notificationType; - } - - public void setNotificationType(String notificationType) { - this.notificationType = notificationType; - } -} diff --git a/im-sdk-core/src/main/java/com/easemob/im/server/model/EMPage.java b/im-sdk-core/src/main/java/com/easemob/im/server/model/EMPage.java deleted file mode 100644 index f7e6a1371..000000000 --- a/im-sdk-core/src/main/java/com/easemob/im/server/model/EMPage.java +++ /dev/null @@ -1,24 +0,0 @@ -package com.easemob.im.server.model; - -import java.util.List; - -public class EMPage { - - private List values; - - private String cursor; - - public EMPage(List values, String cursor) { - this.values = values; - this.cursor = cursor; - } - - public List getValues() { - return this.values; - } - - public String getCursor() { - return this.cursor; - } - -} diff --git a/im-sdk-core/src/main/java/com/easemob/im/server/model/EMRemoveMember.java b/im-sdk-core/src/main/java/com/easemob/im/server/model/EMRemoveMember.java deleted file mode 100644 index 23887cb09..000000000 --- a/im-sdk-core/src/main/java/com/easemob/im/server/model/EMRemoveMember.java +++ /dev/null @@ -1,61 +0,0 @@ -package com.easemob.im.server.model; - -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonProperty; - -public class EMRemoveMember { - - @JsonProperty("result") - private boolean isSuccess; - - @JsonProperty("user") - private String memberName; - - @JsonProperty("reason") - private String failReason; - - @JsonCreator - public EMRemoveMember(@JsonProperty("result") boolean isSuccess, - @JsonProperty("user") String memberName, - @JsonProperty("reason") String failReason) { - this.isSuccess = isSuccess; - this.memberName = memberName; - this.failReason = failReason; - } - -// @JsonCreator -// public EMRemoveMember(@JsonProperty("result") boolean isSuccess, -// @JsonProperty("user") String memberName -// ) { -// this.isSuccess = isSuccess; -// this.memberName = memberName; -// } -// -// public EMRemoveMember of() { -// if (this.isSuccess) { -// return new EMRemoveMember(true, this.memberName); -// } else { -// return new EMRemoveMember(false, this.memberName, this.failReason); -// } -// } - - public String getMemberName() { - return memberName; - } - - public boolean getIsSuccess() { - return isSuccess; - } - - public String getFailReason() { - return failReason; - } - - @Override public String toString() { - return "EMRemoveMember{" + - "isSuccess=" + isSuccess + - ", memberName='" + memberName + '\'' + - ", failReason='" + failReason + '\'' + - '}'; - } -} diff --git a/im-sdk-core/src/main/java/com/easemob/im/server/model/EMRoom.java b/im-sdk-core/src/main/java/com/easemob/im/server/model/EMRoom.java deleted file mode 100644 index 39b50a442..000000000 --- a/im-sdk-core/src/main/java/com/easemob/im/server/model/EMRoom.java +++ /dev/null @@ -1,127 +0,0 @@ -package com.easemob.im.server.model; - -import java.util.List; -import java.util.Map; - -public class EMRoom extends EMEntity { - - /** - * The room's name. - */ - private String name; - - /** - * The room's description. - */ - private String description; - - /** - * Does new member need approve of admins to join this room. - */ - private boolean needApproveToJoin; - - /** - * The owner's username. - */ - private String owner; - - /** - * How many members can this room hold. - */ - private int maxMembers; - - private Boolean mute; - - /** - * The room's members - */ - private List> members; - - /** - * The room's member count - */ - private Integer memberCount; - - /** - * The room's custom - */ - private String custom; - - /** - * The room's created time stamp - */ - private Long created; - - public EMRoom(String roomId, String name, String description, boolean needApproveToJoin, - String owner, int maxMembers, Boolean mute, List> members, - Integer memberCount, String custom, Long created) { - super(EntityType.ROOM); - super.id(roomId); - - this.name = name; - this.description = description; - this.needApproveToJoin = needApproveToJoin; - this.owner = owner; - this.maxMembers = maxMembers; - this.mute = mute; - this.members = members; - this.memberCount = memberCount; - this.custom = custom; - this.created = created; - } - - public String name() { - return this.name; - } - - public String description() { - return this.description; - } - - public String owner() { - return this.owner; - } - - public boolean needApprove() { - return this.needApproveToJoin; - } - - public int maxMembers() { - return this.maxMembers; - } - - public Boolean mute() { - return this.mute; - } - - public List> members() { - return this.members; - } - - public Integer memberCount() { - return this.memberCount; - } - - public String custom() { - return this.custom; - } - - public Long created() { - return this.created; - } - - @Override public String toString() { - return "EMRoom{" + - "name='" + name + '\'' + - ", description='" + description + '\'' + - ", needApproveToJoin=" + needApproveToJoin + - ", owner='" + owner + '\'' + - ", maxMembers=" + maxMembers + - ", mute=" + mute + - ", members=" + members + - ", memberCount=" + memberCount + - ", custom='" + custom + '\'' + - ", created=" + created + - '}'; - } -} diff --git a/im-sdk-core/src/main/java/com/easemob/im/server/model/EMSentMessageIds.java b/im-sdk-core/src/main/java/com/easemob/im/server/model/EMSentMessageIds.java deleted file mode 100644 index 6e937d8fc..000000000 --- a/im-sdk-core/src/main/java/com/easemob/im/server/model/EMSentMessageIds.java +++ /dev/null @@ -1,16 +0,0 @@ -package com.easemob.im.server.model; - -import java.util.Map; - -public class EMSentMessageIds { - - private Map messageIdsByEntityId; - - public EMSentMessageIds(Map messageIdsByEntityId) { - this.messageIdsByEntityId = messageIdsByEntityId; - } - - public Map getMessageIdsByEntityId() { - return this.messageIdsByEntityId; - } -} \ No newline at end of file diff --git a/im-sdk-core/src/main/java/com/easemob/im/server/model/EMSentMessageResults.java b/im-sdk-core/src/main/java/com/easemob/im/server/model/EMSentMessageResults.java deleted file mode 100644 index d3ad32562..000000000 --- a/im-sdk-core/src/main/java/com/easemob/im/server/model/EMSentMessageResults.java +++ /dev/null @@ -1,16 +0,0 @@ -package com.easemob.im.server.model; - -import java.util.Map; - -public class EMSentMessageResults { - - private Map messageResultsByEntityId; - - public EMSentMessageResults(Map messageResultsByEntityId) { - this.messageResultsByEntityId = messageResultsByEntityId; - } - - public Map getMessageResultsByEntityId() { - return this.messageResultsByEntityId; - } -} diff --git a/im-sdk-core/src/main/java/com/easemob/im/server/model/EMTextMessage.java b/im-sdk-core/src/main/java/com/easemob/im/server/model/EMTextMessage.java deleted file mode 100644 index 7d2ebf746..000000000 --- a/im-sdk-core/src/main/java/com/easemob/im/server/model/EMTextMessage.java +++ /dev/null @@ -1,45 +0,0 @@ -package com.easemob.im.server.model; - -import java.util.Objects; - -public class EMTextMessage extends EMMessage { - - private String text; - - public EMTextMessage() { - super(MessageType.TEXT); - } - - public String text() { - return this.text; - } - - public EMTextMessage text(String text) { - this.text = text; - return this; - } - - @Override - public boolean equals(Object o) { - if (this == o) - return true; - if (o == null || getClass() != o.getClass()) - return false; - if (!super.equals(o)) - return false; - EMTextMessage that = (EMTextMessage) o; - return Objects.equals(text, that.text); - } - - @Override - public int hashCode() { - return Objects.hash(super.hashCode(), text); - } - - @Override - public String toString() { - return "EMTextMessage{" + - "text='" + text + '\'' + - '}'; - } -} diff --git a/im-sdk-core/src/main/java/com/easemob/im/server/model/EMUser.java b/im-sdk-core/src/main/java/com/easemob/im/server/model/EMUser.java deleted file mode 100644 index 68e489f31..000000000 --- a/im-sdk-core/src/main/java/com/easemob/im/server/model/EMUser.java +++ /dev/null @@ -1,123 +0,0 @@ -package com.easemob.im.server.model; - -import com.easemob.im.server.api.user.PushResource; -import com.easemob.im.server.exception.EMInvalidArgumentException; -import io.netty.util.internal.StringUtil; - -import java.util.List; -import java.util.Objects; -import java.util.regex.Pattern; - -public class EMUser extends EMEntity { - - private static final Pattern USERNAME_PATTERN = Pattern.compile("^[a-z][0-9a-z-]{1,32}$"); - - private static final Pattern PASSWORD_PATTERN = - Pattern.compile("^[a-zA-Z0-9~!@#$%^&*\\-_=+<>;:,./?]{1,32}$"); - - private final String username; - private final String uuid; - private final Boolean canLogin; - private final List pushResources; - - /** - * @param username 用户名 - * @param canLogin 是否可登录 - * @deprecated use {@link EMUser} instead - */ - @Deprecated - public EMUser(String username, Boolean canLogin) { - this(username, null, canLogin, null); - } - - /** - * @param username 用户名 - * @param uuid 用户的uuid - * @param canLogin 是否可登录 - */ - public EMUser(String username, String uuid, Boolean canLogin) { - this(username, uuid, canLogin, null); - } - - /** - * @param username 用户名 - * @param uuid 用户 UUID - * @param canLogin 是否可登录 - * @param pushResources 推送信息,例如 deviceId、deviceToken - */ - public EMUser(String username, String uuid, Boolean canLogin, List pushResources) { - super(EntityType.USER); - if (StringUtil.isNullOrEmpty(username)) { - throw new EMInvalidArgumentException("username cannot be blank"); - } - super.id(username); - this.username = username; - this.uuid = uuid; - this.canLogin = canLogin; - this.pushResources = pushResources; - } - - public static void validateUsername(String username) { - if (StringUtil.isNullOrEmpty(username)) { - throw new EMInvalidArgumentException("username must not be null or blank"); - } - if (!USERNAME_PATTERN.matcher(username).matches()) { - throw new EMInvalidArgumentException( - String.format("username '%s' should match regex %s", username, - USERNAME_PATTERN.toString())); - } - } - - public static void validatePassword(String password) { - if (StringUtil.isNullOrEmpty(password)) { - throw new EMInvalidArgumentException("password must not be null or empty"); - } - if (!PASSWORD_PATTERN.matcher(password).matches()) { - // DO NOT show password - throw new EMInvalidArgumentException( - String.format("password should match regex %s", PASSWORD_PATTERN.toString())); - } - } - - public String getUsername() { - return this.username; - } - - public String getUuid() { - return this.uuid; - } - - public boolean getCanLogin() { - return this.canLogin; - } - - public List getPushResources() { - return pushResources; - } - - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (!(o instanceof EMUser)) { - return false; - } - EMUser emUser = (EMUser) o; - return username.equals(emUser.username); - } - - @Override - public int hashCode() { - return Objects.hash(username); - } - - @Override public String toString() { - return "EMUser{" + - "username='" + username + '\'' + - ", uuid='" + uuid + '\'' + - ", canLogin=" + canLogin + - ", pushResources=" + pushResources + - '}'; - } -} diff --git a/im-sdk-core/src/main/java/com/easemob/im/server/model/EMUserStatus.java b/im-sdk-core/src/main/java/com/easemob/im/server/model/EMUserStatus.java deleted file mode 100644 index 5237faca4..000000000 --- a/im-sdk-core/src/main/java/com/easemob/im/server/model/EMUserStatus.java +++ /dev/null @@ -1,21 +0,0 @@ -package com.easemob.im.server.model; - -public class EMUserStatus { - - private final String username; - - private final Boolean online; - - public EMUserStatus(String username, Boolean online) { - this.username = username; - this.online = online; - } - - public String getUsername() { - return this.username; - } - - public Boolean isOnline() { - return this.online; - } -} diff --git a/im-sdk-core/src/main/java/com/easemob/im/server/model/EMVideoMessage.java b/im-sdk-core/src/main/java/com/easemob/im/server/model/EMVideoMessage.java deleted file mode 100644 index 94947d646..000000000 --- a/im-sdk-core/src/main/java/com/easemob/im/server/model/EMVideoMessage.java +++ /dev/null @@ -1,105 +0,0 @@ -package com.easemob.im.server.model; - -import com.fasterxml.jackson.annotation.JsonProperty; - -import java.net.URI; - -@SuppressWarnings("java:S2160") -public class EMVideoMessage extends EMMessage { - private URI uri; - - private String displayName; - - private String secret; - - private Integer bytes; - /** - * the time unit depends on usage - **/ - private Integer duration; - - private String thumb; - - @JsonProperty("thumb_secret") - private String thumbSecret; - - public EMVideoMessage() { - super(MessageType.VIDEO); - } - - public URI uri() { - return this.uri; - } - - public EMVideoMessage uri(URI uri) { - this.uri = uri; - return this; - } - - public String displayName() { - return this.displayName; - } - - public EMVideoMessage displayName(String displayName) { - this.displayName = displayName; - return this; - } - - public String secret() { - return this.secret; - } - - public EMVideoMessage secret(String secret) { - this.secret = secret; - return this; - } - - public Integer bytes() { - return this.bytes; - } - - public EMVideoMessage bytes(int bytes) { - this.bytes = bytes; - return this; - } - - public Integer duration() { - return this.duration; - } - - public EMVideoMessage duration(int duration) { - this.duration = duration; - return this; - } - - public String thumb() { - return this.thumb; - } - - public EMVideoMessage thumb(String thumb) { - this.thumb = thumb; - return this; - } - - public String thumbSecret() { - return this.thumbSecret; - } - - public EMVideoMessage thumbSecret(String thumbSecret) { - this.thumbSecret = thumbSecret; - return this; - } - - @Override - public String toString() { - return "EMVideoMessage{" + - "uri=" + uri + - ", displayName='" + displayName + '\'' + - ", secret='" + secret + '\'' + - ", bytes=" + bytes + - ", duration=" + duration + - ", thumb='" + thumb + '\'' + - ", thumbSecret='" + thumbSecret + '\'' + - '}'; - } -} diff --git a/im-sdk-core/src/main/java/com/easemob/im/server/model/EMVoiceMessage.java b/im-sdk-core/src/main/java/com/easemob/im/server/model/EMVoiceMessage.java deleted file mode 100644 index f9f5ff1a8..000000000 --- a/im-sdk-core/src/main/java/com/easemob/im/server/model/EMVoiceMessage.java +++ /dev/null @@ -1,81 +0,0 @@ -package com.easemob.im.server.model; - -import java.net.URI; - -@SuppressWarnings("java:S2160") -public class EMVoiceMessage extends EMMessage { - - private URI uri; - - private String displayName; - - private String secret; - - private Integer bytes; - - /** - * the time unit depends on usage - **/ - private Integer duration; - - public EMVoiceMessage() { - super(MessageType.AUDIO); - } - - public URI uri() { - return this.uri; - } - - public EMVoiceMessage uri(URI uri) { - this.uri = uri; - return this; - } - - public String displayName() { - return this.displayName; - } - - public EMVoiceMessage displayName(String displayName) { - this.displayName = displayName; - return this; - } - - public String secret() { - return this.secret; - } - - public EMVoiceMessage secret(String secret) { - this.secret = secret; - return this; - } - - public Integer bytes() { - return this.bytes; - } - - public EMVoiceMessage bytes(int bytes) { - this.bytes = bytes; - return this; - } - - public Integer duration() { - return this.duration; - } - - public EMVoiceMessage duration(int duration) { - this.duration = duration; - return this; - } - - @Override - public String toString() { - return "EMVoiceMessage{" + - "uri=" + uri + - ", displayName='" + displayName + '\'' + - ", secret='" + secret + '\'' + - ", bytes=" + bytes + - ", duration=" + duration + - '}'; - } -} - diff --git a/im-sdk-core/src/test/java/com/easemob/im/server/EMPropertiesTest.java b/im-sdk-core/src/test/java/com/easemob/im/server/EMPropertiesTest.java deleted file mode 100644 index f481f537a..000000000 --- a/im-sdk-core/src/test/java/com/easemob/im/server/EMPropertiesTest.java +++ /dev/null @@ -1,113 +0,0 @@ -package com.easemob.im.server; - -import com.easemob.im.server.exception.EMInvalidArgumentException; -import com.easemob.im.server.exception.EMInvalidStateException; -import org.junit.jupiter.api.Test; - -import static org.junit.jupiter.api.Assertions.*; - -public class EMPropertiesTest { - - private static final String DUMMY_APP_KEY = "dummyOrg#dummyApp"; - private static final String DUMMY_CLIENT_ID = "dummyClientId"; - private static final String DUMMY_CLIENT_SECRET = "dummyClientSecret"; - private static final String DUMMY_APP_ID = "dummyAppId"; - private static final String DUMMY_APP_CERT = "dummyAppCert"; - - @Test - public void buildDefaultProperties() { - EMProperties properties = EMProperties.builder() - .setAppkey(DUMMY_APP_KEY) - .setClientId(DUMMY_CLIENT_ID) - .setClientSecret(DUMMY_CLIENT_SECRET) - .build(); - assertEquals(DUMMY_APP_KEY, properties.getAppkey()); - assertEquals(DUMMY_CLIENT_ID, properties.getClientId()); - assertEquals(DUMMY_CLIENT_SECRET, properties.getClientSecret()); - } - - @Test - public void buildEasemobRealmProperties() { - EMProperties properties = EMProperties.builder() - .setRealm(EMProperties.Realm.EASEMOB_REALM) - .setAppkey(DUMMY_APP_KEY) - .setClientId(DUMMY_CLIENT_ID) - .setClientSecret(DUMMY_CLIENT_SECRET) - .build(); - assertEquals(DUMMY_APP_KEY, properties.getAppkey()); - assertEquals(DUMMY_CLIENT_ID, properties.getClientId()); - assertEquals(DUMMY_CLIENT_SECRET, properties.getClientSecret()); - } - - @Test - public void buildAgoraRealmProperties() { - EMProperties properties = EMProperties.builder() - .setRealm(EMProperties.Realm.AGORA_REALM) - .setAppkey(DUMMY_APP_KEY) - .setAppId(DUMMY_APP_ID) - .setAppCert(DUMMY_APP_CERT) - .build(); - assertEquals(DUMMY_APP_KEY, properties.getAppkey()); - assertEquals(DUMMY_APP_ID, properties.getAppId()); - assertEquals(DUMMY_APP_CERT, properties.getAppCert()); - } - - @Test - public void testInvalidAppkeyOfEmpty() { - assertThrows(EMInvalidArgumentException.class, () -> EMProperties.builder().setAppkey("")); - } - - @Test - public void testInvalidAppkeyOfNull() { - assertThrows(EMInvalidArgumentException.class, - () -> EMProperties.builder().setAppkey(null)); - } - - @Test - public void testInvalidClientIdOfEmpty() { - assertThrows(EMInvalidArgumentException.class, - () -> EMProperties.builder().setClientId("")); - } - - @Test - public void testInvalidClientIdOfNull() { - assertThrows(EMInvalidArgumentException.class, - () -> EMProperties.builder().setClientId(null)); - } - - @Test - public void testInvalidClientSecretOfEmpty() { - assertThrows(EMInvalidArgumentException.class, - () -> EMProperties.builder().setClientSecret("")); - } - - @Test - public void testInvalidClientSecretOfNull() { - assertThrows(EMInvalidArgumentException.class, - () -> EMProperties.builder().setClientSecret(null)); - } - - @Test - public void testNotSettingAppkey() { - assertThrows(EMInvalidStateException.class, () -> EMProperties.builder() - .setClientId("id") - .setClientSecret("secret") - .build()); - } - - @Test - public void testNotSettingClientId() { - assertThrows(EMInvalidStateException.class, () -> EMProperties.builder() - .setAppkey("easemob#demo") - .setClientSecret("secret") - .build()); - } - - @Test - public void testNotSettingClientSecret() { - assertThrows(EMInvalidStateException.class, () -> EMProperties.builder() - .setAppkey("easemob#demo") - .setClientId("id") - .build()); - } -} diff --git a/im-sdk-core/src/test/java/com/easemob/im/server/api/AbstractApiTest.java b/im-sdk-core/src/test/java/com/easemob/im/server/api/AbstractApiTest.java deleted file mode 100644 index 1f0d6d3a5..000000000 --- a/im-sdk-core/src/test/java/com/easemob/im/server/api/AbstractApiTest.java +++ /dev/null @@ -1,40 +0,0 @@ -package com.easemob.im.server.api; - -import com.easemob.im.server.EMProperties; -import com.easemob.im.server.api.codec.JsonCodec; -import com.fasterxml.jackson.annotation.JsonAutoDetect; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.PropertyAccessor; -import com.fasterxml.jackson.databind.DeserializationFeature; -import com.fasterxml.jackson.databind.ObjectMapper; - -public abstract class AbstractApiTest { - protected ObjectMapper objectMapper; - - protected MockingHttpServer server; - - protected EMProperties properties; - - protected MockingContext context; - - protected JsonCodec codec; - - protected AbstractApiTest() { - - this.objectMapper = new ObjectMapper() - .configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false) - .setSerializationInclusion(JsonInclude.Include.NON_NULL); - - this.server = MockingHttpServer.builder().build(); - - this.properties = EMProperties.builder() - .setAppkey("easemob#demo") - .setClientId("clientId") - .setClientSecret("clientSecret") - .build(); - - this.context = new MockingContext(properties, this.server.uri()); - - this.codec = new JsonCodec(); - } -} diff --git a/im-sdk-core/src/test/java/com/easemob/im/server/api/MockingContext.java b/im-sdk-core/src/test/java/com/easemob/im/server/api/MockingContext.java deleted file mode 100644 index 790472246..000000000 --- a/im-sdk-core/src/test/java/com/easemob/im/server/api/MockingContext.java +++ /dev/null @@ -1,80 +0,0 @@ -package com.easemob.im.server.api; - -import com.easemob.im.server.EMProperties; -import com.easemob.im.server.EMVersion; -import com.easemob.im.server.api.codec.JsonCodec; -import com.easemob.im.server.api.token.allocate.TokenProvider; -import reactor.core.publisher.Mono; -import reactor.netty.http.client.HttpClient; - -public class MockingContext implements Context { - - private EMProperties properties; - - private Mono httpClient; - - private TokenProvider tokenProvider; - - private BearerAuthorization bearerAuthorization; - - private Codec codec; - - private ErrorMapper errorMapper; - - public MockingContext(EMProperties properties, String serverUri) { - this.properties = properties; - this.httpClient = Mono.just(HttpClient.newConnection() - .baseUrl(String.format("%s/%s", serverUri, properties.getAppkeySlashDelimited())) - .headers(headers -> headers.add("User-Agent", - String.format("EasemobServerSDK/%s", EMVersion.getVersion())))); - this.tokenProvider = new MockingTokenProvider(); - this.bearerAuthorization = new BearerAuthorization(tokenProvider); - this.codec = new JsonCodec(); - this.errorMapper = new DefaultErrorMapper(); - } - - @Override - public EMProperties getProperties() { - return this.properties; - } - - @Override - public Mono getHttpClient() { - return this.httpClient; - } - - public void setHttpClient(Mono httpClient) { - this.httpClient = httpClient; - } - - @Override - public TokenProvider getTokenProvider() { - return this.tokenProvider; - } - - public void setTokenProvider(TokenProvider tokenProvider) { - this.tokenProvider = tokenProvider; - } - - @Override - public Codec getCodec() { - return this.codec; - } - - public void setCodec(Codec codec) { - this.codec = codec; - } - - @Override - public ErrorMapper getErrorMapper() { - return this.errorMapper; - } - - public void setErrorMapper(ErrorMapper errorMapper) { - this.errorMapper = errorMapper; - } - - public void setBearerAuthorization(BearerAuthorization bearerAuthorization) { - this.bearerAuthorization = bearerAuthorization; - } -} diff --git a/im-sdk-core/src/test/java/com/easemob/im/server/api/MockingEndpointProvider.java b/im-sdk-core/src/test/java/com/easemob/im/server/api/MockingEndpointProvider.java deleted file mode 100644 index 9e58273e3..000000000 --- a/im-sdk-core/src/test/java/com/easemob/im/server/api/MockingEndpointProvider.java +++ /dev/null @@ -1,21 +0,0 @@ -package com.easemob.im.server.api; - -import com.easemob.im.server.api.loadbalance.Endpoint; -import com.easemob.im.server.api.loadbalance.EndpointProvider; -import reactor.core.publisher.Mono; - -import java.util.ArrayList; -import java.util.List; - -public class MockingEndpointProvider implements EndpointProvider { - - @Override - public Mono> endpoints() { - Endpoint endpoint1 = new Endpoint("https", "test.easemob.com", 443); - Endpoint endpoint2 = new Endpoint("http", "1.2.3.4", 80); - List endpoints = new ArrayList<>(); - endpoints.add(endpoint1); - endpoints.add(endpoint2); - return Mono.just(endpoints); - } -} diff --git a/im-sdk-core/src/test/java/com/easemob/im/server/api/MockingHttpServer.java b/im-sdk-core/src/test/java/com/easemob/im/server/api/MockingHttpServer.java deleted file mode 100644 index 2702e8ee8..000000000 --- a/im-sdk-core/src/test/java/com/easemob/im/server/api/MockingHttpServer.java +++ /dev/null @@ -1,145 +0,0 @@ -package com.easemob.im.server.api; - -import com.easemob.im.server.EMErrorResponse; -import com.easemob.im.server.exception.EMInvalidArgumentException; -import com.easemob.im.server.exception.EMInvalidStateException; -import com.easemob.im.server.exception.EMJsonException; -import com.fasterxml.jackson.core.JsonGenerator; -import com.fasterxml.jackson.core.JsonProcessingException; -import com.fasterxml.jackson.databind.DeserializationFeature; -import com.fasterxml.jackson.databind.JsonNode; -import com.fasterxml.jackson.databind.ObjectMapper; -import io.netty.buffer.ByteBuf; -import io.netty.buffer.ByteBufUtil; -import io.netty.buffer.Unpooled; -import io.netty.handler.codec.http.HttpResponseStatus; -import io.netty.util.internal.StringUtil; -import reactor.core.publisher.Mono; -import reactor.netty.DisposableServer; -import reactor.netty.http.server.HttpServer; - -import java.io.IOException; -import java.util.HashMap; -import java.util.Map; -import java.util.concurrent.ConcurrentHashMap; -import java.util.function.Function; - -public class MockingHttpServer { - private static final ByteBuf EMPTY_OBJECT = Unpooled.wrappedBuffer(new byte[]{'{', '}'}); - - private final ObjectMapper objectMapper = new ObjectMapper() - .configure(JsonGenerator.Feature.IGNORE_UNKNOWN, true) - .configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); - - private final DisposableServer http; - - private Map> handlers; - - private MockingHttpServer(Map> handlers) { - this.handlers = new ConcurrentHashMap<>(handlers); - - this.http = HttpServer.create() - .host("localhost") - .port(0) - .wiretap(true) - .handle((req, rsp) -> { - String path = String.format("%s %s", req.method().toString(), req.uri()); - if (!this.handlers.containsKey(path)) { - EMErrorResponse emErrorResponse = new EMErrorResponse(" request path not exist "); - byte[] arrayNotFound; - try { - arrayNotFound = this.objectMapper.writeValueAsBytes(emErrorResponse); - } catch (JsonProcessingException e) { - throw new EMJsonException(e.getMessage()); - } - return rsp.status(HttpResponseStatus.NOT_FOUND).send(Mono - .create(sink -> sink - .success(Unpooled.wrappedBuffer(arrayNotFound)))); - } - - Function handler = this.handlers.get(path); - return req.receive().aggregate() - .switchIfEmpty(Mono.just(EMPTY_OBJECT)) - .flatMap(buf -> { - int length = buf.readableBytes(); - byte[] array; - int offset = 0; - - if (buf.hasArray()) { - array = buf.array(); - offset = buf.arrayOffset(); - } else { - array = ByteBufUtil - .getBytes(buf, buf.readerIndex(), buf.readableBytes(), - false); - offset = 0; - } - - JsonNode jsonReq; - try { - jsonReq = this.objectMapper.readTree(array, offset, length); - } catch (IOException e) { - throw new EMJsonException(e.getMessage()); - } - - JsonNode jsonRsp = handler.apply(jsonReq); - - byte[] arrayRsp; - try { - arrayRsp = this.objectMapper.writeValueAsBytes(jsonRsp); - } catch (JsonProcessingException e) { - throw new EMJsonException(e.getMessage()); - } - - return rsp.status(HttpResponseStatus.OK).send(Mono - .create(sink -> sink - .success(Unpooled.wrappedBuffer(arrayRsp)))).then(); - }); - }) - .bindNow(); - } - - public static Builder builder() { - return new Builder(); - } - - public void addHandler(String path, Function handler) { - this.handlers.put(path, handler); - } - - public void removeHandler(String path) { - this.handlers.remove(path); - } - - public String uri() { - return String.format("http://localhost:%s", this.http.port()); - } - - public int port() { - return this.http.port(); - } - - public void shutdown() { - this.http.disposeNow(); - } - - public static class Builder { - private Map> postHandlers = new HashMap<>(); - - public Builder addHandler(String path, Function handler) { - if (StringUtil.isNullOrEmpty(path)) { - throw new EMInvalidArgumentException("path must not be null or blank"); - } - if (handler == null) { - throw new EMInvalidStateException("handler must not be null"); - } - - this.postHandlers.put(path, handler); - return this; - } - - public MockingHttpServer build() { - return new MockingHttpServer(this.postHandlers); - } - } -} diff --git a/im-sdk-core/src/test/java/com/easemob/im/server/api/MockingTokenProvider.java b/im-sdk-core/src/test/java/com/easemob/im/server/api/MockingTokenProvider.java deleted file mode 100644 index 64f2d1cd0..000000000 --- a/im-sdk-core/src/test/java/com/easemob/im/server/api/MockingTokenProvider.java +++ /dev/null @@ -1,16 +0,0 @@ -package com.easemob.im.server.api; - -import com.easemob.im.server.api.token.allocate.TokenProvider; -import com.easemob.im.server.api.token.Token; -import reactor.core.publisher.Mono; - -import java.time.Instant; - -public class MockingTokenProvider implements TokenProvider { - - @Override - public Mono fetchAppToken() { - return Mono.just(new Token("token", Instant.MAX)); - } - -} diff --git a/im-sdk-core/src/test/java/com/easemob/im/server/api/block/BlockSendMsgTest.java b/im-sdk-core/src/test/java/com/easemob/im/server/api/block/BlockSendMsgTest.java deleted file mode 100644 index 9181e7f19..000000000 --- a/im-sdk-core/src/test/java/com/easemob/im/server/api/block/BlockSendMsgTest.java +++ /dev/null @@ -1,101 +0,0 @@ -package com.easemob.im.server.api.block; - -import com.easemob.im.server.api.AbstractApiTest; -import com.easemob.im.server.api.block.login.BlockUserLogin; -import com.easemob.im.server.api.block.user.SendMsgToUser; -import com.easemob.im.server.model.EMBlock; -import com.fasterxml.jackson.databind.JsonNode; -import org.junit.jupiter.api.Test; - -import com.easemob.im.server.api.util.Utilities; - -import java.util.Set; -import java.util.stream.Collectors; - -import static org.junit.jupiter.api.Assertions.*; - -public class BlockSendMsgTest extends AbstractApiTest { - - private SendMsgToUser sendMsgToUser; - - private BlockUserLogin blockUserLogin; - - public BlockSendMsgTest() { - super(); - this.server.addHandler("POST /easemob/demo/users/alice/blocks/users", - this::handleUserBlockFromSendMsgRequest); - this.server.addHandler("DELETE /easemob/demo/users/alice/blocks/users/rabbit", - this::handleUserUnblockFromSendMsgRequest); - this.server.addHandler("GET /easemob/demo/users/alice/blocks/users", - this::handleGetUserBlockedFromSendMsgRequest); - this.server.addHandler("POST /easemob/demo/users/alice/deactivate", - this::handleUserBlockFromLoginRequest); - this.server.addHandler("POST /easemob/demo/users/alice/activate", - this::handleUserUnblockFromLoginRequest); - sendMsgToUser = new SendMsgToUser(this.context); - blockUserLogin = new BlockUserLogin(this.context); - } - - @Test - public void testBlockUserFromSendMsg() { - assertDoesNotThrow(() -> { - this.sendMsgToUser.blockUser("rabbit", "alice").block(Utilities.UT_TIMEOUT); - }); - } - - @Test - public void testUnBlockUserFromSendMsg() { - assertDoesNotThrow(() -> { - this.sendMsgToUser.unblockUser("rabbit", "alice").block(Utilities.UT_TIMEOUT); - }); - } - - @Test - public void testGetUserBlockedFromSendMsg() { - Set blockedUsers = - this.sendMsgToUser.getUsersBlocked("alice").collect(Collectors.toSet()) - .block(Utilities.UT_TIMEOUT); - Set blockedUsernames = - blockedUsers.stream().map(EMBlock::getUsername).collect(Collectors.toSet()); - assertTrue(blockedUsernames.contains("queen")); - assertTrue(blockedUsernames.contains("madhat")); - assertTrue(blockedUsernames.contains("rabbit")); - } - - @Test - public void testBlockUserFromLogin() { - assertDoesNotThrow(() -> { - this.blockUserLogin.blockUser("alice").block(Utilities.UT_TIMEOUT); - }); - } - - @Test - public void testUnblockUserFromLogin() { - assertDoesNotThrow(() -> { - this.blockUserLogin.unblockUser("alice").block(Utilities.UT_TIMEOUT); - }); - } - - private JsonNode handleGetUserBlockedFromSendMsgRequest(JsonNode jsonNode) { - JsonNode usernames = - this.objectMapper.createArrayNode().add("queen").add("madhat").add("rabbit"); - JsonNode response = this.objectMapper.createObjectNode().set("data", usernames); - return response; - } - - private JsonNode handleUserUnblockFromSendMsgRequest(JsonNode jsonNode) { - return this.objectMapper.createObjectNode(); - } - - private JsonNode handleUserBlockFromSendMsgRequest(JsonNode jsonNode) { - return this.objectMapper.createObjectNode(); - } - - private JsonNode handleUserBlockFromLoginRequest(JsonNode jsonNode) { - return this.objectMapper.createObjectNode(); - } - - private JsonNode handleUserUnblockFromLoginRequest(JsonNode jsonNode) { - return this.objectMapper.createObjectNode(); - } -} diff --git a/im-sdk-core/src/test/java/com/easemob/im/server/api/block/group/join/BlockUserJoinGroupTest.java b/im-sdk-core/src/test/java/com/easemob/im/server/api/block/group/join/BlockUserJoinGroupTest.java deleted file mode 100644 index a232c88e6..000000000 --- a/im-sdk-core/src/test/java/com/easemob/im/server/api/block/group/join/BlockUserJoinGroupTest.java +++ /dev/null @@ -1,91 +0,0 @@ -package com.easemob.im.server.api.block.group.join; - -import com.easemob.im.server.api.AbstractApiTest; -import com.easemob.im.server.api.block.room.join.BlockUserJoinRoom; -import com.easemob.im.server.model.EMBlock; -import com.fasterxml.jackson.databind.JsonNode; -import com.fasterxml.jackson.databind.node.ArrayNode; -import com.fasterxml.jackson.databind.node.ObjectNode; -import org.junit.jupiter.api.Test; - -import com.easemob.im.server.api.util.Utilities; - -import java.util.List; -import java.util.stream.Collectors; - -import static org.junit.jupiter.api.Assertions.*; - -class BlockUserJoinGroupTest extends AbstractApiTest { - - private BlockUserJoinGroup blockUserJoinGroup; - - BlockUserJoinGroupTest() { - super(); - this.server.addHandler("GET /easemob/demo/chatgroups/1/blocks/users", - this::handleGetBlockedUserRequest); - this.server.addHandler("POST /easemob/demo/chatgroups/1/blocks/users/alice", - req -> handleBlockUserRequest(req, "alice")); - this.server.addHandler("DELETE /easemob/demo/chatgroups/1/blocks/users/alice", - req -> handleUnblockUserRequest(req, "alice")); - this.blockUserJoinGroup = new BlockUserJoinGroup(this.context); - } - - private JsonNode handleGetBlockedUserRequest(JsonNode jsonNode) { - ArrayNode res = this.objectMapper.createArrayNode(); - res.add("alice"); - res.add("rabbit"); - - ObjectNode rsp = this.objectMapper.createObjectNode(); - rsp.set("data", res); - return rsp; - } - - private JsonNode handleBlockUserRequest(JsonNode req, String username) { - ObjectNode res = this.objectMapper.createObjectNode(); - res.put("result", true); - res.put("user", username); - - ObjectNode rsp = this.objectMapper.createObjectNode(); - rsp.set("data", res); - - return rsp; - } - - private JsonNode handleUnblockUserRequest(JsonNode req, String username) { - ObjectNode res = this.objectMapper.createObjectNode(); - res.put("result", true); - res.put("user", username); - - ObjectNode rsp = this.objectMapper.createObjectNode(); - rsp.set("data", res); - return rsp; - } - - @Test - public void testBlockUserJoinGroup() { - assertDoesNotThrow(() -> { - this.blockUserJoinGroup.blockUser("alice", "1").block(Utilities.UT_TIMEOUT); - }); - } - - @Test - public void testUnblockUserJoinGroup() { - assertDoesNotThrow(() -> { - this.blockUserJoinGroup.unblockUser("alice", "1").block(Utilities.UT_TIMEOUT); - }); - } - - @Test - public void testGetUsersBlockedJoinGroup() { - assertDoesNotThrow(() -> { - List blocks = this.blockUserJoinGroup.getBlockedUsers("1") - .collect(Collectors.toList()) - .block(Utilities.UT_TIMEOUT); - - assertEquals(2, blocks.size()); - assertTrue(blocks.contains(new EMBlock("alice", null))); - assertTrue(blocks.contains(new EMBlock("rabbit", null))); - }); - } - -} diff --git a/im-sdk-core/src/test/java/com/easemob/im/server/api/block/group/msg/BlockUserSendMsgToGroupTest.java b/im-sdk-core/src/test/java/com/easemob/im/server/api/block/group/msg/BlockUserSendMsgToGroupTest.java deleted file mode 100644 index e8071b576..000000000 --- a/im-sdk-core/src/test/java/com/easemob/im/server/api/block/group/msg/BlockUserSendMsgToGroupTest.java +++ /dev/null @@ -1,153 +0,0 @@ -package com.easemob.im.server.api.block.group.msg; - -import com.easemob.im.server.api.AbstractApiTest; -import com.easemob.im.server.exception.EMUnknownException; -import com.easemob.im.server.model.EMBlock; -import com.fasterxml.jackson.databind.JsonNode; -import com.fasterxml.jackson.databind.node.ArrayNode; -import com.fasterxml.jackson.databind.node.ObjectNode; -import org.junit.jupiter.api.Test; - -import com.easemob.im.server.api.util.Utilities; - -import java.time.Duration; -import java.time.Instant; -import java.util.List; - -import static org.junit.jupiter.api.Assertions.*; - -class BlockUserSendMsgToGroupTest extends AbstractApiTest { - - private BlockUserSendMsgToGroup blockUserSendMsgToGroup; - - BlockUserSendMsgToGroupTest() { - super(); - this.server.addHandler("GET /easemob/demo/chatgroups/1/mute", - this::handleGetBlockedUserRequest); - this.server.addHandler("POST /easemob/demo/chatgroups/1/mute", - this::handleBlockUserRequestSuccess); - this.server.addHandler("POST /easemob/demo/chatgroups/2/mute", - this::handleBlockUserRequestFail); - this.server.addHandler("DELETE /easemob/demo/chatgroups/1/mute/alice", - req -> handleUnblockUserRequestSuccess(req, "alice")); - this.server.addHandler("DELETE /easemob/demo/chatgroups/2/mute/alice", - req -> handleUnblockUserRequestFail(req, "alice")); - this.blockUserSendMsgToGroup = new BlockUserSendMsgToGroup(this.context); - } - - private JsonNode handleUnblockUserRequestSuccess(JsonNode req, String username) { - ObjectNode user = this.objectMapper.createObjectNode(); - user.put("result", true); - user.put("user", username); - - ArrayNode res = this.objectMapper.createArrayNode(); - res.add(user); - - ObjectNode rsp = this.objectMapper.createObjectNode(); - rsp.set("data", res); - - return rsp; - } - - private JsonNode handleUnblockUserRequestFail(JsonNode req, String username) { - ObjectNode user = this.objectMapper.createObjectNode(); - user.put("result", false); - user.put("user", username); - - ArrayNode res = this.objectMapper.createArrayNode(); - res.add(user); - - ObjectNode rsp = this.objectMapper.createObjectNode(); - rsp.set("data", res); - - return rsp; - } - - private JsonNode handleBlockUserRequestSuccess(JsonNode req) { - ArrayNode res = this.objectMapper.createArrayNode(); - - ObjectNode alice = this.objectMapper.createObjectNode(); - alice.put("result", true); - alice.put("user", "alice"); - - res.add(alice); - - ObjectNode rsp = this.objectMapper.createObjectNode(); - rsp.set("data", res); - return rsp; - } - - private JsonNode handleBlockUserRequestFail(JsonNode req) { - ArrayNode res = this.objectMapper.createArrayNode(); - - ObjectNode alice = this.objectMapper.createObjectNode(); - alice.put("result", false); - alice.put("user", "alice"); - - ObjectNode rsp = this.objectMapper.createObjectNode(); - rsp.set("data", res); - return rsp; - } - - private JsonNode handleGetBlockedUserRequest(JsonNode req) { - ObjectNode alice = this.objectMapper.createObjectNode(); - alice.put("user", "alice"); - alice.put("expire", 1000000); - - ObjectNode rabbit = this.objectMapper.createObjectNode(); - rabbit.put("user", "rabbit"); - rabbit.put("expire", 1000000); - - ArrayNode res = this.objectMapper.createArrayNode(); - res.add(alice); - res.add(rabbit); - - ObjectNode rsp = this.objectMapper.createObjectNode(); - rsp.set("data", res); - - return rsp; - } - - @Test - void testGetBlockedUsers() { - List blocks = this.blockUserSendMsgToGroup.getBlockedUsers("1").collectList() - .block(Utilities.UT_TIMEOUT); - assertEquals(2, blocks.size()); - assertTrue(blocks.contains(new EMBlock("alice", Instant.ofEpochMilli(1000000)))); - assertTrue(blocks.contains(new EMBlock("rabbit", Instant.ofEpochMilli(1000000)))); - } - - @Test - void testBlockUserSuccess() { - assertDoesNotThrow(() -> this.blockUserSendMsgToGroup.blockUser("alice", "1", null) - .block(Utilities.UT_TIMEOUT)); - } - - @Test - void testBlockUserFail() { - assertThrows(EMUnknownException.class, - () -> this.blockUserSendMsgToGroup.blockUser("alice", "2", null) - .block(Utilities.UT_TIMEOUT)); - } - - @Test - void testBlockUserMaxDuration() { - assertDoesNotThrow(() -> this.blockUserSendMsgToGroup - .blockUser("alice", "1", Duration.ofMillis(Integer.MAX_VALUE)) - .block(Utilities.UT_TIMEOUT)); - } - - @Test - void testUnblockUserSuccess() { - assertDoesNotThrow(() -> this.blockUserSendMsgToGroup.unblockUser("alice", "1") - .block(Utilities.UT_TIMEOUT)); - } - - @Test - void testUnblockUserFail() { - assertThrows(EMUnknownException.class, - () -> this.blockUserSendMsgToGroup.unblockUser("alice", "2") - .block(Utilities.UT_TIMEOUT)); - } - -} diff --git a/im-sdk-core/src/test/java/com/easemob/im/server/api/block/room/join/BlockUserJoinRoomTest.java b/im-sdk-core/src/test/java/com/easemob/im/server/api/block/room/join/BlockUserJoinRoomTest.java deleted file mode 100644 index 0b3101a6a..000000000 --- a/im-sdk-core/src/test/java/com/easemob/im/server/api/block/room/join/BlockUserJoinRoomTest.java +++ /dev/null @@ -1,91 +0,0 @@ -package com.easemob.im.server.api.block.room.join; - -import com.easemob.im.server.api.AbstractApiTest; -import com.easemob.im.server.api.block.room.join.BlockUserJoinRoom; -import com.easemob.im.server.model.EMBlock; -import com.fasterxml.jackson.databind.JsonNode; -import com.fasterxml.jackson.databind.node.ArrayNode; -import com.fasterxml.jackson.databind.node.ObjectNode; -import org.junit.jupiter.api.Test; - -import com.easemob.im.server.api.util.Utilities; - -import java.util.List; -import java.util.stream.Collectors; - -import static org.junit.jupiter.api.Assertions.*; - -class BlockUserJoinRoomTest extends AbstractApiTest { - - private BlockUserJoinRoom blockUserJoinRoom; - - BlockUserJoinRoomTest() { - super(); - this.server.addHandler("GET /easemob/demo/chatrooms/1/blocks/users", - this::handleGetBlockedUserRequest); - this.server.addHandler("POST /easemob/demo/chatrooms/1/blocks/users/alice", - req -> handleBlockUserRequest(req, "alice")); - this.server.addHandler("DELETE /easemob/demo/chatrooms/1/blocks/users/alice", - req -> handleUnblockUserRequest(req, "alice")); - this.blockUserJoinRoom = new BlockUserJoinRoom(this.context); - } - - private JsonNode handleGetBlockedUserRequest(JsonNode jsonNode) { - ArrayNode res = this.objectMapper.createArrayNode(); - res.add("alice"); - res.add("rabbit"); - - ObjectNode rsp = this.objectMapper.createObjectNode(); - rsp.set("data", res); - return rsp; - } - - private JsonNode handleBlockUserRequest(JsonNode req, String username) { - ObjectNode res = this.objectMapper.createObjectNode(); - res.put("result", true); - res.put("user", username); - - ObjectNode rsp = this.objectMapper.createObjectNode(); - rsp.set("data", res); - - return rsp; - } - - private JsonNode handleUnblockUserRequest(JsonNode req, String username) { - ObjectNode res = this.objectMapper.createObjectNode(); - res.put("result", true); - res.put("user", username); - - ObjectNode rsp = this.objectMapper.createObjectNode(); - rsp.set("data", res); - return rsp; - } - - @Test - public void testBlockUserJoinRoom() { - assertDoesNotThrow(() -> { - this.blockUserJoinRoom.blockUser("alice", "1").block(Utilities.UT_TIMEOUT); - }); - } - - @Test - public void testUnBlockUserJoinRoom() { - assertDoesNotThrow(() -> { - this.blockUserJoinRoom.unblockUser("alice", "1").block(Utilities.UT_TIMEOUT); - }); - } - - @Test - public void testGetUsersBlockedJoinRoom() { - assertDoesNotThrow(() -> { - List blocks = this.blockUserJoinRoom.getBlockedUsers("1") - .collect(Collectors.toList()) - .block(Utilities.UT_TIMEOUT); - - assertEquals(2, blocks.size()); - assertTrue(blocks.contains(new EMBlock("alice", null))); - assertTrue(blocks.contains(new EMBlock("rabbit", null))); - }); - } - -} diff --git a/im-sdk-core/src/test/java/com/easemob/im/server/api/block/room/msg/block/BlockUserSendMsgToRoomTest.java b/im-sdk-core/src/test/java/com/easemob/im/server/api/block/room/msg/block/BlockUserSendMsgToRoomTest.java deleted file mode 100644 index 6129cd0a2..000000000 --- a/im-sdk-core/src/test/java/com/easemob/im/server/api/block/room/msg/block/BlockUserSendMsgToRoomTest.java +++ /dev/null @@ -1,161 +0,0 @@ -package com.easemob.im.server.api.block.room.msg.block; - -import com.easemob.im.server.api.AbstractApiTest; -import com.easemob.im.server.api.block.room.msg.list.ListUsersBlockedSendMsgToRoom; -import com.easemob.im.server.api.block.room.msg.unblock.UnblockUserSendMsgToRoom; -import com.easemob.im.server.exception.EMUnknownException; -import com.easemob.im.server.model.EMBlock; -import com.fasterxml.jackson.databind.JsonNode; -import com.fasterxml.jackson.databind.node.ArrayNode; -import com.fasterxml.jackson.databind.node.ObjectNode; -import org.junit.jupiter.api.Test; - -import com.easemob.im.server.api.util.Utilities; - -import java.time.Duration; -import java.time.Instant; -import java.util.List; - -import static org.junit.jupiter.api.Assertions.*; - -class BlockUserSendMsgToRoomTest extends AbstractApiTest { - - private ListUsersBlockedSendMsgToRoom listUsersBlockedSendMsgToRoom; - - private BlockUserSendMsgToRoom blockUserSendMsgToRoom; - - private UnblockUserSendMsgToRoom unblockUserSendMsgToRoom; - - BlockUserSendMsgToRoomTest() { - super(); - this.server.addHandler("GET /easemob/demo/chatrooms/1/mute", - this::handleGetBlockedUserRequest); - this.server.addHandler("POST /easemob/demo/chatrooms/1/mute", - this::handleBlockUserRequestSuccess); - this.server.addHandler("POST /easemob/demo/chatrooms/2/mute", - this::handleBlockUserRequestFail); - this.server.addHandler("DELETE /easemob/demo/chatrooms/1/mute/alice", - req -> handleUnblockUserRequestSuccess(req, "alice")); - this.server.addHandler("DELETE /easemob/demo/chatrooms/2/mute/alice", - req -> handleUnblockUserRequestFail(req, "alice")); - this.listUsersBlockedSendMsgToRoom = new ListUsersBlockedSendMsgToRoom(this.context); - this.blockUserSendMsgToRoom = new BlockUserSendMsgToRoom(this.context); - this.unblockUserSendMsgToRoom = new UnblockUserSendMsgToRoom(this.context); - } - - private JsonNode handleUnblockUserRequestSuccess(JsonNode req, String username) { - ObjectNode user = this.objectMapper.createObjectNode(); - user.put("result", true); - user.put("user", username); - - ArrayNode res = this.objectMapper.createArrayNode(); - res.add(user); - - ObjectNode rsp = this.objectMapper.createObjectNode(); - rsp.set("data", res); - - return rsp; - } - - private JsonNode handleUnblockUserRequestFail(JsonNode req, String username) { - ObjectNode user = this.objectMapper.createObjectNode(); - user.put("result", false); - user.put("user", username); - - ArrayNode res = this.objectMapper.createArrayNode(); - res.add(user); - - ObjectNode rsp = this.objectMapper.createObjectNode(); - rsp.set("data", res); - - return rsp; - } - - private JsonNode handleBlockUserRequestSuccess(JsonNode req) { - ArrayNode res = this.objectMapper.createArrayNode(); - - ObjectNode alice = this.objectMapper.createObjectNode(); - alice.put("result", true); - alice.put("user", "alice"); - - res.add(alice); - - ObjectNode rsp = this.objectMapper.createObjectNode(); - rsp.set("data", res); - return rsp; - } - - private JsonNode handleBlockUserRequestFail(JsonNode req) { - ArrayNode res = this.objectMapper.createArrayNode(); - - ObjectNode alice = this.objectMapper.createObjectNode(); - alice.put("result", false); - alice.put("user", "alice"); - - ObjectNode rsp = this.objectMapper.createObjectNode(); - rsp.set("data", res); - return rsp; - } - - private JsonNode handleGetBlockedUserRequest(JsonNode req) { - ObjectNode alice = this.objectMapper.createObjectNode(); - alice.put("user", "alice"); - alice.put("expire", 1000000); - - ObjectNode rabbit = this.objectMapper.createObjectNode(); - rabbit.put("user", "rabbit"); - rabbit.put("expire", 1000000); - - ArrayNode res = this.objectMapper.createArrayNode(); - res.add(alice); - res.add(rabbit); - - ObjectNode rsp = this.objectMapper.createObjectNode(); - rsp.set("data", res); - - return rsp; - } - - @Test - void testGetBlockedUsers() { - List blocks = this.listUsersBlockedSendMsgToRoom.all("1").collectList() - .block(Utilities.UT_TIMEOUT); - assertEquals(2, blocks.size()); - assertTrue(blocks.contains(new EMBlock("alice", Instant.ofEpochMilli(1000000)))); - assertTrue(blocks.contains(new EMBlock("rabbit", Instant.ofEpochMilli(1000000)))); - } - - @Test - void testBlockUserSuccess() { - assertDoesNotThrow(() -> this.blockUserSendMsgToRoom.single("alice", "1", null) - .block(Utilities.UT_TIMEOUT)); - } - - @Test - void testBlockUserFail() { - assertThrows(EMUnknownException.class, - () -> this.blockUserSendMsgToRoom.single("alice", "2", null) - .block(Utilities.UT_TIMEOUT)); - } - - @Test - void testBlockUserMaxDuration() { - assertDoesNotThrow(() -> this.blockUserSendMsgToRoom - .single("alice", "1", Duration.ofMillis(Integer.MAX_VALUE)) - .block(Utilities.UT_TIMEOUT)); - } - - @Test - void testUnblockUserSuccess() { - assertDoesNotThrow(() -> this.unblockUserSendMsgToRoom.single("alice", "1") - .block(Utilities.UT_TIMEOUT)); - } - - @Test - void testUnblockUserFail() { - assertThrows(EMUnknownException.class, - () -> this.unblockUserSendMsgToRoom.single("alice", "2") - .block(Utilities.UT_TIMEOUT)); - } - -} diff --git a/im-sdk-core/src/test/java/com/easemob/im/server/api/block/room/msg/list/ListUsersBlockedSendMsgToRoomTest.java b/im-sdk-core/src/test/java/com/easemob/im/server/api/block/room/msg/list/ListUsersBlockedSendMsgToRoomTest.java deleted file mode 100644 index 4871c4631..000000000 --- a/im-sdk-core/src/test/java/com/easemob/im/server/api/block/room/msg/list/ListUsersBlockedSendMsgToRoomTest.java +++ /dev/null @@ -1,54 +0,0 @@ -package com.easemob.im.server.api.block.room.msg.list; - -import com.easemob.im.server.api.AbstractApiTest; -import com.easemob.im.server.model.EMBlock; -import com.fasterxml.jackson.databind.JsonNode; -import com.fasterxml.jackson.databind.node.ArrayNode; -import com.fasterxml.jackson.databind.node.ObjectNode; -import org.junit.jupiter.api.Test; - -import com.easemob.im.server.api.util.Utilities; - -import java.time.Instant; -import java.util.List; - -import static org.junit.jupiter.api.Assertions.*; - -class ListUsersBlockedSendMsgToRoomTest extends AbstractApiTest { - - private ListUsersBlockedSendMsgToRoom listUsersBlockedSendMsgToRoom; - - ListUsersBlockedSendMsgToRoomTest() { - this.server.addHandler("GET /easemob/demo/chatrooms/r1/mute", - this::handleListUsersBlockedSendMsgToRoom); - this.listUsersBlockedSendMsgToRoom = new ListUsersBlockedSendMsgToRoom(this.context); - } - - private JsonNode handleListUsersBlockedSendMsgToRoom(JsonNode jsonNode) { - ArrayNode blockedUsers = this.objectMapper.createArrayNode(); - - ObjectNode user1 = this.objectMapper.createObjectNode(); - user1.put("expire", 1000000); - user1.put("user", "rabbit"); - blockedUsers.add(user1); - - ObjectNode user2 = this.objectMapper.createObjectNode(); - user2.put("expire", 1000000); - user2.put("user", "madhat"); - blockedUsers.add(user2); - - ObjectNode rsp = this.objectMapper.createObjectNode(); - rsp.set("data", blockedUsers); - - return rsp; - } - - @Test - void testListUsersBlockedSendMsgToRoom() { - List blocks = this.listUsersBlockedSendMsgToRoom.all("r1").collectList() - .block(Utilities.UT_TIMEOUT); - assertEquals(2, blocks.size()); - assertEquals(new EMBlock("rabbit", Instant.ofEpochMilli(1000000)), blocks.get(0)); - assertEquals(new EMBlock("madhat", Instant.ofEpochMilli(1000000)), blocks.get(1)); - } -} diff --git a/im-sdk-core/src/test/java/com/easemob/im/server/api/block/room/msg/unblock/UnblockUserSendMsgToRoomTest.java b/im-sdk-core/src/test/java/com/easemob/im/server/api/block/room/msg/unblock/UnblockUserSendMsgToRoomTest.java deleted file mode 100644 index 6677dd04a..000000000 --- a/im-sdk-core/src/test/java/com/easemob/im/server/api/block/room/msg/unblock/UnblockUserSendMsgToRoomTest.java +++ /dev/null @@ -1,42 +0,0 @@ -package com.easemob.im.server.api.block.room.msg.unblock; - -import com.easemob.im.server.api.AbstractApiTest; -import com.fasterxml.jackson.databind.JsonNode; -import com.fasterxml.jackson.databind.node.ArrayNode; -import com.fasterxml.jackson.databind.node.ObjectNode; -import org.junit.jupiter.api.Test; - -import com.easemob.im.server.api.util.Utilities; - -import static org.junit.jupiter.api.Assertions.*; - -class UnblockUserSendMsgToRoomTest extends AbstractApiTest { - - private UnblockUserSendMsgToRoom unblockUserSendMsgToRoom; - - UnblockUserSendMsgToRoomTest() { - this.server.addHandler("DELETE /easemob/demo/chatrooms/r1/mute/rabbit", - this::handleUnblockUserSendMsgToRoom); - this.unblockUserSendMsgToRoom = new UnblockUserSendMsgToRoom(this.context); - } - - private JsonNode handleUnblockUserSendMsgToRoom(JsonNode jsonNode) { - ArrayNode results = this.objectMapper.createArrayNode(); - - ObjectNode result1 = this.objectMapper.createObjectNode(); - result1.put("result", true); - result1.put("user", "rabbit"); - results.add(result1); - - ObjectNode rsp = this.objectMapper.createObjectNode(); - rsp.set("data", results); - - return rsp; - } - - @Test - void testUnblockUserSendMsgToRoom() { - assertDoesNotThrow(() -> this.unblockUserSendMsgToRoom.single("rabbit", "r1") - .block(Utilities.UT_TIMEOUT)); - } -} diff --git a/im-sdk-core/src/test/java/com/easemob/im/server/api/contact/user/ContactUserTest.java b/im-sdk-core/src/test/java/com/easemob/im/server/api/contact/user/ContactUserTest.java deleted file mode 100644 index 2ce7cdbab..000000000 --- a/im-sdk-core/src/test/java/com/easemob/im/server/api/contact/user/ContactUserTest.java +++ /dev/null @@ -1,67 +0,0 @@ -package com.easemob.im.server.api.contact.user; - -import com.easemob.im.server.EMProperties; -import com.easemob.im.server.api.AbstractApiTest; -import com.easemob.im.server.api.MockingContext; -import com.easemob.im.server.api.MockingHttpServer; -import com.fasterxml.jackson.databind.JsonNode; -import com.fasterxml.jackson.databind.ObjectMapper; -import org.junit.jupiter.api.Test; - -import com.easemob.im.server.api.util.Utilities; - -import java.util.List; -import java.util.Set; -import java.util.stream.Collectors; - -import static org.junit.jupiter.api.Assertions.*; - -public class ContactUserTest extends AbstractApiTest { - - private ContactUser contactUser; - - public ContactUserTest() { - this.server.addHandler("POST /easemob/demo/users/alice/contacts/users/bob", - this::handleContactUserAdd); - this.server.addHandler("DELETE /easemob/demo/users/alice/contacts/users/bob", - this::handleContactUserRemove); - this.server.addHandler("GET /easemob/demo/users/alice/contacts/users", - this::handleContactUserList); - this.contactUser = new ContactUser(this.context); - } - - @Test - public void testAddContact() { - assertDoesNotThrow(() -> this.contactUser.add("alice", "bob").block()); - } - - @Test - public void testRemoveContact() { - assertDoesNotThrow(() -> this.contactUser.remove("alice", "bob")); - } - - @Test - public void testListContacts() { - Set contacts = this.contactUser.list("alice").collect(Collectors.toSet()) - .block(Utilities.UT_TIMEOUT); - assertEquals(3, contacts.size()); - assertTrue(contacts.contains("queen")); - assertTrue(contacts.contains("madhat")); - assertTrue(contacts.contains("rabbit")); - } - - private JsonNode handleContactUserList(JsonNode jsonNode) { - JsonNode contacts = - this.objectMapper.createArrayNode().add("queen").add("madhat").add("rabbit"); - JsonNode response = this.objectMapper.createObjectNode().set("data", contacts); - return response; - } - - private JsonNode handleContactUserRemove(JsonNode jsonNode) { - return this.objectMapper.createObjectNode(); - } - - private JsonNode handleContactUserAdd(JsonNode jsonNode) { - return this.objectMapper.createObjectNode(); - } -} diff --git a/im-sdk-core/src/test/java/com/easemob/im/server/api/group/admin/list/GroupAdminListTest.java b/im-sdk-core/src/test/java/com/easemob/im/server/api/group/admin/list/GroupAdminListTest.java deleted file mode 100644 index a962c4974..000000000 --- a/im-sdk-core/src/test/java/com/easemob/im/server/api/group/admin/list/GroupAdminListTest.java +++ /dev/null @@ -1,43 +0,0 @@ -package com.easemob.im.server.api.group.admin.list; - -import com.easemob.im.server.api.AbstractApiTest; -import com.easemob.im.server.api.group.admin.GroupAdminList; -import com.fasterxml.jackson.databind.JsonNode; -import com.fasterxml.jackson.databind.node.ArrayNode; -import com.fasterxml.jackson.databind.node.ObjectNode; -import org.junit.jupiter.api.Test; - -import com.easemob.im.server.api.util.Utilities; - -import java.util.Set; -import java.util.stream.Collectors; - -import static org.junit.jupiter.api.Assertions.*; - -class GroupAdminListTest extends AbstractApiTest { - - GroupAdminList groupAdminList = new GroupAdminList(this.context); - - public GroupAdminListTest() { - this.server.addHandler("GET /easemob/demo/chatgroups/1/admin", - this::handleGroupAdminListRequest); - } - - @Test - void testListGroupAdmin() { - Set admins = this.groupAdminList.all("1").collect(Collectors.toSet()) - .block(Utilities.UT_TIMEOUT); - assertTrue(admins.contains("madhat")); - assertTrue(admins.contains("rabbit")); - } - - private JsonNode handleGroupAdminListRequest(JsonNode jsonNode) { - ArrayNode data = this.objectMapper.createArrayNode(); - data.add("madhat"); - data.add("rabbit"); - ObjectNode rsp = this.objectMapper.createObjectNode(); - rsp.set("data", data); - return rsp; - } - -} diff --git a/im-sdk-core/src/test/java/com/easemob/im/server/api/group/admin/remove/GroupAdminRemoveTest.java b/im-sdk-core/src/test/java/com/easemob/im/server/api/group/admin/remove/GroupAdminRemoveTest.java deleted file mode 100644 index e41d85a8c..000000000 --- a/im-sdk-core/src/test/java/com/easemob/im/server/api/group/admin/remove/GroupAdminRemoveTest.java +++ /dev/null @@ -1,36 +0,0 @@ -package com.easemob.im.server.api.group.admin.remove; - -import com.easemob.im.server.api.AbstractApiTest; -import com.easemob.im.server.api.group.admin.GroupAdminAdd; -import com.fasterxml.jackson.databind.JsonNode; -import org.junit.jupiter.api.Test; - -import static org.junit.jupiter.api.Assertions.*; - -class GroupAdminRemoveTest extends AbstractApiTest { - - GroupAdminAdd groupAdminAdd = new GroupAdminAdd(this.context); - - public GroupAdminRemoveTest() { - this.server.addHandler("DELETE /easemob/demo/chatgroups/1/admin/rabbit", - this::handleGroupAdminRemoveRequest); - } - - @Test - void testRemoveGroupAdmin() { - assertDoesNotThrow(() -> { - this.groupAdminAdd.single("1", "rabbit"); - }); - } - - @Test - void testRemoveGroupAdminNotFound() { - assertDoesNotThrow(() -> { - this.groupAdminAdd.single("1", "alice"); - }); - } - - private JsonNode handleGroupAdminRemoveRequest(JsonNode jsonNode) { - return this.objectMapper.createObjectNode(); - } -} diff --git a/im-sdk-core/src/test/java/com/easemob/im/server/api/group/announcement/GroupAnnouncementTest.java b/im-sdk-core/src/test/java/com/easemob/im/server/api/group/announcement/GroupAnnouncementTest.java deleted file mode 100644 index ec908222e..000000000 --- a/im-sdk-core/src/test/java/com/easemob/im/server/api/group/announcement/GroupAnnouncementTest.java +++ /dev/null @@ -1,48 +0,0 @@ -package com.easemob.im.server.api.group.announcement; - -import com.easemob.im.server.api.AbstractApiTest; -import com.fasterxml.jackson.databind.JsonNode; -import com.fasterxml.jackson.databind.node.ObjectNode; -import org.junit.jupiter.api.Test; - -import com.easemob.im.server.api.util.Utilities; - -import static org.junit.jupiter.api.Assertions.*; - -class GroupAnnouncementTest extends AbstractApiTest { - - GroupAnnouncement groupAnnouncement = new GroupAnnouncement(this.context); - - public GroupAnnouncementTest() { - this.server.addHandler("GET /easemob/demo/chatgroups/1/announcement", - this::handleGroupAnnouncementGetRequest); - this.server.addHandler("POST /easemob/demo/chatgroups/1/announcement", - this::handleGroupAnnouncementUpdateRequest); - } - - @Test - public void testGroupAnnouncementGet() { - String announcement = this.groupAnnouncement.get("1").block(Utilities.UT_TIMEOUT); - assertEquals("Hello World", announcement); - } - - @Test - public void testGroupAnnouncementSet() { - assertDoesNotThrow( - () -> this.groupAnnouncement.set("1", "你好,世界").block(Utilities.UT_TIMEOUT)); - } - - private JsonNode handleGroupAnnouncementGetRequest(JsonNode jsonNode) { - ObjectNode data = this.objectMapper.createObjectNode(); - data.put("announcement", "Hello World"); - ObjectNode rsp = this.objectMapper.createObjectNode(); - rsp.set("data", data); - return rsp; - } - - private JsonNode handleGroupAnnouncementUpdateRequest(JsonNode req) { - assertEquals("你好,世界", req.get("announcement").asText()); - return this.objectMapper.createObjectNode(); - } - -} diff --git a/im-sdk-core/src/test/java/com/easemob/im/server/api/group/assign/AssignGroupTest.java b/im-sdk-core/src/test/java/com/easemob/im/server/api/group/assign/AssignGroupTest.java deleted file mode 100644 index 27cd401f4..000000000 --- a/im-sdk-core/src/test/java/com/easemob/im/server/api/group/assign/AssignGroupTest.java +++ /dev/null @@ -1,33 +0,0 @@ -package com.easemob.im.server.api.group.assign; - -import com.easemob.im.server.api.AbstractApiTest; -import com.easemob.im.server.api.util.Utilities; -import com.fasterxml.jackson.databind.JsonNode; -import com.fasterxml.jackson.databind.node.ObjectNode; -import org.junit.jupiter.api.Test; - -import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; - -public class AssignGroupTest extends AbstractApiTest { - - AssignGroup assignGroup=new AssignGroup(context); - - public AssignGroupTest() { - this.server.addHandler("PUT /easemob/demo/chatgroups/1", this::handleAssignGroupRequest); - } - - @Test - public void testAssignGroup(){ - assertDoesNotThrow(() -> { - this.assignGroup.execute("1","newOwner1").block(Utilities.UT_TIMEOUT); - }); - } - - private JsonNode handleAssignGroupRequest(JsonNode jsonNode) { - ObjectNode data = this.objectMapper.createObjectNode(); - data.put("newowner", "newOwner1"); - ObjectNode rsp = this.objectMapper.createObjectNode(); - rsp.set("data", data); - return rsp; - } -} diff --git a/im-sdk-core/src/test/java/com/easemob/im/server/api/group/crud/CreateGroupTest.java b/im-sdk-core/src/test/java/com/easemob/im/server/api/group/crud/CreateGroupTest.java deleted file mode 100644 index 79a3bc9e5..000000000 --- a/im-sdk-core/src/test/java/com/easemob/im/server/api/group/crud/CreateGroupTest.java +++ /dev/null @@ -1,71 +0,0 @@ -package com.easemob.im.server.api.group.crud; - -import com.easemob.im.server.api.AbstractApiTest; -import com.easemob.im.server.api.group.create.CreateGroup; -import com.fasterxml.jackson.databind.JsonNode; -import com.fasterxml.jackson.databind.node.ObjectNode; -import org.junit.jupiter.api.Test; - -import com.easemob.im.server.api.util.Utilities; - -import java.util.ArrayList; -import java.util.List; - -import static org.junit.jupiter.api.Assertions.assertEquals; - -class CreateGroupTest extends AbstractApiTest { - - CreateGroup createGroup = new CreateGroup(this.context); - - public CreateGroupTest() { - this.server.addHandler("POST /easemob/demo/chatgroups", this::handleGroupCreateRequest); - } - - @Test - public void testCreatePublicGroup() { - List members = new ArrayList<>(); - members.add("madhat"); - members.add("rabbit"); - assertEquals("group-create-test", - this.createGroup.publicGroup("alice", "test-group", "test-desc", members, 10, true) - .block(Utilities.UT_TIMEOUT)); - } - - @Test - public void testCreatePublicGroupWithCustom() { - List members = new ArrayList<>(); - members.add("madhat"); - members.add("rabbit"); - assertEquals("group-create-test", - this.createGroup.publicGroup("alice", "test-group", "test-desc", members, 10, true, "custom") - .block(Utilities.UT_TIMEOUT)); - } - - @Test - public void testCreatePrivateGroup() { - List members = new ArrayList<>(); - members.add("madhat"); - members.add("rabbit"); - assertEquals("group-create-test", - this.createGroup.privateGroup("alice", "test-group", "test-desc", members, 10, true) - .block(Utilities.UT_TIMEOUT)); - } - - @Test - public void testCreatePrivateGroupWithCustom() { - List members = new ArrayList<>(); - members.add("madhat"); - members.add("rabbit"); - assertEquals("group-create-test", - this.createGroup.privateGroup("alice", "test-group", "test-desc", members, 10, true, "custom") - .block(Utilities.UT_TIMEOUT)); - } - - private JsonNode handleGroupCreateRequest(JsonNode jsonNode) { - ObjectNode data = this.objectMapper.createObjectNode(); - data.put("groupid", "group-create-test"); - ObjectNode rsp = this.objectMapper.createObjectNode(); - rsp.set("data", data); - return rsp; - } -} diff --git a/im-sdk-core/src/test/java/com/easemob/im/server/api/group/delete/DeleteGroupTest.java b/im-sdk-core/src/test/java/com/easemob/im/server/api/group/delete/DeleteGroupTest.java deleted file mode 100644 index 761057d72..000000000 --- a/im-sdk-core/src/test/java/com/easemob/im/server/api/group/delete/DeleteGroupTest.java +++ /dev/null @@ -1,37 +0,0 @@ -package com.easemob.im.server.api.group.delete; - -import com.easemob.im.server.api.AbstractApiTest; -import com.fasterxml.jackson.databind.JsonNode; -import org.junit.jupiter.api.Test; - -import com.easemob.im.server.api.util.Utilities; - -import static org.junit.jupiter.api.Assertions.*; - -class DeleteGroupTest extends AbstractApiTest { - - DeleteGroup deleteGroup = new DeleteGroup(this.context); - - public DeleteGroupTest() { - this.server.addHandler("DELETE /easemob/demo/chatgroups/1", this::handleDeleteGroupRequest); - } - - @Test - public void testGroupDeleteSuccess() { - assertDoesNotThrow(() -> { - this.deleteGroup.execute("1").block(Utilities.UT_TIMEOUT); - }); - } - - @Test - public void testGroupDeleteNotFoundAlsoSuccess() { - assertDoesNotThrow(() -> { - this.deleteGroup.execute("2").block(Utilities.UT_TIMEOUT); - }); - } - - private JsonNode handleDeleteGroupRequest(JsonNode jsonNode) { - return this.objectMapper.createObjectNode(); - } - -} \ No newline at end of file diff --git a/im-sdk-core/src/test/java/com/easemob/im/server/api/group/get/GroupDetailTest.java b/im-sdk-core/src/test/java/com/easemob/im/server/api/group/get/GroupDetailTest.java deleted file mode 100644 index 4854e95b7..000000000 --- a/im-sdk-core/src/test/java/com/easemob/im/server/api/group/get/GroupDetailTest.java +++ /dev/null @@ -1,65 +0,0 @@ -package com.easemob.im.server.api.group.get; - -import com.easemob.im.server.api.AbstractApiTest; -import com.easemob.im.server.model.EMGroup; -import com.fasterxml.jackson.databind.JsonNode; -import com.fasterxml.jackson.databind.node.ArrayNode; -import com.fasterxml.jackson.databind.node.ObjectNode; -import org.junit.jupiter.api.Test; - -import com.easemob.im.server.api.util.Utilities; - -import static org.junit.jupiter.api.Assertions.assertEquals; - -class GroupDetailTest extends AbstractApiTest { - - private GetGroup getGroup = new GetGroup(this.context); - - public GroupDetailTest() { - this.server.addHandler("GET /easemob/demo/chatgroups/1", this::handleGroupDetailRequest1); - } - - @Test - public void testGroupDetails() { - EMGroup detail = this.getGroup.execute("1").block(Utilities.UT_TIMEOUT); - assertEquals("1", detail.getGroupId()); - assertEquals("test-group", detail.getName()); - assertEquals("test-description", detail.getDescription()); - assertEquals(true, detail.getIsPublic()); - assertEquals(false, detail.getNeedApproveToJoin()); - assertEquals(false, detail.getCanMemberInviteOthers()); - assertEquals("alice", detail.getOwner()); - assertEquals(200, detail.getMaxMembers()); - assertEquals(true, detail.getIsMute()); - assertEquals("custom", detail.getCustom()); - } - - private JsonNode handleGroupDetailRequest1(JsonNode jsonNode) { - ObjectNode group = buildGroupJson("1"); - - ArrayNode data = this.objectMapper.createArrayNode(); - data.add(group); - - ObjectNode rsp = this.objectMapper.createObjectNode(); - rsp.set("data", data); - - return rsp; - } - - private ObjectNode buildGroupJson(String groupId) { - ObjectNode group1 = this.objectMapper.createObjectNode(); - group1.put("id", groupId); - group1.put("name", "test-group"); - group1.put("description", "test-description"); - group1.put("public", true); - group1.put("membersonly", false); - group1.put("allowinvites", false); - group1.put("owner", "alice"); - group1.put("maxusers", 200); - group1.put("affiliations_count", 1); - group1.put("mute", true); - group1.put("custom", "custom"); - return group1; - } - -} diff --git a/im-sdk-core/src/test/java/com/easemob/im/server/api/group/list/GroupListTest.java b/im-sdk-core/src/test/java/com/easemob/im/server/api/group/list/GroupListTest.java deleted file mode 100644 index f597a1b49..000000000 --- a/im-sdk-core/src/test/java/com/easemob/im/server/api/group/list/GroupListTest.java +++ /dev/null @@ -1,101 +0,0 @@ -package com.easemob.im.server.api.group.list; - -import com.easemob.im.server.api.AbstractApiTest; -import com.fasterxml.jackson.databind.JsonNode; -import com.fasterxml.jackson.databind.node.ArrayNode; -import com.fasterxml.jackson.databind.node.ObjectNode; -import org.junit.jupiter.api.Test; -import reactor.test.StepVerifier; - -import java.time.Duration; - -public class GroupListTest extends AbstractApiTest { - private static int seq = 0; - - private GroupList groupList = new GroupList(this.context); - - public GroupListTest() { - super(); - this.server - .addHandler("GET /easemob/demo/chatgroups?limit=10", this::handleGroupListRequest1); - this.server.addHandler("GET /easemob/demo/chatgroups?limit=10&cursor=1", - this::handleGroupListRequest2); - this.server.addHandler("GET /easemob/demo/chatgroups?limit=10&cursor=2", - this::handleGroupListRequest3); - this.server.addHandler("GET /easemob/demo/users/alice/joined_chatgroups", - this::handleGroupListUserJoined); - } - - @Test - public void testGroupListHighLevelApi() { - this.groupList.all(10) - .as(StepVerifier::create) - .expectNextCount(25) - .expectComplete() - .verify(Duration.ofSeconds(3)); - } - - @Test - public void testGroupListLowLevelApi() { - this.groupList.next(10, "1") - .as(StepVerifier::create) - .expectNextMatches( - page -> page.getValues().size() == 10 && page.getCursor().equals("2")) - .expectComplete() - .verify(Duration.ofSeconds(3)); - } - - @Test - public void testGroupListUserJoined() { - this.groupList.userJoined("alice") - .as(StepVerifier::create) - .expectNext("aliceGroup") - .expectNext("rabbitGroup") - .expectComplete() - .verify(Duration.ofSeconds(3)); - } - - private JsonNode handleGroupListRequest1(JsonNode jsonNode) { - return buildResponse(10, "1"); - } - - private JsonNode handleGroupListRequest2(JsonNode jsonNode) { - return buildResponse(10, "2"); - } - - private JsonNode handleGroupListRequest3(JsonNode jsonNode) { - return buildResponse(5, null); - } - - private JsonNode handleGroupListUserJoined(JsonNode jsonNode) { - ArrayNode data = this.objectMapper.createArrayNode(); - - ObjectNode group1 = this.objectMapper.createObjectNode(); - group1.put("groupid", "aliceGroup"); - data.add(group1); - - ObjectNode group2 = this.objectMapper.createObjectNode(); - group2.put("groupid", "rabbitGroup"); - data.add(group2); - - ObjectNode rsp = this.objectMapper.createObjectNode(); - rsp.set("data", data); - return rsp; - } - - private ObjectNode buildResponse(int count, String cursor) { - ArrayNode data = this.objectMapper.createArrayNode(); - for (int i = 0; i < count; i++) { - ObjectNode group = this.objectMapper.createObjectNode(); - group.put("groupid", String.format("%d", seq++)); - data.add(group); - } - ObjectNode rsp = this.objectMapper.createObjectNode(); - rsp.set("data", data); - if (cursor != null) { - rsp.put("cursor", cursor); - } - return rsp; - } - -} diff --git a/im-sdk-core/src/test/java/com/easemob/im/server/api/group/member/add/GroupMemberAddTest.java b/im-sdk-core/src/test/java/com/easemob/im/server/api/group/member/add/GroupMemberAddTest.java deleted file mode 100644 index 228098b38..000000000 --- a/im-sdk-core/src/test/java/com/easemob/im/server/api/group/member/add/GroupMemberAddTest.java +++ /dev/null @@ -1,39 +0,0 @@ -package com.easemob.im.server.api.group.member.add; - -import com.easemob.im.server.api.AbstractApiTest; -import com.easemob.im.server.exception.EMNotFoundException; -import com.fasterxml.jackson.databind.JsonNode; -import org.junit.jupiter.api.Test; - -import com.easemob.im.server.api.util.Utilities; - -import static org.junit.jupiter.api.Assertions.*; - -class GroupMemberAddTest extends AbstractApiTest { - - GroupMemberAdd groupMemberAdd = new GroupMemberAdd(this.context); - - GroupMemberAddTest() { - this.server.addHandler("POST /easemob/demo/chatgroups/1/users/alice", - this::handleGroupMemberAddRequest); - } - - @Test - void testAddGroupMember() { - assertDoesNotThrow(() -> { - this.groupMemberAdd.single("1", "alice").block(Utilities.UT_TIMEOUT); - }); - } - -// @Test -// void testAddGroupMemberNotFound() { -// assertThrows(EMNotFoundException.class, () -> { -// this.groupMemberAdd.single("1", "bob").block(Utilities.UT_TIMEOUT); -// }); -// } - - private JsonNode handleGroupMemberAddRequest(JsonNode jsonNode) { - return this.objectMapper.createObjectNode(); - } - -} diff --git a/im-sdk-core/src/test/java/com/easemob/im/server/api/group/member/list/GroupMemberListTest.java b/im-sdk-core/src/test/java/com/easemob/im/server/api/group/member/list/GroupMemberListTest.java deleted file mode 100644 index 92214fe61..000000000 --- a/im-sdk-core/src/test/java/com/easemob/im/server/api/group/member/list/GroupMemberListTest.java +++ /dev/null @@ -1,58 +0,0 @@ -package com.easemob.im.server.api.group.member.list; - -import com.easemob.im.server.api.AbstractApiTest; -import com.fasterxml.jackson.databind.JsonNode; -import com.fasterxml.jackson.databind.node.ArrayNode; -import com.fasterxml.jackson.databind.node.ObjectNode; -import org.junit.jupiter.api.Test; - -import com.easemob.im.server.api.util.Utilities; - -import java.util.List; -import java.util.stream.Collectors; - -import static org.junit.jupiter.api.Assertions.*; - -class GroupMemberListTest extends AbstractApiTest { - - GroupMemberList groupMemberList = new GroupMemberList(this.context); - - public GroupMemberListTest() { - this.server.addHandler("GET /easemob/demo/chatgroups/1/users?version=v3&limit=10", - this::handleGroupMemberListRequest1); - this.server.addHandler("GET /easemob/demo/chatgroups/1/users?version=v3&limit=10&cursor=1", - this::handleGroupMemberListRequest2); - } - - @Test - public void testListGroupMemberAll() { - List usernames = this.groupMemberList.all("1", 10, null).collect(Collectors.toList()) - .block(Utilities.UT_TIMEOUT); - assertEquals(15, usernames.size()); - } - - private JsonNode handleGroupMemberListRequest1(JsonNode jsonNode) { - ArrayNode data = this.objectMapper.createArrayNode(); - for (int i = 0; i < 10; i++) { - data.add(String.format("user-%d", i)); - } - - ObjectNode rsp = this.objectMapper.createObjectNode(); - rsp.set("data", data); - rsp.put("cursor", "1"); - - return rsp; - } - - private JsonNode handleGroupMemberListRequest2(JsonNode jsonNode) { - ArrayNode data = this.objectMapper.createArrayNode(); - for (int i = 10; i < 15; i++) { - data.add(String.format("user-%d", i)); - } - - ObjectNode rsp = this.objectMapper.createObjectNode(); - rsp.set("data", data); - - return rsp; - } -} diff --git a/im-sdk-core/src/test/java/com/easemob/im/server/api/group/member/remove/GroupMemberRemoveTest.java b/im-sdk-core/src/test/java/com/easemob/im/server/api/group/member/remove/GroupMemberRemoveTest.java deleted file mode 100644 index fc35c64d0..000000000 --- a/im-sdk-core/src/test/java/com/easemob/im/server/api/group/member/remove/GroupMemberRemoveTest.java +++ /dev/null @@ -1,37 +0,0 @@ -package com.easemob.im.server.api.group.member.remove; - -import com.easemob.im.server.api.AbstractApiTest; -import com.fasterxml.jackson.databind.JsonNode; -import org.junit.jupiter.api.Test; - -import com.easemob.im.server.api.util.Utilities; - -import static org.junit.jupiter.api.Assertions.*; - -class GroupMemberRemoveTest extends AbstractApiTest { - - private GroupMemberRemove groupMemberRemove = new GroupMemberRemove(this.context); - - public GroupMemberRemoveTest() { - this.server.addHandler("DELETE /easemob/demo/chatgroups/1/users/alice", - this::handleGroupMemberRemoveRequest); - } - - @Test - void testRemoveGroupMember() { - assertDoesNotThrow(() -> { - this.groupMemberRemove.single("1", "alice").block(Utilities.UT_TIMEOUT); - }); - } - - @Test - void testRemoveGroupMemberNotFound() { - assertDoesNotThrow(() -> { - this.groupMemberRemove.single("1", "bob").block(Utilities.UT_TIMEOUT); - }); - } - - private JsonNode handleGroupMemberRemoveRequest(JsonNode jsonNode) { - return this.objectMapper.createObjectNode(); - } -} diff --git a/im-sdk-core/src/test/java/com/easemob/im/server/api/group/settings/UpdateGroupTest.java b/im-sdk-core/src/test/java/com/easemob/im/server/api/group/settings/UpdateGroupTest.java deleted file mode 100644 index da5884d17..000000000 --- a/im-sdk-core/src/test/java/com/easemob/im/server/api/group/settings/UpdateGroupTest.java +++ /dev/null @@ -1,87 +0,0 @@ -package com.easemob.im.server.api.group.settings; - -import com.easemob.im.server.api.AbstractApiTest; -import com.easemob.im.server.exception.EMUnknownException; -import com.fasterxml.jackson.databind.JsonNode; -import com.fasterxml.jackson.databind.node.ObjectNode; -import org.junit.jupiter.api.Test; - -import com.easemob.im.server.api.util.Utilities; - -import static org.junit.jupiter.api.Assertions.*; - -class UpdateGroupTest extends AbstractApiTest { - - UpdateGroup updateGroup = new UpdateGroup(this.context); - - public UpdateGroupTest() { - this.server.addHandler("PUT /easemob/demo/chatgroups/1", - this::handleGroupUpdateRequestSuccess); - this.server.addHandler("PUT /easemob/demo/chatgroups/2", - this::handleGroupUpdateRequestFailure); - this.server - .addHandler("PUT /easemob/demo/chatgroups/3", this::handleGroupUpdateOwnerRequest); - } - - @Test - public void testGroupUpdateSuccess() { - assertDoesNotThrow( - () -> this.updateGroup.update("1", settings -> settings.setMaxMembers(10)) - .block(Utilities.UT_TIMEOUT)); - } - - @Test - public void testGroupUpdateFailure() { - assertThrows(EMUnknownException.class, () -> this.updateGroup.update("2", - settings -> settings.setMaxMembers(1000000).setCanMemberInviteOthers(false)) - .block(Utilities.UT_TIMEOUT)); - } - - private JsonNode handleGroupUpdateRequestSuccess(JsonNode jsonNode) { - ObjectNode data = this.objectMapper.createObjectNode(); - if (jsonNode.has("maxusers")) { - data.put("maxusers", true); - } - if (jsonNode.has("membersonly")) { - data.put("membersonly", true); - } - if (jsonNode.has("allowinvites")) { - data.put("allowinvites", true); - } - - ObjectNode rsp = this.objectMapper.createObjectNode(); - rsp.set("data", data); - - return rsp; - } - - @Test - void testUpdateGroupOwner() { - assertDoesNotThrow(() -> { - this.updateGroup.updateOwner("3", "rabbit").block(Utilities.UT_TIMEOUT); - }); - } - - private JsonNode handleGroupUpdateOwnerRequest(JsonNode jsonNode) { - return this.objectMapper.createObjectNode(); - } - - private JsonNode handleGroupUpdateRequestFailure(JsonNode jsonNode) { - ObjectNode data = this.objectMapper.createObjectNode(); - if (jsonNode.has("maxusers")) { - data.put("maxusers", false); - } - if (jsonNode.has("membersonly")) { - data.put("membersonly", false); - } - if (jsonNode.has("allowinvites")) { - data.put("allowinvites", false); - } - - ObjectNode rsp = this.objectMapper.createObjectNode(); - rsp.set("data", data); - - return rsp; - } - -} diff --git a/im-sdk-core/src/test/java/com/easemob/im/server/api/loadbalance/BaseUriProviderTest.java b/im-sdk-core/src/test/java/com/easemob/im/server/api/loadbalance/BaseUriProviderTest.java deleted file mode 100644 index 39e0c46e7..000000000 --- a/im-sdk-core/src/test/java/com/easemob/im/server/api/loadbalance/BaseUriProviderTest.java +++ /dev/null @@ -1,28 +0,0 @@ -package com.easemob.im.server.api.loadbalance; - -import com.easemob.im.server.EMProperties; -import com.easemob.im.server.api.AbstractApiTest; -import org.junit.jupiter.api.Test; - -import java.util.List; - -import static org.junit.jupiter.api.Assertions.assertEquals; - -class BaseUriProviderTest extends AbstractApiTest { - BaseUriProviderTest() { - this.properties = EMProperties.builder() - .setBaseUri("http://test.easemob.com") - .setAppkey("easemob#demo") - .setClientId("clientId") - .setClientSecret("ClientSecret") - .build(); - } - - @Test - void testGetDnsConfig() { - FixedEndpointProvider provider = new FixedEndpointProvider(this.properties); - List endpoints = provider.endpoints().block(); - assertEquals(1, endpoints.size()); - assertEquals(new Endpoint("http", "test.easemob.com", -1), endpoints.get(0)); - } -} diff --git a/im-sdk-core/src/test/java/com/easemob/im/server/api/loadbalance/DnsConfigEndpointProviderTest.java b/im-sdk-core/src/test/java/com/easemob/im/server/api/loadbalance/DnsConfigEndpointProviderTest.java deleted file mode 100644 index 20cc5df36..000000000 --- a/im-sdk-core/src/test/java/com/easemob/im/server/api/loadbalance/DnsConfigEndpointProviderTest.java +++ /dev/null @@ -1,58 +0,0 @@ -package com.easemob.im.server.api.loadbalance; - -import com.easemob.im.server.api.AbstractApiTest; -import com.fasterxml.jackson.databind.JsonNode; -import com.fasterxml.jackson.databind.node.ArrayNode; -import com.fasterxml.jackson.databind.node.ObjectNode; -import org.junit.jupiter.api.Test; -import reactor.netty.http.client.HttpClient; - -import java.util.List; - -import static org.junit.jupiter.api.Assertions.*; - -class DnsConfigEndpointProviderTest extends AbstractApiTest { - DnsConfigEndpointProviderTest() { - this.server.addHandler("GET /easemob/server.json?app_key=easemob%23demo", - this::handleGetDnsConfig); - } - - private JsonNode handleGetDnsConfig(JsonNode jsonNode) { - ObjectNode rsp = this.objectMapper.createObjectNode(); - rsp.put("file_version", "243"); - rsp.put("deploy_name", "magic"); - - ArrayNode hosts = this.objectMapper.createArrayNode(); - - ObjectNode host1 = this.objectMapper.createObjectNode(); - host1.put("protocol", "https"); - host1.put("domain", "test.easemob.com"); - host1.put("port", 443); - hosts.add(host1); - - ObjectNode host2 = this.objectMapper.createObjectNode(); - host2.put("protocol", "http"); - host2.put("ip", "1.2.3.4"); - host2.put("port", 80); - hosts.add(host2); - - ObjectNode rest = this.objectMapper.createObjectNode(); - rest.set("hosts", hosts); - - rsp.set("rest", rest); - - return rsp; - } - - @Test - void testGetDnsConfig() { - HttpClient httpClient = HttpClient.newConnection().baseUrl(this.server.uri()); - DnsConfigEndpointProvider provider = - new DnsConfigEndpointProvider(this.properties, this.context.getCodec(), httpClient, - this.context.getErrorMapper()); - List endpoints = provider.endpoints().block(); - assertEquals(2, endpoints.size()); - assertEquals(new Endpoint("https", "test.easemob.com", 443), endpoints.get(0)); - assertEquals(new Endpoint("http", "1.2.3.4", 80), endpoints.get(1)); - } -} diff --git a/im-sdk-core/src/test/java/com/easemob/im/server/api/loadbalance/TimedRefreshEndpointRegistryTest.java b/im-sdk-core/src/test/java/com/easemob/im/server/api/loadbalance/TimedRefreshEndpointRegistryTest.java deleted file mode 100644 index f5ad921dd..000000000 --- a/im-sdk-core/src/test/java/com/easemob/im/server/api/loadbalance/TimedRefreshEndpointRegistryTest.java +++ /dev/null @@ -1,24 +0,0 @@ -package com.easemob.im.server.api.loadbalance; - -import com.easemob.im.server.api.AbstractApiTest; -import com.easemob.im.server.api.MockingEndpointProvider; -import org.junit.jupiter.api.Test; - -import com.easemob.im.server.api.util.Utilities; - -import java.time.Duration; -import java.util.List; - -import static org.junit.jupiter.api.Assertions.assertEquals; - -class TimedRefreshEndpointRegistryTest extends AbstractApiTest { - - @Test - public void testTimedRefreshEndpoint() { - MockingEndpointProvider provider = new MockingEndpointProvider(); - TimedRefreshEndpointRegistry endpointRegistry = - new TimedRefreshEndpointRegistry(provider, Duration.ofSeconds(10)); - List endpointList = endpointRegistry.endpoints().block(Utilities.UT_TIMEOUT); - assertEquals(2, endpointList.size()); - } -} diff --git a/im-sdk-core/src/test/java/com/easemob/im/server/api/message/history/MessageHistoryTest.java b/im-sdk-core/src/test/java/com/easemob/im/server/api/message/history/MessageHistoryTest.java deleted file mode 100644 index f98570432..000000000 --- a/im-sdk-core/src/test/java/com/easemob/im/server/api/message/history/MessageHistoryTest.java +++ /dev/null @@ -1,46 +0,0 @@ -package com.easemob.im.server.api.message.history; - -import com.easemob.im.server.api.AbstractApiTest; -import com.fasterxml.jackson.databind.JsonNode; -import com.fasterxml.jackson.databind.node.ArrayNode; -import com.fasterxml.jackson.databind.node.ObjectNode; -import org.junit.jupiter.api.Test; - -import java.nio.file.Paths; - -import com.easemob.im.server.api.util.Utilities; - -import java.time.Instant; -import java.util.Objects; - -import static org.junit.jupiter.api.Assertions.*; - -class MessageHistoryTest extends AbstractApiTest { - - MessageHistory messageHistory = new MessageHistory(this.context, "+8"); - - MessageHistoryTest() { - this.server.addHandler("GET /easemob/demo/chatmessages/2020020200", - this::handleGetMessageHistoryTest); - } - - private JsonNode handleGetMessageHistoryTest(JsonNode jsonNode) { - ObjectNode history = this.objectMapper.createObjectNode(); - history.put("url", "https://example.com/history"); - - ArrayNode data = this.objectMapper.createArrayNode(); - data.add(history); - - ObjectNode rsp = this.objectMapper.createObjectNode(); - rsp.set("data", data); - - return rsp; - } - - @Test - void testGetUrl() { - String url = this.messageHistory.toUri(Instant.ofEpochSecond(1580574630)) - .block(Utilities.UT_TIMEOUT); - assertEquals("https://example.com/history", url); - } -} diff --git a/im-sdk-core/src/test/java/com/easemob/im/server/api/message/missed/MessageMissedTest.java b/im-sdk-core/src/test/java/com/easemob/im/server/api/message/missed/MessageMissedTest.java deleted file mode 100644 index a25de126d..000000000 --- a/im-sdk-core/src/test/java/com/easemob/im/server/api/message/missed/MessageMissedTest.java +++ /dev/null @@ -1,42 +0,0 @@ -package com.easemob.im.server.api.message.missed; - -import com.easemob.im.server.api.AbstractApiTest; -import com.fasterxml.jackson.databind.JsonNode; -import com.fasterxml.jackson.databind.node.ObjectNode; -import org.junit.jupiter.api.Test; -import reactor.test.StepVerifier; - -import java.time.Duration; - -public class MessageMissedTest extends AbstractApiTest { - - public MessageMissedTest() { - this.server.addHandler("GET /easemob/demo/users/alice/offline_msg_count", - this::handleMessageMisssedCountRequest); - } - - @Test - public void testMsgMissedCount() { - MessageMissed missed = new MessageMissed(this.context); - MissedMessageCount mmc1 = new MissedMessageCount("queen", 99); - MissedMessageCount mmc2 = new MissedMessageCount("madhat", 1); - - missed.count("alice") - .log() - .as(StepVerifier::create) - .expectNextMatches(mmc -> mmc1.equals(mmc) || mmc2.equals(mmc)) - .expectNextMatches(mmc -> mmc1.equals(mmc) || mmc2.equals(mmc)) - .expectComplete() - .verify(Duration.ofSeconds(3)); - } - - private JsonNode handleMessageMisssedCountRequest(JsonNode jsonNode) { - ObjectNode data = this.objectMapper.createObjectNode(); - data.put("queen", 99); - data.put("madhat", 1); - ObjectNode rsp = this.objectMapper.createObjectNode(); - rsp.set("data", data); - return rsp; - } - -} diff --git a/im-sdk-core/src/test/java/com/easemob/im/server/api/message/send/SendMessageTest.java b/im-sdk-core/src/test/java/com/easemob/im/server/api/message/send/SendMessageTest.java deleted file mode 100644 index 256963345..000000000 --- a/im-sdk-core/src/test/java/com/easemob/im/server/api/message/send/SendMessageTest.java +++ /dev/null @@ -1,106 +0,0 @@ -package com.easemob.im.server.api.message.send; - -import com.easemob.im.server.api.AbstractApiTest; -import com.easemob.im.server.model.EMKeyValue; -import com.fasterxml.jackson.databind.JsonNode; -import com.fasterxml.jackson.databind.node.ObjectNode; -import org.junit.jupiter.api.Test; - -import java.net.URI; - -import com.easemob.im.server.api.util.Utilities; - -import java.util.concurrent.ThreadLocalRandom; - -import static org.junit.jupiter.api.Assertions.*; - -class SendMessageTest extends AbstractApiTest { - - SendMessage sendMessage = new SendMessage(this.context); - - SendMessageTest() { - this.server - .addHandler("POST /easemob/demo/messages?useMsgId=true", this::handleSendMessage); - } - - private JsonNode handleSendMessage(JsonNode jsonNode) { - System.out.println("send msg request:"); - System.out.println(jsonNode.toPrettyString()); - - JsonNode targets = jsonNode.get("target"); - - ObjectNode messageIdsByReceiverId = this.objectMapper.createObjectNode(); - for (int i = 0; i < targets.size(); i++) { - String target = targets.get(i).asText(); - messageIdsByReceiverId.put(target, ThreadLocalRandom.current().nextLong(2 ^ 63 - 1)); - } - - ObjectNode rsp = this.objectMapper.createObjectNode(); - rsp.set("data", messageIdsByReceiverId); - return rsp; - } - - @Test - void testSendUser2UserTextMessage() { - assertDoesNotThrow(() -> this.sendMessage.fromUser("alice").toUser("rabbit") - .text(msg -> msg.text("hello")) - .extension(exts -> exts.add(EMKeyValue.of("timeout", 1))) - .send() - .block(Utilities.UT_TIMEOUT)); - } - - @Test - void testSendUser2UserImageMessage() { - assertDoesNotThrow(() -> this.sendMessage.fromUser("alice").toUser("rabbit") - .image(msg -> msg.uri(URI.create("http://example/image.jpg")).height(100.000) - .width(200.000)) - .extension(exts -> exts.add(EMKeyValue.of("timeout", 1))) - .send() - .block(Utilities.UT_TIMEOUT)); - } - - @Test - void testSendUser2UserVoiceMessage() { - assertDoesNotThrow(() -> this.sendMessage.fromUser("alice").toUser("rabbit") - .voice(msg -> msg.uri(URI.create("http://example/voice.amr")).duration(18)) - .extension(exts -> exts.add(EMKeyValue.of("timeout", 1))) - .send() - .block(Utilities.UT_TIMEOUT)); - } - - @Test - void testSendUser2UserVideoMessage() { - assertDoesNotThrow(() -> this.sendMessage.fromUser("alice").toUser("rabbit") - .video(msg -> msg.uri(URI.create("http://example/video.mp4")).duration(18)) - .extension(exts -> exts.add(EMKeyValue.of("timeout", 1))) - .send() - .block(Utilities.UT_TIMEOUT)); - } - - @Test - void testSendUser2UserLocationMessage() { - assertDoesNotThrow(() -> this.sendMessage.fromUser("alice").toUser("rabbit") - .location(msg -> msg.latitude(1.234567).longitude(1.234567).address("some where")) - .extension(exts -> exts.add(EMKeyValue.of("timeout", 1))) - .send() - .block(Utilities.UT_TIMEOUT)); - } - - @Test - void testSendUser2UserCommandMessage() { - assertDoesNotThrow(() -> this.sendMessage.fromUser("alice").toUser("rabbit") - .command(msg -> msg.action("run").param("name", "rabbit")) - .extension(exts -> exts.add(EMKeyValue.of("timeout", 1))) - .send() - .block(Utilities.UT_TIMEOUT)); - } - - @Test - void testSendUser2UserCustomMessage() { - assertDoesNotThrow(() -> this.sendMessage.fromUser("alice").toUser("rabbit") - .custom(msg -> msg.customEvent("liked").customExtension("name", "forest")) - .extension(exts -> exts.add(EMKeyValue.of("timeout", 1))) - .send() - .block(Utilities.UT_TIMEOUT)); - } -} diff --git a/im-sdk-core/src/test/java/com/easemob/im/server/api/message/send/message/MessageSendTest.java b/im-sdk-core/src/test/java/com/easemob/im/server/api/message/send/message/MessageSendTest.java deleted file mode 100644 index 35bac53e9..000000000 --- a/im-sdk-core/src/test/java/com/easemob/im/server/api/message/send/message/MessageSendTest.java +++ /dev/null @@ -1,105 +0,0 @@ -package com.easemob.im.server.api.message.send.message; - -import com.easemob.im.server.api.AbstractApiTest; -import com.easemob.im.server.api.message.send.message.MessageSend; -import com.easemob.im.server.api.util.Utilities; -import com.easemob.im.server.model.EMKeyValue; -import com.fasterxml.jackson.databind.JsonNode; -import com.fasterxml.jackson.databind.node.ObjectNode; -import org.junit.jupiter.api.Test; - -import java.net.URI; -import java.util.concurrent.ThreadLocalRandom; - -import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; - -public class MessageSendTest extends AbstractApiTest { - - MessageSend messageSend = new MessageSend(this.context); - - MessageSendTest(){ - this.server - .addHandler("POST /easemob/demo/messages/users", this::handleSendMessage); - } - - private JsonNode handleSendMessage(JsonNode jsonNode) { - System.out.println("send msg request:"); - System.out.println(jsonNode.toPrettyString()); - - JsonNode targets = jsonNode.get("to"); - - ObjectNode messageIdsByReceiverId = this.objectMapper.createObjectNode(); - for (int i = 0; i < targets.size(); i++) { - String target = targets.get(i).asText(); - messageIdsByReceiverId.put(target, ThreadLocalRandom.current().nextLong(2 ^ 63 - 1)); - } - - ObjectNode rsp = this.objectMapper.createObjectNode(); - rsp.set("data", messageIdsByReceiverId); - return rsp; - } - - @Test - void testSendUser2UserTextMessage() { - assertDoesNotThrow(() -> this.messageSend.fromUser("alice").toUser("rabbit") - .text(msg -> msg.text("hello")) - .extension(exts -> exts.add(EMKeyValue.of("timeout", 1))) - .send() - .block(Utilities.IT_TIMEOUT)); - } - - @Test - void testSendUser2UserImageMessage() { - assertDoesNotThrow(() -> this.messageSend.fromUser("alice").toUser("rabbit") - .image(msg -> msg.uri(URI.create("http://example/image.jpg")).height(100.000) - .width(200.000)) - .extension(exts -> exts.add(EMKeyValue.of("timeout", 1))) - .send() - .block(Utilities.IT_TIMEOUT)); - } - - @Test - void testSendUser2UserVoiceMessage() { - assertDoesNotThrow(() -> this.messageSend.fromUser("alice").toUser("rabbit") - .voice(msg -> msg.uri(URI.create("http://example/voice.amr")).duration(18)) - .extension(exts -> exts.add(EMKeyValue.of("timeout", 1))) - .send() - .block(Utilities.IT_TIMEOUT)); - } - - @Test - void testSendUser2UserVideoMessage() { - assertDoesNotThrow(() -> this.messageSend.fromUser("alice").toUser("rabbit") - .video(msg -> msg.uri(URI.create("http://example/video.mp4")).duration(18)) - .extension(exts -> exts.add(EMKeyValue.of("timeout", 1))) - .send() - .block(Utilities.IT_TIMEOUT)); - } - - @Test - void testSendUser2UserLocationMessage() { - assertDoesNotThrow(() -> this.messageSend.fromUser("alice").toUser("rabbit") - .location(msg -> msg.latitude(1.234567).longitude(1.234567).address("some where")) - .extension(exts -> exts.add(EMKeyValue.of("timeout", 1))) - .send() - .block(Utilities.IT_TIMEOUT)); - } - - @Test - void testSendUser2UserCommandMessage() { - assertDoesNotThrow(() -> this.messageSend.fromUser("alice").toUser("rabbit") - .command(msg -> msg.action("run").param("name", "rabbit")) - .extension(exts -> exts.add(EMKeyValue.of("timeout", 1))) - .send() - .block(Utilities.IT_TIMEOUT)); - } - - @Test - void testSendUser2UserCustomMessage() { - assertDoesNotThrow(() -> this.messageSend.fromUser("alice").toUser("rabbit") - .custom(msg -> msg.customEvent("liked").customExtension("name", "forest")) - .extension(exts -> exts.add(EMKeyValue.of("timeout", 1))) - .send() - .block(Utilities.IT_TIMEOUT)); - } -} diff --git a/im-sdk-core/src/test/java/com/easemob/im/server/api/message/status/MessageStatusTest.java b/im-sdk-core/src/test/java/com/easemob/im/server/api/message/status/MessageStatusTest.java deleted file mode 100644 index 48529b38d..000000000 --- a/im-sdk-core/src/test/java/com/easemob/im/server/api/message/status/MessageStatusTest.java +++ /dev/null @@ -1,37 +0,0 @@ -package com.easemob.im.server.api.message.status; - -import com.easemob.im.server.api.AbstractApiTest; -import com.fasterxml.jackson.databind.JsonNode; -import com.fasterxml.jackson.databind.node.ObjectNode; -import org.junit.jupiter.api.Test; - -import com.easemob.im.server.api.util.Utilities; - -import static org.junit.jupiter.api.Assertions.*; - -public class MessageStatusTest extends AbstractApiTest { - - private MessageStatus messageStatus; - - public MessageStatusTest() { - this.server.addHandler("GET /easemob/demo/users/alice/offline_msg_status/123456789", - this::handleMessageStatusRequest); - this.messageStatus = new MessageStatus(this.context); - } - - @Test - public void testMessageStatus() { - boolean messageIsDelivered = - this.messageStatus.isMessageDeliveredToUser("123456789", "alice") - .block(Utilities.UT_TIMEOUT); - assertEquals(true, messageIsDelivered); - } - - private JsonNode handleMessageStatusRequest(JsonNode jsonNode) { - ObjectNode data = this.objectMapper.createObjectNode(); - data.put("123456789", "delivered"); - ObjectNode rsp = this.objectMapper.createObjectNode(); - rsp.set("data", data); - return rsp; - } -} diff --git a/im-sdk-core/src/test/java/com/easemob/im/server/api/message/upload/ImportMessageTest.java b/im-sdk-core/src/test/java/com/easemob/im/server/api/message/upload/ImportMessageTest.java deleted file mode 100644 index 0b4a11078..000000000 --- a/im-sdk-core/src/test/java/com/easemob/im/server/api/message/upload/ImportMessageTest.java +++ /dev/null @@ -1,68 +0,0 @@ -package com.easemob.im.server.api.message.upload; - -import com.easemob.im.server.api.AbstractApiTest; -import com.easemob.im.server.api.util.Utilities; -import com.easemob.im.server.model.EMKeyValue; -import com.easemob.im.server.model.EMTextMessage; -import com.fasterxml.jackson.databind.JsonNode; -import com.fasterxml.jackson.databind.node.ObjectNode; -import org.junit.jupiter.api.Test; - -import java.net.URI; -import java.time.Instant; -import java.util.concurrent.ThreadLocalRandom; - -import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; - -public class ImportMessageTest extends AbstractApiTest { - - ImportMessage importMessage = new ImportMessage(this.context); - - public ImportMessageTest() { - this.server.addHandler("POST /easemob/demo/messages/chatgroups/import", - this::handleSendMessage); - this.server.addHandler("POST /easemob/demo/messages/users/import", - this::handleSendMessage); - } - - private JsonNode handleSendMessage(JsonNode jsonNode) { - System.out.println("import msg request:"); - System.out.println(jsonNode.toPrettyString()); - - ObjectNode messageIdsByReceiverId = this.objectMapper.createObjectNode(); - messageIdsByReceiverId.put("msg_id", ThreadLocalRandom.current().nextLong(2 ^ 63 - 1)); - - ObjectNode rsp = this.objectMapper.createObjectNode(); - rsp.set("data", messageIdsByReceiverId); - return rsp; - } - - @Test - void testImportChatGroupTextMessage() { - assertDoesNotThrow( - () -> this.importMessage.from("alice") - .toGroup("186774875865089") - .text(msg -> msg.text("hello")) - .extension(exts -> exts.add(EMKeyValue.of("timeout", 1))) - .isAckRead(true) - .msgTimestamp(Instant.now().toEpochMilli()) - .needDownload(true) - .importChatMessage() - .block(Utilities.UT_TIMEOUT)); - } - - @Test - void testImportChatImageMessage() { - assertDoesNotThrow( - () -> this.importMessage.from("alice") - .toGroup("186774875865089") - .image(msg -> msg.uri(URI.create("http://example/image.jpg")).height(100.000) - .width(200.000)) - .extension(exts -> exts.add(EMKeyValue.of("timeout", 1))) - .isAckRead(true) - .msgTimestamp(Instant.now().toEpochMilli()) - .needDownload(true) - .importChatMessage() - .block(Utilities.UT_TIMEOUT)); - } -} diff --git a/im-sdk-core/src/test/java/com/easemob/im/server/api/metadata/chatroom/delete/ChatRoomMetadataDeleteTest.java b/im-sdk-core/src/test/java/com/easemob/im/server/api/metadata/chatroom/delete/ChatRoomMetadataDeleteTest.java deleted file mode 100644 index 76d60522d..000000000 --- a/im-sdk-core/src/test/java/com/easemob/im/server/api/metadata/chatroom/delete/ChatRoomMetadataDeleteTest.java +++ /dev/null @@ -1,54 +0,0 @@ -package com.easemob.im.server.api.metadata.chatroom.delete; - -import com.easemob.im.server.api.AbstractApiTest; -import com.easemob.im.server.api.util.Utilities; -import com.fasterxml.jackson.databind.JsonNode; -import com.fasterxml.jackson.databind.node.ObjectNode; -import org.junit.jupiter.api.Test; - -import java.util.ArrayList; -import java.util.List; - -import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; - -class ChatRoomMetadataDeleteTest extends AbstractApiTest { - ChatRoomMetadataDelete chatRoomMetadataDelete = new ChatRoomMetadataDelete(this.context); - - public ChatRoomMetadataDeleteTest() { - this.server.addHandler("DELETE /easemob/demo/metadata/chatroom/r1/user/bob", - this::handleChatRoomMetadataDelete); - - this.server.addHandler("DELETE /easemob/demo/metadata/chatroom/r1/user/admin/forced", - this::handleChatRoomMetadataDelete); - } - - @Test - public void testMetadataSet() { - List list = new ArrayList<>(); - list.add("nickname"); - assertDoesNotThrow( - () -> this.chatRoomMetadataDelete.fromChatRoom("bob", "r1", list) - .block(Utilities.UT_TIMEOUT)); - } - - @Test - public void testMetadataSetForced() { - List list = new ArrayList<>(); - list.add("nickname"); - assertDoesNotThrow( - () -> this.chatRoomMetadataDelete.fromChatRoomForced("r1", list) - .block(Utilities.UT_TIMEOUT)); - } - - public JsonNode handleChatRoomMetadataDelete(JsonNode req) { - ObjectNode data = this.objectMapper.createObjectNode(); - List successKeys = new ArrayList<>(); - successKeys.add("nickname"); - data.putPOJO("successKeys", successKeys); - - ObjectNode jsonRsp = this.objectMapper.createObjectNode(); - jsonRsp.set("data", data); - - return jsonRsp; - } -} diff --git a/im-sdk-core/src/test/java/com/easemob/im/server/api/metadata/chatroom/get/ChatRoomMetadataGetTest.java b/im-sdk-core/src/test/java/com/easemob/im/server/api/metadata/chatroom/get/ChatRoomMetadataGetTest.java deleted file mode 100644 index 33be75d5a..000000000 --- a/im-sdk-core/src/test/java/com/easemob/im/server/api/metadata/chatroom/get/ChatRoomMetadataGetTest.java +++ /dev/null @@ -1,42 +0,0 @@ -package com.easemob.im.server.api.metadata.chatroom.get; - -import com.easemob.im.server.api.AbstractApiTest; -import com.easemob.im.server.api.util.Utilities; -import com.fasterxml.jackson.databind.JsonNode; -import com.fasterxml.jackson.databind.node.ObjectNode; -import org.junit.jupiter.api.Test; - -import java.util.ArrayList; -import java.util.List; - -import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; - -class ChatRoomMetadataGetTest extends AbstractApiTest { - ChatRoomMetadataGet chatRoomMetadataDeleteGet = new ChatRoomMetadataGet(this.context); - - public ChatRoomMetadataGetTest() { - this.server.addHandler("POST /easemob/demo/metadata/chatroom/r1", - this::handleChatRoomMetadataGet); - } - - @Test - public void testMetadataGet() { - List list = new ArrayList<>(); - list.add("nickname"); - assertDoesNotThrow( - () -> this.chatRoomMetadataDeleteGet.listChatRoomMetadata("r1", list) - .block(Utilities.UT_TIMEOUT)); - } - - public JsonNode handleChatRoomMetadataGet(JsonNode req) { - ObjectNode data = this.objectMapper.createObjectNode(); - data.put("nickname", "昵称"); - data.put("avatar", "http://www.easemob.com/avatar.png"); - data.put("phone", "159"); - - ObjectNode jsonRsp = this.objectMapper.createObjectNode(); - jsonRsp.set("data", data); - - return jsonRsp; - } -} diff --git a/im-sdk-core/src/test/java/com/easemob/im/server/api/metadata/chatroom/set/ChatRoomMetadataSetTest.java b/im-sdk-core/src/test/java/com/easemob/im/server/api/metadata/chatroom/set/ChatRoomMetadataSetTest.java deleted file mode 100644 index d8a414a3b..000000000 --- a/im-sdk-core/src/test/java/com/easemob/im/server/api/metadata/chatroom/set/ChatRoomMetadataSetTest.java +++ /dev/null @@ -1,63 +0,0 @@ -package com.easemob.im.server.api.metadata.chatroom.set; - -import com.easemob.im.server.api.AbstractApiTest; -import com.easemob.im.server.api.metadata.chatroom.AutoDelete; -import com.easemob.im.server.api.util.Utilities; -import com.fasterxml.jackson.databind.JsonNode; -import com.fasterxml.jackson.databind.node.ObjectNode; -import org.junit.jupiter.api.Test; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; - -class ChatRoomMetadataSetTest extends AbstractApiTest { - ChatRoomMetadataSet chatRoomMetadataSet = new ChatRoomMetadataSet(this.context); - - public ChatRoomMetadataSetTest() { - this.server.addHandler("PUT /easemob/demo/metadata/chatroom/r1/user/bob", - this::handleChatRoomMetadataSet); - - this.server.addHandler("PUT /easemob/demo/metadata/chatroom/r1/user/bob/forced", - this::handleChatRoomMetadataSet); - } - - @Test - public void testMetadataSet() { - Map map = new HashMap<>(); - map.put("nickname", "昵称"); - map.put("avatar", "http://www.easemob.com/avatar.png"); - map.put("phone", "159"); - assertDoesNotThrow( - () -> this.chatRoomMetadataSet.toChatRoom("bob", "r1", map, AutoDelete.DELETE) - .block(Utilities.UT_TIMEOUT)); - } - - @Test - public void testMetadataSetForced() { - Map map = new HashMap<>(); - map.put("nickname", "昵称"); - map.put("avatar", "http://www.easemob.com/avatar.png"); - map.put("phone", "159"); - assertDoesNotThrow( - () -> this.chatRoomMetadataSet.toChatRoomForced("bob", "r1", map, AutoDelete.DELETE) - .block(Utilities.UT_TIMEOUT)); - } - - public JsonNode handleChatRoomMetadataSet(JsonNode req) { - ObjectNode data = this.objectMapper.createObjectNode(); - List successKeys = new ArrayList<>(); - successKeys.add("phone"); - successKeys.add("avatar"); - successKeys.add("nickname"); - data.putPOJO("successKeys", successKeys); - - ObjectNode jsonRsp = this.objectMapper.createObjectNode(); - jsonRsp.set("data", data); - - return jsonRsp; - } -} diff --git a/im-sdk-core/src/test/java/com/easemob/im/server/api/metadata/user/delete/MetadataDeleteTest.java b/im-sdk-core/src/test/java/com/easemob/im/server/api/metadata/user/delete/MetadataDeleteTest.java deleted file mode 100644 index 5c02d67c5..000000000 --- a/im-sdk-core/src/test/java/com/easemob/im/server/api/metadata/user/delete/MetadataDeleteTest.java +++ /dev/null @@ -1,32 +0,0 @@ -package com.easemob.im.server.api.metadata.user.delete; - -import com.easemob.im.server.api.AbstractApiTest; -import com.fasterxml.jackson.databind.JsonNode; -import com.fasterxml.jackson.databind.node.ObjectNode; -import org.junit.jupiter.api.Test; - -import com.easemob.im.server.api.util.Utilities; - -import static org.junit.jupiter.api.Assertions.*; - -class MetadataDeleteTest extends AbstractApiTest { - MetadataDelete metadataDelete = new MetadataDelete(this.context); - - public MetadataDeleteTest() { - this.server.addHandler("DELETE /easemob/demo/metadata/user/bob", - this::handleMetadataDeleteSuccess); - } - - @Test - public void testMetadataDeleteFromUserSuccess() { - boolean deletionSuccess = assertDoesNotThrow( - () -> this.metadataDelete.fromUser("bob").block(Utilities.UT_TIMEOUT)); - assertTrue(deletionSuccess); - } - - public JsonNode handleMetadataDeleteSuccess(JsonNode req) { - ObjectNode jsonRsp = this.objectMapper.createObjectNode(); - jsonRsp.put("data", true); - return jsonRsp; - } -} diff --git a/im-sdk-core/src/test/java/com/easemob/im/server/api/metadata/user/get/MetadataGetTest.java b/im-sdk-core/src/test/java/com/easemob/im/server/api/metadata/user/get/MetadataGetTest.java deleted file mode 100644 index ca4762ee2..000000000 --- a/im-sdk-core/src/test/java/com/easemob/im/server/api/metadata/user/get/MetadataGetTest.java +++ /dev/null @@ -1,34 +0,0 @@ -package com.easemob.im.server.api.metadata.user.get; - -import com.easemob.im.server.api.AbstractApiTest; -import com.easemob.im.server.api.util.Utilities; -import com.fasterxml.jackson.databind.JsonNode; -import com.fasterxml.jackson.databind.node.ObjectNode; -import org.junit.jupiter.api.Test; - -import static org.junit.jupiter.api.Assertions.*; - -class MetadataGetTest extends AbstractApiTest { - MetadataGet metadataGet = new MetadataGet(this.context); - - public MetadataGetTest() { - this.server.addHandler("GET /easemob/demo/metadata/user/bob", this::handleMetadataGet); - } - - @Test - public void testMetadataGet() { - assertDoesNotThrow(() -> this.metadataGet.fromUser("bob").block(Utilities.UT_TIMEOUT)); - } - - public JsonNode handleMetadataGet(JsonNode req) { - ObjectNode data = this.objectMapper.createObjectNode(); - data.put("nickname", "昵称"); - data.put("avatar", "http://www.easemob.com/avatar.png"); - data.put("phone", "159"); - - ObjectNode jsonRsp = this.objectMapper.createObjectNode(); - jsonRsp.set("data", data); - - return jsonRsp; - } -} diff --git a/im-sdk-core/src/test/java/com/easemob/im/server/api/metadata/user/set/MetadataSetUserTest.java b/im-sdk-core/src/test/java/com/easemob/im/server/api/metadata/user/set/MetadataSetUserTest.java deleted file mode 100644 index 38a70045d..000000000 --- a/im-sdk-core/src/test/java/com/easemob/im/server/api/metadata/user/set/MetadataSetUserTest.java +++ /dev/null @@ -1,44 +0,0 @@ -package com.easemob.im.server.api.metadata.user.set; - -import com.easemob.im.server.api.AbstractApiTest; -import com.fasterxml.jackson.databind.JsonNode; -import com.fasterxml.jackson.databind.node.ObjectNode; -import org.junit.jupiter.api.Test; - -import com.easemob.im.server.api.util.Utilities; - -import java.util.HashMap; -import java.util.Map; - -import static org.junit.jupiter.api.Assertions.*; - -class MetadataSetUserTest extends AbstractApiTest { - MetadataSet metadataSetUser = new MetadataSet(this.context); - - public MetadataSetUserTest() { - this.server.addHandler("PUT /easemob/demo/metadata/user/bob", this::handleMetadataSet); - } - -// @Test -// public void testMetadataSet() { -// Map map = new HashMap<>(); -// map.put("nickname", "昵称"); -// map.put("avatar", "http://www.easemob.com/avatar.png"); -// map.put("phone", "159"); -// -// assertDoesNotThrow( -// () -> this.metadataSetUser.toUser("bob", map).block(Utilities.UT_TIMEOUT)); -// } - - public JsonNode handleMetadataSet(JsonNode req) { - ObjectNode data = this.objectMapper.createObjectNode(); - data.put("nickname", "昵称"); - data.put("avatar", "http://www.easemob.com/avatar.png"); - data.put("phone", "159"); - - ObjectNode jsonRsp = this.objectMapper.createObjectNode(); - jsonRsp.set("data", data); - - return jsonRsp; - } -} diff --git a/im-sdk-core/src/test/java/com/easemob/im/server/api/metadata/user/usage/MetadataUsageTest.java b/im-sdk-core/src/test/java/com/easemob/im/server/api/metadata/user/usage/MetadataUsageTest.java deleted file mode 100644 index ea1802dfa..000000000 --- a/im-sdk-core/src/test/java/com/easemob/im/server/api/metadata/user/usage/MetadataUsageTest.java +++ /dev/null @@ -1,34 +0,0 @@ -package com.easemob.im.server.api.metadata.user.usage; - -import com.easemob.im.server.api.AbstractApiTest; -import com.easemob.im.server.model.EMMetadata; -import com.easemob.im.server.model.EMMetadataUsage; -import com.fasterxml.jackson.databind.JsonNode; -import com.fasterxml.jackson.databind.node.ObjectNode; -import org.junit.jupiter.api.Test; - -import com.easemob.im.server.api.util.Utilities; - -import static org.junit.jupiter.api.Assertions.*; - -class MetadataUsageTest extends AbstractApiTest { - MetadataUsage metadataUsage = new MetadataUsage(this.context); - - public MetadataUsageTest() { - this.server - .addHandler("GET /easemob/demo/metadata/user/capacity", this::handleMetadataUsage); - } - - @Test - public void testUsage() { - EMMetadataUsage emMetadataUsage = assertDoesNotThrow( - () -> this.metadataUsage.getUsage().block(Utilities.UT_TIMEOUT)); - assertEquals(1600, emMetadataUsage.getBytesUsed()); - } - - private JsonNode handleMetadataUsage(JsonNode req) { - ObjectNode jsonRsp = this.objectMapper.createObjectNode(); - jsonRsp.put("data", 1600); - return jsonRsp; - } -} diff --git a/im-sdk-core/src/test/java/com/easemob/im/server/api/mute/detail/MuteDetailTest.java b/im-sdk-core/src/test/java/com/easemob/im/server/api/mute/detail/MuteDetailTest.java deleted file mode 100644 index 17a1a59b1..000000000 --- a/im-sdk-core/src/test/java/com/easemob/im/server/api/mute/detail/MuteDetailTest.java +++ /dev/null @@ -1,42 +0,0 @@ -package com.easemob.im.server.api.mute.detail; - -import com.easemob.im.server.api.AbstractApiTest; -import com.easemob.im.server.api.util.Utilities; -import com.fasterxml.jackson.databind.JsonNode; -import com.fasterxml.jackson.databind.node.ObjectNode; -import org.junit.jupiter.api.Test; - -import java.util.HashMap; -import java.util.Map; - -import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; - -public class MuteDetailTest extends AbstractApiTest { - - MuteDetail muteDetail = new MuteDetail(this.context); - - public MuteDetailTest() { - this.server.addHandler("GET /easemob/demo/mutes/bob", this::handleGetMuteDetailRequest); - } - - @Test - public void testGetMuteDetail() { - Map map = new HashMap<>(); - assertDoesNotThrow( - () -> this.muteDetail.execute("bob").block(Utilities.UT_TIMEOUT)); - } - - public JsonNode handleGetMuteDetailRequest(JsonNode req) { - ObjectNode data = this.objectMapper.createObjectNode(); - data.put("userid", "bob"); - data.put("chat", 96); - data.put("groupchat", 96); - data.put("chatroom", 96); - data.put("unixtime", 1631609831); - - ObjectNode jsonRsp = this.objectMapper.createObjectNode(); - jsonRsp.set("data", data); - - return jsonRsp; - } -} diff --git a/im-sdk-core/src/test/java/com/easemob/im/server/api/mute/list/MuteUserListTest.java b/im-sdk-core/src/test/java/com/easemob/im/server/api/mute/list/MuteUserListTest.java deleted file mode 100644 index 2110e0b5b..000000000 --- a/im-sdk-core/src/test/java/com/easemob/im/server/api/mute/list/MuteUserListTest.java +++ /dev/null @@ -1,48 +0,0 @@ -package com.easemob.im.server.api.mute.list; - -import com.easemob.im.server.api.AbstractApiTest; -import com.easemob.im.server.api.util.Utilities; -import com.fasterxml.jackson.databind.JsonNode; -import com.fasterxml.jackson.databind.node.ArrayNode; -import com.fasterxml.jackson.databind.node.ObjectNode; -import org.junit.jupiter.api.Test; - -import java.util.HashMap; -import java.util.Map; - -import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; - -public class MuteUserListTest extends AbstractApiTest { - - MuteList muteUserList = new MuteList(this.context); - - public MuteUserListTest() { - this.server.addHandler("GET /easemob/demo/mutes", this::handleGetMuteDetailRequest); - } - - @Test - public void testGetMuteDetail() { - Map map = new HashMap<>(); - assertDoesNotThrow( - () -> this.muteUserList.execute().block(Utilities.UT_TIMEOUT)); - } - - public JsonNode handleGetMuteDetailRequest(JsonNode req) { - ArrayNode data = this.objectMapper.createArrayNode(); - ObjectNode mute = this.objectMapper.createObjectNode(); - mute.put("userid", "bob"); - mute.put("chat", 96); - mute.put("groupchat", 96); - mute.put("chatroom", 96); - data.add(mute); - - ObjectNode jsonData = this.objectMapper.createObjectNode(); - jsonData.set("data", data); - jsonData.put("unixtime", 1631609831); - - ObjectNode jsonRsp = this.objectMapper.createObjectNode(); - jsonRsp.set("data", jsonData); - - return jsonRsp; - } -} diff --git a/im-sdk-core/src/test/java/com/easemob/im/server/api/mute/mute/MuteUserTest.java b/im-sdk-core/src/test/java/com/easemob/im/server/api/mute/mute/MuteUserTest.java deleted file mode 100644 index 11a3ff782..000000000 --- a/im-sdk-core/src/test/java/com/easemob/im/server/api/mute/mute/MuteUserTest.java +++ /dev/null @@ -1,18 +0,0 @@ -package com.easemob.im.server.api.mute.mute; - -import com.easemob.im.server.api.AbstractApiTest; -import com.easemob.im.server.api.util.Utilities; -import org.junit.jupiter.api.Test; - -import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; - -public class MuteUserTest extends AbstractApiTest { - - MuteUser muteUser = new MuteUser(this.context); - - @Test - public void testGetMuteDetail() { - assertDoesNotThrow( - () -> this.muteUser.execute(MuteUserRequest.builder().username("bob").chatroom(100).build()).block(Utilities.UT_TIMEOUT)); - } -} diff --git a/im-sdk-core/src/test/java/com/easemob/im/server/api/push/nickname/UpdateUserNicknameTest.java b/im-sdk-core/src/test/java/com/easemob/im/server/api/push/nickname/UpdateUserNicknameTest.java deleted file mode 100644 index 4e5c5f116..000000000 --- a/im-sdk-core/src/test/java/com/easemob/im/server/api/push/nickname/UpdateUserNicknameTest.java +++ /dev/null @@ -1,46 +0,0 @@ -package com.easemob.im.server.api.push.nickname; - -import com.easemob.im.server.api.AbstractApiTest; -import com.easemob.im.server.api.util.Utilities; -import com.fasterxml.jackson.databind.JsonNode; -import com.fasterxml.jackson.databind.node.ArrayNode; -import com.fasterxml.jackson.databind.node.ObjectNode; -import org.junit.jupiter.api.Test; - -import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; - -public class UpdateUserNicknameTest extends AbstractApiTest { - - private static final String DUMMY_USER_NAME = "dummy-user-name"; - private static final String DUMMY_USER_UUID = "b2832810-e91f-11eb-901b-1d2efade27a3"; - private static final String DUMMY_USER_NICKNAME = "dummy-user-nickname"; - private static final boolean DUMMY_USER_ACTIVATED = true; - - UpdateUserNickname updateUserNickname = new UpdateUserNickname(this.context); - - UpdateUserNicknameTest() { - this.server.addHandler(String.format("PUT /easemob/demo/users/%s", DUMMY_USER_NAME), - this::handleUpdateUserNickname); - } - - @Test - public void testUpdateUserNickname() { - assertDoesNotThrow(() -> this.updateUserNickname.update(DUMMY_USER_NAME, DUMMY_USER_NICKNAME) - .block(Utilities.UT_TIMEOUT)); - } - - private JsonNode handleUpdateUserNickname(JsonNode req) { - ObjectNode user = this.objectMapper.createObjectNode(); - user.put("username", DUMMY_USER_NAME); - user.put("uuid", DUMMY_USER_UUID); - user.put("activated", DUMMY_USER_ACTIVATED); - - ArrayNode users = this.objectMapper.createArrayNode(); - users.add(user); - - ObjectNode rsp = this.objectMapper.createObjectNode(); - rsp.set("entities", users); - - return rsp; - } -} diff --git a/im-sdk-core/src/test/java/com/easemob/im/server/api/room/admin/demote/DemoteRoomAdminTest.java b/im-sdk-core/src/test/java/com/easemob/im/server/api/room/admin/demote/DemoteRoomAdminTest.java deleted file mode 100644 index 71008a9eb..000000000 --- a/im-sdk-core/src/test/java/com/easemob/im/server/api/room/admin/demote/DemoteRoomAdminTest.java +++ /dev/null @@ -1,36 +0,0 @@ -package com.easemob.im.server.api.room.admin.demote; - -import com.easemob.im.server.api.AbstractApiTest; -import com.fasterxml.jackson.databind.JsonNode; -import com.fasterxml.jackson.databind.node.ObjectNode; -import org.junit.jupiter.api.Test; - -import com.easemob.im.server.api.util.Utilities; - -import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; - -class DemoteRoomAdminTest extends AbstractApiTest { - - private DemoteRoomAdmin demoteRoomAdmin; - - DemoteRoomAdminTest() { - this.server.addHandler("DELETE /easemob/demo/chatrooms/r1/admin/rabbit", - this::handleDemoteRoomAdmin); - this.demoteRoomAdmin = new DemoteRoomAdmin(this.context); - } - - private JsonNode handleDemoteRoomAdmin(JsonNode jsonNode) { - ObjectNode data = this.objectMapper.createObjectNode(); - data.put("result", "success"); - data.put("oldadmin", "rabbit"); - ObjectNode rsp = this.objectMapper.createObjectNode(); - rsp.set("data", data); - return rsp; - } - - @Test - void testDemoteRoomAdmin() { - assertDoesNotThrow( - () -> this.demoteRoomAdmin.single("r1", "rabbit").block(Utilities.UT_TIMEOUT)); - } -} diff --git a/im-sdk-core/src/test/java/com/easemob/im/server/api/room/admin/list/ListRoomAdminsTest.java b/im-sdk-core/src/test/java/com/easemob/im/server/api/room/admin/list/ListRoomAdminsTest.java deleted file mode 100644 index 62f7f67b4..000000000 --- a/im-sdk-core/src/test/java/com/easemob/im/server/api/room/admin/list/ListRoomAdminsTest.java +++ /dev/null @@ -1,42 +0,0 @@ -package com.easemob.im.server.api.room.admin.list; - -import com.easemob.im.server.api.AbstractApiTest; -import com.fasterxml.jackson.databind.JsonNode; -import com.fasterxml.jackson.databind.node.ArrayNode; -import com.fasterxml.jackson.databind.node.ObjectNode; -import org.junit.jupiter.api.Test; - -import com.easemob.im.server.api.util.Utilities; - -import java.util.List; - -import static org.junit.jupiter.api.Assertions.*; - -class ListRoomAdminsTest extends AbstractApiTest { - - private ListRoomAdmins listRoomAdmins; - - ListRoomAdminsTest() { - this.server.addHandler("GET /easemob/demo/chatrooms/r1/admin", this::handleListRoomAdmins); - this.listRoomAdmins = new ListRoomAdmins(this.context); - } - - private JsonNode handleListRoomAdmins(JsonNode jsonNode) { - ArrayNode admins = this.objectMapper.createArrayNode(); - admins.add("rabbit"); - admins.add("madhat"); - ObjectNode rsp = this.objectMapper.createObjectNode(); - rsp.set("data", admins); - return rsp; - } - - @Test - void testListRoomAdmins() { - List admins = - this.listRoomAdmins.all("r1").collectList().block(Utilities.UT_TIMEOUT); - assertEquals(2, admins.size()); - assertEquals("rabbit", admins.get(0)); - assertEquals("madhat", admins.get(1)); - } - -} diff --git a/im-sdk-core/src/test/java/com/easemob/im/server/api/room/admin/promote/PromoteRoomAdminTest.java b/im-sdk-core/src/test/java/com/easemob/im/server/api/room/admin/promote/PromoteRoomAdminTest.java deleted file mode 100644 index 5b18ae02b..000000000 --- a/im-sdk-core/src/test/java/com/easemob/im/server/api/room/admin/promote/PromoteRoomAdminTest.java +++ /dev/null @@ -1,37 +0,0 @@ -package com.easemob.im.server.api.room.admin.promote; - -import com.easemob.im.server.api.AbstractApiTest; -import com.fasterxml.jackson.databind.JsonNode; -import com.fasterxml.jackson.databind.node.ObjectNode; -import org.junit.jupiter.api.Test; - -import com.easemob.im.server.api.util.Utilities; - -import static org.junit.jupiter.api.Assertions.*; - -class PromoteRoomAdminTest extends AbstractApiTest { - - private PromoteRoomAdmin promoteRoomAdmin; - - PromoteRoomAdminTest() { - this.server.addHandler("POST /easemob/demo/chatrooms/r1/admin", this::handleAddRoomAdmin); - this.promoteRoomAdmin = new PromoteRoomAdmin(this.context); - } - - private JsonNode handleAddRoomAdmin(JsonNode jsonNode) { - ObjectNode data = this.objectMapper.createObjectNode(); - data.put("result", "success"); - data.put("newadmin", "rabbit"); - - ObjectNode rsp = this.objectMapper.createObjectNode(); - rsp.set("data", data); - - return rsp; - } - - @Test - void testPromoteRoomAdmin() { - assertDoesNotThrow( - () -> this.promoteRoomAdmin.single("r1", "rabbit").block(Utilities.UT_TIMEOUT)); - } -} diff --git a/im-sdk-core/src/test/java/com/easemob/im/server/api/room/create/CreateRoomTest.java b/im-sdk-core/src/test/java/com/easemob/im/server/api/room/create/CreateRoomTest.java deleted file mode 100644 index a3f68812c..000000000 --- a/im-sdk-core/src/test/java/com/easemob/im/server/api/room/create/CreateRoomTest.java +++ /dev/null @@ -1,44 +0,0 @@ -package com.easemob.im.server.api.room.create; - -import com.easemob.im.server.api.AbstractApiTest; -import com.fasterxml.jackson.databind.JsonNode; -import com.fasterxml.jackson.databind.node.ObjectNode; -import org.junit.jupiter.api.Test; - -import com.easemob.im.server.api.util.Utilities; - -import java.util.ArrayList; -import java.util.List; - -import static org.junit.jupiter.api.Assertions.*; - -class CreateRoomTest extends AbstractApiTest { - - private CreateRoom createRoom; - - CreateRoomTest() { - this.server.addHandler("POST /easemob/demo/chatrooms", this::handleCreateRoomRequest); - this.createRoom = new CreateRoom(this.context); - } - - private JsonNode handleCreateRoomRequest(JsonNode jsonNode) { - ObjectNode data = this.objectMapper.createObjectNode(); - data.put("id", "r1"); - - ObjectNode rsp = this.objectMapper.createObjectNode(); - rsp.set("data", data); - - return rsp; - } - - @Test - void testCreateRoom() { - List members = new ArrayList<>(); - members.add("rabbit"); - members.add("madhat"); - String id = this.createRoom.createRoom("room one", "have a nice day", "alice", members, 200) - .block(Utilities.UT_TIMEOUT); - assertEquals("r1", id); - } - -} diff --git a/im-sdk-core/src/test/java/com/easemob/im/server/api/room/delete/DeleteRoomTest.java b/im-sdk-core/src/test/java/com/easemob/im/server/api/room/delete/DeleteRoomTest.java deleted file mode 100644 index fdcb5e8b4..000000000 --- a/im-sdk-core/src/test/java/com/easemob/im/server/api/room/delete/DeleteRoomTest.java +++ /dev/null @@ -1,36 +0,0 @@ -package com.easemob.im.server.api.room.delete; - -import com.easemob.im.server.api.AbstractApiTest; -import com.fasterxml.jackson.databind.JsonNode; -import com.fasterxml.jackson.databind.node.ObjectNode; -import org.junit.jupiter.api.Test; - -import com.easemob.im.server.api.util.Utilities; - -import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; - -class DeleteRoomTest extends AbstractApiTest { - - private DeleteRoom deleteRoom; - - DeleteRoomTest() { - this.server.addHandler("DELETE /easemob/demo/chatrooms/r1", this::handleDeleteRoomRequest); - this.deleteRoom = new DeleteRoom(this.context); - } - - private JsonNode handleDeleteRoomRequest(JsonNode jsonNode) { - ObjectNode data = this.objectMapper.createObjectNode(); - data.put("id", "r1"); - data.put("success", true); - - ObjectNode rsp = this.objectMapper.createObjectNode(); - rsp.set("data", data); - - return rsp; - } - - @Test - void testDeleteRoom() { - assertDoesNotThrow(() -> this.deleteRoom.byId("r1").block(Utilities.UT_TIMEOUT)); - } -} diff --git a/im-sdk-core/src/test/java/com/easemob/im/server/api/room/detail/GetRoomDetailTest.java b/im-sdk-core/src/test/java/com/easemob/im/server/api/room/detail/GetRoomDetailTest.java deleted file mode 100644 index f416bee7b..000000000 --- a/im-sdk-core/src/test/java/com/easemob/im/server/api/room/detail/GetRoomDetailTest.java +++ /dev/null @@ -1,49 +0,0 @@ -package com.easemob.im.server.api.room.detail; - -import com.easemob.im.server.api.AbstractApiTest; -import com.easemob.im.server.model.EMRoom; -import com.fasterxml.jackson.databind.JsonNode; -import com.fasterxml.jackson.databind.node.ArrayNode; -import com.fasterxml.jackson.databind.node.ObjectNode; -import org.junit.jupiter.api.Test; - -import com.easemob.im.server.api.util.Utilities; - -import static org.junit.jupiter.api.Assertions.assertEquals; - -class GetRoomDetailTest extends AbstractApiTest { - - private GetRoomDetail getRoomDetail; - - GetRoomDetailTest() { - this.server.addHandler("GET /easemob/demo/chatrooms/r1", this::handleGetRoomDetailRequest); - this.getRoomDetail = new GetRoomDetail(this.context); - } - - private JsonNode handleGetRoomDetailRequest(JsonNode jsonNode) { - ObjectNode room1 = this.objectMapper.createObjectNode(); - room1.put("id", "r1"); - room1.put("name", "room1"); - room1.put("description", "The first room."); - room1.put("owner", "alice"); - room1.put("membersonly", true); - room1.put("allowinvites", false); - room1.put("maxusers", 200); - ArrayNode rooms = this.objectMapper.createArrayNode(); - rooms.add(room1); - ObjectNode rsp = this.objectMapper.createObjectNode(); - rsp.set("data", rooms); - return rsp; - } - - @Test - void testGetRoomDetail() { - EMRoom r1 = this.getRoomDetail.byId("r1").block(Utilities.UT_TIMEOUT); - assertEquals("r1", r1.id()); - assertEquals("room1", r1.name()); - assertEquals("The first room.", r1.description()); - assertEquals("alice", r1.owner()); - assertEquals(200, r1.maxMembers()); - } - -} \ No newline at end of file diff --git a/im-sdk-core/src/test/java/com/easemob/im/server/api/room/list/ListRoomsTest.java b/im-sdk-core/src/test/java/com/easemob/im/server/api/room/list/ListRoomsTest.java deleted file mode 100644 index bf9331002..000000000 --- a/im-sdk-core/src/test/java/com/easemob/im/server/api/room/list/ListRoomsTest.java +++ /dev/null @@ -1,101 +0,0 @@ -package com.easemob.im.server.api.room.list; - -import com.easemob.im.server.api.AbstractApiTest; -import com.easemob.im.server.model.EMPage; -import com.fasterxml.jackson.databind.JsonNode; -import com.fasterxml.jackson.databind.node.ArrayNode; -import com.fasterxml.jackson.databind.node.ObjectNode; -import org.junit.jupiter.api.Test; - -import com.easemob.im.server.api.util.Utilities; - -import java.util.List; - -import static org.junit.jupiter.api.Assertions.*; - -class ListRoomsTest extends AbstractApiTest { - - private ListRooms listRooms; - - public ListRoomsTest() { - this.server.addHandler("GET /easemob/demo/chatrooms?limit=2", - req -> handleListRoomsRequest(req, 0, 2, "1")); - this.server.addHandler("GET /easemob/demo/chatrooms?limit=2&cursor=1", - req -> handleListRoomsRequest(req, 2, 1, null)); - this.server.addHandler("GET /easemob/demo/users/alice/joined_chatrooms", - this::handleListRoomsUserJoined); - this.listRooms = new ListRooms(this.context); - } - - private JsonNode handleListRoomsUserJoined(JsonNode jsonNode) { - ObjectNode room1 = this.objectMapper.createObjectNode(); - room1.put("id", "r1"); - room1.put("name", "room-1"); - - ObjectNode room2 = this.objectMapper.createObjectNode(); - room2.put("id", "r2"); - room2.put("name", "room-2"); - - ArrayNode rooms = this.objectMapper.createArrayNode(); - rooms.add(room1); - rooms.add(room2); - - ObjectNode rsp = this.objectMapper.createObjectNode(); - rsp.set("data", rooms); - - return rsp; - } - - private JsonNode handleListRoomsRequest(JsonNode jsonNode, int offset, int count, - String cursor) { - ArrayNode rooms = this.objectMapper.createArrayNode(); - - for (int i = 1; i <= count; i++) { - ObjectNode room = this.objectMapper.createObjectNode(); - room.put("id", String.format("r%d", i + offset)); - room.put("name", String.format("room-%d", i + offset)); - room.put("owner", String.format("owner-%d", i + offset)); - room.put("affiliations_count", i + offset); - rooms.add(room); - } - - ObjectNode rsp = this.objectMapper.createObjectNode(); - rsp.set("data", rooms); - if (cursor != null) { - rsp.put("cursor", cursor); - } - - return rsp; - } - - @Test - void testListAll() { - List rooms = this.listRooms.all(2).collectList().block(Utilities.UT_TIMEOUT); - assertEquals(3, rooms.size()); - assertEquals("r1", rooms.get(0)); - assertEquals("r2", rooms.get(1)); - assertEquals("r3", rooms.get(2)); - } - - @Test - void testListFirstPage() { - EMPage page = this.listRooms.next(2, null).block(Utilities.UT_TIMEOUT); - assertEquals(2, page.getValues().size()); - } - - @Test - void testListSecondPage() { - EMPage page = this.listRooms.next(2, "1").block(Utilities.UT_TIMEOUT); - assertEquals(1, page.getValues().size()); - } - - @Test - void testListUserJoined() { - List rooms = - this.listRooms.userJoined("alice").collectList().block(Utilities.UT_TIMEOUT); - assertEquals(2, rooms.size()); - assertEquals("r1", rooms.get(0)); - assertEquals("r2", rooms.get(1)); - } - -} diff --git a/im-sdk-core/src/test/java/com/easemob/im/server/api/room/member/add/AddRoomMemberTest.java b/im-sdk-core/src/test/java/com/easemob/im/server/api/room/member/add/AddRoomMemberTest.java deleted file mode 100644 index 1666b6b8e..000000000 --- a/im-sdk-core/src/test/java/com/easemob/im/server/api/room/member/add/AddRoomMemberTest.java +++ /dev/null @@ -1,35 +0,0 @@ -package com.easemob.im.server.api.room.member.add; - -import com.easemob.im.server.api.AbstractApiTest; -import com.fasterxml.jackson.databind.JsonNode; -import com.fasterxml.jackson.databind.node.ObjectNode; -import org.junit.jupiter.api.Test; - -import com.easemob.im.server.api.util.Utilities; - -import static org.junit.jupiter.api.Assertions.*; - -class AddRoomMemberTest extends AbstractApiTest { - - private AddRoomMember addRoomMember; - - AddRoomMemberTest() { - this.server.addHandler("POST /easemob/demo/chatrooms/r1/users/alice", - this::handleAddRoomMember); - this.addRoomMember = new AddRoomMember(this.context); - } - - private JsonNode handleAddRoomMember(JsonNode jsonNode) { - ObjectNode data = this.objectMapper.createObjectNode(); - data.put("result", true); - ObjectNode rsp = this.objectMapper.createObjectNode(); - rsp.set("data", data); - return rsp; - } - - @Test - void testAddRoomMember() { - assertDoesNotThrow( - () -> this.addRoomMember.single("r1", "alice").block(Utilities.UT_TIMEOUT)); - } -} diff --git a/im-sdk-core/src/test/java/com/easemob/im/server/api/room/member/list/ListRoomMembersTest.java b/im-sdk-core/src/test/java/com/easemob/im/server/api/room/member/list/ListRoomMembersTest.java deleted file mode 100644 index f6e1e2139..000000000 --- a/im-sdk-core/src/test/java/com/easemob/im/server/api/room/member/list/ListRoomMembersTest.java +++ /dev/null @@ -1,58 +0,0 @@ -package com.easemob.im.server.api.room.member.list; - -import com.easemob.im.server.api.AbstractApiTest; -import com.fasterxml.jackson.databind.JsonNode; -import com.fasterxml.jackson.databind.node.ArrayNode; -import com.fasterxml.jackson.databind.node.ObjectNode; -import org.junit.jupiter.api.Test; - -import com.easemob.im.server.api.util.Utilities; - -import java.util.List; - -import static org.junit.jupiter.api.Assertions.assertEquals; - -class ListRoomMembersTest extends AbstractApiTest { - - private ListRoomMembers listRoomMembers; - - ListRoomMembersTest() { - this.server.addHandler("GET /easemob/demo/chatrooms/r1/users?version=v3&limit=2", - this::handleListMembersFirst); - this.server.addHandler("GET /easemob/demo/chatrooms/r1/users?version=v3&limit=2&cursor=1", - this::handleListMembersLast); - this.listRoomMembers = new ListRoomMembers(this.context); - } - - private JsonNode handleListMembersLast(JsonNode jsonNode) { - ArrayNode data = this.objectMapper.createArrayNode(); - data.add("madhat"); - - ObjectNode rsp = this.objectMapper.createObjectNode(); - rsp.set("data", data); - - return rsp; - } - - private JsonNode handleListMembersFirst(JsonNode jsonNode) { - ArrayNode data = this.objectMapper.createArrayNode(); - data.add("alice"); - data.add("rabbit"); - - ObjectNode rsp = this.objectMapper.createObjectNode(); - rsp.set("data", data); - rsp.put("cursor", 1); - - return rsp; - } - - @Test - void testListRoomMembers() { - List members = - this.listRoomMembers.all("r1", 2, null).collectList().block(Utilities.UT_TIMEOUT); - assertEquals(3, members.size()); - assertEquals("alice", members.get(0)); - assertEquals("rabbit", members.get(1)); - assertEquals("madhat", members.get(2)); - } -} diff --git a/im-sdk-core/src/test/java/com/easemob/im/server/api/room/member/remove/RemoveRoomMemberTest.java b/im-sdk-core/src/test/java/com/easemob/im/server/api/room/member/remove/RemoveRoomMemberTest.java deleted file mode 100644 index 7a2ea67e7..000000000 --- a/im-sdk-core/src/test/java/com/easemob/im/server/api/room/member/remove/RemoveRoomMemberTest.java +++ /dev/null @@ -1,35 +0,0 @@ -package com.easemob.im.server.api.room.member.remove; - -import com.easemob.im.server.api.AbstractApiTest; -import com.fasterxml.jackson.databind.JsonNode; -import com.fasterxml.jackson.databind.node.ObjectNode; -import org.junit.jupiter.api.Test; - -import com.easemob.im.server.api.util.Utilities; - -import static org.junit.jupiter.api.Assertions.*; - -class RemoveRoomMemberTest extends AbstractApiTest { - - private RemoveRoomMember removeRoomMember; - - RemoveRoomMemberTest() { - this.server.addHandler("DELETE /easemob/demo/chatrooms/r1/users/alice", - this::handleRemoveMemberRequest); - removeRoomMember = new RemoveRoomMember(this.context); - } - - private JsonNode handleRemoveMemberRequest(JsonNode jsonNode) { - ObjectNode data = this.objectMapper.createObjectNode(); - data.put("result", true); - ObjectNode rsp = this.objectMapper.createObjectNode(); - rsp.set("data", data); - return rsp; - } - - @Test - void testRemoveRoomMember() { - assertDoesNotThrow( - () -> this.removeRoomMember.single("r1", "alice").block(Utilities.UT_TIMEOUT)); - } -} diff --git a/im-sdk-core/src/test/java/com/easemob/im/server/api/room/superadmin/demote/DemoteRoomSuperAdminsTest.java b/im-sdk-core/src/test/java/com/easemob/im/server/api/room/superadmin/demote/DemoteRoomSuperAdminsTest.java deleted file mode 100644 index e5469deee..000000000 --- a/im-sdk-core/src/test/java/com/easemob/im/server/api/room/superadmin/demote/DemoteRoomSuperAdminsTest.java +++ /dev/null @@ -1,36 +0,0 @@ -package com.easemob.im.server.api.room.superadmin.demote; - -import com.easemob.im.server.api.AbstractApiTest; -import com.fasterxml.jackson.databind.JsonNode; -import com.fasterxml.jackson.databind.node.ObjectNode; -import org.junit.jupiter.api.Test; - -import com.easemob.im.server.api.util.Utilities; - -import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; - -class DemoteRoomSuperAdminsTest extends AbstractApiTest { - - private DemoteRoomSuperAdmin demoteRoomSuperAdmin; - - DemoteRoomSuperAdminsTest() { - this.server.addHandler("DELETE /easemob/demo/chatrooms/super_admin/rabbit", - this::handleDemoteRoomSuperAdmin); - this.demoteRoomSuperAdmin = new DemoteRoomSuperAdmin(this.context); - } - - private JsonNode handleDemoteRoomSuperAdmin(JsonNode jsonNode) { - ObjectNode data = this.objectMapper.createObjectNode(); - data.put("newSuperAdmin", "rabbit"); - data.put("resource", ""); - ObjectNode rsp = this.objectMapper.createObjectNode(); - rsp.set("data", data); - return rsp; - } - - @Test - void testDemoteRoomSuperAdmin() { - assertDoesNotThrow( - () -> this.demoteRoomSuperAdmin.single("rabbit").block(Utilities.UT_TIMEOUT)); - } -} diff --git a/im-sdk-core/src/test/java/com/easemob/im/server/api/room/superadmin/list/ListRoomSuperAdminsTest.java b/im-sdk-core/src/test/java/com/easemob/im/server/api/room/superadmin/list/ListRoomSuperAdminsTest.java deleted file mode 100644 index 0fa8c588a..000000000 --- a/im-sdk-core/src/test/java/com/easemob/im/server/api/room/superadmin/list/ListRoomSuperAdminsTest.java +++ /dev/null @@ -1,51 +0,0 @@ -package com.easemob.im.server.api.room.superadmin.list; - -import com.easemob.im.server.api.AbstractApiTest; -import com.fasterxml.jackson.databind.JsonNode; -import com.fasterxml.jackson.databind.node.ArrayNode; -import com.fasterxml.jackson.databind.node.ObjectNode; -import org.junit.jupiter.api.Test; - -import com.easemob.im.server.api.util.Utilities; - -import java.util.List; - -import static org.junit.jupiter.api.Assertions.*; - -class ListRoomSuperAdminsTest extends AbstractApiTest { - - private ListRoomSuperAdmins listRoomSuperAdmins; - - ListRoomSuperAdminsTest() { - this.server.addHandler("GET /easemob/demo/chatrooms/super_admin?pagenum=1&pagesize=10", - this::handleListRoomSuperAdminsFirst); - this.server.addHandler("GET /easemob/demo/chatrooms/super_admin?pagenum=2&pagesize=10", - this::handleListRoomSuperAdminsLast); - this.listRoomSuperAdmins = new ListRoomSuperAdmins(this.context); - } - - private JsonNode handleListRoomSuperAdminsFirst(JsonNode jsonNode) { - ArrayNode admins = this.objectMapper.createArrayNode(); - admins.add("rabbit"); - admins.add("madhat"); - ObjectNode rsp = this.objectMapper.createObjectNode(); - rsp.set("data", admins); - return rsp; - } - - private JsonNode handleListRoomSuperAdminsLast(JsonNode jsonNode) { - ArrayNode admins = this.objectMapper.createArrayNode(); - ObjectNode rsp = this.objectMapper.createObjectNode(); - rsp.set("data", admins); - return rsp; - } - - @Test - void testListRoomSuperAdmins() { - List admins = - this.listRoomSuperAdmins.all(10).collectList().block(Utilities.UT_TIMEOUT); - assertEquals(2, admins.size()); - assertEquals("rabbit", admins.get(0)); - assertEquals("madhat", admins.get(1)); - } -} diff --git a/im-sdk-core/src/test/java/com/easemob/im/server/api/room/superadmin/promote/PromoteRoomSuperAdminsTest.java b/im-sdk-core/src/test/java/com/easemob/im/server/api/room/superadmin/promote/PromoteRoomSuperAdminsTest.java deleted file mode 100644 index 281b4c26d..000000000 --- a/im-sdk-core/src/test/java/com/easemob/im/server/api/room/superadmin/promote/PromoteRoomSuperAdminsTest.java +++ /dev/null @@ -1,38 +0,0 @@ -package com.easemob.im.server.api.room.superadmin.promote; - -import com.easemob.im.server.api.AbstractApiTest; -import com.fasterxml.jackson.databind.JsonNode; -import com.fasterxml.jackson.databind.node.ObjectNode; -import org.junit.jupiter.api.Test; - -import com.easemob.im.server.api.util.Utilities; - -import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; - -class PromoteRoomSuperAdminsTest extends AbstractApiTest { - - private PromoteRoomSuperAdmin promoteRoomSuperAdmin; - - PromoteRoomSuperAdminsTest() { - this.server.addHandler("POST /easemob/demo/chatrooms/super_admin", - this::handleAddRoomSuperAdmin); - this.promoteRoomSuperAdmin = new PromoteRoomSuperAdmin(this.context); - } - - private JsonNode handleAddRoomSuperAdmin(JsonNode jsonNode) { - ObjectNode data = this.objectMapper.createObjectNode(); - data.put("result", "success"); - data.put("resource", ""); - - ObjectNode rsp = this.objectMapper.createObjectNode(); - rsp.set("data", data); - - return rsp; - } - - @Test - void testPromoteRoomSuperAdmin() { - assertDoesNotThrow( - () -> this.promoteRoomSuperAdmin.single("rabbit").block(Utilities.UT_TIMEOUT)); - } -} diff --git a/im-sdk-core/src/test/java/com/easemob/im/server/api/room/update/UpdateRoomTest.java b/im-sdk-core/src/test/java/com/easemob/im/server/api/room/update/UpdateRoomTest.java deleted file mode 100644 index e395c6be3..000000000 --- a/im-sdk-core/src/test/java/com/easemob/im/server/api/room/update/UpdateRoomTest.java +++ /dev/null @@ -1,72 +0,0 @@ -package com.easemob.im.server.api.room.update; - -import com.easemob.im.server.api.AbstractApiTest; -import com.easemob.im.server.exception.EMUnknownException; -import com.fasterxml.jackson.databind.JsonNode; -import com.fasterxml.jackson.databind.node.ObjectNode; -import org.junit.jupiter.api.Test; - -import com.easemob.im.server.api.util.Utilities; - -import static org.junit.jupiter.api.Assertions.*; - -class UpdateRoomTest extends AbstractApiTest { - - private UpdateRoom updateRoom; - - UpdateRoomTest() { - this.server - .addHandler("PUT /easemob/demo/chatrooms/r1", this::handleUpdateRoomRequestSuccess); - this.server.addHandler("PUT /easemob/demo/chatrooms/r2", this::handleUpdateRoomRequestFail); - this.updateRoom = new UpdateRoom(this.context); - } - - private JsonNode handleUpdateRoomRequestSuccess(JsonNode jsonNode) { - ObjectNode data = this.objectMapper.createObjectNode(); - if (jsonNode.has("name")) { - data.put("groupname", true); - } - if (jsonNode.has("description")) { - data.put("description", true); - } - if (jsonNode.has("maxusers")) { - data.put("maxusers", true); - } - - ObjectNode rsp = this.objectMapper.createObjectNode(); - rsp.set("data", data); - - return rsp; - } - - private JsonNode handleUpdateRoomRequestFail(JsonNode jsonNode) { - ObjectNode data = this.objectMapper.createObjectNode(); - if (jsonNode.has("name")) { - data.put("groupname", false); - } - if (jsonNode.has("description")) { - data.put("description", false); - } - if (jsonNode.has("maxusers")) { - data.put("maxusers", false); - } - - ObjectNode rsp = this.objectMapper.createObjectNode(); - rsp.set("data", data); - - return rsp; - } - - @Test - void testUpdateRoomSuccess() { - assertDoesNotThrow(() -> this.updateRoom.byId("r1", req -> req.withName("room-one")) - .block(Utilities.UT_TIMEOUT)); - } - - @Test - void testUpdateRoomFail() { - assertThrows(EMUnknownException.class, - () -> this.updateRoom.byId("r2", req -> req.withMaxMembers(1000)) - .block(Utilities.UT_TIMEOUT)); - } -} diff --git a/im-sdk-core/src/test/java/com/easemob/im/server/api/token/allocate/AppTokenRequestTest.java b/im-sdk-core/src/test/java/com/easemob/im/server/api/token/allocate/AppTokenRequestTest.java deleted file mode 100644 index 191a7f9a8..000000000 --- a/im-sdk-core/src/test/java/com/easemob/im/server/api/token/allocate/AppTokenRequestTest.java +++ /dev/null @@ -1,24 +0,0 @@ -package com.easemob.im.server.api.token.allocate; - -import com.fasterxml.jackson.core.JsonProcessingException; -import com.fasterxml.jackson.databind.JsonNode; -import com.fasterxml.jackson.databind.ObjectMapper; -import org.junit.jupiter.api.Test; - -import static org.junit.jupiter.api.Assertions.assertEquals; - -public class AppTokenRequestTest { - - private ObjectMapper mapper = new ObjectMapper(); - - @Test - public void testAppTokenSerialized() throws JsonProcessingException { - AppTokenRequest appTokenRequest = AppTokenRequest.of("id", "secret"); - String encoded = this.mapper.writeValueAsString(appTokenRequest); - JsonNode decoded = this.mapper.readTree(encoded); - assertEquals("client_credentials", decoded.get("grant_type").asText()); - assertEquals("id", decoded.get("client_id").asText()); - assertEquals("secret", decoded.get("client_secret").asText()); - } - -} \ No newline at end of file diff --git a/im-sdk-core/src/test/java/com/easemob/im/server/api/token/allocate/DefaultTokenProviderTest.java b/im-sdk-core/src/test/java/com/easemob/im/server/api/token/allocate/DefaultTokenProviderTest.java deleted file mode 100644 index 5ebd26770..000000000 --- a/im-sdk-core/src/test/java/com/easemob/im/server/api/token/allocate/DefaultTokenProviderTest.java +++ /dev/null @@ -1,52 +0,0 @@ -package com.easemob.im.server.api.token.allocate; - -import com.easemob.im.server.api.AbstractApiTest; -import com.easemob.im.server.api.loadbalance.Endpoint; -import com.easemob.im.server.api.loadbalance.EndpointRegistry; -import com.easemob.im.server.api.loadbalance.LoadBalancer; -import com.easemob.im.server.api.token.Token; -import com.fasterxml.jackson.databind.JsonNode; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; -import reactor.core.publisher.Mono; -import reactor.netty.http.client.HttpClient; - -import com.easemob.im.server.api.util.Utilities; - -import java.util.Arrays; - -import static org.junit.jupiter.api.Assertions.*; - -public class DefaultTokenProviderTest extends AbstractApiTest { - - private DefaultTokenProvider tokenProvider; - - public DefaultTokenProviderTest() { - this.server.addHandler("POST /easemob/demo/token", this::handlePostToken); - } - - @BeforeEach - void init() { - HttpClient httpClient = HttpClient.newConnection(); - LoadBalancer loadBalancer = endpoints -> endpoints.get(0); - EndpointRegistry endpointRegistry = () -> Mono - .just(Arrays.asList(new Endpoint("http", "localhost", this.server.port()))); - this.tokenProvider = - new DefaultTokenProvider(this.context.getProperties(), httpClient, endpointRegistry, - loadBalancer, this.context.getCodec(), this.context.getErrorMapper()); - } - - @Test - public void testFetchAppToken() { - Token appToken = this.tokenProvider.fetchAppToken().block(Utilities.UT_TIMEOUT); - assertEquals("access_token", appToken.getValue()); - assertTrue(appToken.isValid()); - } - - private JsonNode handlePostToken(JsonNode jsonNode) { - return this.objectMapper.createObjectNode() - .put("access_token", "access_token") - .put("expires_in", 3600); - } - -} diff --git a/im-sdk-core/src/test/java/com/easemob/im/server/api/token/allocate/UserTokenRequestTest.java b/im-sdk-core/src/test/java/com/easemob/im/server/api/token/allocate/UserTokenRequestTest.java deleted file mode 100644 index f50cc7775..000000000 --- a/im-sdk-core/src/test/java/com/easemob/im/server/api/token/allocate/UserTokenRequestTest.java +++ /dev/null @@ -1,24 +0,0 @@ -package com.easemob.im.server.api.token.allocate; - -import com.fasterxml.jackson.core.JsonProcessingException; -import com.fasterxml.jackson.databind.JsonNode; -import com.fasterxml.jackson.databind.ObjectMapper; -import org.junit.jupiter.api.Test; - -import static org.junit.jupiter.api.Assertions.assertEquals; - -public class UserTokenRequestTest { - - private ObjectMapper mapper = new ObjectMapper(); - - @Test - public void testUserTokenRequestSerialized() throws JsonProcessingException { - UserTokenRequest userTokenRequest = UserTokenRequest.of("username", "password"); - String encoded = this.mapper.writeValueAsString(userTokenRequest); - JsonNode decoded = this.mapper.readTree(encoded); - assertEquals("password", decoded.get("grant_type").asText()); - assertEquals("username", decoded.get("username").asText()); - assertEquals("password", decoded.get("password").asText()); - } - -} \ No newline at end of file diff --git a/im-sdk-core/src/test/java/com/easemob/im/server/api/user/create/CreateUserTest.java b/im-sdk-core/src/test/java/com/easemob/im/server/api/user/create/CreateUserTest.java deleted file mode 100644 index 89f92b9e3..000000000 --- a/im-sdk-core/src/test/java/com/easemob/im/server/api/user/create/CreateUserTest.java +++ /dev/null @@ -1,58 +0,0 @@ -package com.easemob.im.server.api.user.create; - -import com.easemob.im.server.EMException; -import com.easemob.im.server.api.AbstractApiTest; -import com.easemob.im.server.api.util.Utilities; -import com.easemob.im.server.exception.EMNotFoundException; -import com.fasterxml.jackson.databind.JsonNode; -import com.fasterxml.jackson.databind.node.ArrayNode; -import com.fasterxml.jackson.databind.node.ObjectNode; -import io.netty.handler.codec.http.HttpResponseStatus; -import org.junit.jupiter.api.Test; - -import static org.junit.jupiter.api.Assertions.*; - -class CreateUserTest extends AbstractApiTest { - - private static final String DUMMY_USER_NAME = "dummy-user-name"; - private static final String DUMMY_USER_PASSWORD = "dummy-user-password"; - private static final String DUMMY_USER_UUID = "b2832810-e91f-11eb-901b-1d2efade27a3"; - private static final boolean DUMMY_USER_ACTIVATED = true; - - CreateUser createUser = new CreateUser(this.context); - - CreateUserTest() { - this.server.addHandler("POST /easemob/demo/users", this::handleUserRegisterRequest); - } - - @Test - public void testUserRegisterSingle() { - assertDoesNotThrow( - () -> this.createUser.single(DUMMY_USER_NAME, DUMMY_USER_PASSWORD).block(Utilities.UT_TIMEOUT)); - } - - @Test - public void testReturnExceptionErrorCode() { - //移除钩子函数 抛出EMNotFoundException异常 - this.server.removeHandler("POST /easemob/demo/users"); - EMException emException = assertThrows(EMNotFoundException.class, () -> this.createUser.single(DUMMY_USER_NAME, DUMMY_USER_PASSWORD).block(Utilities.UT_TIMEOUT)); - assertNotNull(emException.getErrorCode()); - assertEquals(emException.getErrorCode(), HttpResponseStatus.NOT_FOUND.code()); - } - - private JsonNode handleUserRegisterRequest(JsonNode req) { - ObjectNode user = this.objectMapper.createObjectNode(); - user.put("username", DUMMY_USER_NAME); - user.put("uuid", DUMMY_USER_UUID); - user.put("activated", DUMMY_USER_ACTIVATED); - - ArrayNode users = this.objectMapper.createArrayNode(); - users.add(user); - - ObjectNode rsp = this.objectMapper.createObjectNode(); - rsp.set("entities", users); - - return rsp; - } - -} diff --git a/im-sdk-core/src/test/java/com/easemob/im/server/api/user/forcelogout/ForceLogoutUserTest.java b/im-sdk-core/src/test/java/com/easemob/im/server/api/user/forcelogout/ForceLogoutUserTest.java deleted file mode 100644 index 1702762fa..000000000 --- a/im-sdk-core/src/test/java/com/easemob/im/server/api/user/forcelogout/ForceLogoutUserTest.java +++ /dev/null @@ -1,55 +0,0 @@ -package com.easemob.im.server.api.user.forcelogout; - -import com.easemob.im.server.api.AbstractApiTest; -import com.easemob.im.server.exception.EMInternalServerErrorException; -import com.fasterxml.jackson.databind.JsonNode; -import com.fasterxml.jackson.databind.node.ObjectNode; -import org.junit.jupiter.api.Test; - -import com.easemob.im.server.api.util.Utilities; - -import static org.junit.jupiter.api.Assertions.*; - -class ForceLogoutUserTest extends AbstractApiTest { - - ForceLogoutUser forceLogoutUser = new ForceLogoutUser(this.context); - - ForceLogoutUserTest() { - super(); - this.server.addHandler("GET /easemob/demo/users/alice/disconnect", - this::handlDisconnectByUsernameSucc); - this.server.addHandler("GET /easemob/demo/users/alice/disconnect/slippers", - this::handlDisconnectByUsernameAndResourceFail); - } - - @Test - public void testForceLogoutByUsername() { - assertDoesNotThrow(() -> { - this.forceLogoutUser.byUsername("alice").block(Utilities.UT_TIMEOUT); - }); - } - - @Test - public void testForceLogoutByUsernameAndResource() { - assertThrows(EMInternalServerErrorException.class, () -> { - this.forceLogoutUser.byUsernameAndResource("alice", "slippers") - .block(Utilities.UT_TIMEOUT); - }); - } - - private JsonNode handlDisconnectByUsernameSucc(JsonNode jsonNode) { - ObjectNode data = this.objectMapper.createObjectNode(); - data.put("result", true); - ObjectNode rsp = this.objectMapper.createObjectNode(); - rsp.set("data", data); - return rsp; - } - - private JsonNode handlDisconnectByUsernameAndResourceFail(JsonNode jsonNode) { - ObjectNode data = this.objectMapper.createObjectNode(); - data.put("result", false); - ObjectNode rsp = this.objectMapper.createObjectNode(); - rsp.set("data", data); - return rsp; - } -} diff --git a/im-sdk-core/src/test/java/com/easemob/im/server/api/user/get/UserGetTest.java b/im-sdk-core/src/test/java/com/easemob/im/server/api/user/get/UserGetTest.java deleted file mode 100644 index 6b3c459ca..000000000 --- a/im-sdk-core/src/test/java/com/easemob/im/server/api/user/get/UserGetTest.java +++ /dev/null @@ -1,72 +0,0 @@ -package com.easemob.im.server.api.user.get; - -import com.easemob.im.server.EMProxy; -import com.easemob.im.server.api.AbstractApiTest; -import com.easemob.im.server.model.EMUser; -import com.fasterxml.jackson.databind.JsonNode; -import com.fasterxml.jackson.databind.node.ArrayNode; -import com.fasterxml.jackson.databind.node.ObjectNode; -import org.junit.jupiter.api.Test; -import reactor.core.publisher.Mono; -import reactor.netty.http.client.HttpClient; -import reactor.netty.transport.ProxyProvider; - -import java.net.InetSocketAddress; - -import com.easemob.im.server.api.util.Utilities; - -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertThrows; - -public class UserGetTest extends AbstractApiTest { - - private static final String DUMMY_USER_NAME = "dummy-user-name"; - private static final String DUMMY_USER_UUID = "b2832810-e91f-11eb-901b-1d2efade27a3"; - private static final boolean DUMMY_USER_ACTIVATED = true; - - private UserGet userGet; - - public UserGetTest() { - this.server.addHandler(String.format("GET /easemob/demo/users/%s", DUMMY_USER_NAME), - this::handleUserGetSingle); - this.userGet = new UserGet(this.context); - } - - @Test - public void testUserGetSingle() { - EMUser user = this.userGet.single(DUMMY_USER_NAME).block(Utilities.UT_TIMEOUT); - assertEquals(DUMMY_USER_NAME, user.getUsername()); - assertEquals(DUMMY_USER_UUID, user.getUuid()); - assertEquals(DUMMY_USER_ACTIVATED, user.getCanLogin()); - } - - @Test - public void testUserGetSingleUsingHttpClientProxy() { - EMProxy proxyInfo = EMProxy.builder() - .setIP("127.0.0.1") - .setPort(18888) - .build(); - HttpClient httpClient = this.context.getHttpClient().block(); - this.context.setHttpClient( - Mono.just(httpClient.proxy(proxy -> proxy.type(ProxyProvider.Proxy.HTTP) - .address(new InetSocketAddress(proxyInfo.getIp(), proxyInfo.getPort()))))); - - assertThrows(RuntimeException.class, - () -> this.userGet.single("username").block(Utilities.UT_TIMEOUT)); - } - - private JsonNode handleUserGetSingle(JsonNode req) { - ObjectNode user = this.objectMapper.createObjectNode(); - user.put("username", DUMMY_USER_NAME); - user.put("uuid", DUMMY_USER_UUID); - user.put("activated", DUMMY_USER_ACTIVATED); - - ArrayNode users = this.objectMapper.createArrayNode(); - users.add(user); - - ObjectNode rsp = this.objectMapper.createObjectNode(); - rsp.set("entities", users); - - return rsp; - } -} diff --git a/im-sdk-core/src/test/java/com/easemob/im/server/api/user/list/ListUsersTest.java b/im-sdk-core/src/test/java/com/easemob/im/server/api/user/list/ListUsersTest.java deleted file mode 100644 index bb89fa2fb..000000000 --- a/im-sdk-core/src/test/java/com/easemob/im/server/api/user/list/ListUsersTest.java +++ /dev/null @@ -1,128 +0,0 @@ -package com.easemob.im.server.api.user.list; - -import com.easemob.im.server.api.AbstractApiTest; -import com.easemob.im.server.model.EMUser; -import com.fasterxml.jackson.databind.JsonNode; -import com.fasterxml.jackson.databind.node.ArrayNode; -import com.fasterxml.jackson.databind.node.ObjectNode; -import org.junit.jupiter.api.Test; - -import com.easemob.im.server.api.util.Utilities; - -import java.util.List; - -import static org.junit.jupiter.api.Assertions.*; - -class ListUsersTest extends AbstractApiTest { - - ListUsers listUsers = new ListUsers(this.context); - - ListUsersTest() { - this.server.addHandler("GET /easemob/demo/users?limit=100", this::handleUserGet100); - this.server.addHandler("GET /easemob/demo/users?limit=100&cursor=cursor-0-99", - this::handleUserGet100Continued); - this.server.addHandler("GET /easemob/demo/users?limit=100&cursor=cursor-100-199", - this::handleUserGet100Last); - this.server.addHandler("GET /easemob/demo/users?limit=200", this::handleUserGet200); - this.server.addHandler("GET /easemob/demo/users?limit=200&cursor=cursor-0-199", - this::handleUserGet200Continued); - } - - @Test - void testUserGetAll100EachTime() { - List users = this.listUsers.all(100) - .collectList().block(Utilities.UT_TIMEOUT); - assertEquals(300, users.size()); - for (int i = 0; i < 300; i++) { - assertEquals("username", users.get(i)); - } - } - - @Test - void testUserGetAll200EachTime() { - List users = this.listUsers.all(200) - .collectList().block(Utilities.UT_TIMEOUT); - assertEquals(300, users.size()); - for (int i = 0; i < 300; i++) { - assertEquals("username", users.get(i)); - } - } - - private JsonNode handleUserGet100(JsonNode req) { - ObjectNode user = this.objectMapper.createObjectNode(); - user.put("username", "username"); - - ArrayNode users = this.objectMapper.createArrayNode(); - for (int i = 0; i < 100; i++) { - users.add(user); - } - - ObjectNode rsp = this.objectMapper.createObjectNode(); - rsp.set("entities", users); - rsp.put("cursor", "cursor-0-99"); - - return rsp; - } - - private JsonNode handleUserGet100Continued(JsonNode req) { - ObjectNode user = this.objectMapper.createObjectNode(); - user.put("username", "username"); - - ArrayNode users = this.objectMapper.createArrayNode(); - for (int i = 0; i < 100; i++) { - users.add(user); - } - - ObjectNode rsp = this.objectMapper.createObjectNode(); - rsp.set("entities", users); - rsp.put("cursor", "cursor-100-199"); - - return rsp; - } - - private JsonNode handleUserGet100Last(JsonNode req) { - ObjectNode user = this.objectMapper.createObjectNode(); - user.put("username", "username"); - - ArrayNode users = this.objectMapper.createArrayNode(); - for (int i = 0; i < 100; i++) { - users.add(user); - } - - ObjectNode rsp = this.objectMapper.createObjectNode(); - rsp.set("entities", users); - - return rsp; - } - - private JsonNode handleUserGet200(JsonNode req) { - ObjectNode user = this.objectMapper.createObjectNode(); - user.put("username", "username"); - - ArrayNode users = this.objectMapper.createArrayNode(); - for (int i = 0; i < 200; i++) { - users.add(user); - } - - ObjectNode rsp = this.objectMapper.createObjectNode(); - rsp.set("entities", users); - rsp.put("cursor", "cursor-0-199"); - - return rsp; - } - - private JsonNode handleUserGet200Continued(JsonNode req) { - ObjectNode user = this.objectMapper.createObjectNode(); - user.put("username", "username"); - - ArrayNode users = this.objectMapper.createArrayNode(); - for (int i = 0; i < 100; i++) { - users.add(user); - } - - ObjectNode rsp = this.objectMapper.createObjectNode(); - rsp.set("entities", users); - - return rsp; - } -} diff --git a/im-sdk-core/src/test/java/com/easemob/im/server/api/user/password/UpdateUserPasswordTest.java b/im-sdk-core/src/test/java/com/easemob/im/server/api/user/password/UpdateUserPasswordTest.java deleted file mode 100644 index c0811ed49..000000000 --- a/im-sdk-core/src/test/java/com/easemob/im/server/api/user/password/UpdateUserPasswordTest.java +++ /dev/null @@ -1,43 +0,0 @@ -package com.easemob.im.server.api.user.password; - -import com.easemob.im.server.EMProperties; -import com.easemob.im.server.api.AbstractApiTest; -import com.easemob.im.server.api.MockingContext; -import com.easemob.im.server.api.MockingHttpServer; -import com.easemob.im.server.exception.EMNotFoundException; -import com.fasterxml.jackson.databind.DeserializationFeature; -import com.fasterxml.jackson.databind.JsonNode; -import com.fasterxml.jackson.databind.ObjectMapper; -import org.junit.jupiter.api.Test; - -import com.easemob.im.server.api.util.Utilities; - -import static org.junit.jupiter.api.Assertions.*; - -public class UpdateUserPasswordTest extends AbstractApiTest { - - UpdateUserPassword updateUserPassword = new UpdateUserPassword(this.context); - - UpdateUserPasswordTest() { - this.server.addHandler("PUT /easemob/demo/users/username/password", - this::handleUserPasswordReset); - } - - @Test - public void testUserPasswordReset() { - assertDoesNotThrow(() -> { - this.updateUserPassword.update("username", "password").block(Utilities.UT_TIMEOUT); - }); - } - -// @Test -// public void testNonRegisteredUserPasswordReset() { -// assertThrows(EMNotFoundException.class, () -> { -// this.updateUserPassword.update("power", "password").block(Utilities.UT_TIMEOUT); -// }); -// } - - private JsonNode handleUserPasswordReset(JsonNode jsonNode) { - return this.objectMapper.createObjectNode(); - } -} diff --git a/im-sdk-core/src/test/java/com/easemob/im/server/api/user/status/UserStatusTest.java b/im-sdk-core/src/test/java/com/easemob/im/server/api/user/status/UserStatusTest.java deleted file mode 100644 index 6d6311d23..000000000 --- a/im-sdk-core/src/test/java/com/easemob/im/server/api/user/status/UserStatusTest.java +++ /dev/null @@ -1,59 +0,0 @@ -package com.easemob.im.server.api.user.status; - -import com.easemob.im.server.api.AbstractApiTest; -import com.easemob.im.server.api.util.Utilities; -import com.easemob.im.server.model.EMUserStatus; -import com.fasterxml.jackson.databind.JsonNode; -import com.fasterxml.jackson.databind.node.ArrayNode; -import com.fasterxml.jackson.databind.node.ObjectNode; -import org.junit.jupiter.api.Test; - -import java.util.Arrays; -import java.util.List; - -import static org.junit.jupiter.api.Assertions.assertEquals; - -public class UserStatusTest extends AbstractApiTest { - - private UserStatus userStatus; - - public UserStatusTest() { - this.server - .addHandler("GET /easemob/demo/users/alice/status", this::handleUserStatusRequest); - - this.server - .addHandler("POST /easemob/demo/users/batch/status", this::handleUserStatusBatchRequest); - this.userStatus = new UserStatus(this.context); - } - - @Test - public void testUserStatusSingle() { - boolean aliceIsOnline = this.userStatus.isUserOnline("alice").block(Utilities.UT_TIMEOUT); - assertEquals(true, aliceIsOnline); - } - - @Test - public void testUserStatusBatch() { - List userStatusList = this.userStatus.isUsersOnline(Arrays.asList("alice")).block(Utilities.UT_TIMEOUT); - assertEquals(true, userStatusList.get(0).isOnline()); - } - - private JsonNode handleUserStatusRequest(JsonNode jsonNode) { - ObjectNode data = this.objectMapper.createObjectNode(); - data.put("alice", "online"); - ObjectNode rsp = this.objectMapper.createObjectNode(); - rsp.set("data", data); - return rsp; - } - - private JsonNode handleUserStatusBatchRequest(JsonNode jsonNode) { - ArrayNode data = this.objectMapper.createArrayNode(); - ObjectNode obj = this.objectMapper.createObjectNode(); - obj.put("alice", "online"); - data.add(obj); - ObjectNode rsp = this.objectMapper.createObjectNode(); - rsp.set("data", data); - return rsp; - } - -} diff --git a/im-sdk-core/src/test/java/com/easemob/im/server/api/user/unregister/DeleteUserTest.java b/im-sdk-core/src/test/java/com/easemob/im/server/api/user/unregister/DeleteUserTest.java deleted file mode 100644 index 3cef592b8..000000000 --- a/im-sdk-core/src/test/java/com/easemob/im/server/api/user/unregister/DeleteUserTest.java +++ /dev/null @@ -1,72 +0,0 @@ -package com.easemob.im.server.api.user.unregister; - -import com.easemob.im.server.api.AbstractApiTest; -import com.easemob.im.server.model.EMUser; -import com.fasterxml.jackson.databind.JsonNode; -import com.fasterxml.jackson.databind.node.ArrayNode; -import com.fasterxml.jackson.databind.node.ObjectNode; -import org.junit.jupiter.api.Test; - -import com.easemob.im.server.api.util.Utilities; - -import java.util.List; - -import static org.junit.jupiter.api.Assertions.*; - -class DeleteUserTest extends AbstractApiTest { - DeleteUser deleteUser = new DeleteUser(this.context); - - DeleteUserTest() { - this.server.addHandler("DELETE /easemob/demo/users/username", - this::handleUserUnregisterSingle); - this.server.addHandler("DELETE /easemob/demo/users?limit=100", - req -> handleUserUnregisterAll(req, 100, "cursor")); - this.server.addHandler("DELETE /easemob/demo/users?limit=100&cursor=cursor", - req -> handleUserUnregisterAll(req, 100, null)); - } - - @Test - void testUserUnregisterSingle() { - assertDoesNotThrow(() -> this.deleteUser.single("username").block(Utilities.UT_TIMEOUT)); - } - - @Test - public void testUserUnregisterAll() { - List users = this.deleteUser.all(100).collectList().block(Utilities.UT_TIMEOUT); - assertEquals(200, users.size()); - for (int i = 0; i < 200; i++) { - assertEquals("username", users.get(i)); - } - } - - private JsonNode handleUserUnregisterSingle(JsonNode jsonNode) { - ObjectNode user = this.objectMapper.createObjectNode(); - user.put("username", "username"); - - ArrayNode users = this.objectMapper.createArrayNode(); - users.add(user); - - ObjectNode rsp = this.objectMapper.createObjectNode(); - rsp.set("entities", users); - - return rsp; - } - - private JsonNode handleUserUnregisterAll(JsonNode jsonNode, int limit, String cursor) { - ObjectNode user = this.objectMapper.createObjectNode(); - user.put("username", "username"); - - ArrayNode users = this.objectMapper.createArrayNode(); - for (int i = 0; i < limit; i++) { - users.add(user); - } - - ObjectNode rsp = this.objectMapper.createObjectNode(); - rsp.set("entities", users); - if (cursor != null) { - rsp.put("cursor", cursor); - } - - return rsp; - } -} diff --git a/im-sdk-core/src/test/java/com/easemob/im/server/api/util/UtilitiesTest.java b/im-sdk-core/src/test/java/com/easemob/im/server/api/util/UtilitiesTest.java deleted file mode 100644 index c9bd9cac9..000000000 --- a/im-sdk-core/src/test/java/com/easemob/im/server/api/util/UtilitiesTest.java +++ /dev/null @@ -1,25 +0,0 @@ -package com.easemob.im.server.api.util; - -import com.easemob.im.server.exception.EMInvalidArgumentException; -import com.easemob.im.server.model.EMUser; -import org.junit.jupiter.api.Test; - -import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; -import static org.junit.jupiter.api.Assertions.assertThrows; - -public class UtilitiesTest { - - @Test - public void illegalUserName() { - String uuidUserName = "eaf4b5b4-7445-40f9-bc4d-78a1a6049269"; - assertThrows(EMInvalidArgumentException.class,()->EMUser.validateUsername(uuidUserName)); - String startWithDigits = "000" + Utilities.randomUserName(); - assertThrows(EMInvalidArgumentException.class,()->EMUser.validateUsername(startWithDigits)); - } - - @Test - public void legalUserName() { - String userName = "it-username-1234567890"; - assertDoesNotThrow(()->EMUser.validateUsername(userName)); - } -} diff --git a/im-sdk-core/src/test/java/com/easemob/im/server/model/EMUserTest.java b/im-sdk-core/src/test/java/com/easemob/im/server/model/EMUserTest.java deleted file mode 100644 index 3b84bb95f..000000000 --- a/im-sdk-core/src/test/java/com/easemob/im/server/model/EMUserTest.java +++ /dev/null @@ -1,44 +0,0 @@ -package com.easemob.im.server.model; - -import com.easemob.im.server.exception.EMInvalidArgumentException; -import org.junit.jupiter.api.Test; - -import static org.junit.jupiter.api.Assertions.*; - -public class EMUserTest { - @Test - public void testUsernameValidate() { - assertDoesNotThrow(() -> EMUser.validateUsername("usr-0001")); - assertThrows(EMInvalidArgumentException.class, () -> EMUser.validateUsername(null)); // null - assertThrows(EMInvalidArgumentException.class, () -> EMUser.validateUsername("")); // empty - assertThrows(EMInvalidArgumentException.class, () -> EMUser - .validateUsername("000000000000000000000000000000000")); // too long, 32 bytes max - assertThrows(EMInvalidArgumentException.class, - () -> EMUser.validateUsername("USR00001")); // invalid character - } - - @Test - public void testPasswordValidate() { - assertDoesNotThrow(() -> EMUser.validatePassword("0xBEEF?!?!")); - assertThrows(EMInvalidArgumentException.class, () -> EMUser.validatePassword(null)); // null - assertThrows(EMInvalidArgumentException.class, () -> EMUser.validatePassword("")); // empty - assertThrows(EMInvalidArgumentException.class, () -> EMUser - .validatePassword("000000000000000000000000000000000")); // too long, 32 bytes max - assertThrows(EMInvalidArgumentException.class, - () -> EMUser.validatePassword("\r\n")); // invalid character - assertThrows(EMInvalidArgumentException.class, - () -> EMUser.validatePassword("\"")); // invalid character - assertThrows(EMInvalidArgumentException.class, - () -> EMUser.validatePassword("\\")); // invalid character - assertThrows(EMInvalidArgumentException.class, - () -> EMUser.validatePassword("'")); // invalid character - assertThrows(EMInvalidArgumentException.class, - () -> EMUser.validatePassword("`")); // invalid character - assertThrows(EMInvalidArgumentException.class, - () -> EMUser.validatePassword("(")); // invalid character - assertThrows(EMInvalidArgumentException.class, - () -> EMUser.validatePassword("[")); // invalid character - assertThrows(EMInvalidArgumentException.class, - () -> EMUser.validatePassword("{")); // invalid character - } -} diff --git a/im-sdk-core/src/test/java/com/easemob/im/server/utils/UriEncoderTest.java b/im-sdk-core/src/test/java/com/easemob/im/server/utils/UriEncoderTest.java deleted file mode 100644 index b778bccb8..000000000 --- a/im-sdk-core/src/test/java/com/easemob/im/server/utils/UriEncoderTest.java +++ /dev/null @@ -1,26 +0,0 @@ -package com.easemob.im.server.utils; - -import io.netty.handler.codec.http.QueryStringEncoder; -import org.junit.jupiter.api.Test; - -import static org.junit.jupiter.api.Assertions.assertEquals; - -public class UriEncoderTest { - - private static final String CURSOR_VALUE = "asdjhbsaiuyhishfdxhsk"; - - @Test - public void encodeUri() { - String uriString = next(123, CURSOR_VALUE); - assertEquals("/users?limit=123&cursor=asdjhbsaiuyhishfdxhsk", uriString); - } - - private String next(int limit, String cursor) { - QueryStringEncoder encoder = new QueryStringEncoder("/users"); - encoder.addParam("limit", String.valueOf(limit)); - if (cursor != null) { - encoder.addParam("cursor", cursor); - } - return encoder.toString(); - } -} diff --git a/im-sdk-core/src/test/resources/logback-test.xml b/im-sdk-core/src/test/resources/logback-test.xml deleted file mode 100644 index 74599de6a..000000000 --- a/im-sdk-core/src/test/resources/logback-test.xml +++ /dev/null @@ -1,10 +0,0 @@ - - - - %d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n - - - - - - diff --git a/pom.xml b/pom.xml index 5f0ff5b0f..205dd8fc8 100644 --- a/pom.xml +++ b/pom.xml @@ -1,78 +1,49 @@ - - + 4.0.0 - com.easemob.im - im-sdk-parent - 0.8.3-SNAPSHOT - pom + im-sdk-core + jar + im-sdk-core + 1.0.0 + https://github.com/openapitools/openapi-generator + OpenAPI Java + + scm:git:git@github.com:easemob/easemob-im-server-sdk.git + scm:git:git@github.com:easemob/easemob-im-server-sdk.git + https://github.com/easemob/easemob-im-server-sdk/tree/master_java_2.0 + - Easemob IM SDK for Java - https://www.easemob.com - - An SDK to accelerate integration with Easemob instant messaging service. - + + + ossrh-snapshots + Nexus Snapshot Repository + https://oss.sonatype.org/content/repositories/snapshots/ + + + ossrh-releases + Nexus Release Repository + https://oss.sonatype.org/service/local/staging/deploy/maven2/ + + - - im-sdk-core - - + + + The Apache Software License, Version 2.0 + http://www.apache.org/licenses/LICENSE-2.0.txt + + - - 2.14.0 - 1.8 - 5.7.0 - ${java.version} - ${java.version} - 3.6.28 - UTF-8 - UTF-8 - 2020.0.4 - 4.1.85.Final - 1.1.0 - 2.17.0 - + + + fudonghai + fudonghai@easemob.com + https://github.com/fudonghai + + - - org.apache.maven.plugins - maven-shade-plugin - 3.2.4 - - - - shade - - - - - io.netty - io.projectreactor - io.projectreactor.netty - org.reactivestreams - - - - - io.netty - com.easemob.im.shaded.io.netty - - - reactor - com.easemob.im.shaded.reactor - - - org.reactivestreams - com.easemob.im.shaded.org.reactivestreams - - - - - - org.apache.maven.plugins maven-compiler-plugin @@ -137,14 +108,6 @@ **/*Test.java - - org.apache.maven.plugins - maven-failsafe-plugin - 2.22.2 - - **/*IT.java - - maven-source-plugin 3.2.1 @@ -180,7 +143,7 @@ maven-gpg-plugin 1.6 - + --pinentry-mode loopback @@ -241,39 +204,6 @@ - - org.codehaus.mojo - build-helper-maven-plugin - 3.0.0 - - - add-integration-test-source - generate-test-sources - - add-test-source - - - - src/integration-test/java - - - - - add-integration-test-resource - generate-test-resources - - add-test-resource - - - - - src/integration-test/resources - - - - - - @@ -289,175 +219,115 @@ - - - - org.apache.logging.log4j - log4j-api - ${log4j.version} - - - org.apache.logging.log4j - log4j-to-slf4j - ${log4j.version} - - - org.apache.logging.log4j - log4j-core - ${log4j.version} - - - org.apache.logging.log4j - log4j-jul - ${log4j.version} - - - io.projectreactor - reactor-bom - ${reactor.version} - pom - import - - - io.netty - netty-bom - ${netty.version} - pom - import - - - org.junit - junit-bom - ${junit.version} - pom - import - - - io.github.resilience4j - resilience4j-circuitbreaker - ${resilience4j.version} - - - io.github.resilience4j - resilience4j-reactor - ${resilience4j.version} - - - + + + ci + + + + org.apache.maven.plugins + maven-gpg-plugin + 1.6 + + + sign-artifacts + none + + + + + + + + - io.projectreactor.netty - reactor-netty-core + com.google.code.findbugs + jsr305 + 3.0.2 - io.projectreactor.netty - reactor-netty-http + com.squareup.okhttp3 + okhttp + ${okhttp-version} - io.netty - netty-resolver-dns-native-macos - osx-aarch_64 + com.squareup.okhttp3 + logging-interceptor + ${okhttp-version} - com.fasterxml.jackson.core - jackson-annotations - ${jackson.version} + com.google.code.gson + gson + ${gson-version} - com.fasterxml.jackson.core - jackson-databind - ${jackson.version} + io.gsonfire + gson-fire + ${gson-fire-version} - io.projectreactor - reactor-test - test + org.apache.commons + commons-lang3 + ${commons-lang3-version} - org.mockito - mockito-core - ${mockito.version} - test + jakarta.annotation + jakarta.annotation-api + ${jakarta-annotation-version} + provided + + + org.openapitools + jackson-databind-nullable + ${jackson-databind-nullable-version} + + + javax.ws.rs + jsr311-api + ${jsr311-api-version} + + + javax.ws.rs + javax.ws.rs-api + ${javax.ws.rs-api-version} + org.junit.jupiter - junit-jupiter - ${junit.version} + junit-jupiter-engine + ${junit-version} + test + + + org.junit.platform + junit-platform-runner + ${junit-platform-runner.version} test + + com.google.guava + guava + 30.0-jre + - - - - The Apache Software License, Version 2.0 - http://www.apache.org/licenses/LICENSE-2.0.txt - - - - - - fudonghai - fudh@easemob.com - https://github.com/fudonghai - - - harryhao - Harry Hao - harry-hao(at)outlook.com - - - yubing - Yubing - yubing.qi@easemob.com - - - kenuiuc - Ken Wang - kenuiuc@gmail.com - - - - - master - scm:git:https://github.com/easemob/easemob-im-server-sdk - scm:git:https://github.com/easemob/easemob-im-server-sdk - scm:git:https://github.com/easemob/easemob-im-server-sdk - - - - - - ossrh-snapshots - Nexus Snapshot Repository - https://oss.sonatype.org/content/repositories/snapshots/ - - - ossrh-releases - Nexus Release Repository - https://oss.sonatype.org/service/local/staging/deploy/maven2/ - - - - - - ci - - - - org.apache.maven.plugins - maven-gpg-plugin - 1.6 - - - sign-artifacts - none - - - - - - - + + 1.8 + ${java.version} + ${java.version} + 1.9.0 + 4.11.0 + 2.10.1 + 3.13.0 + 0.2.6 + 1.3.5 + 5.10.0 + 1.10.0 + 2.1.1 + 1.1.1 + UTF-8 + 2.27.2 + diff --git a/release.sh b/release.sh deleted file mode 100644 index ccf2e5f30..000000000 --- a/release.sh +++ /dev/null @@ -1,22 +0,0 @@ -#!/usr/bin/env bash - -# usage: ./release.sh 当前Release版本 下一个开发版本 - -RELEASE=$1 -SNAPSHOT=$2 - -mvn versions:set -DnewVersion=$RELEASE -DgenerateBackupPoms=false -git add . -git commit --message "v$RELEASE Release" - -# Tag the release -git tag -s v$RELEASE -m "v$RELEASE" - -# Bump up the version in pom.xml to the next snapshot -mvn versions:set -DnewVersion="$SNAPSHOT-SNAPSHOT" -DgenerateBackupPoms=false -git add . -git commit --message "v$SNAPSHOT Development" - -git push && git push --tags - -mvn deploy diff --git a/settings.gradle b/settings.gradle new file mode 100644 index 000000000..84a7e5e5b --- /dev/null +++ b/settings.gradle @@ -0,0 +1 @@ +rootProject.name = "im-sdk-core" \ No newline at end of file diff --git a/src/main/java/com/easemob/im/ApiCallback.java b/src/main/java/com/easemob/im/ApiCallback.java new file mode 100644 index 000000000..76f6ab417 --- /dev/null +++ b/src/main/java/com/easemob/im/ApiCallback.java @@ -0,0 +1,62 @@ +/* + * EMService + * Easemob Rest API + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.easemob.im; + +import java.io.IOException; + +import java.util.Map; +import java.util.List; + +/** + * Callback for asynchronous API call. + * + * @param The return type + */ +public interface ApiCallback { + /** + * This is called when the API call fails. + * + * @param e The exception causing the failure + * @param statusCode Status code of the response if available, otherwise it would be 0 + * @param responseHeaders Headers of the response if available, otherwise it would be null + */ + void onFailure(ApiException e, int statusCode, Map> responseHeaders); + + /** + * This is called when the API call succeeded. + * + * @param result The result deserialized from response + * @param statusCode Status code of the response + * @param responseHeaders Headers of the response + */ + void onSuccess(T result, int statusCode, Map> responseHeaders); + + /** + * This is called when the API upload processing. + * + * @param bytesWritten bytes Written + * @param contentLength content length of request body + * @param done write end + */ + void onUploadProgress(long bytesWritten, long contentLength, boolean done); + + /** + * This is called when the API download processing. + * + * @param bytesRead bytes Read + * @param contentLength content length of the response + * @param done Read end + */ + void onDownloadProgress(long bytesRead, long contentLength, boolean done); +} diff --git a/src/main/java/com/easemob/im/ApiClient.java b/src/main/java/com/easemob/im/ApiClient.java new file mode 100644 index 000000000..8cd491630 --- /dev/null +++ b/src/main/java/com/easemob/im/ApiClient.java @@ -0,0 +1,2090 @@ +/* + * EMService + * Easemob Rest API + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.easemob.im; + +import com.easemob.im.agora.AccessToken2; +import com.easemob.im.api.model.EMCreateToken; +import com.google.common.cache.Cache; +import com.google.common.cache.CacheBuilder; +import com.google.gson.reflect.TypeToken; +import okhttp3.*; +import okhttp3.Authenticator; +import okhttp3.internal.http.HttpMethod; +import okhttp3.internal.tls.OkHostnameVerifier; +import okhttp3.logging.HttpLoggingInterceptor; +import okhttp3.logging.HttpLoggingInterceptor.Level; +import okio.Buffer; +import okio.BufferedSink; +import okio.Okio; + +import javax.net.ssl.*; +import java.io.File; +import java.io.IOException; +import java.io.InputStream; +import java.io.UnsupportedEncodingException; +import java.lang.reflect.Type; +import java.net.*; +import java.nio.file.Files; +import java.nio.file.Paths; +import java.security.GeneralSecurityException; +import java.security.KeyStore; +import java.security.SecureRandom; +import java.security.cert.Certificate; +import java.security.cert.CertificateException; +import java.security.cert.CertificateFactory; +import java.text.DateFormat; +import java.time.Duration; +import java.time.LocalDate; +import java.time.OffsetDateTime; +import java.time.format.DateTimeFormatter; +import java.util.*; +import java.util.Map.Entry; +import java.util.concurrent.TimeUnit; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +import com.easemob.im.auth.Authentication; +import com.easemob.im.auth.HttpBasicAuth; +import com.easemob.im.auth.ApiKeyAuth; +import org.apache.commons.lang3.StringUtils; + +/** + *

ApiClient class.

+ */ +public class ApiClient { + + private String basePath; + + private Realm realm; + + private String appKey; + + private String clientId; + + private String clientSecret; + + private String appId; + + private String appCert; + + public static String version = "${project.version}"; + + public static Builder builder() { + return new Builder().setRealm(Realm.EASEMOB_REALM); + } + + private Cache appTokenCache; + + protected List servers = new ArrayList(); + protected Integer serverIndex = 0; + protected Map serverVariables = null; + private boolean debugging = false; + private Map defaultHeaderMap = new HashMap(); + private Map defaultCookieMap = new HashMap(); + private String tempFolderPath = null; + + private Map authentications; + + private DateFormat dateFormat; + private DateFormat datetimeFormat; + private boolean lenientDatetimeFormat; + private int dateLength; + + private InputStream sslCaCert; + private boolean verifyingSsl; + private KeyManager[] keyManagers; + + private OkHttpClient httpClient; + private JSON json; + + private HttpLoggingInterceptor loggingInterceptor; + + public ApiClient() { + + } + + public ApiClient(String basePath, Realm realm, String appKey, String clientId, String clientSecret, String appId, String appCert, int maxIdleConnections, int connectKeepAliveMilliSeconds, + int connectTimeoutMilliSeconds, EMProxy proxy) + throws ApiException { + this.basePath = basePath; + this.realm = realm; + this.appKey = appKey; + this.clientId = clientId; + this.clientSecret = clientSecret; + this.appId = appId; + this.appCert = appCert; + this.servers = Collections.singletonList( + new ServerConfiguration( + String.format("%s/%s/%s", basePath, this.appKey.split("#")[0], + this.appKey.split("#")[1]), + "No description provided", + new HashMap() + ) + ); + + initHttpClient(Collections.emptyList(), maxIdleConnections, + connectKeepAliveMilliSeconds, connectTimeoutMilliSeconds, proxy); + init(); + + // Setup authentications (key: authentication name, value: authentication). + // Prevent the authentications from being modified. + authentications = Collections.unmodifiableMap(authentications); + } + + /** + * Basic constructor with custom OkHttpClient + * + * @param client a {@link okhttp3.OkHttpClient} object + */ + public ApiClient(OkHttpClient client) throws ApiException { + init(); + + httpClient = client; + + // Setup authentications (key: authentication name, value: authentication). + // Prevent the authentications from being modified. + authentications = Collections.unmodifiableMap(authentications); + } + + private void initHttpClient(List interceptors, int maxIdleConnections, + int connectKeepAliveMilliSeconds, int connectTimeoutMilliSeconds, EMProxy emProxy) { + OkHttpClient.Builder builder = new OkHttpClient.Builder(); + builder.addNetworkInterceptor(getProgressInterceptor()); + for (Interceptor interceptor: interceptors) { + builder.addInterceptor(interceptor); + } + + builder.connectionPool(new ConnectionPool(maxIdleConnections, connectKeepAliveMilliSeconds, + TimeUnit.MILLISECONDS)) + .connectTimeout(Duration.ofMillis(connectTimeoutMilliSeconds)); + + if (emProxy != null) { + if (emProxy.getIp() != null && emProxy.getPort() != 0) { + Proxy proxy = new Proxy(Proxy.Type.HTTP, new InetSocketAddress(emProxy.getIp(), emProxy.getPort())); + builder.proxy(proxy); + } + + if (emProxy.getUsername() != null && emProxy.getPassword() != null) { + Authenticator authenticator = (route, response) -> { + String credential = Credentials.basic(emProxy.getUsername(), emProxy.getPassword()); + return response.request().newBuilder() + .header("Proxy-Authorization", credential) + .build(); + }; + builder.proxyAuthenticator(authenticator); + } + } + + httpClient = builder.build(); + } + + private void init() throws ApiException { + verifyingSsl = true; + + json = new JSON(); + + // Set default User-Agent. + setUserAgent(String.format("Easemob-ServerSDK2.0_Java_%s", version)); + + appTokenCache = CacheBuilder.newBuilder().maximumSize(1).expireAfterWrite(43200, TimeUnit.SECONDS).build(); + + setAuthorizationToken(getAppToken()); + + authentications = new HashMap(); + } + + public String getAppToken() throws ApiException { + try { + if (this.realm.equals(Realm.EASEMOB_REALM)) { + return appTokenCache.get("app-token", () -> { + EMCreateToken createAppToken = new EMCreateToken(); + createAppToken.setGrantType("client_credentials"); + createAppToken.setClientId(this.clientId); + createAppToken.setClientSecret(this.clientSecret); + Map appTokenObj = (Map)createAppToken(createAppToken); + return (String) appTokenObj.get("access_token"); + }); + } else { + return appTokenCache.get("agora-app-token", () -> { + return generateAgoraAppToken(); + }); + } + } catch (Exception e) { + throw new ApiException("get app token from cache error : " + e.getMessage()); + } + } + + public enum Realm { + AGORA_REALM(1), + EASEMOB_REALM(2), + ; + public short intValue; + + Realm(int value) { + intValue = (short) value; + } + } + + /** + * Build call for createAppToken + * @param createAppToken (optional) + * @param _callback Callback for upload/download progress + * @return Call to execute + * @throws ApiException If fail to serialize the request body object + * @http.response.details + + + +
Status Code Description Response Headers
200 OK -
+ */ + public okhttp3.Call createAppTokenCall(EMCreateToken createAppToken, final ApiCallback _callback) throws ApiException { + // Determine Base Path to Use + String baseURL = servers.get(serverIndex).URL(serverVariables); + + Object localVarPostBody = createAppToken; + + // create path and map variables + String localVarPath = "/token"; + + List localVarQueryParams = new ArrayList(); + List localVarCollectionQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + Map localVarCookieParams = new HashMap(); + Map localVarFormParams = new HashMap(); + + final String[] localVarAccepts = { + "*/*" + }; + final String localVarAccept = selectHeaderAccept(localVarAccepts); + if (localVarAccept != null) { + localVarHeaderParams.put("Accept", localVarAccept); + } + + final String[] localVarContentTypes = { + "application/json" + }; + final String localVarContentType = selectHeaderContentType(localVarContentTypes); + if (localVarContentType != null) { + localVarHeaderParams.put("Content-Type", localVarContentType); + } + + String[] localVarAuthNames = new String[] { }; + Request request = buildAppTokenRequest(baseURL, localVarPath, "POST", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); + + return httpClient.newCall(request); + } + + @SuppressWarnings("rawtypes") + private okhttp3.Call createAppTokenValidateBeforeCall(EMCreateToken createAppToken, final ApiCallback _callback) throws ApiException { + return createAppTokenCall(createAppToken, _callback); + + } + + /** + * POST token + * + * @param createAppToken (optional) + * @return Object + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + +
Status Code Description Response Headers
200 OK -
+ */ + public Object createAppToken(EMCreateToken createAppToken) throws ApiException { + ApiResponse localVarResp = createAppTokenWithHttpInfo(createAppToken); + return localVarResp.getData(); + } + + /** + * POST token + * + * @param createAppToken (optional) + * @return ApiResponse<Object> + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + +
Status Code Description Response Headers
200 OK -
+ */ + public ApiResponse createAppTokenWithHttpInfo(EMCreateToken createAppToken) throws ApiException { + okhttp3.Call localVarCall = createAppTokenValidateBeforeCall(createAppToken, null); + Type localVarReturnType = new TypeToken(){}.getType(); + return execute(localVarCall, localVarReturnType); + } + + private String generateAgoraAppToken() { + AccessToken2 accessToken = new AccessToken2(appId, appCert, 86400); + AccessToken2.Service serviceChat = new AccessToken2.ServiceChat(); + serviceChat.addPrivilegeChat(AccessToken2.PrivilegeChat.PRIVILEGE_CHAT_APP, 86400); + accessToken.addService(serviceChat); + try { + return accessToken.build(); + } catch (Exception e) { + throw new IllegalArgumentException("building agora app token failed"); + } + } + + public static class Builder { + private String basePath; + + private Realm realm; + + private String appKey; + + private String clientId; + + private String clientSecret; + + private String appId; + + private String appCert; + + private int maxIdleConnections = 100; + + private int connectKeepAliveMilliSeconds = 10000; + + private int connectTimeoutMilliSeconds = 10000; + + private EMProxy proxy; + + public Builder setRealm(Realm realm) { + this.realm = realm; + return this; + } + + public Builder setBasePath(String basePath) { + if (StringUtils.isBlank(basePath)) { + throw new IllegalArgumentException("basePath must not be null"); + } + this.basePath = basePath; + return this; + } + + public Builder setAppKey(String appKey) { + if (StringUtils.isBlank(appKey)) { + throw new IllegalArgumentException("appKey must not be null"); + } + String[] tokens = appKey.split("#"); + if (tokens.length != 2) { + throw new IllegalArgumentException("appKey must contains #"); + } + if (tokens[0].isEmpty()) { + throw new IllegalArgumentException("appKey must contains {org}"); + } + if (tokens[1].isEmpty()) { + throw new IllegalArgumentException("appKey must contains {app}"); + } + this.appKey = appKey; + return this; + } + + public Builder setClientId(String clientId) { + if (StringUtils.isBlank(clientId)) { + throw new IllegalArgumentException("clientId must not be null"); + } + this.clientId = clientId; + return this; + } + + public Builder setClientSecret(String clientSecret) { + if (StringUtils.isBlank(clientSecret)) { + throw new IllegalArgumentException("clientSecret must not be null"); + } + this.clientSecret = clientSecret; + return this; + } + + public Builder setAppId(String appId) { + if (StringUtils.isBlank(appId)) { + throw new IllegalArgumentException("appId must not be null or blank"); + } + this.appId = appId; + return this; + } + + public Builder setAppCert(String appCert) { + if (StringUtils.isBlank(appCert)) { + throw new IllegalArgumentException("appCert must not be null or blank"); + } + this.appCert = appCert; + return this; + } + + public Builder setMaxIdleConnections(int maxIdleConnections) { + if (maxIdleConnections < 0) { + throw new IllegalArgumentException("maxIdleConnections must not be negative"); + } + this.maxIdleConnections = maxIdleConnections; + return this; + } + + public Builder setConnectKeepAliveMilliSeconds(int connectKeepAliveMilliSeconds) { + if (connectKeepAliveMilliSeconds < 0) { + throw new IllegalArgumentException("connectKeepAliveMilliSeconds must not be negative"); + } + this.connectKeepAliveMilliSeconds = connectKeepAliveMilliSeconds; + return this; + } + + public Builder setConnectTimeoutMilliSeconds(int connectTimeoutMilliSeconds) { + if (connectTimeoutMilliSeconds < 0) { + throw new IllegalArgumentException("connectTimeoutMilliSeconds must not be negative"); + } + this.connectTimeoutMilliSeconds = connectTimeoutMilliSeconds; + return this; + } + + public Builder setProxy(EMProxy proxy) { + this.proxy = proxy; + return this; + } + + public ApiClient build() throws ApiException { + if (StringUtils.isBlank(basePath)) { + throw new IllegalArgumentException("basePath must not be null"); + } + + if (StringUtils.isBlank(appKey)) { + throw new IllegalArgumentException("appKey must not be null"); + } + String[] split = appKey.split("#"); + if (split.length != 2) { + throw new IllegalArgumentException("appKey must contains #"); + } + if (split[0].isEmpty()) { + throw new IllegalArgumentException("appKey must contains {org}"); + } + if (split[1].isEmpty()) { + throw new IllegalArgumentException("appKey must contains {app}"); + } + + if (this.realm.equals(Realm.EASEMOB_REALM)) { + if (this.clientId == null) { + throw new IllegalArgumentException("clientId not set"); + } + if (this.clientSecret == null) { + throw new IllegalArgumentException("clientSecret not set"); + } + if (this.appId != null || this.appCert != null) { + throw new IllegalArgumentException("appId and appCert must be blank"); + } + + return new ApiClient(this.basePath, this.realm, this.appKey, this.clientId, + this.clientSecret, null, null, this.maxIdleConnections, + this.connectKeepAliveMilliSeconds, this.connectTimeoutMilliSeconds, + this.proxy); + } else if (this.realm.equals(Realm.AGORA_REALM)) { + if (this.appId == null) { + throw new IllegalArgumentException("appId not set"); + } + if (this.appCert == null) { + throw new IllegalArgumentException("appCert not set"); + } + if (this.clientId != null || this.clientSecret != null) { + throw new IllegalArgumentException("clientId and clientSecret must be blank"); + } + + return new ApiClient(this.basePath, this.realm, this.appKey, null, null, this.appId, + this.appCert, this.maxIdleConnections, this.connectKeepAliveMilliSeconds, + this.connectTimeoutMilliSeconds, this.proxy); + } else { + throw new IllegalArgumentException( + String.format("invalid realm type %s", this.realm)); + } + } + + } + + public static class EMProxy { + private String ip; + private int port; + private String username; + private String password; + + public EMProxy(String ip, int port, String username, String password) { + this.ip = ip; + this.port = port; + this.username = username; + this.password = password; + } + + public static Builder builder() { + return new Builder(); + } + + public String getIp() { + return ip; + } + + public int getPort() { + return port; + } + + public String getUsername() { + return username; + } + + public String getPassword() { + return password; + } + + @Override + public String toString() { + return "EMProxy{" + + "ip='" + ip + '\'' + + ", port=" + port + + ", username='" + username + '\'' + + ", password='" + password + '\'' + + '}'; + } + + public static class Builder { + private String ip; + private int port; + private String username; + private String password; + + public Builder setIP(String ip) { + if (StringUtils.isBlank(ip)) { + throw new IllegalArgumentException("ip must not be null"); + } + this.ip = ip; + return this; + } + + public Builder setPort(int port) { + if (port < 0 || port > 65535) { + throw new IllegalArgumentException(String.format("port %s is illegal", port)); + } + this.port = port; + return this; + } + + public Builder setUsername(String username) { + this.username = username; + return this; + } + + public Builder setPassword(String password) { + this.password = password; + return this; + } + + public EMProxy build() { + if (StringUtils.isBlank(this.ip)) { + throw new IllegalArgumentException( + "the IP of setting proxy cannot be null or blank"); + } + return new EMProxy(this.ip, this.port, this.username, this.password); + } + + @Override + public String toString() { + return "Builder{" + + "ip='" + ip + '\'' + + ", port=" + port + + ", username='" + username + '\'' + + ", password='" + password + '\'' + + '}'; + } + } + } + + /** + * Get base path + * + * @return Base path + */ + public String getBasePath() { + return basePath; + } + + /** + * Set base path + * + * @param basePath Base path of the URL (e.g http://a1.easemob.com/ + * @return An instance of OkHttpClient + */ + public ApiClient setBasePath(String basePath) { + this.basePath = basePath; + this.serverIndex = null; + return this; + } + + public List getServers() { + return servers; + } + + public ApiClient setServers(List servers) { + this.servers = servers; + return this; + } + + public Integer getServerIndex() { + return serverIndex; + } + + public ApiClient setServerIndex(Integer serverIndex) { + this.serverIndex = serverIndex; + return this; + } + + public Map getServerVariables() { + return serverVariables; + } + + public ApiClient setServerVariables(Map serverVariables) { + this.serverVariables = serverVariables; + return this; + } + + /** + * Get HTTP client + * + * @return An instance of OkHttpClient + */ + public OkHttpClient getHttpClient() { + return httpClient; + } + + /** + * Set HTTP client, which must never be null. + * + * @param newHttpClient An instance of OkHttpClient + * @return Api Client + * @throws java.lang.NullPointerException when newHttpClient is null + */ + public ApiClient setHttpClient(OkHttpClient newHttpClient) { + this.httpClient = Objects.requireNonNull(newHttpClient, "HttpClient must not be null!"); + return this; + } + + /** + * Get JSON + * + * @return JSON object + */ + public JSON getJSON() { + return json; + } + + /** + * Set JSON + * + * @param json JSON object + * @return Api client + */ + public ApiClient setJSON(JSON json) { + this.json = json; + return this; + } + + /** + * True if isVerifyingSsl flag is on + * + * @return True if isVerifySsl flag is on + */ + public boolean isVerifyingSsl() { + return verifyingSsl; + } + + /** + * Configure whether to verify certificate and hostname when making https requests. + * Default to true. + * NOTE: Do NOT set to false in production code, otherwise you would face multiple types of cryptographic attacks. + * + * @param verifyingSsl True to verify TLS/SSL connection + * @return ApiClient + */ + public ApiClient setVerifyingSsl(boolean verifyingSsl) { + this.verifyingSsl = verifyingSsl; + applySslSettings(); + return this; + } + + /** + * Get SSL CA cert. + * + * @return Input stream to the SSL CA cert + */ + public InputStream getSslCaCert() { + return sslCaCert; + } + + /** + * Configure the CA certificate to be trusted when making https requests. + * Use null to reset to default. + * + * @param sslCaCert input stream for SSL CA cert + * @return ApiClient + */ + public ApiClient setSslCaCert(InputStream sslCaCert) { + this.sslCaCert = sslCaCert; + applySslSettings(); + return this; + } + + /** + *

Getter for the field keyManagers.

+ * + * @return an array of {@link javax.net.ssl.KeyManager} objects + */ + public KeyManager[] getKeyManagers() { + return keyManagers; + } + + /** + * Configure client keys to use for authorization in an SSL session. + * Use null to reset to default. + * + * @param managers The KeyManagers to use + * @return ApiClient + */ + public ApiClient setKeyManagers(KeyManager[] managers) { + this.keyManagers = managers; + applySslSettings(); + return this; + } + + /** + *

Getter for the field dateFormat.

+ * + * @return a {@link java.text.DateFormat} object + */ + public DateFormat getDateFormat() { + return dateFormat; + } + + /** + *

Setter for the field dateFormat.

+ * + * @param dateFormat a {@link java.text.DateFormat} object + * @return a {@link ApiClient} object + */ + public ApiClient setDateFormat(DateFormat dateFormat) { + JSON.setDateFormat(dateFormat); + return this; + } + + /** + *

Set SqlDateFormat.

+ * + * @param dateFormat a {@link java.text.DateFormat} object + * @return a {@link ApiClient} object + */ + public ApiClient setSqlDateFormat(DateFormat dateFormat) { + JSON.setSqlDateFormat(dateFormat); + return this; + } + + /** + *

Set OffsetDateTimeFormat.

+ * + * @param dateFormat a {@link java.time.format.DateTimeFormatter} object + * @return a {@link ApiClient} object + */ + public ApiClient setOffsetDateTimeFormat(DateTimeFormatter dateFormat) { + JSON.setOffsetDateTimeFormat(dateFormat); + return this; + } + + /** + *

Set LocalDateFormat.

+ * + * @param dateFormat a {@link java.time.format.DateTimeFormatter} object + * @return a {@link ApiClient} object + */ + public ApiClient setLocalDateFormat(DateTimeFormatter dateFormat) { + JSON.setLocalDateFormat(dateFormat); + return this; + } + + /** + *

Set LenientOnJson.

+ * + * @param lenientOnJson a boolean + * @return a {@link ApiClient} object + */ + public ApiClient setLenientOnJson(boolean lenientOnJson) { + JSON.setLenientOnJson(lenientOnJson); + return this; + } + + /** + * Get authentications (key: authentication name, value: authentication). + * + * @return Map of authentication objects + */ + public Map getAuthentications() { + return authentications; + } + + /** + * Get authentication for the given name. + * + * @param authName The authentication name + * @return The authentication, null if not found + */ + public Authentication getAuthentication(String authName) { + return authentications.get(authName); + } + + + /** + * Helper method to set username for the first HTTP basic authentication. + * + * @param username Username + */ + public void setUsername(String username) { + for (Authentication auth : authentications.values()) { + if (auth instanceof HttpBasicAuth) { + ((HttpBasicAuth) auth).setUsername(username); + return; + } + } + throw new RuntimeException("No HTTP basic authentication configured!"); + } + + /** + * Helper method to set password for the first HTTP basic authentication. + * + * @param password Password + */ + public void setPassword(String password) { + for (Authentication auth : authentications.values()) { + if (auth instanceof HttpBasicAuth) { + ((HttpBasicAuth) auth).setPassword(password); + return; + } + } + throw new RuntimeException("No HTTP basic authentication configured!"); + } + + /** + * Helper method to set API key value for the first API key authentication. + * + * @param apiKey API key + */ + public void setApiKey(String apiKey) { + for (Authentication auth : authentications.values()) { + if (auth instanceof ApiKeyAuth) { + ((ApiKeyAuth) auth).setApiKey(apiKey); + return; + } + } + throw new RuntimeException("No API key authentication configured!"); + } + + /** + * Helper method to set API key prefix for the first API key authentication. + * + * @param apiKeyPrefix API key prefix + */ + public void setApiKeyPrefix(String apiKeyPrefix) { + for (Authentication auth : authentications.values()) { + if (auth instanceof ApiKeyAuth) { + ((ApiKeyAuth) auth).setApiKeyPrefix(apiKeyPrefix); + return; + } + } + throw new RuntimeException("No API key authentication configured!"); + } + + /** + * Helper method to set access token for the first OAuth2 authentication. + * + * @param accessToken Access token + */ + public void setAccessToken(String accessToken) { + throw new RuntimeException("No OAuth2 authentication configured!"); + } + + /** + * Helper method to set credentials for AWSV4 Signature + * + * @param accessKey Access Key + * @param secretKey Secret Key + * @param region Region + * @param service Service to access to + */ + public void setAWS4Configuration(String accessKey, String secretKey, String region, String service) { + throw new RuntimeException("No AWS4 authentication configured!"); + } + + /** + * Set the User-Agent header's value (by adding to the default header map). + * + * @param userAgent HTTP request's user agent + * @return ApiClient + */ + public ApiClient setUserAgent(String userAgent) { + addDefaultHeader("User-Agent", userAgent); + return this; + } + + public ApiClient setAuthorizationToken(String appToken) { + addDefaultHeader("Authorization", String.format("Bearer %s", appToken)); + return this; + } + + /** + * Add a default header. + * + * @param key The header's key + * @param value The header's value + * @return ApiClient + */ + public ApiClient addDefaultHeader(String key, String value) { + defaultHeaderMap.put(key, value); + return this; + } + + /** + * Add a default cookie. + * + * @param key The cookie's key + * @param value The cookie's value + * @return ApiClient + */ + public ApiClient addDefaultCookie(String key, String value) { + defaultCookieMap.put(key, value); + return this; + } + + /** + * Check that whether debugging is enabled for this API client. + * + * @return True if debugging is enabled, false otherwise. + */ + public boolean isDebugging() { + return debugging; + } + + /** + * Enable/disable debugging for this API client. + * + * @param debugging To enable (true) or disable (false) debugging + * @return ApiClient + */ + public ApiClient setDebugging(boolean debugging) { + if (debugging != this.debugging) { + if (debugging) { + loggingInterceptor = new HttpLoggingInterceptor(); + loggingInterceptor.setLevel(Level.BODY); + httpClient = httpClient.newBuilder().addInterceptor(loggingInterceptor).build(); + } else { + final OkHttpClient.Builder builder = httpClient.newBuilder(); + builder.interceptors().remove(loggingInterceptor); + httpClient = builder.build(); + loggingInterceptor = null; + } + } + this.debugging = debugging; + return this; + } + + /** + * The path of temporary folder used to store downloaded files from endpoints + * with file response. The default value is null, i.e. using + * the system's default temporary folder. + * + * @see createTempFile + * @return Temporary folder path + */ + public String getTempFolderPath() { + return tempFolderPath; + } + + /** + * Set the temporary folder path (for downloading files) + * + * @param tempFolderPath Temporary folder path + * @return ApiClient + */ + public ApiClient setTempFolderPath(String tempFolderPath) { + this.tempFolderPath = tempFolderPath; + return this; + } + + /** + * Get connection timeout (in milliseconds). + * + * @return Timeout in milliseconds + */ + public int getConnectTimeout() { + return httpClient.connectTimeoutMillis(); + } + + /** + * Sets the connect timeout (in milliseconds). + * A value of 0 means no timeout, otherwise values must be between 1 and + * {@link java.lang.Integer#MAX_VALUE}. + * + * @param connectionTimeout connection timeout in milliseconds + * @return Api client + */ + public ApiClient setConnectTimeout(int connectionTimeout) { + httpClient = httpClient.newBuilder().connectTimeout(connectionTimeout, TimeUnit.MILLISECONDS).build(); + return this; + } + + /** + * Get read timeout (in milliseconds). + * + * @return Timeout in milliseconds + */ + public int getReadTimeout() { + return httpClient.readTimeoutMillis(); + } + + /** + * Sets the read timeout (in milliseconds). + * A value of 0 means no timeout, otherwise values must be between 1 and + * {@link java.lang.Integer#MAX_VALUE}. + * + * @param readTimeout read timeout in milliseconds + * @return Api client + */ + public ApiClient setReadTimeout(int readTimeout) { + httpClient = httpClient.newBuilder().readTimeout(readTimeout, TimeUnit.MILLISECONDS).build(); + return this; + } + + /** + * Get write timeout (in milliseconds). + * + * @return Timeout in milliseconds + */ + public int getWriteTimeout() { + return httpClient.writeTimeoutMillis(); + } + + /** + * Sets the write timeout (in milliseconds). + * A value of 0 means no timeout, otherwise values must be between 1 and + * {@link java.lang.Integer#MAX_VALUE}. + * + * @param writeTimeout connection timeout in milliseconds + * @return Api client + */ + public ApiClient setWriteTimeout(int writeTimeout) { + httpClient = httpClient.newBuilder().writeTimeout(writeTimeout, TimeUnit.MILLISECONDS).build(); + return this; + } + + + /** + * Format the given parameter object into string. + * + * @param param Parameter + * @return String representation of the parameter + */ + public String parameterToString(Object param) { + if (param == null) { + return ""; + } else if (param instanceof Date || param instanceof OffsetDateTime || param instanceof LocalDate) { + //Serialize to json string and remove the " enclosing characters + String jsonStr = JSON.serialize(param); + return jsonStr.substring(1, jsonStr.length() - 1); + } else if (param instanceof Collection) { + StringBuilder b = new StringBuilder(); + for (Object o : (Collection) param) { + if (b.length() > 0) { + b.append(","); + } + b.append(o); + } + return b.toString(); + } else { + return String.valueOf(param); + } + } + + /** + * Formats the specified query parameter to a list containing a single {@code Pair} object. + * + * Note that {@code value} must not be a collection. + * + * @param name The name of the parameter. + * @param value The value of the parameter. + * @return A list containing a single {@code Pair} object. + */ + public List parameterToPair(String name, Object value) { + List params = new ArrayList(); + + // preconditions + if (name == null || name.isEmpty() || value == null || value instanceof Collection) { + return params; + } + + params.add(new Pair(name, parameterToString(value))); + return params; + } + + /** + * Formats the specified collection query parameters to a list of {@code Pair} objects. + * + * Note that the values of each of the returned Pair objects are percent-encoded. + * + * @param collectionFormat The collection format of the parameter. + * @param name The name of the parameter. + * @param value The value of the parameter. + * @return A list of {@code Pair} objects. + */ + public List parameterToPairs(String collectionFormat, String name, Collection value) { + List params = new ArrayList(); + + // preconditions + if (name == null || name.isEmpty() || value == null || value.isEmpty()) { + return params; + } + + // create the params based on the collection format + if ("multi".equals(collectionFormat)) { + for (Object item : value) { + params.add(new Pair(name, escapeString(parameterToString(item)))); + } + return params; + } + + // collectionFormat is assumed to be "csv" by default + String delimiter = ","; + + // escape all delimiters except commas, which are URI reserved + // characters + if ("ssv".equals(collectionFormat)) { + delimiter = escapeString(" "); + } else if ("tsv".equals(collectionFormat)) { + delimiter = escapeString("\t"); + } else if ("pipes".equals(collectionFormat)) { + delimiter = escapeString("|"); + } + + StringBuilder sb = new StringBuilder(); + for (Object item : value) { + sb.append(delimiter); + sb.append(escapeString(parameterToString(item))); + } + + params.add(new Pair(name, sb.substring(delimiter.length()))); + + return params; + } + + /** + * Formats the specified collection path parameter to a string value. + * + * @param collectionFormat The collection format of the parameter. + * @param value The value of the parameter. + * @return String representation of the parameter + */ + public String collectionPathParameterToString(String collectionFormat, Collection value) { + // create the value based on the collection format + if ("multi".equals(collectionFormat)) { + // not valid for path params + return parameterToString(value); + } + + // collectionFormat is assumed to be "csv" by default + String delimiter = ","; + + if ("ssv".equals(collectionFormat)) { + delimiter = " "; + } else if ("tsv".equals(collectionFormat)) { + delimiter = "\t"; + } else if ("pipes".equals(collectionFormat)) { + delimiter = "|"; + } + + StringBuilder sb = new StringBuilder() ; + for (Object item : value) { + sb.append(delimiter); + sb.append(parameterToString(item)); + } + + return sb.substring(delimiter.length()); + } + + /** + * Sanitize filename by removing path. + * e.g. ../../sun.gif becomes sun.gif + * + * @param filename The filename to be sanitized + * @return The sanitized filename + */ + public String sanitizeFilename(String filename) { + return filename.replaceAll(".*[/\\\\]", ""); + } + + /** + * Check if the given MIME is a JSON MIME. + * JSON MIME examples: + * application/json + * application/json; charset=UTF8 + * APPLICATION/JSON + * application/vnd.company+json + * "* / *" is also default to JSON + * @param mime MIME (Multipurpose Internet Mail Extensions) + * @return True if the given MIME is JSON, false otherwise. + */ + public boolean isJsonMime(String mime) { + String jsonMime = "(?i)^(application/json|[^;/ \t]+/[^;/ \t]+[+]json)[ \t]*(;.*)?$"; + return mime != null && (mime.matches(jsonMime) || mime.equals("*/*")); + } + + /** + * Select the Accept header's value from the given accepts array: + * if JSON exists in the given array, use it; + * otherwise use all of them (joining into a string) + * + * @param accepts The accepts array to select from + * @return The Accept header to use. If the given array is empty, + * null will be returned (not to set the Accept header explicitly). + */ + public String selectHeaderAccept(String[] accepts) { + if (accepts.length == 0) { + return null; + } + for (String accept : accepts) { + if (isJsonMime(accept)) { + return accept; + } + } + return StringUtil.join(accepts, ","); + } + + /** + * Select the Content-Type header's value from the given array: + * if JSON exists in the given array, use it; + * otherwise use the first one of the array. + * + * @param contentTypes The Content-Type array to select from + * @return The Content-Type header to use. If the given array is empty, + * returns null. If it matches "any", JSON will be used. + */ + public String selectHeaderContentType(String[] contentTypes) { + if (contentTypes.length == 0) { + return null; + } + + if (contentTypes[0].equals("*/*")) { + return "application/json"; + } + + for (String contentType : contentTypes) { + if (isJsonMime(contentType)) { + return contentType; + } + } + + return contentTypes[0]; + } + + /** + * Escape the given string to be used as URL query value. + * + * @param str String to be escaped + * @return Escaped string + */ + public String escapeString(String str) { + try { + return URLEncoder.encode(str, "utf8").replaceAll("\\+", "%20"); + } catch (UnsupportedEncodingException e) { + return str; + } + } + + /** + * Deserialize response body to Java object, according to the return type and + * the Content-Type response header. + * + * @param Type + * @param response HTTP response + * @param returnType The type of the Java object + * @return The deserialized Java object + * @throws ApiException If fail to deserialize response body, i.e. cannot read response body + * or the Content-Type of the response is not supported. + */ + @SuppressWarnings("unchecked") + public T deserialize(Response response, Type returnType) throws ApiException { + if (response == null || returnType == null) { + return null; + } + + if ("byte[]".equals(returnType.toString())) { + // Handle binary response (byte array). + try { + return (T) response.body().bytes(); + } catch (IOException e) { + throw new ApiException(e); + } + } else if (returnType.equals(File.class)) { + // Handle file downloading. + return (T) downloadFileFromResponse(response); + } + + String respBody; + try { + if (response.body() != null) + respBody = response.body().string(); + else + respBody = null; + } catch (IOException e) { + throw new ApiException(e); + } + + if (respBody == null || "".equals(respBody)) { + return null; + } + + String contentType = response.headers().get("Content-Type"); + if (contentType == null) { + // ensuring a default content type + contentType = "application/json"; + } + if (isJsonMime(contentType)) { + return JSON.deserialize(respBody, returnType); + } else if (returnType.equals(String.class)) { + // Expecting string, return the raw response body. + return (T) respBody; + } else { + throw new ApiException( + "Content type \"" + contentType + "\" is not supported for type: " + returnType, + response.code(), + response.headers().toMultimap(), + respBody); + } + } + + /** + * Serialize the given Java object into request body according to the object's + * class and the request Content-Type. + * + * @param obj The Java object + * @param contentType The request Content-Type + * @return The serialized request body + * @throws ApiException If fail to serialize the given object + */ + public RequestBody serialize(Object obj, String contentType) throws ApiException { + if (obj instanceof byte[]) { + // Binary (byte array) body parameter support. + return RequestBody.create((byte[]) obj, MediaType.parse(contentType)); + } else if (obj instanceof File) { + // File body parameter support. + return RequestBody.create((File) obj, MediaType.parse(contentType)); + } else if ("text/plain".equals(contentType) && obj instanceof String) { + return RequestBody.create((String) obj, MediaType.parse(contentType)); + } else if (isJsonMime(contentType)) { + String content; + if (obj != null) { + content = JSON.serialize(obj); + } else { + content = null; + } + return RequestBody.create(content, MediaType.parse(contentType)); + } else if (obj instanceof String) { + return RequestBody.create((String) obj, MediaType.parse(contentType)); + } else { + throw new ApiException("Content type \"" + contentType + "\" is not supported"); + } + } + + /** + * Download file from the given response. + * + * @param response An instance of the Response object + * @throws ApiException If fail to read file content from response and write to disk + * @return Downloaded file + */ + public File downloadFileFromResponse(Response response) throws ApiException { + try { + File file = prepareDownloadFile(response); + BufferedSink sink = Okio.buffer(Okio.sink(file)); + sink.writeAll(response.body().source()); + sink.close(); + return file; + } catch (IOException e) { + throw new ApiException(e); + } + } + + /** + * Prepare file for download + * + * @param response An instance of the Response object + * @return Prepared file for the download + * @throws java.io.IOException If fail to prepare file for download + */ + public File prepareDownloadFile(Response response) throws IOException { + String filename = null; + String contentDisposition = response.header("Content-Disposition"); + if (contentDisposition != null && !"".equals(contentDisposition)) { + // Get filename from the Content-Disposition header. + Pattern pattern = Pattern.compile("filename=['\"]?([^'\"\\s]+)['\"]?"); + Matcher matcher = pattern.matcher(contentDisposition); + if (matcher.find()) { + filename = sanitizeFilename(matcher.group(1)); + } + } + + String prefix = null; + String suffix = null; + if (filename == null) { + prefix = "download-"; + suffix = ""; + } else { + int pos = filename.lastIndexOf("."); + if (pos == -1) { + prefix = filename + "-"; + } else { + prefix = filename.substring(0, pos) + "-"; + suffix = filename.substring(pos); + } + // Files.createTempFile requires the prefix to be at least three characters long + if (prefix.length() < 3) + prefix = "download-"; + } + + if (tempFolderPath == null) + return Files.createTempFile(prefix, suffix).toFile(); + else + return Files.createTempFile(Paths.get(tempFolderPath), prefix, suffix).toFile(); + } + + /** + * {@link #execute(Call, Type)} + * + * @param Type + * @param call An instance of the Call object + * @return ApiResponse<T> + * @throws ApiException If fail to execute the call + */ + public ApiResponse execute(Call call) throws ApiException { + return execute(call, null); + } + + /** + * Execute HTTP call and deserialize the HTTP response body into the given return type. + * + * @param returnType The return type used to deserialize HTTP response body + * @param The return type corresponding to (same with) returnType + * @param call Call + * @return ApiResponse object containing response status, headers and + * data, which is a Java object deserialized from response body and would be null + * when returnType is null. + * @throws ApiException If fail to execute the call + */ + public ApiResponse execute(Call call, Type returnType) throws ApiException { + try { + Response response = call.execute(); + T data = handleResponse(response, returnType); + return new ApiResponse(response.code(), response.headers().toMultimap(), data); + } catch (IOException e) { + throw new ApiException(e); + } + } + + /** + * {@link #executeAsync(Call, Type, ApiCallback)} + * + * @param Type + * @param call An instance of the Call object + * @param callback ApiCallback<T> + */ + public void executeAsync(Call call, ApiCallback callback) { + executeAsync(call, null, callback); + } + + /** + * Execute HTTP call asynchronously. + * + * @param Type + * @param call The callback to be executed when the API call finishes + * @param returnType Return type + * @param callback ApiCallback + * @see #execute(Call, Type) + */ + @SuppressWarnings("unchecked") + public void executeAsync(Call call, final Type returnType, final ApiCallback callback) { + call.enqueue(new Callback() { + @Override + public void onFailure(Call call, IOException e) { + callback.onFailure(new ApiException(e), 0, null); + } + + @Override + public void onResponse(Call call, Response response) throws IOException { + T result; + try { + result = (T) handleResponse(response, returnType); + } catch (ApiException e) { + callback.onFailure(e, response.code(), response.headers().toMultimap()); + return; + } catch (Exception e) { + callback.onFailure(new ApiException(e), response.code(), response.headers().toMultimap()); + return; + } + callback.onSuccess(result, response.code(), response.headers().toMultimap()); + } + }); + } + + /** + * Handle the given response, return the deserialized object when the response is successful. + * + * @param Type + * @param response Response + * @param returnType Return type + * @return Type + * @throws ApiException If the response has an unsuccessful status code or + * fail to deserialize the response body + */ + public T handleResponse(Response response, Type returnType) throws ApiException { + if (response.isSuccessful()) { + if (returnType == null || response.code() == 204) { + // returning null if the returnType is not defined, + // or the status code is 204 (No Content) + if (response.body() != null) { + try { + response.body().close(); + } catch (Exception e) { + throw new ApiException(response.message(), e, response.code(), response.headers().toMultimap()); + } + } + return null; + } else { + return deserialize(response, returnType); + } + } else { + String respBody = null; + if (response.body() != null) { + try { + respBody = response.body().string(); + } catch (IOException e) { + throw new ApiException(response.message(), e, response.code(), response.headers().toMultimap()); + } + } + throw new ApiException(response.message(), response.code(), response.headers().toMultimap(), respBody); + } + } + + /** + * Build HTTP call with the given options. + * + * @param baseUrl The base URL + * @param path The sub-path of the HTTP URL + * @param method The request method, one of "GET", "HEAD", "OPTIONS", "POST", "PUT", "PATCH" and "DELETE" + * @param queryParams The query parameters + * @param collectionQueryParams The collection query parameters + * @param body The request body object + * @param headerParams The header parameters + * @param cookieParams The cookie parameters + * @param formParams The form parameters + * @param authNames The authentications to apply + * @param callback Callback for upload/download progress + * @return The HTTP call + * @throws ApiException If fail to serialize the request body object + */ + public Call buildCall(String baseUrl, String path, String method, List queryParams, List collectionQueryParams, Object body, Map headerParams, Map cookieParams, Map formParams, String[] authNames, ApiCallback callback) throws ApiException { + Request request = buildRequest(baseUrl, path, method, queryParams, collectionQueryParams, body, headerParams, cookieParams, formParams, authNames, callback); + + return httpClient.newCall(request); + } + + /** + * Build an HTTP request with the given options. + * + * @param baseUrl The base URL + * @param path The sub-path of the HTTP URL + * @param method The request method, one of "GET", "HEAD", "OPTIONS", "POST", "PUT", "PATCH" and "DELETE" + * @param queryParams The query parameters + * @param collectionQueryParams The collection query parameters + * @param body The request body object + * @param headerParams The header parameters + * @param cookieParams The cookie parameters + * @param formParams The form parameters + * @param authNames The authentications to apply + * @param callback Callback for upload/download progress + * @return The HTTP request + * @throws ApiException If fail to serialize the request body object + */ + public Request buildRequest(String baseUrl, String path, String method, List queryParams, List collectionQueryParams, Object body, Map headerParams, Map cookieParams, Map formParams, String[] authNames, ApiCallback callback) throws ApiException { + // aggregate queryParams (non-collection) and collectionQueryParams into allQueryParams + List allQueryParams = new ArrayList(queryParams); + allQueryParams.addAll(collectionQueryParams); + + final String url = buildUrl(baseUrl, path, queryParams, collectionQueryParams); + + // prepare HTTP request body + RequestBody reqBody; + String contentType = headerParams.get("Content-Type"); + String contentTypePure = contentType; + if (contentTypePure != null && contentTypePure.contains(";")) { + contentTypePure = contentType.substring(0, contentType.indexOf(";")); + } + if (!HttpMethod.permitsRequestBody(method)) { + reqBody = null; + } else if ("application/x-www-form-urlencoded".equals(contentTypePure)) { + reqBody = buildRequestBodyFormEncoding(formParams); + } else if ("multipart/form-data".equals(contentTypePure)) { + reqBody = buildRequestBodyMultipart(formParams); + } else if (body == null) { + if ("DELETE".equals(method)) { + // allow calling DELETE without sending a request body + reqBody = null; + } else { + // use an empty request body (for POST, PUT and PATCH) + reqBody = RequestBody.create("", contentType == null ? null : MediaType.parse(contentType)); + } + } else { + reqBody = serialize(body, contentType); + } + + headerParams.put("Authorization", String.format("Bearer %s", getAppToken())); + + // update parameters with authentication settings + updateParamsForAuth(authNames, allQueryParams, headerParams, cookieParams, requestBodyToString(reqBody), method, URI.create(url)); + + final Request.Builder reqBuilder = new Request.Builder().url(url); + processHeaderParams(headerParams, reqBuilder); + processCookieParams(cookieParams, reqBuilder); + + // Associate callback with request (if not null) so interceptor can + // access it when creating ProgressResponseBody + reqBuilder.tag(callback); + + Request request = null; + + if (callback != null && reqBody != null) { + ProgressRequestBody progressRequestBody = new ProgressRequestBody(reqBody, callback); + request = reqBuilder.method(method, progressRequestBody).build(); + } else { + request = reqBuilder.method(method, reqBody).build(); + } + + return request; + } + + /** + * Build an HTTP request with the given options. + * + * @param baseUrl The base URL + * @param path The sub-path of the HTTP URL + * @param method The request method, one of "GET", "HEAD", "OPTIONS", "POST", "PUT", "PATCH" and "DELETE" + * @param queryParams The query parameters + * @param collectionQueryParams The collection query parameters + * @param body The request body object + * @param headerParams The header parameters + * @param cookieParams The cookie parameters + * @param formParams The form parameters + * @param authNames The authentications to apply + * @param callback Callback for upload/download progress + * @return The HTTP request + * @throws ApiException If fail to serialize the request body object + */ + public Request buildAppTokenRequest(String baseUrl, String path, String method, List queryParams, List collectionQueryParams, Object body, Map headerParams, Map cookieParams, Map formParams, String[] authNames, ApiCallback callback) throws ApiException { + // aggregate queryParams (non-collection) and collectionQueryParams into allQueryParams + List allQueryParams = new ArrayList(queryParams); + allQueryParams.addAll(collectionQueryParams); + + final String url = buildUrl(baseUrl, path, queryParams, collectionQueryParams); + + // prepare HTTP request body + RequestBody reqBody; + String contentType = headerParams.get("Content-Type"); + String contentTypePure = contentType; + if (contentTypePure != null && contentTypePure.contains(";")) { + contentTypePure = contentType.substring(0, contentType.indexOf(";")); + } + if (!HttpMethod.permitsRequestBody(method)) { + reqBody = null; + } else if ("application/x-www-form-urlencoded".equals(contentTypePure)) { + reqBody = buildRequestBodyFormEncoding(formParams); + } else if ("multipart/form-data".equals(contentTypePure)) { + reqBody = buildRequestBodyMultipart(formParams); + } else if (body == null) { + if ("DELETE".equals(method)) { + // allow calling DELETE without sending a request body + reqBody = null; + } else { + // use an empty request body (for POST, PUT and PATCH) + reqBody = RequestBody.create("", contentType == null ? null : MediaType.parse(contentType)); + } + } else { + reqBody = serialize(body, contentType); + } + + // update parameters with authentication settings + updateParamsForAuth(authNames, allQueryParams, headerParams, cookieParams, requestBodyToString(reqBody), method, URI.create(url)); + + final Request.Builder reqBuilder = new Request.Builder().url(url); + processHeaderParams(headerParams, reqBuilder); + processCookieParams(cookieParams, reqBuilder); + + // Associate callback with request (if not null) so interceptor can + // access it when creating ProgressResponseBody + reqBuilder.tag(callback); + + Request request = null; + + if (callback != null && reqBody != null) { + ProgressRequestBody progressRequestBody = new ProgressRequestBody(reqBody, callback); + request = reqBuilder.method(method, progressRequestBody).build(); + } else { + request = reqBuilder.method(method, reqBody).build(); + } + + return request; + } + + /** + * Build full URL by concatenating base path, the given sub path and query parameters. + * + * @param baseUrl The base URL + * @param path The sub path + * @param queryParams The query parameters + * @param collectionQueryParams The collection query parameters + * @return The full URL + */ + public String buildUrl(String baseUrl, String path, List queryParams, List collectionQueryParams) { + final StringBuilder url = new StringBuilder(); + if (baseUrl != null) { + url.append(baseUrl).append(path); + } else { + String baseURL; + if (serverIndex != null) { + if (serverIndex < 0 || serverIndex >= servers.size()) { + throw new ArrayIndexOutOfBoundsException(String.format( + "Invalid index %d when selecting the host settings. Must be less than %d", serverIndex, servers.size() + )); + } + baseURL = servers.get(serverIndex).URL(serverVariables); + } else { + baseURL = basePath; + } + url.append(baseURL).append(path); + } + + if (queryParams != null && !queryParams.isEmpty()) { + // support (constant) query string in `path`, e.g. "/posts?draft=1" + String prefix = path.contains("?") ? "&" : "?"; + for (Pair param : queryParams) { + if (param.getValue() != null) { + if (prefix != null) { + url.append(prefix); + prefix = null; + } else { + url.append("&"); + } + String value = parameterToString(param.getValue()); + url.append(escapeString(param.getName())).append("=").append(escapeString(value)); + } + } + } + + if (collectionQueryParams != null && !collectionQueryParams.isEmpty()) { + String prefix = url.toString().contains("?") ? "&" : "?"; + for (Pair param : collectionQueryParams) { + if (param.getValue() != null) { + if (prefix != null) { + url.append(prefix); + prefix = null; + } else { + url.append("&"); + } + String value = parameterToString(param.getValue()); + // collection query parameter value already escaped as part of parameterToPairs + url.append(escapeString(param.getName())).append("=").append(value); + } + } + } + + return url.toString(); + } + + /** + * Set header parameters to the request builder, including default headers. + * + * @param headerParams Header parameters in the form of Map + * @param reqBuilder Request.Builder + */ + public void processHeaderParams(Map headerParams, Request.Builder reqBuilder) { + for (Entry param : headerParams.entrySet()) { + reqBuilder.header(param.getKey(), parameterToString(param.getValue())); + } + for (Entry header : defaultHeaderMap.entrySet()) { + if (!headerParams.containsKey(header.getKey())) { + reqBuilder.header(header.getKey(), parameterToString(header.getValue())); + } + } + } + + /** + * Set cookie parameters to the request builder, including default cookies. + * + * @param cookieParams Cookie parameters in the form of Map + * @param reqBuilder Request.Builder + */ + public void processCookieParams(Map cookieParams, Request.Builder reqBuilder) { + for (Entry param : cookieParams.entrySet()) { + reqBuilder.addHeader("Cookie", String.format("%s=%s", param.getKey(), param.getValue())); + } + for (Entry param : defaultCookieMap.entrySet()) { + if (!cookieParams.containsKey(param.getKey())) { + reqBuilder.addHeader("Cookie", String.format("%s=%s", param.getKey(), param.getValue())); + } + } + } + + /** + * Update query and header parameters based on authentication settings. + * + * @param authNames The authentications to apply + * @param queryParams List of query parameters + * @param headerParams Map of header parameters + * @param cookieParams Map of cookie parameters + * @param payload HTTP request body + * @param method HTTP method + * @param uri URI + * @throws ApiException If fails to update the parameters + */ + public void updateParamsForAuth(String[] authNames, List queryParams, Map headerParams, + Map cookieParams, String payload, String method, URI uri) throws ApiException { + for (String authName : authNames) { + Authentication auth = authentications.get(authName); + if (auth == null) { + throw new RuntimeException("Authentication undefined: " + authName); + } + auth.applyToParams(queryParams, headerParams, cookieParams, payload, method, uri); + } + } + + /** + * Build a form-encoding request body with the given form parameters. + * + * @param formParams Form parameters in the form of Map + * @return RequestBody + */ + public RequestBody buildRequestBodyFormEncoding(Map formParams) { + okhttp3.FormBody.Builder formBuilder = new okhttp3.FormBody.Builder(); + for (Entry param : formParams.entrySet()) { + formBuilder.add(param.getKey(), parameterToString(param.getValue())); + } + return formBuilder.build(); + } + + /** + * Build a multipart (file uploading) request body with the given form parameters, + * which could contain text fields and file fields. + * + * @param formParams Form parameters in the form of Map + * @return RequestBody + */ + public RequestBody buildRequestBodyMultipart(Map formParams) { + MultipartBody.Builder mpBuilder = new MultipartBody.Builder().setType(MultipartBody.FORM); + for (Entry param : formParams.entrySet()) { + if (param.getValue() instanceof File) { + File file = (File) param.getValue(); + addPartToMultiPartBuilder(mpBuilder, param.getKey(), file); + } else if (param.getValue() instanceof List) { + List list = (List) param.getValue(); + for (Object item: list) { + if (item instanceof File) { + addPartToMultiPartBuilder(mpBuilder, param.getKey(), (File) item); + } else { + addPartToMultiPartBuilder(mpBuilder, param.getKey(), param.getValue()); + } + } + } else { + addPartToMultiPartBuilder(mpBuilder, param.getKey(), param.getValue()); + } + } + return mpBuilder.build(); + } + + /** + * Guess Content-Type header from the given file (defaults to "application/octet-stream"). + * + * @param file The given file + * @return The guessed Content-Type + */ + public String guessContentTypeFromFile(File file) { + String contentType = URLConnection.guessContentTypeFromName(file.getName()); + if (contentType == null) { + return "application/octet-stream"; + } else { + return contentType; + } + } + + /** + * Add a Content-Disposition Header for the given key and file to the MultipartBody Builder. + * + * @param mpBuilder MultipartBody.Builder + * @param key The key of the Header element + * @param file The file to add to the Header + */ + private void addPartToMultiPartBuilder(MultipartBody.Builder mpBuilder, String key, File file) { + Headers partHeaders = Headers.of("Content-Disposition", "form-data; name=\"" + key + "\"; filename=\"" + file.getName() + "\""); + MediaType mediaType = MediaType.parse(guessContentTypeFromFile(file)); + mpBuilder.addPart(partHeaders, RequestBody.create(file, mediaType)); + } + + /** + * Add a Content-Disposition Header for the given key and complex object to the MultipartBody Builder. + * + * @param mpBuilder MultipartBody.Builder + * @param key The key of the Header element + * @param obj The complex object to add to the Header + */ + private void addPartToMultiPartBuilder(MultipartBody.Builder mpBuilder, String key, Object obj) { + RequestBody requestBody; + if (obj instanceof String) { + requestBody = RequestBody.create((String) obj, MediaType.parse("text/plain")); + } else { + String content; + if (obj != null) { + content = JSON.serialize(obj); + } else { + content = null; + } + requestBody = RequestBody.create(content, MediaType.parse("application/json")); + } + + Headers partHeaders = Headers.of("Content-Disposition", "form-data; name=\"" + key + "\""); + mpBuilder.addPart(partHeaders, requestBody); + } + + /** + * Get network interceptor to add it to the httpClient to track download progress for + * async requests. + */ + private Interceptor getProgressInterceptor() { + return new Interceptor() { + @Override + public Response intercept(Interceptor.Chain chain) throws IOException { + final Request request = chain.request(); + final Response originalResponse = chain.proceed(request); + if (request.tag() instanceof ApiCallback) { + final ApiCallback callback = (ApiCallback) request.tag(); + return originalResponse.newBuilder() + .body(new ProgressResponseBody(originalResponse.body(), callback)) + .build(); + } + return originalResponse; + } + }; + } + + /** + * Apply SSL related settings to httpClient according to the current values of + * verifyingSsl and sslCaCert. + */ + private void applySslSettings() { + try { + TrustManager[] trustManagers; + HostnameVerifier hostnameVerifier; + if (!verifyingSsl) { + trustManagers = new TrustManager[]{ + new X509TrustManager() { + @Override + public void checkClientTrusted(java.security.cert.X509Certificate[] chain, String authType) throws CertificateException { + } + + @Override + public void checkServerTrusted(java.security.cert.X509Certificate[] chain, String authType) throws CertificateException { + } + + @Override + public java.security.cert.X509Certificate[] getAcceptedIssuers() { + return new java.security.cert.X509Certificate[]{}; + } + } + }; + hostnameVerifier = new HostnameVerifier() { + @Override + public boolean verify(String hostname, SSLSession session) { + return true; + } + }; + } else { + TrustManagerFactory trustManagerFactory = TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm()); + + if (sslCaCert == null) { + trustManagerFactory.init((KeyStore) null); + } else { + char[] password = null; // Any password will work. + CertificateFactory certificateFactory = CertificateFactory.getInstance("X.509"); + Collection certificates = certificateFactory.generateCertificates(sslCaCert); + if (certificates.isEmpty()) { + throw new IllegalArgumentException("expected non-empty set of trusted certificates"); + } + KeyStore caKeyStore = newEmptyKeyStore(password); + int index = 0; + for (Certificate certificate : certificates) { + String certificateAlias = "ca" + (index++); + caKeyStore.setCertificateEntry(certificateAlias, certificate); + } + trustManagerFactory.init(caKeyStore); + } + trustManagers = trustManagerFactory.getTrustManagers(); + hostnameVerifier = OkHostnameVerifier.INSTANCE; + } + + SSLContext sslContext = SSLContext.getInstance("TLS"); + sslContext.init(keyManagers, trustManagers, new SecureRandom()); + httpClient = httpClient.newBuilder() + .sslSocketFactory(sslContext.getSocketFactory(), (X509TrustManager) trustManagers[0]) + .hostnameVerifier(hostnameVerifier) + .build(); + } catch (GeneralSecurityException e) { + throw new RuntimeException(e); + } + } + + private KeyStore newEmptyKeyStore(char[] password) throws GeneralSecurityException { + try { + KeyStore keyStore = KeyStore.getInstance(KeyStore.getDefaultType()); + keyStore.load(null, password); + return keyStore; + } catch (IOException e) { + throw new AssertionError(e); + } + } + + /** + * Convert the HTTP request body to a string. + * + * @param requestBody The HTTP request object + * @return The string representation of the HTTP request body + * @throws ApiException If fail to serialize the request body object into a string + */ + private String requestBodyToString(RequestBody requestBody) throws ApiException { + if (requestBody != null) { + try { + final Buffer buffer = new Buffer(); + requestBody.writeTo(buffer); + return buffer.readUtf8(); + } catch (final IOException e) { + throw new ApiException(e); + } + } + + // empty http request body + return ""; + } +} diff --git a/src/main/java/com/easemob/im/ApiException.java b/src/main/java/com/easemob/im/ApiException.java new file mode 100644 index 000000000..517414cbe --- /dev/null +++ b/src/main/java/com/easemob/im/ApiException.java @@ -0,0 +1,165 @@ +/* + * EMService + * Easemob Rest API + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.easemob.im; + +import java.util.Map; +import java.util.List; + + +/** + *

ApiException class.

+ */ +@SuppressWarnings("serial") +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-01-25T14:51:53.998371+08:00[Asia/Shanghai]") +public class ApiException extends Exception { + private int code = 0; + private Map> responseHeaders = null; + private String responseBody = null; + + /** + *

Constructor for ApiException.

+ */ + public ApiException() {} + + /** + *

Constructor for ApiException.

+ * + * @param throwable a {@link java.lang.Throwable} object + */ + public ApiException(Throwable throwable) { + super(throwable); + } + + /** + *

Constructor for ApiException.

+ * + * @param message the error message + */ + public ApiException(String message) { + super(message); + } + + /** + *

Constructor for ApiException.

+ * + * @param message the error message + * @param throwable a {@link java.lang.Throwable} object + * @param code HTTP status code + * @param responseHeaders a {@link java.util.Map} of HTTP response headers + * @param responseBody the response body + */ + public ApiException(String message, Throwable throwable, int code, Map> responseHeaders, String responseBody) { + super(message, throwable); + this.code = code; + this.responseHeaders = responseHeaders; + this.responseBody = responseBody; + } + + /** + *

Constructor for ApiException.

+ * + * @param message the error message + * @param code HTTP status code + * @param responseHeaders a {@link java.util.Map} of HTTP response headers + * @param responseBody the response body + */ + public ApiException(String message, int code, Map> responseHeaders, String responseBody) { + this(message, (Throwable) null, code, responseHeaders, responseBody); + } + + /** + *

Constructor for ApiException.

+ * + * @param message the error message + * @param throwable a {@link java.lang.Throwable} object + * @param code HTTP status code + * @param responseHeaders a {@link java.util.Map} of HTTP response headers + */ + public ApiException(String message, Throwable throwable, int code, Map> responseHeaders) { + this(message, throwable, code, responseHeaders, null); + } + + /** + *

Constructor for ApiException.

+ * + * @param code HTTP status code + * @param responseHeaders a {@link java.util.Map} of HTTP response headers + * @param responseBody the response body + */ + public ApiException(int code, Map> responseHeaders, String responseBody) { + this("Response Code: " + code + " Response Body: " + responseBody, (Throwable) null, code, responseHeaders, responseBody); + } + + /** + *

Constructor for ApiException.

+ * + * @param code HTTP status code + * @param message a {@link java.lang.String} object + */ + public ApiException(int code, String message) { + super(message); + this.code = code; + } + + /** + *

Constructor for ApiException.

+ * + * @param code HTTP status code + * @param message the error message + * @param responseHeaders a {@link java.util.Map} of HTTP response headers + * @param responseBody the response body + */ + public ApiException(int code, String message, Map> responseHeaders, String responseBody) { + this(code, message); + this.responseHeaders = responseHeaders; + this.responseBody = responseBody; + } + + /** + * Get the HTTP status code. + * + * @return HTTP status code + */ + public int getCode() { + return code; + } + + /** + * Get the HTTP response headers. + * + * @return A map of list of string + */ + public Map> getResponseHeaders() { + return responseHeaders; + } + + /** + * Get the HTTP response body. + * + * @return Response body in the form of string + */ + public String getResponseBody() { + return responseBody; + } + + /** + * Get the exception message including HTTP response data. + * + * @return The exception message + */ + public String getMessage() { + return String.format("Message: %s%nHTTP response code: %s%nHTTP response body: %s%nHTTP response headers: %s", + super.getMessage(), this.getCode(), this.getResponseBody(), this.getResponseHeaders()); + } +} diff --git a/src/main/java/com/easemob/im/ApiResponse.java b/src/main/java/com/easemob/im/ApiResponse.java new file mode 100644 index 000000000..fdfce5aae --- /dev/null +++ b/src/main/java/com/easemob/im/ApiResponse.java @@ -0,0 +1,76 @@ +/* + * EMService + * Easemob Rest API + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.easemob.im; + +import java.util.List; +import java.util.Map; + +/** + * API response returned by API call. + */ +public class ApiResponse { + final private int statusCode; + final private Map> headers; + final private T data; + + /** + *

Constructor for ApiResponse.

+ * + * @param statusCode The status code of HTTP response + * @param headers The headers of HTTP response + */ + public ApiResponse(int statusCode, Map> headers) { + this(statusCode, headers, null); + } + + /** + *

Constructor for ApiResponse.

+ * + * @param statusCode The status code of HTTP response + * @param headers The headers of HTTP response + * @param data The object deserialized from response bod + */ + public ApiResponse(int statusCode, Map> headers, T data) { + this.statusCode = statusCode; + this.headers = headers; + this.data = data; + } + + /** + *

Get the status code.

+ * + * @return the status code + */ + public int getStatusCode() { + return statusCode; + } + + /** + *

Get the headers.

+ * + * @return a {@link java.util.Map} of headers + */ + public Map> getHeaders() { + return headers; + } + + /** + *

Get the data.

+ * + * @return the data + */ + public T getData() { + return data; + } +} diff --git a/src/main/java/com/easemob/im/Configuration.java b/src/main/java/com/easemob/im/Configuration.java new file mode 100644 index 000000000..2b9f401b7 --- /dev/null +++ b/src/main/java/com/easemob/im/Configuration.java @@ -0,0 +1,41 @@ +/* + * EMService + * Easemob Rest API + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.easemob.im; + +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-01-25T14:51:53.998371+08:00[Asia/Shanghai]") +public class Configuration { + public static final String VERSION = "1.0.0"; + + private static ApiClient defaultApiClient = new ApiClient(); + + /** + * Get the default API client, which would be used when creating API + * instances without providing an API client. + * + * @return Default API client + */ + public static ApiClient getDefaultApiClient() { + return defaultApiClient; + } + + /** + * Set the default API client, which would be used when creating API + * instances without providing an API client. + * + * @param apiClient API client + */ + public static void setDefaultApiClient(ApiClient apiClient) { + defaultApiClient = apiClient; + } +} diff --git a/src/main/java/com/easemob/im/GzipRequestInterceptor.java b/src/main/java/com/easemob/im/GzipRequestInterceptor.java new file mode 100644 index 000000000..5b28fcea3 --- /dev/null +++ b/src/main/java/com/easemob/im/GzipRequestInterceptor.java @@ -0,0 +1,85 @@ +/* + * EMService + * Easemob Rest API + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.easemob.im; + +import okhttp3.*; +import okio.Buffer; +import okio.BufferedSink; +import okio.GzipSink; +import okio.Okio; + +import java.io.IOException; + +/** + * Encodes request bodies using gzip. + * + * Taken from https://github.com/square/okhttp/issues/350 + */ +class GzipRequestInterceptor implements Interceptor { + @Override + public Response intercept(Chain chain) throws IOException { + Request originalRequest = chain.request(); + if (originalRequest.body() == null || originalRequest.header("Content-Encoding") != null) { + return chain.proceed(originalRequest); + } + + Request compressedRequest = originalRequest.newBuilder() + .header("Content-Encoding", "gzip") + .method(originalRequest.method(), forceContentLength(gzip(originalRequest.body()))) + .build(); + return chain.proceed(compressedRequest); + } + + private RequestBody forceContentLength(final RequestBody requestBody) throws IOException { + final Buffer buffer = new Buffer(); + requestBody.writeTo(buffer); + return new RequestBody() { + @Override + public MediaType contentType() { + return requestBody.contentType(); + } + + @Override + public long contentLength() { + return buffer.size(); + } + + @Override + public void writeTo(BufferedSink sink) throws IOException { + sink.write(buffer.snapshot()); + } + }; + } + + private RequestBody gzip(final RequestBody body) { + return new RequestBody() { + @Override + public MediaType contentType() { + return body.contentType(); + } + + @Override + public long contentLength() { + return -1; // We don't know the compressed length in advance! + } + + @Override + public void writeTo(BufferedSink sink) throws IOException { + BufferedSink gzipSink = Okio.buffer(new GzipSink(sink)); + body.writeTo(gzipSink); + gzipSink.close(); + } + }; + } +} diff --git a/src/main/java/com/easemob/im/JSON.java b/src/main/java/com/easemob/im/JSON.java new file mode 100644 index 000000000..73e0716d7 --- /dev/null +++ b/src/main/java/com/easemob/im/JSON.java @@ -0,0 +1,397 @@ +/* + * EMService + * Easemob Rest API + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.easemob.im; + +import com.google.gson.*; +import com.google.gson.internal.bind.util.ISO8601Utils; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import io.gsonfire.GsonFireBuilder; +import io.gsonfire.TypeSelector; + +import okio.ByteString; + +import java.io.IOException; +import java.io.StringReader; +import java.lang.reflect.Type; +import java.text.DateFormat; +import java.text.ParseException; +import java.text.ParsePosition; +import java.time.LocalDate; +import java.time.OffsetDateTime; +import java.time.format.DateTimeFormatter; +import java.util.Date; +import java.util.Locale; +import java.util.Map; +import java.util.HashMap; + +/* + * A JSON utility class + * + * NOTE: in the future, this class may be converted to static, which may break + * backward-compatibility + */ +public class JSON { + private static Gson gson; + private static boolean isLenientOnJson = false; + private static DateTypeAdapter dateTypeAdapter = new DateTypeAdapter(); + private static SqlDateTypeAdapter sqlDateTypeAdapter = new SqlDateTypeAdapter(); + private static OffsetDateTimeTypeAdapter offsetDateTimeTypeAdapter = new OffsetDateTimeTypeAdapter(); + private static LocalDateTypeAdapter localDateTypeAdapter = new LocalDateTypeAdapter(); + private static ByteArrayAdapter byteArrayAdapter = new ByteArrayAdapter(); + + @SuppressWarnings("unchecked") + public static GsonBuilder createGson() { + GsonFireBuilder fireBuilder = new GsonFireBuilder() + ; + GsonBuilder builder = fireBuilder.createGsonBuilder(); + return builder; + } + + private static String getDiscriminatorValue(JsonElement readElement, String discriminatorField) { + JsonElement element = readElement.getAsJsonObject().get(discriminatorField); + if (null == element) { + throw new IllegalArgumentException("missing discriminator field: <" + discriminatorField + ">"); + } + return element.getAsString(); + } + + /** + * Returns the Java class that implements the OpenAPI schema for the specified discriminator value. + * + * @param classByDiscriminatorValue The map of discriminator values to Java classes. + * @param discriminatorValue The value of the OpenAPI discriminator in the input data. + * @return The Java class that implements the OpenAPI schema + */ + private static Class getClassByDiscriminator(Map classByDiscriminatorValue, String discriminatorValue) { + Class clazz = (Class) classByDiscriminatorValue.get(discriminatorValue); + if (null == clazz) { + throw new IllegalArgumentException("cannot determine model class of name: <" + discriminatorValue + ">"); + } + return clazz; + } + + { + GsonBuilder gsonBuilder = createGson(); + gsonBuilder.setObjectToNumberStrategy(ToNumberPolicy.LAZILY_PARSED_NUMBER); + gsonBuilder.registerTypeAdapter(Date.class, dateTypeAdapter); + gsonBuilder.registerTypeAdapter(java.sql.Date.class, sqlDateTypeAdapter); + gsonBuilder.registerTypeAdapter(OffsetDateTime.class, offsetDateTimeTypeAdapter); + gsonBuilder.registerTypeAdapter(LocalDate.class, localDateTypeAdapter); + gsonBuilder.registerTypeAdapter(byte[].class, byteArrayAdapter); + gson = gsonBuilder.create(); + } + + /** + * Get Gson. + * + * @return Gson + */ + public static Gson getGson() { + return gson; + } + + /** + * Set Gson. + * + * @param gson Gson + */ + public static void setGson(Gson gson) { + JSON.gson = gson; + } + + public static void setLenientOnJson(boolean lenientOnJson) { + isLenientOnJson = lenientOnJson; + } + + /** + * Serialize the given Java object into JSON string. + * + * @param obj Object + * @return String representation of the JSON + */ + public static String serialize(Object obj) { + return gson.toJson(obj); + } + + /** + * Deserialize the given JSON string to Java object. + * + * @param Type + * @param body The JSON string + * @param returnType The type to deserialize into + * @return The deserialized Java object + */ + @SuppressWarnings("unchecked") + public static T deserialize(String body, Type returnType) { + try { + if (isLenientOnJson) { + JsonReader jsonReader = new JsonReader(new StringReader(body)); + // see https://google-gson.googlecode.com/svn/trunk/gson/docs/javadocs/com/google/gson/stream/JsonReader.html#setLenient(boolean) + jsonReader.setLenient(true); + return gson.fromJson(jsonReader, returnType); + } else { + return gson.fromJson(body, returnType); + } + } catch (JsonParseException e) { + // Fallback processing when failed to parse JSON form response body: + // return the response body string directly for the String return type; + if (returnType.equals(String.class)) { + return (T) body; + } else { + throw (e); + } + } + } + + /** + * Gson TypeAdapter for Byte Array type + */ + public static class ByteArrayAdapter extends TypeAdapter { + + @Override + public void write(JsonWriter out, byte[] value) throws IOException { + if (value == null) { + out.nullValue(); + } else { + out.value(ByteString.of(value).base64()); + } + } + + @Override + public byte[] read(JsonReader in) throws IOException { + switch (in.peek()) { + case NULL: + in.nextNull(); + return null; + default: + String bytesAsBase64 = in.nextString(); + ByteString byteString = ByteString.decodeBase64(bytesAsBase64); + return byteString.toByteArray(); + } + } + } + + /** + * Gson TypeAdapter for JSR310 OffsetDateTime type + */ + public static class OffsetDateTimeTypeAdapter extends TypeAdapter { + + private DateTimeFormatter formatter; + + public OffsetDateTimeTypeAdapter() { + this(DateTimeFormatter.ISO_OFFSET_DATE_TIME); + } + + public OffsetDateTimeTypeAdapter(DateTimeFormatter formatter) { + this.formatter = formatter; + } + + public void setFormat(DateTimeFormatter dateFormat) { + this.formatter = dateFormat; + } + + @Override + public void write(JsonWriter out, OffsetDateTime date) throws IOException { + if (date == null) { + out.nullValue(); + } else { + out.value(formatter.format(date)); + } + } + + @Override + public OffsetDateTime read(JsonReader in) throws IOException { + switch (in.peek()) { + case NULL: + in.nextNull(); + return null; + default: + String date = in.nextString(); + if (date.endsWith("+0000")) { + date = date.substring(0, date.length()-5) + "Z"; + } + return OffsetDateTime.parse(date, formatter); + } + } + } + + /** + * Gson TypeAdapter for JSR310 LocalDate type + */ + public static class LocalDateTypeAdapter extends TypeAdapter { + + private DateTimeFormatter formatter; + + public LocalDateTypeAdapter() { + this(DateTimeFormatter.ISO_LOCAL_DATE); + } + + public LocalDateTypeAdapter(DateTimeFormatter formatter) { + this.formatter = formatter; + } + + public void setFormat(DateTimeFormatter dateFormat) { + this.formatter = dateFormat; + } + + @Override + public void write(JsonWriter out, LocalDate date) throws IOException { + if (date == null) { + out.nullValue(); + } else { + out.value(formatter.format(date)); + } + } + + @Override + public LocalDate read(JsonReader in) throws IOException { + switch (in.peek()) { + case NULL: + in.nextNull(); + return null; + default: + String date = in.nextString(); + return LocalDate.parse(date, formatter); + } + } + } + + public static void setOffsetDateTimeFormat(DateTimeFormatter dateFormat) { + offsetDateTimeTypeAdapter.setFormat(dateFormat); + } + + public static void setLocalDateFormat(DateTimeFormatter dateFormat) { + localDateTypeAdapter.setFormat(dateFormat); + } + + /** + * Gson TypeAdapter for java.sql.Date type + * If the dateFormat is null, a simple "yyyy-MM-dd" format will be used + * (more efficient than SimpleDateFormat). + */ + public static class SqlDateTypeAdapter extends TypeAdapter { + + private DateFormat dateFormat; + + public SqlDateTypeAdapter() {} + + public SqlDateTypeAdapter(DateFormat dateFormat) { + this.dateFormat = dateFormat; + } + + public void setFormat(DateFormat dateFormat) { + this.dateFormat = dateFormat; + } + + @Override + public void write(JsonWriter out, java.sql.Date date) throws IOException { + if (date == null) { + out.nullValue(); + } else { + String value; + if (dateFormat != null) { + value = dateFormat.format(date); + } else { + value = date.toString(); + } + out.value(value); + } + } + + @Override + public java.sql.Date read(JsonReader in) throws IOException { + switch (in.peek()) { + case NULL: + in.nextNull(); + return null; + default: + String date = in.nextString(); + try { + if (dateFormat != null) { + return new java.sql.Date(dateFormat.parse(date).getTime()); + } + return new java.sql.Date(ISO8601Utils.parse(date, new ParsePosition(0)).getTime()); + } catch (ParseException e) { + throw new JsonParseException(e); + } + } + } + } + + /** + * Gson TypeAdapter for java.util.Date type + * If the dateFormat is null, ISO8601Utils will be used. + */ + public static class DateTypeAdapter extends TypeAdapter { + + private DateFormat dateFormat; + + public DateTypeAdapter() {} + + public DateTypeAdapter(DateFormat dateFormat) { + this.dateFormat = dateFormat; + } + + public void setFormat(DateFormat dateFormat) { + this.dateFormat = dateFormat; + } + + @Override + public void write(JsonWriter out, Date date) throws IOException { + if (date == null) { + out.nullValue(); + } else { + String value; + if (dateFormat != null) { + value = dateFormat.format(date); + } else { + value = ISO8601Utils.format(date, true); + } + out.value(value); + } + } + + @Override + public Date read(JsonReader in) throws IOException { + try { + switch (in.peek()) { + case NULL: + in.nextNull(); + return null; + default: + String date = in.nextString(); + try { + if (dateFormat != null) { + return dateFormat.parse(date); + } + return ISO8601Utils.parse(date, new ParsePosition(0)); + } catch (ParseException e) { + throw new JsonParseException(e); + } + } + } catch (IllegalArgumentException e) { + throw new JsonParseException(e); + } + } + } + + public static void setDateFormat(DateFormat dateFormat) { + dateTypeAdapter.setFormat(dateFormat); + } + + public static void setSqlDateFormat(DateFormat dateFormat) { + sqlDateTypeAdapter.setFormat(dateFormat); + } +} diff --git a/src/main/java/com/easemob/im/Pair.java b/src/main/java/com/easemob/im/Pair.java new file mode 100644 index 000000000..62f8bfcb0 --- /dev/null +++ b/src/main/java/com/easemob/im/Pair.java @@ -0,0 +1,57 @@ +/* + * EMService + * Easemob Rest API + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.easemob.im; + +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-01-25T14:51:53.998371+08:00[Asia/Shanghai]") +public class Pair { + private String name = ""; + private String value = ""; + + public Pair (String name, String value) { + setName(name); + setValue(value); + } + + private void setName(String name) { + if (!isValidString(name)) { + return; + } + + this.name = name; + } + + private void setValue(String value) { + if (!isValidString(value)) { + return; + } + + this.value = value; + } + + public String getName() { + return this.name; + } + + public String getValue() { + return this.value; + } + + private boolean isValidString(String arg) { + if (arg == null) { + return false; + } + + return true; + } +} diff --git a/src/main/java/com/easemob/im/ProgressRequestBody.java b/src/main/java/com/easemob/im/ProgressRequestBody.java new file mode 100644 index 000000000..70c53e523 --- /dev/null +++ b/src/main/java/com/easemob/im/ProgressRequestBody.java @@ -0,0 +1,73 @@ +/* + * EMService + * Easemob Rest API + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.easemob.im; + +import okhttp3.MediaType; +import okhttp3.RequestBody; + +import java.io.IOException; + +import okio.Buffer; +import okio.BufferedSink; +import okio.ForwardingSink; +import okio.Okio; +import okio.Sink; + +public class ProgressRequestBody extends RequestBody { + + private final RequestBody requestBody; + + private final ApiCallback callback; + + public ProgressRequestBody(RequestBody requestBody, ApiCallback callback) { + this.requestBody = requestBody; + this.callback = callback; + } + + @Override + public MediaType contentType() { + return requestBody.contentType(); + } + + @Override + public long contentLength() throws IOException { + return requestBody.contentLength(); + } + + @Override + public void writeTo(BufferedSink sink) throws IOException { + BufferedSink bufferedSink = Okio.buffer(sink(sink)); + requestBody.writeTo(bufferedSink); + bufferedSink.flush(); + } + + private Sink sink(Sink sink) { + return new ForwardingSink(sink) { + + long bytesWritten = 0L; + long contentLength = 0L; + + @Override + public void write(Buffer source, long byteCount) throws IOException { + super.write(source, byteCount); + if (contentLength == 0) { + contentLength = contentLength(); + } + + bytesWritten += byteCount; + callback.onUploadProgress(bytesWritten, contentLength, bytesWritten == contentLength); + } + }; + } +} diff --git a/src/main/java/com/easemob/im/ProgressResponseBody.java b/src/main/java/com/easemob/im/ProgressResponseBody.java new file mode 100644 index 000000000..abbc7f132 --- /dev/null +++ b/src/main/java/com/easemob/im/ProgressResponseBody.java @@ -0,0 +1,70 @@ +/* + * EMService + * Easemob Rest API + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.easemob.im; + +import okhttp3.MediaType; +import okhttp3.ResponseBody; + +import java.io.IOException; + +import okio.Buffer; +import okio.BufferedSource; +import okio.ForwardingSource; +import okio.Okio; +import okio.Source; + +public class ProgressResponseBody extends ResponseBody { + + private final ResponseBody responseBody; + private final ApiCallback callback; + private BufferedSource bufferedSource; + + public ProgressResponseBody(ResponseBody responseBody, ApiCallback callback) { + this.responseBody = responseBody; + this.callback = callback; + } + + @Override + public MediaType contentType() { + return responseBody.contentType(); + } + + @Override + public long contentLength() { + return responseBody.contentLength(); + } + + @Override + public BufferedSource source() { + if (bufferedSource == null) { + bufferedSource = Okio.buffer(source(responseBody.source())); + } + return bufferedSource; + } + + private Source source(Source source) { + return new ForwardingSource(source) { + long totalBytesRead = 0L; + + @Override + public long read(Buffer sink, long byteCount) throws IOException { + long bytesRead = super.read(sink, byteCount); + // read() returns the number of bytes read, or -1 if this source is exhausted. + totalBytesRead += bytesRead != -1 ? bytesRead : 0; + callback.onDownloadProgress(totalBytesRead, responseBody.contentLength(), bytesRead == -1); + return bytesRead; + } + }; + } +} diff --git a/src/main/java/com/easemob/im/ServerConfiguration.java b/src/main/java/com/easemob/im/ServerConfiguration.java new file mode 100644 index 000000000..0ca398f78 --- /dev/null +++ b/src/main/java/com/easemob/im/ServerConfiguration.java @@ -0,0 +1,58 @@ +package com.easemob.im; + +import java.util.Map; + +/** + * Representing a Server configuration. + */ +public class ServerConfiguration { + public String URL; + public String description; + public Map variables; + + /** + * @param URL A URL to the target host. + * @param description A description of the host designated by the URL. + * @param variables A map between a variable name and its value. The value is used for substitution in the server's URL template. + */ + public ServerConfiguration(String URL, String description, Map variables) { + this.URL = URL; + this.description = description; + this.variables = variables; + } + + /** + * Format URL template using given variables. + * + * @param variables A map between a variable name and its value. + * @return Formatted URL. + */ + public String URL(Map variables) { + String url = this.URL; + + // go through variables and replace placeholders + for (Map.Entry variable: this.variables.entrySet()) { + String name = variable.getKey(); + ServerVariable serverVariable = variable.getValue(); + String value = serverVariable.defaultValue; + + if (variables != null && variables.containsKey(name)) { + value = variables.get(name); + if (serverVariable.enumValues.size() > 0 && !serverVariable.enumValues.contains(value)) { + throw new IllegalArgumentException("The variable " + name + " in the server URL has invalid value " + value + "."); + } + } + url = url.replace("{" + name + "}", value); + } + return url; + } + + /** + * Format URL template using default server variables. + * + * @return Formatted URL. + */ + public String URL() { + return URL(null); + } +} diff --git a/src/main/java/com/easemob/im/ServerVariable.java b/src/main/java/com/easemob/im/ServerVariable.java new file mode 100644 index 000000000..fff21e047 --- /dev/null +++ b/src/main/java/com/easemob/im/ServerVariable.java @@ -0,0 +1,23 @@ +package com.easemob.im; + +import java.util.HashSet; + +/** + * Representing a Server Variable for server URL template substitution. + */ +public class ServerVariable { + public String description; + public String defaultValue; + public HashSet enumValues = null; + + /** + * @param description A description for the server variable. + * @param defaultValue The default value to use for substitution. + * @param enumValues An enumeration of string values to be used if the substitution options are from a limited set. + */ + public ServerVariable(String description, String defaultValue, HashSet enumValues) { + this.description = description; + this.defaultValue = defaultValue; + this.enumValues = enumValues; + } +} diff --git a/src/main/java/com/easemob/im/StringUtil.java b/src/main/java/com/easemob/im/StringUtil.java new file mode 100644 index 000000000..8e0538f3a --- /dev/null +++ b/src/main/java/com/easemob/im/StringUtil.java @@ -0,0 +1,83 @@ +/* + * EMService + * Easemob Rest API + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.easemob.im; + +import java.util.Collection; +import java.util.Iterator; + +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-01-25T14:51:53.998371+08:00[Asia/Shanghai]") +public class StringUtil { + /** + * Check if the given array contains the given value (with case-insensitive comparison). + * + * @param array The array + * @param value The value to search + * @return true if the array contains the value + */ + public static boolean containsIgnoreCase(String[] array, String value) { + for (String str : array) { + if (value == null && str == null) { + return true; + } + if (value != null && value.equalsIgnoreCase(str)) { + return true; + } + } + return false; + } + + /** + * Join an array of strings with the given separator. + *

+ * Note: This might be replaced by utility method from commons-lang or guava someday + * if one of those libraries is added as dependency. + *

+ * + * @param array The array of strings + * @param separator The separator + * @return the resulting string + */ + public static String join(String[] array, String separator) { + int len = array.length; + if (len == 0) { + return ""; + } + + StringBuilder out = new StringBuilder(); + out.append(array[0]); + for (int i = 1; i < len; i++) { + out.append(separator).append(array[i]); + } + return out.toString(); + } + + /** + * Join a list of strings with the given separator. + * + * @param list The list of strings + * @param separator The separator + * @return the resulting string + */ + public static String join(Collection list, String separator) { + Iterator iterator = list.iterator(); + StringBuilder out = new StringBuilder(); + if (iterator.hasNext()) { + out.append(iterator.next()); + } + while (iterator.hasNext()) { + out.append(separator).append(iterator.next()); + } + return out.toString(); + } +} diff --git a/im-sdk-core/src/main/java/com/easemob/im/server/api/token/agora/AccessToken2.java b/src/main/java/com/easemob/im/agora/AccessToken2.java similarity index 65% rename from im-sdk-core/src/main/java/com/easemob/im/server/api/token/agora/AccessToken2.java rename to src/main/java/com/easemob/im/agora/AccessToken2.java index 354bc6412..d555ff1cd 100644 --- a/im-sdk-core/src/main/java/com/easemob/im/server/api/token/agora/AccessToken2.java +++ b/src/main/java/com/easemob/im/agora/AccessToken2.java @@ -1,39 +1,89 @@ -package com.easemob.im.server.api.token.agora; +package com.easemob.im.agora; import javax.crypto.Mac; import javax.crypto.spec.SecretKeySpec; import java.util.Map; import java.util.TreeMap; -/** - * This class is copied from - * Agora Authentication Tool - *

- * It serves as an authentication protocol among multiple Agora and Easemob Services - *

- * Do not change this class as it might break the authentication process - */ public class AccessToken2 { + public enum PrivilegeRtc { + PRIVILEGE_JOIN_CHANNEL(1), + PRIVILEGE_PUBLISH_AUDIO_STREAM(2), + PRIVILEGE_PUBLISH_VIDEO_STREAM(3), + PRIVILEGE_PUBLISH_DATA_STREAM(4), + ; + + public short intValue; + + PrivilegeRtc(int value) { + intValue = (short) value; + } + } + + public enum PrivilegeRtm { + PRIVILEGE_LOGIN(1), + ; + + public short intValue; + + PrivilegeRtm(int value) { + intValue = (short) value; + } + } + + public enum PrivilegeFpa { + PRIVILEGE_LOGIN(1), + ; + + public short intValue; + + PrivilegeFpa(int value) { + intValue = (short) value; + } + } + + public enum PrivilegeChat { + PRIVILEGE_CHAT_USER(1), + PRIVILEGE_CHAT_APP(2), + ; + + public short intValue; + + PrivilegeChat(int value) { + intValue = (short) value; + } + } + + public enum PrivilegeEducation { + PRIVILEGE_ROOM_USER(1), + PRIVILEGE_USER(2), + PRIVILEGE_APP(3), + ; + + public short intValue; + + PrivilegeEducation(int value) { + intValue = (short) value; + } + } + + private static final String VERSION = "007"; public static final short SERVICE_TYPE_RTC = 1; public static final short SERVICE_TYPE_RTM = 2; - public static final short SERVICE_TYPE_STREAMING = 3; + public static final short SERVICE_TYPE_FPA = 4; public static final short SERVICE_TYPE_CHAT = 5; - private static final String VERSION = "007"; + public static final short SERVICE_TYPE_EDUCATION = 7; + public String appCert = ""; public String appId = ""; public int expire; public int issueTs; public int salt; public Map services = new TreeMap<>(); + public AccessToken2() { } - /** - * - * @param appId appId - * @param appCert appCert - * @param expire expire Duration in seconds - */ public AccessToken2(String appId, String appCert, int expire) { this.appCert = appCert; this.appId = appId; @@ -42,17 +92,6 @@ public AccessToken2(String appId, String appCert, int expire) { this.salt = Utils.randomInt(); } - public static String getUidStr(int uid) { - if (uid == 0) { - return ""; - } - return String.valueOf(uid); - } - - public static String getVersion() { - return VERSION; - } - public void addService(Service service) { this.services.put(service.getServiceType(), service); } @@ -62,9 +101,8 @@ public String build() throws Exception { return ""; } - ByteBuf buf = - new ByteBuf().put(this.appId).put(this.issueTs).put(this.expire).put(this.salt) - .put((short) this.services.size()); + ByteBuf buf = new ByteBuf().put(this.appId).put(this.issueTs).put(this.expire).put(this.salt) + .put((short) this.services.size()); byte[] signing = getSign(); this.services.forEach((k, v) -> { @@ -89,14 +127,16 @@ public Service getService(short serviceType) { if (serviceType == SERVICE_TYPE_RTM) { return new ServiceRtm(); } - if (serviceType == SERVICE_TYPE_STREAMING) { - return new ServiceStreaming(); + if (serviceType == SERVICE_TYPE_FPA) { + return new ServiceFpa(); } if (serviceType == SERVICE_TYPE_CHAT) { return new ServiceChat(); } - throw new IllegalArgumentException( - String.format("unknown service type: `%d`", serviceType)); + if (serviceType == SERVICE_TYPE_EDUCATION) { + return new ServiceEducation(); + } + throw new IllegalArgumentException(String.format("unknown service type: `%d`", serviceType)); } public byte[] getSign() throws Exception { @@ -107,78 +147,46 @@ public byte[] getSign() throws Exception { return mac.doFinal(signing); } - public boolean parse(String token) { - if (!getVersion().equals(token.substring(0, Utils.VERSION_LENGTH))) { - return false; - } - byte[] data = Utils.decompress(Utils.base64Decode(token.substring(Utils.VERSION_LENGTH))); - ByteBuf buff = new ByteBuf(data); - String signature = buff.readString(); - this.appId = buff.readString(); - this.issueTs = buff.readInt(); - this.expire = buff.readInt(); - this.salt = buff.readInt(); - short servicesNum = buff.readShort(); - - for (int i = 0; i < servicesNum; i++) { - short serviceType = buff.readShort(); - Service service = getService(serviceType); - service.unpack(buff); - this.services.put(serviceType, service); + public static String getUidStr(int uid) { + if (uid == 0) { + return ""; } - return true; + return String.valueOf(uid & 0xFFFFFFFFL); } - public enum PrivilegeRtc { - PRIVILEGE_JOIN_CHANNEL(1), - PRIVILEGE_PUBLISH_AUDIO_STREAM(2), - PRIVILEGE_PUBLISH_VIDEO_STREAM(3), - PRIVILEGE_PUBLISH_DATA_STREAM(4), - ; - - public short intValue; - - PrivilegeRtc(int value) { - intValue = (short) value; - } + public static String getVersion() { + return VERSION; } - public enum PrivilegeRtm { - PRIVILEGE_JOIN_LOGIN(1), - ; - - public short intValue; - - PrivilegeRtm(int value) { - intValue = (short) value; + public boolean parse(String token) { + if (!getVersion().equals(token.substring(0, Utils.VERSION_LENGTH))) { + return false; } - } - public enum PrivilegeStreaming { - PRIVILEGE_PUBLISH_MIX_STREAM(1), - PRIVILEGE_PUBLISH_RAW_STREAM(2), - ; - - public short intValue; - - PrivilegeStreaming(int value) { - intValue = (short) value; + try { + byte[] data = Utils.decompress(Utils.base64Decode(token.substring(Utils.VERSION_LENGTH))); + ByteBuf buff = new ByteBuf(data); + String signature = buff.readString(); + this.appId = buff.readString(); + this.issueTs = buff.readInt(); + this.expire = buff.readInt(); + this.salt = buff.readInt(); + short servicesNum = buff.readShort(); + + for (int i = 0; i < servicesNum; i++) { + short serviceType = buff.readShort(); + Service service = getService(serviceType); + service.unpack(buff); + this.services.put(serviceType, service); + } + } catch (Exception e) { + e.printStackTrace(); + return false; } - } - - public enum PrivilegeChat { - PRIVILEGE_CHAT_USER(1), - PRIVILEGE_CHAT_APP(2), - ; - public short intValue; - - PrivilegeChat(int value) { - intValue = (short) value; - } + return true; } - public static class Service { public short type; public TreeMap privileges = new TreeMap() { @@ -199,10 +207,18 @@ public void addPrivilegeRtm(PrivilegeRtm privilege, int expire) { this.privileges.put(privilege.intValue, expire); } + public void addPrivilegeFpa(PrivilegeFpa privilege, int expire) { + this.privileges.put(privilege.intValue, expire); + } + public void addPrivilegeChat(PrivilegeChat privilege, int expire) { this.privileges.put(privilege.intValue, expire); } + public void addPrivilegeEducation(PrivilegeEducation privilege, int expire) { + this.privileges.put(privilege.intValue, expire); + } + public TreeMap getPrivileges() { return this.privileges; } @@ -220,7 +236,6 @@ public void unpack(ByteBuf byteBuf) { } } - public static class ServiceRtc extends Service { public String channelName; public String uid; @@ -254,7 +269,6 @@ public void unpack(ByteBuf byteBuf) { } } - public static class ServiceRtm extends Service { public String userId; @@ -281,33 +295,20 @@ public void unpack(ByteBuf byteBuf) { } } - - public static class ServiceStreaming extends Service { - public String channelName; - public String uid; - - public ServiceStreaming() { - this.type = SERVICE_TYPE_STREAMING; - } - - public ServiceStreaming(String channelName, String uid) { - this.type = SERVICE_TYPE_STREAMING; - this.channelName = channelName; - this.uid = uid; + public static class ServiceFpa extends Service { + public ServiceFpa() { + this.type = SERVICE_TYPE_FPA; } public ByteBuf pack(ByteBuf buf) { - return super.pack(buf).put(this.channelName).put(this.uid); + return super.pack(buf); } public void unpack(ByteBuf byteBuf) { super.unpack(byteBuf); - this.channelName = byteBuf.readString(); - this.uid = byteBuf.readString(); } } - public static class ServiceChat extends Service { public String userId; @@ -334,4 +335,54 @@ public void unpack(ByteBuf byteBuf) { this.userId = byteBuf.readString(); } } + + public static class ServiceEducation extends Service { + public String roomUuid; + public String userUuid; + public Short role; + + public ServiceEducation() { + this.type = SERVICE_TYPE_EDUCATION; + this.roomUuid = ""; + this.userUuid = ""; + this.role = -1; + } + + public ServiceEducation(String roomUuid, String userUuid, Short role) { + this.type = SERVICE_TYPE_EDUCATION; + this.roomUuid = roomUuid; + this.userUuid = userUuid; + this.role = role; + } + + public ServiceEducation(String userUuid) { + this.type = SERVICE_TYPE_EDUCATION; + this.roomUuid = ""; + this.userUuid = userUuid; + this.role = -1; + } + + public String getRoomUuid() { + return this.roomUuid; + } + + public String getUserUuid() { + return this.userUuid; + } + + public Short getRole() { + return this.role; + } + + public ByteBuf pack(ByteBuf buf) { + return super.pack(buf).put(this.roomUuid).put(this.userUuid).put(this.role); + } + + public void unpack(ByteBuf byteBuf) { + super.unpack(byteBuf); + this.roomUuid = byteBuf.readString(); + this.userUuid = byteBuf.readString(); + this.role = byteBuf.readShort(); + } + } } diff --git a/im-sdk-core/src/main/java/com/easemob/im/server/api/token/agora/ByteBuf.java b/src/main/java/com/easemob/im/agora/ByteBuf.java similarity index 96% rename from im-sdk-core/src/main/java/com/easemob/im/server/api/token/agora/ByteBuf.java rename to src/main/java/com/easemob/im/agora/ByteBuf.java index 02a4ef3e7..857e13473 100644 --- a/im-sdk-core/src/main/java/com/easemob/im/server/api/token/agora/ByteBuf.java +++ b/src/main/java/com/easemob/im/agora/ByteBuf.java @@ -1,13 +1,10 @@ -package com.easemob.im.server.api.token.agora; +package com.easemob.im.agora; import java.nio.ByteBuffer; import java.nio.ByteOrder; import java.util.Map; import java.util.TreeMap; -/** - * Created by Li on 10/1/2016. - */ public class ByteBuf { ByteBuffer buffer = ByteBuffer.allocate(1024).order(ByteOrder.LITTLE_ENDIAN); diff --git a/src/main/java/com/easemob/im/agora/Packable.java b/src/main/java/com/easemob/im/agora/Packable.java new file mode 100644 index 000000000..12bae419e --- /dev/null +++ b/src/main/java/com/easemob/im/agora/Packable.java @@ -0,0 +1,5 @@ +package com.easemob.im.agora; + +public interface Packable { + ByteBuf marshal(ByteBuf out); +} diff --git a/im-sdk-core/src/main/java/com/easemob/im/server/api/token/agora/PackableEx.java b/src/main/java/com/easemob/im/agora/PackableEx.java similarity index 63% rename from im-sdk-core/src/main/java/com/easemob/im/server/api/token/agora/PackableEx.java rename to src/main/java/com/easemob/im/agora/PackableEx.java index b03283e91..f4e25c7b3 100644 --- a/im-sdk-core/src/main/java/com/easemob/im/server/api/token/agora/PackableEx.java +++ b/src/main/java/com/easemob/im/agora/PackableEx.java @@ -1,4 +1,4 @@ -package com.easemob.im.server.api.token.agora; +package com.easemob.im.agora; public interface PackableEx extends Packable { void unmarshal(ByteBuf in); diff --git a/im-sdk-core/src/main/java/com/easemob/im/server/api/token/agora/Utils.java b/src/main/java/com/easemob/im/agora/Utils.java similarity index 98% rename from im-sdk-core/src/main/java/com/easemob/im/server/api/token/agora/Utils.java rename to src/main/java/com/easemob/im/agora/Utils.java index f0e10c8c5..85d41eb0e 100644 --- a/im-sdk-core/src/main/java/com/easemob/im/server/api/token/agora/Utils.java +++ b/src/main/java/com/easemob/im/agora/Utils.java @@ -1,4 +1,4 @@ -package com.easemob.im.server.api.token.agora; +package com.easemob.im.agora; import javax.crypto.Mac; import javax.crypto.spec.SecretKeySpec; diff --git a/src/main/java/com/easemob/im/api/BlockApi.java b/src/main/java/com/easemob/im/api/BlockApi.java new file mode 100644 index 000000000..b25a61cd5 --- /dev/null +++ b/src/main/java/com/easemob/im/api/BlockApi.java @@ -0,0 +1,502 @@ +/* + * EMService + * Easemob Rest API + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.easemob.im.api; + +import com.easemob.im.ApiCallback; +import com.easemob.im.ApiClient; +import com.easemob.im.ApiException; +import com.easemob.im.ApiResponse; +import com.easemob.im.Configuration; +import com.easemob.im.Pair; +import com.easemob.im.ProgressRequestBody; +import com.easemob.im.ProgressResponseBody; + +import com.google.gson.reflect.TypeToken; + +import java.io.IOException; + + +import com.easemob.im.api.model.EMAddUserToBlockList; +import com.easemob.im.api.model.EMAddUserToBlockListResult; +import com.easemob.im.api.model.EMGetBlockListResult; +import com.easemob.im.api.model.EMRemoveUserFromBlockListResult; + +import java.lang.reflect.Type; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +public class BlockApi { + private ApiClient localVarApiClient; + private int localHostIndex; + private String localCustomBaseUrl; + + public BlockApi() { + this(Configuration.getDefaultApiClient()); + } + + public BlockApi(ApiClient apiClient) { + this.localVarApiClient = apiClient; + } + + public ApiClient getApiClient() { + return localVarApiClient; + } + + public void setApiClient(ApiClient apiClient) { + this.localVarApiClient = apiClient; + } + + public int getHostIndex() { + return localHostIndex; + } + + public void setHostIndex(int hostIndex) { + this.localHostIndex = hostIndex; + } + + public String getCustomBaseUrl() { + return localCustomBaseUrl; + } + + public void setCustomBaseUrl(String customBaseUrl) { + this.localCustomBaseUrl = customBaseUrl; + } + + /** + * Build call for addUserToBlockList + * @param ownerUsername (required) + * @param emAddUserToBlockList (optional) + * @param _callback Callback for upload/download progress + * @return Call to execute + * @throws ApiException If fail to serialize the request body object + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public okhttp3.Call addUserToBlockListCall(String ownerUsername, EMAddUserToBlockList emAddUserToBlockList, final ApiCallback _callback) throws ApiException { + String basePath = null; + // Operation Servers + String[] localBasePaths = new String[] { }; + + // Determine Base Path to Use + if (localCustomBaseUrl != null){ + basePath = localCustomBaseUrl; + } else if ( localBasePaths.length > 0 ) { + basePath = localBasePaths[localHostIndex]; + } else { + basePath = null; + } + + Object localVarPostBody = emAddUserToBlockList; + + // create path and map variables + String localVarPath = "/users/{owner_username}/blocks/users" + .replace("{" + "owner_username" + "}", localVarApiClient.escapeString(ownerUsername.toString())); + + List localVarQueryParams = new ArrayList(); + List localVarCollectionQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + Map localVarCookieParams = new HashMap(); + Map localVarFormParams = new HashMap(); + + final String[] localVarAccepts = { + "application/json" + }; + final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts); + if (localVarAccept != null) { + localVarHeaderParams.put("Accept", localVarAccept); + } + + final String[] localVarContentTypes = { + "application/json" + }; + final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); + if (localVarContentType != null) { + localVarHeaderParams.put("Content-Type", localVarContentType); + } + + String[] localVarAuthNames = new String[] { }; + return localVarApiClient.buildCall(basePath, localVarPath, "POST", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); + } + + @SuppressWarnings("rawtypes") + private okhttp3.Call addUserToBlockListValidateBeforeCall(String ownerUsername, EMAddUserToBlockList emAddUserToBlockList, final ApiCallback _callback) throws ApiException { + // verify the required parameter 'ownerUsername' is set + if (ownerUsername == null) { + throw new ApiException("Missing the required parameter 'ownerUsername' when calling addUserToBlockList(Async)"); + } + + return addUserToBlockListCall(ownerUsername, emAddUserToBlockList, _callback); + + } + + /** + * 添加用户至黑名单 + * 将一个或多个用户添加用户到黑名单。用户被加入黑名单后,无法向你发送消息,也无法发送好友申请。用户可以将任何其他用户添加到黑名单列表,无论该用户是否是好友。好友被加入黑名单后仍在好友列表上显示。每个用户的黑名单人数上限为 500。文档介绍:https://docs-im-beta.easemob.com/document/server-side/user_relationship.html#%E6%B7%BB%E5%8A%A0%E7%94%A8%E6%88%B7%E8%87%B3%E9%BB%91%E5%90%8D%E5%8D%95 + * @param ownerUsername (required) + * @param emAddUserToBlockList (optional) + * @return EMAddUserToBlockListResult + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public EMAddUserToBlockListResult addUserToBlockList(String ownerUsername, EMAddUserToBlockList emAddUserToBlockList) throws ApiException { + ApiResponse localVarResp = addUserToBlockListWithHttpInfo(ownerUsername, emAddUserToBlockList); + return localVarResp.getData(); + } + + /** + * 添加用户至黑名单 + * 将一个或多个用户添加用户到黑名单。用户被加入黑名单后,无法向你发送消息,也无法发送好友申请。用户可以将任何其他用户添加到黑名单列表,无论该用户是否是好友。好友被加入黑名单后仍在好友列表上显示。每个用户的黑名单人数上限为 500。文档介绍:https://docs-im-beta.easemob.com/document/server-side/user_relationship.html#%E6%B7%BB%E5%8A%A0%E7%94%A8%E6%88%B7%E8%87%B3%E9%BB%91%E5%90%8D%E5%8D%95 + * @param ownerUsername (required) + * @param emAddUserToBlockList (optional) + * @return ApiResponse<EMAddUserToBlockListResult> + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public ApiResponse addUserToBlockListWithHttpInfo(String ownerUsername, EMAddUserToBlockList emAddUserToBlockList) throws ApiException { + okhttp3.Call localVarCall = addUserToBlockListValidateBeforeCall(ownerUsername, emAddUserToBlockList, null); + Type localVarReturnType = new TypeToken(){}.getType(); + return localVarApiClient.execute(localVarCall, localVarReturnType); + } + + /** + * 添加用户至黑名单 (asynchronously) + * 将一个或多个用户添加用户到黑名单。用户被加入黑名单后,无法向你发送消息,也无法发送好友申请。用户可以将任何其他用户添加到黑名单列表,无论该用户是否是好友。好友被加入黑名单后仍在好友列表上显示。每个用户的黑名单人数上限为 500。文档介绍:https://docs-im-beta.easemob.com/document/server-side/user_relationship.html#%E6%B7%BB%E5%8A%A0%E7%94%A8%E6%88%B7%E8%87%B3%E9%BB%91%E5%90%8D%E5%8D%95 + * @param ownerUsername (required) + * @param emAddUserToBlockList (optional) + * @param _callback The callback to be executed when the API call finishes + * @return The request call + * @throws ApiException If fail to process the API call, e.g. serializing the request body object + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public okhttp3.Call addUserToBlockListAsync(String ownerUsername, EMAddUserToBlockList emAddUserToBlockList, final ApiCallback _callback) throws ApiException { + + okhttp3.Call localVarCall = addUserToBlockListValidateBeforeCall(ownerUsername, emAddUserToBlockList, _callback); + Type localVarReturnType = new TypeToken(){}.getType(); + localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); + return localVarCall; + } + /** + * Build call for getBlockList + * @param ownerUsername (required) + * @param pageSize 每次期望返回的黑名单用户的数量。取值范围为 [1,50]。该参数仅在分页获取时为必需 (optional) + * @param cursor 数据查询的起始位置。该参数仅在分页获取时为必需 (optional) + * @param _callback Callback for upload/download progress + * @return Call to execute + * @throws ApiException If fail to serialize the request body object + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public okhttp3.Call getBlockListCall(String ownerUsername, Integer pageSize, String cursor, final ApiCallback _callback) throws ApiException { + String basePath = null; + // Operation Servers + String[] localBasePaths = new String[] { }; + + // Determine Base Path to Use + if (localCustomBaseUrl != null){ + basePath = localCustomBaseUrl; + } else if ( localBasePaths.length > 0 ) { + basePath = localBasePaths[localHostIndex]; + } else { + basePath = null; + } + + Object localVarPostBody = null; + + // create path and map variables + String localVarPath = "/users/{owner_username}/blocks/users" + .replace("{" + "owner_username" + "}", localVarApiClient.escapeString(ownerUsername.toString())); + + List localVarQueryParams = new ArrayList(); + List localVarCollectionQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + Map localVarCookieParams = new HashMap(); + Map localVarFormParams = new HashMap(); + + if (pageSize != null) { + localVarQueryParams.addAll(localVarApiClient.parameterToPair("pageSize", pageSize)); + } + + if (cursor != null) { + localVarQueryParams.addAll(localVarApiClient.parameterToPair("cursor", cursor)); + } + + final String[] localVarAccepts = { + "application/json" + }; + final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts); + if (localVarAccept != null) { + localVarHeaderParams.put("Accept", localVarAccept); + } + + final String[] localVarContentTypes = { + }; + final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); + if (localVarContentType != null) { + localVarHeaderParams.put("Content-Type", localVarContentType); + } + + String[] localVarAuthNames = new String[] { }; + return localVarApiClient.buildCall(basePath, localVarPath, "GET", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); + } + + @SuppressWarnings("rawtypes") + private okhttp3.Call getBlockListValidateBeforeCall(String ownerUsername, Integer pageSize, String cursor, final ApiCallback _callback) throws ApiException { + // verify the required parameter 'ownerUsername' is set + if (ownerUsername == null) { + throw new ApiException("Missing the required parameter 'ownerUsername' when calling getBlockList(Async)"); + } + + return getBlockListCall(ownerUsername, pageSize, cursor, _callback); + + } + + /** + * 获取黑名单列表 + * 获取指定用户的好友列表。文档介绍:https://docs-im-beta.easemob.com/document/server-side/user_relationship.html#%E8%8E%B7%E5%8F%96%E5%A5%BD%E5%8F%8B%E5%88%97%E8%A1%A8 + * @param ownerUsername (required) + * @param pageSize 每次期望返回的黑名单用户的数量。取值范围为 [1,50]。该参数仅在分页获取时为必需 (optional) + * @param cursor 数据查询的起始位置。该参数仅在分页获取时为必需 (optional) + * @return EMGetBlockListResult + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public EMGetBlockListResult getBlockList(String ownerUsername, Integer pageSize, String cursor) throws ApiException { + ApiResponse localVarResp = getBlockListWithHttpInfo(ownerUsername, pageSize, cursor); + return localVarResp.getData(); + } + + /** + * 获取黑名单列表 + * 获取指定用户的好友列表。文档介绍:https://docs-im-beta.easemob.com/document/server-side/user_relationship.html#%E8%8E%B7%E5%8F%96%E5%A5%BD%E5%8F%8B%E5%88%97%E8%A1%A8 + * @param ownerUsername (required) + * @param pageSize 每次期望返回的黑名单用户的数量。取值范围为 [1,50]。该参数仅在分页获取时为必需 (optional) + * @param cursor 数据查询的起始位置。该参数仅在分页获取时为必需 (optional) + * @return ApiResponse<EMGetBlockListResult> + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public ApiResponse getBlockListWithHttpInfo(String ownerUsername, Integer pageSize, String cursor) throws ApiException { + okhttp3.Call localVarCall = getBlockListValidateBeforeCall(ownerUsername, pageSize, cursor, null); + Type localVarReturnType = new TypeToken(){}.getType(); + return localVarApiClient.execute(localVarCall, localVarReturnType); + } + + /** + * 获取黑名单列表 (asynchronously) + * 获取指定用户的好友列表。文档介绍:https://docs-im-beta.easemob.com/document/server-side/user_relationship.html#%E8%8E%B7%E5%8F%96%E5%A5%BD%E5%8F%8B%E5%88%97%E8%A1%A8 + * @param ownerUsername (required) + * @param pageSize 每次期望返回的黑名单用户的数量。取值范围为 [1,50]。该参数仅在分页获取时为必需 (optional) + * @param cursor 数据查询的起始位置。该参数仅在分页获取时为必需 (optional) + * @param _callback The callback to be executed when the API call finishes + * @return The request call + * @throws ApiException If fail to process the API call, e.g. serializing the request body object + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public okhttp3.Call getBlockListAsync(String ownerUsername, Integer pageSize, String cursor, final ApiCallback _callback) throws ApiException { + + okhttp3.Call localVarCall = getBlockListValidateBeforeCall(ownerUsername, pageSize, cursor, _callback); + Type localVarReturnType = new TypeToken(){}.getType(); + localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); + return localVarCall; + } + /** + * Build call for removeUserFromBlockList + * @param ownerUsername (required) + * @param blockedUsername (required) + * @param _callback Callback for upload/download progress + * @return Call to execute + * @throws ApiException If fail to serialize the request body object + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public okhttp3.Call removeUserFromBlockListCall(String ownerUsername, String blockedUsername, final ApiCallback _callback) throws ApiException { + String basePath = null; + // Operation Servers + String[] localBasePaths = new String[] { }; + + // Determine Base Path to Use + if (localCustomBaseUrl != null){ + basePath = localCustomBaseUrl; + } else if ( localBasePaths.length > 0 ) { + basePath = localBasePaths[localHostIndex]; + } else { + basePath = null; + } + + Object localVarPostBody = null; + + // create path and map variables + String localVarPath = "/users/{owner_username}/blocks/users/{blocked_username}" + .replace("{" + "owner_username" + "}", localVarApiClient.escapeString(ownerUsername.toString())) + .replace("{" + "blocked_username" + "}", localVarApiClient.escapeString(blockedUsername.toString())); + + List localVarQueryParams = new ArrayList(); + List localVarCollectionQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + Map localVarCookieParams = new HashMap(); + Map localVarFormParams = new HashMap(); + + final String[] localVarAccepts = { + "application/json" + }; + final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts); + if (localVarAccept != null) { + localVarHeaderParams.put("Accept", localVarAccept); + } + + final String[] localVarContentTypes = { + }; + final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); + if (localVarContentType != null) { + localVarHeaderParams.put("Content-Type", localVarContentType); + } + + String[] localVarAuthNames = new String[] { }; + return localVarApiClient.buildCall(basePath, localVarPath, "DELETE", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); + } + + @SuppressWarnings("rawtypes") + private okhttp3.Call removeUserFromBlockListValidateBeforeCall(String ownerUsername, String blockedUsername, final ApiCallback _callback) throws ApiException { + // verify the required parameter 'ownerUsername' is set + if (ownerUsername == null) { + throw new ApiException("Missing the required parameter 'ownerUsername' when calling removeUserFromBlockList(Async)"); + } + + // verify the required parameter 'blockedUsername' is set + if (blockedUsername == null) { + throw new ApiException("Missing the required parameter 'blockedUsername' when calling removeUserFromBlockList(Async)"); + } + + return removeUserFromBlockListCall(ownerUsername, blockedUsername, _callback); + + } + + /** + * 从黑名单中移除用户 + * 从用户的黑名单中移除用户: 将好友从黑名单中移除后,恢复好友关系,可以正常收发消息; 将非好友从黑名单中移除后,恢复到未添加好友的状态。文档介绍:https://docs-im-beta.easemob.com/document/server-side/user_relationship.html#%E4%BB%8E%E9%BB%91%E5%90%8D%E5%8D%95%E4%B8%AD%E7%A7%BB%E9%99%A4%E7%94%A8%E6%88%B7 + * @param ownerUsername (required) + * @param blockedUsername (required) + * @return EMRemoveUserFromBlockListResult + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public EMRemoveUserFromBlockListResult removeUserFromBlockList(String ownerUsername, String blockedUsername) throws ApiException { + ApiResponse localVarResp = removeUserFromBlockListWithHttpInfo(ownerUsername, blockedUsername); + return localVarResp.getData(); + } + + /** + * 从黑名单中移除用户 + * 从用户的黑名单中移除用户: 将好友从黑名单中移除后,恢复好友关系,可以正常收发消息; 将非好友从黑名单中移除后,恢复到未添加好友的状态。文档介绍:https://docs-im-beta.easemob.com/document/server-side/user_relationship.html#%E4%BB%8E%E9%BB%91%E5%90%8D%E5%8D%95%E4%B8%AD%E7%A7%BB%E9%99%A4%E7%94%A8%E6%88%B7 + * @param ownerUsername (required) + * @param blockedUsername (required) + * @return ApiResponse<EMRemoveUserFromBlockListResult> + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public ApiResponse removeUserFromBlockListWithHttpInfo(String ownerUsername, String blockedUsername) throws ApiException { + okhttp3.Call localVarCall = removeUserFromBlockListValidateBeforeCall(ownerUsername, blockedUsername, null); + Type localVarReturnType = new TypeToken(){}.getType(); + return localVarApiClient.execute(localVarCall, localVarReturnType); + } + + /** + * 从黑名单中移除用户 (asynchronously) + * 从用户的黑名单中移除用户: 将好友从黑名单中移除后,恢复好友关系,可以正常收发消息; 将非好友从黑名单中移除后,恢复到未添加好友的状态。文档介绍:https://docs-im-beta.easemob.com/document/server-side/user_relationship.html#%E4%BB%8E%E9%BB%91%E5%90%8D%E5%8D%95%E4%B8%AD%E7%A7%BB%E9%99%A4%E7%94%A8%E6%88%B7 + * @param ownerUsername (required) + * @param blockedUsername (required) + * @param _callback The callback to be executed when the API call finishes + * @return The request call + * @throws ApiException If fail to process the API call, e.g. serializing the request body object + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public okhttp3.Call removeUserFromBlockListAsync(String ownerUsername, String blockedUsername, final ApiCallback _callback) throws ApiException { + + okhttp3.Call localVarCall = removeUserFromBlockListValidateBeforeCall(ownerUsername, blockedUsername, _callback); + Type localVarReturnType = new TypeToken(){}.getType(); + localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); + return localVarCall; + } +} diff --git a/src/main/java/com/easemob/im/api/ChatFileApi.java b/src/main/java/com/easemob/im/api/ChatFileApi.java new file mode 100644 index 000000000..8a167b485 --- /dev/null +++ b/src/main/java/com/easemob/im/api/ChatFileApi.java @@ -0,0 +1,362 @@ +/* + * EMService + * Easemob Rest API + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.easemob.im.api; + +import com.easemob.im.ApiCallback; +import com.easemob.im.ApiClient; +import com.easemob.im.ApiException; +import com.easemob.im.ApiResponse; +import com.easemob.im.Configuration; +import com.easemob.im.Pair; +import com.easemob.im.ProgressRequestBody; +import com.easemob.im.ProgressResponseBody; + +import com.google.gson.reflect.TypeToken; + +import java.io.IOException; + + +import com.easemob.im.api.model.EMUploadChatFileResult; +import java.io.File; + +import java.lang.reflect.Type; +import java.nio.file.Path; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +public class ChatFileApi { + private ApiClient localVarApiClient; + private int localHostIndex; + private String localCustomBaseUrl; + + public ChatFileApi() { + this(Configuration.getDefaultApiClient()); + } + + public ChatFileApi(ApiClient apiClient) { + this.localVarApiClient = apiClient; + } + + public ApiClient getApiClient() { + return localVarApiClient; + } + + public void setApiClient(ApiClient apiClient) { + this.localVarApiClient = apiClient; + } + + public int getHostIndex() { + return localHostIndex; + } + + public void setHostIndex(int hostIndex) { + this.localHostIndex = hostIndex; + } + + public String getCustomBaseUrl() { + return localCustomBaseUrl; + } + + public void setCustomBaseUrl(String customBaseUrl) { + this.localCustomBaseUrl = customBaseUrl; + } + + /** + * Build call for downloadChatFile + * @param fileUuid 服务器为文件生成的 UUID (required) + * @param shareSecret 文件访问密钥。若上传文件时限制了访问,下载该文件时则需要该访问密钥。成功上传文件后,从 文件上传 的响应 body 中获取该密钥 (optional) + * @param thumbnail 是否下载缩略图: true:是,下载缩略图 false:否,下载原文件 若该参数为空,下载原文件 (optional) + * @param _callback Callback for upload/download progress + * @return Call to execute + * @throws ApiException If fail to serialize the request body object + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public okhttp3.Call downloadChatFileCall(String fileUuid, String shareSecret, Boolean thumbnail, final ApiCallback _callback) throws ApiException { + String basePath = null; + // Operation Servers + String[] localBasePaths = new String[] { }; + + // Determine Base Path to Use + if (localCustomBaseUrl != null){ + basePath = localCustomBaseUrl; + } else if ( localBasePaths.length > 0 ) { + basePath = localBasePaths[localHostIndex]; + } else { + basePath = null; + } + + Object localVarPostBody = null; + + // create path and map variables + String localVarPath = "/chatfiles/{file_uuid}" + .replace("{" + "file_uuid" + "}", localVarApiClient.escapeString(fileUuid.toString())); + + List localVarQueryParams = new ArrayList(); + List localVarCollectionQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + Map localVarCookieParams = new HashMap(); + Map localVarFormParams = new HashMap(); + + if (shareSecret != null) { + localVarHeaderParams.put("share-secret", localVarApiClient.parameterToString(shareSecret)); + } + + if (thumbnail != null) { + localVarHeaderParams.put("thumbnail", localVarApiClient.parameterToString(thumbnail)); + } + + final String[] localVarAccepts = { + "application/octet-stream" + }; + final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts); + if (localVarAccept != null) { + localVarHeaderParams.put("Accept", localVarAccept); + } + + final String[] localVarContentTypes = { + }; + final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); + if (localVarContentType != null) { + localVarHeaderParams.put("Content-Type", localVarContentType); + } + + String[] localVarAuthNames = new String[] { }; + return localVarApiClient.buildCall(basePath, localVarPath, "GET", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); + } + + @SuppressWarnings("rawtypes") + private okhttp3.Call downloadChatFileValidateBeforeCall(String fileUuid, String shareSecret, Boolean thumbnail, final ApiCallback _callback) throws ApiException { + // verify the required parameter 'fileUuid' is set + if (fileUuid == null) { + throw new ApiException("Missing the required parameter 'fileUuid' when calling downloadChatFile(Async)"); + } + + return downloadChatFileCall(fileUuid, shareSecret, thumbnail, _callback); + + } + + /** + * 下载文件/下载缩略图 + * 可利用该方法下载图片、语音、视频或其他类型的文件。文档介绍:https://docs-im-beta.easemob.com/document/server-side/message_download.html#%E4%B8%8B%E8%BD%BD%E6%96%87%E4%BB%B6 + * @param fileUuid 服务器为文件生成的 UUID (required) + * @param shareSecret 文件访问密钥。若上传文件时限制了访问,下载该文件时则需要该访问密钥。成功上传文件后,从 文件上传 的响应 body 中获取该密钥 (optional) + * @param thumbnail 是否下载缩略图: true:是,下载缩略图 false:否,下载原文件 若该参数为空,下载原文件 (optional) + * @return File + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public File downloadChatFile(String fileUuid, String shareSecret, Boolean thumbnail) throws ApiException { + ApiResponse localVarResp = downloadChatFileWithHttpInfo(fileUuid, shareSecret, thumbnail); + return localVarResp.getData(); + } + + /** + * 下载文件/下载缩略图 + * 可利用该方法下载图片、语音、视频或其他类型的文件。文档介绍:https://docs-im-beta.easemob.com/document/server-side/message_download.html#%E4%B8%8B%E8%BD%BD%E6%96%87%E4%BB%B6 + * @param fileUuid 服务器为文件生成的 UUID (required) + * @param shareSecret 文件访问密钥。若上传文件时限制了访问,下载该文件时则需要该访问密钥。成功上传文件后,从 文件上传 的响应 body 中获取该密钥 (optional) + * @param thumbnail 是否下载缩略图: true:是,下载缩略图 false:否,下载原文件 若该参数为空,下载原文件 (optional) + * @return ApiResponse<File> + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public ApiResponse downloadChatFileWithHttpInfo(String fileUuid, String shareSecret, Boolean thumbnail) throws ApiException { + okhttp3.Call localVarCall = downloadChatFileValidateBeforeCall(fileUuid, shareSecret, thumbnail, null); + Type localVarReturnType = new TypeToken(){}.getType(); + return localVarApiClient.execute(localVarCall, localVarReturnType); + } + + /** + * 下载文件/下载缩略图 (asynchronously) + * 可利用该方法下载图片、语音、视频或其他类型的文件。文档介绍:https://docs-im-beta.easemob.com/document/server-side/message_download.html#%E4%B8%8B%E8%BD%BD%E6%96%87%E4%BB%B6 + * @param fileUuid 服务器为文件生成的 UUID (required) + * @param shareSecret 文件访问密钥。若上传文件时限制了访问,下载该文件时则需要该访问密钥。成功上传文件后,从 文件上传 的响应 body 中获取该密钥 (optional) + * @param thumbnail 是否下载缩略图: true:是,下载缩略图 false:否,下载原文件 若该参数为空,下载原文件 (optional) + * @param _callback The callback to be executed when the API call finishes + * @return The request call + * @throws ApiException If fail to process the API call, e.g. serializing the request body object + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public okhttp3.Call downloadChatFileAsync(String fileUuid, String shareSecret, Boolean thumbnail, final ApiCallback _callback) throws ApiException { + + okhttp3.Call localVarCall = downloadChatFileValidateBeforeCall(fileUuid, shareSecret, thumbnail, _callback); + Type localVarReturnType = new TypeToken(){}.getType(); + localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); + return localVarCall; + } + /** + * Build call for uploadChatFile + * @param restrictAccess 是否限制访问该文件: - true:是。用户需要通过响应 body 中获取的文件访问密钥(share-secret)才能下载该文件 - false:否。表示不限制访问。用户可以直接下载该文件 要使用文件访问限制功能,请联系商务开通 (optional) + * @param _file 文件本地路径 (optional) + * @param _callback Callback for upload/download progress + * @return Call to execute + * @throws ApiException If fail to serialize the request body object + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public okhttp3.Call uploadChatFileCall(Boolean restrictAccess, File _file, final ApiCallback _callback) throws ApiException { + String basePath = null; + // Operation Servers + String[] localBasePaths = new String[] { }; + + // Determine Base Path to Use + if (localCustomBaseUrl != null){ + basePath = localCustomBaseUrl; + } else if ( localBasePaths.length > 0 ) { + basePath = localBasePaths[localHostIndex]; + } else { + basePath = null; + } + + Object localVarPostBody = null; + + // create path and map variables + String localVarPath = "/chatfiles"; + + List localVarQueryParams = new ArrayList(); + List localVarCollectionQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + Map localVarCookieParams = new HashMap(); + Map localVarFormParams = new HashMap(); + + if (_file != null) { + localVarFormParams.put("file", _file); + } + + if (restrictAccess != null) { + localVarHeaderParams.put("restrict-access", localVarApiClient.parameterToString(restrictAccess)); + } + + final String[] localVarAccepts = { + "application/json" + }; + final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts); + if (localVarAccept != null) { + localVarHeaderParams.put("Accept", localVarAccept); + } + + final String[] localVarContentTypes = { + "multipart/form-data" + }; + final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); + if (localVarContentType != null) { + localVarHeaderParams.put("Content-Type", localVarContentType); + } + + String[] localVarAuthNames = new String[] { }; + return localVarApiClient.buildCall(basePath, localVarPath, "POST", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); + } + + @SuppressWarnings("rawtypes") + private okhttp3.Call uploadChatFileValidateBeforeCall(Boolean restrictAccess, File _file, final ApiCallback _callback) throws ApiException { + return uploadChatFileCall(restrictAccess, _file, _callback); + + } + + /** + * 上传文件 + * 对于附件类型的消息,如图片、语音、视频或其他类型文件,发送消息前需上传文件。文档介绍:https://docs-im-beta.easemob.com/document/server-side/message_download.html#%E4%B8%8A%E4%BC%A0%E6%96%87%E4%BB%B6 + * @param restrictAccess 是否限制访问该文件: - true:是。用户需要通过响应 body 中获取的文件访问密钥(share-secret)才能下载该文件 - false:否。表示不限制访问。用户可以直接下载该文件 要使用文件访问限制功能,请联系商务开通 (optional) + * @param _file 文件本地路径 (optional) + * @return EMUploadChatFileResult + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public EMUploadChatFileResult uploadChatFile(Boolean restrictAccess, File _file) throws ApiException { + ApiResponse localVarResp = uploadChatFileWithHttpInfo(restrictAccess, _file); + return localVarResp.getData(); + } + + /** + * 上传文件 + * 对于附件类型的消息,如图片、语音、视频或其他类型文件,发送消息前需上传文件。文档介绍:https://docs-im-beta.easemob.com/document/server-side/message_download.html#%E4%B8%8A%E4%BC%A0%E6%96%87%E4%BB%B6 + * @param restrictAccess 是否限制访问该文件: - true:是。用户需要通过响应 body 中获取的文件访问密钥(share-secret)才能下载该文件 - false:否。表示不限制访问。用户可以直接下载该文件 要使用文件访问限制功能,请联系商务开通 (optional) + * @param _file 文件本地路径 (optional) + * @return ApiResponse<EMUploadChatFileResult> + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public ApiResponse uploadChatFileWithHttpInfo(Boolean restrictAccess, File _file) throws ApiException { + okhttp3.Call localVarCall = uploadChatFileValidateBeforeCall(restrictAccess, _file, null); + Type localVarReturnType = new TypeToken(){}.getType(); + return localVarApiClient.execute(localVarCall, localVarReturnType); + } + + /** + * 上传文件 (asynchronously) + * 对于附件类型的消息,如图片、语音、视频或其他类型文件,发送消息前需上传文件。文档介绍:https://docs-im-beta.easemob.com/document/server-side/message_download.html#%E4%B8%8A%E4%BC%A0%E6%96%87%E4%BB%B6 + * @param restrictAccess 是否限制访问该文件: - true:是。用户需要通过响应 body 中获取的文件访问密钥(share-secret)才能下载该文件 - false:否。表示不限制访问。用户可以直接下载该文件 要使用文件访问限制功能,请联系商务开通 (optional) + * @param _file 文件本地路径 (optional) + * @param _callback The callback to be executed when the API call finishes + * @return The request call + * @throws ApiException If fail to process the API call, e.g. serializing the request body object + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public okhttp3.Call uploadChatFileAsync(Boolean restrictAccess, File _file, final ApiCallback _callback) throws ApiException { + + okhttp3.Call localVarCall = uploadChatFileValidateBeforeCall(restrictAccess, _file, _callback); + Type localVarReturnType = new TypeToken(){}.getType(); + localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); + return localVarCall; + } +} diff --git a/src/main/java/com/easemob/im/api/ContactApi.java b/src/main/java/com/easemob/im/api/ContactApi.java new file mode 100644 index 000000000..6c43be85c --- /dev/null +++ b/src/main/java/com/easemob/im/api/ContactApi.java @@ -0,0 +1,662 @@ +/* + * EMService + * Easemob Rest API + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.easemob.im.api; + +import com.easemob.im.ApiCallback; +import com.easemob.im.ApiClient; +import com.easemob.im.ApiException; +import com.easemob.im.ApiResponse; +import com.easemob.im.Configuration; +import com.easemob.im.Pair; +import com.easemob.im.ProgressRequestBody; +import com.easemob.im.ProgressResponseBody; + +import com.google.gson.reflect.TypeToken; + +import java.io.IOException; + + +import com.easemob.im.api.model.EMAddContactResult; +import com.easemob.im.api.model.EMGetContactListResult; +import com.easemob.im.api.model.EMRemoveContactResult; +import com.easemob.im.api.model.EMSetContactNote; +import com.easemob.im.api.model.EMSetContactNoteResult; + +import java.lang.reflect.Type; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +public class ContactApi { + private ApiClient localVarApiClient; + private int localHostIndex; + private String localCustomBaseUrl; + + public ContactApi() { + this(Configuration.getDefaultApiClient()); + } + + public ContactApi(ApiClient apiClient) { + this.localVarApiClient = apiClient; + } + + public ApiClient getApiClient() { + return localVarApiClient; + } + + public void setApiClient(ApiClient apiClient) { + this.localVarApiClient = apiClient; + } + + public int getHostIndex() { + return localHostIndex; + } + + public void setHostIndex(int hostIndex) { + this.localHostIndex = hostIndex; + } + + public String getCustomBaseUrl() { + return localCustomBaseUrl; + } + + public void setCustomBaseUrl(String customBaseUrl) { + this.localCustomBaseUrl = customBaseUrl; + } + + /** + * Build call for addContact + * @param ownerUsername (required) + * @param friendUsername (required) + * @param _callback Callback for upload/download progress + * @return Call to execute + * @throws ApiException If fail to serialize the request body object + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public okhttp3.Call addContactCall(String ownerUsername, String friendUsername, final ApiCallback _callback) throws ApiException { + String basePath = null; + // Operation Servers + String[] localBasePaths = new String[] { }; + + // Determine Base Path to Use + if (localCustomBaseUrl != null){ + basePath = localCustomBaseUrl; + } else if ( localBasePaths.length > 0 ) { + basePath = localBasePaths[localHostIndex]; + } else { + basePath = null; + } + + Object localVarPostBody = null; + + // create path and map variables + String localVarPath = "/users/{owner_username}/contacts/users/{friend_username}" + .replace("{" + "owner_username" + "}", localVarApiClient.escapeString(ownerUsername.toString())) + .replace("{" + "friend_username" + "}", localVarApiClient.escapeString(friendUsername.toString())); + + List localVarQueryParams = new ArrayList(); + List localVarCollectionQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + Map localVarCookieParams = new HashMap(); + Map localVarFormParams = new HashMap(); + + final String[] localVarAccepts = { + "application/json" + }; + final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts); + if (localVarAccept != null) { + localVarHeaderParams.put("Accept", localVarAccept); + } + + final String[] localVarContentTypes = { + }; + final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); + if (localVarContentType != null) { + localVarHeaderParams.put("Content-Type", localVarContentType); + } + + String[] localVarAuthNames = new String[] { }; + return localVarApiClient.buildCall(basePath, localVarPath, "POST", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); + } + + @SuppressWarnings("rawtypes") + private okhttp3.Call addContactValidateBeforeCall(String ownerUsername, String friendUsername, final ApiCallback _callback) throws ApiException { + // verify the required parameter 'ownerUsername' is set + if (ownerUsername == null) { + throw new ApiException("Missing the required parameter 'ownerUsername' when calling addContact(Async)"); + } + + // verify the required parameter 'friendUsername' is set + if (friendUsername == null) { + throw new ApiException("Missing the required parameter 'friendUsername' when calling addContact(Async)"); + } + + return addContactCall(ownerUsername, friendUsername, _callback); + + } + + /** + * 添加好友 + * 添加好友,好友必须是和当前用户在一个 App Key 下的用户。对于免费版即时通讯服务,单个 App Key 下的每个用户的好友数量上限为 1000,不同服务版本的 App Key 的该数量上限不同。文档介绍:https://docs-im-beta.easemob.com/document/server-side/user_relationship.html#%E6%B7%BB%E5%8A%A0%E5%A5%BD%E5%8F%8B + * @param ownerUsername (required) + * @param friendUsername (required) + * @return EMAddContactResult + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public EMAddContactResult addContact(String ownerUsername, String friendUsername) throws ApiException { + ApiResponse localVarResp = addContactWithHttpInfo(ownerUsername, friendUsername); + return localVarResp.getData(); + } + + /** + * 添加好友 + * 添加好友,好友必须是和当前用户在一个 App Key 下的用户。对于免费版即时通讯服务,单个 App Key 下的每个用户的好友数量上限为 1000,不同服务版本的 App Key 的该数量上限不同。文档介绍:https://docs-im-beta.easemob.com/document/server-side/user_relationship.html#%E6%B7%BB%E5%8A%A0%E5%A5%BD%E5%8F%8B + * @param ownerUsername (required) + * @param friendUsername (required) + * @return ApiResponse<EMAddContactResult> + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public ApiResponse addContactWithHttpInfo(String ownerUsername, String friendUsername) throws ApiException { + okhttp3.Call localVarCall = addContactValidateBeforeCall(ownerUsername, friendUsername, null); + Type localVarReturnType = new TypeToken(){}.getType(); + return localVarApiClient.execute(localVarCall, localVarReturnType); + } + + /** + * 添加好友 (asynchronously) + * 添加好友,好友必须是和当前用户在一个 App Key 下的用户。对于免费版即时通讯服务,单个 App Key 下的每个用户的好友数量上限为 1000,不同服务版本的 App Key 的该数量上限不同。文档介绍:https://docs-im-beta.easemob.com/document/server-side/user_relationship.html#%E6%B7%BB%E5%8A%A0%E5%A5%BD%E5%8F%8B + * @param ownerUsername (required) + * @param friendUsername (required) + * @param _callback The callback to be executed when the API call finishes + * @return The request call + * @throws ApiException If fail to process the API call, e.g. serializing the request body object + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public okhttp3.Call addContactAsync(String ownerUsername, String friendUsername, final ApiCallback _callback) throws ApiException { + + okhttp3.Call localVarCall = addContactValidateBeforeCall(ownerUsername, friendUsername, _callback); + Type localVarReturnType = new TypeToken(){}.getType(); + localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); + return localVarCall; + } + /** + * Build call for getContactList + * @param ownerUsername (required) + * @param limit 每次期望返回的好友数量,取值范围为 [1,50],默认值为 10 (optional) + * @param cursor 数据查询的起始位置 (optional) + * @param needReturnRemark 是否需要返回好友备注,默认为 true (optional) + * @param _callback Callback for upload/download progress + * @return Call to execute + * @throws ApiException If fail to serialize the request body object + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public okhttp3.Call getContactListCall(String ownerUsername, Integer limit, String cursor, Boolean needReturnRemark, final ApiCallback _callback) throws ApiException { + String basePath = null; + // Operation Servers + String[] localBasePaths = new String[] { }; + + // Determine Base Path to Use + if (localCustomBaseUrl != null){ + basePath = localCustomBaseUrl; + } else if ( localBasePaths.length > 0 ) { + basePath = localBasePaths[localHostIndex]; + } else { + basePath = null; + } + + Object localVarPostBody = null; + + // create path and map variables + String localVarPath = "/users/{owner_username}/contacts" + .replace("{" + "owner_username" + "}", localVarApiClient.escapeString(ownerUsername.toString())); + + List localVarQueryParams = new ArrayList(); + List localVarCollectionQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + Map localVarCookieParams = new HashMap(); + Map localVarFormParams = new HashMap(); + + if (limit != null) { + localVarQueryParams.addAll(localVarApiClient.parameterToPair("limit", limit)); + } + + if (cursor != null) { + localVarQueryParams.addAll(localVarApiClient.parameterToPair("cursor", cursor)); + } + + if (needReturnRemark != null) { + localVarQueryParams.addAll(localVarApiClient.parameterToPair("needReturnRemark", needReturnRemark)); + } + + final String[] localVarAccepts = { + "application/json" + }; + final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts); + if (localVarAccept != null) { + localVarHeaderParams.put("Accept", localVarAccept); + } + + final String[] localVarContentTypes = { + }; + final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); + if (localVarContentType != null) { + localVarHeaderParams.put("Content-Type", localVarContentType); + } + + String[] localVarAuthNames = new String[] { }; + return localVarApiClient.buildCall(basePath, localVarPath, "GET", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); + } + + @SuppressWarnings("rawtypes") + private okhttp3.Call getContactListValidateBeforeCall(String ownerUsername, Integer limit, String cursor, Boolean needReturnRemark, final ApiCallback _callback) throws ApiException { + // verify the required parameter 'ownerUsername' is set + if (ownerUsername == null) { + throw new ApiException("Missing the required parameter 'ownerUsername' when calling getContactList(Async)"); + } + + return getContactListCall(ownerUsername, limit, cursor, needReturnRemark, _callback); + + } + + /** + * 获取好友列表 + * 获取指定用户的好友列表。文档介绍:https://docs-im-beta.easemob.com/document/server-side/user_relationship.html#%E8%8E%B7%E5%8F%96%E5%A5%BD%E5%8F%8B%E5%88%97%E8%A1%A8 + * @param ownerUsername (required) + * @param limit 每次期望返回的好友数量,取值范围为 [1,50],默认值为 10 (optional) + * @param cursor 数据查询的起始位置 (optional) + * @param needReturnRemark 是否需要返回好友备注,默认为 true (optional) + * @return EMGetContactListResult + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public EMGetContactListResult getContactList(String ownerUsername, Integer limit, String cursor, Boolean needReturnRemark) throws ApiException { + ApiResponse localVarResp = getContactListWithHttpInfo(ownerUsername, limit, cursor, needReturnRemark); + return localVarResp.getData(); + } + + /** + * 获取好友列表 + * 获取指定用户的好友列表。文档介绍:https://docs-im-beta.easemob.com/document/server-side/user_relationship.html#%E8%8E%B7%E5%8F%96%E5%A5%BD%E5%8F%8B%E5%88%97%E8%A1%A8 + * @param ownerUsername (required) + * @param limit 每次期望返回的好友数量,取值范围为 [1,50],默认值为 10 (optional) + * @param cursor 数据查询的起始位置 (optional) + * @param needReturnRemark 是否需要返回好友备注,默认为 true (optional) + * @return ApiResponse<EMGetContactListResult> + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public ApiResponse getContactListWithHttpInfo(String ownerUsername, Integer limit, String cursor, Boolean needReturnRemark) throws ApiException { + okhttp3.Call localVarCall = getContactListValidateBeforeCall(ownerUsername, limit, cursor, needReturnRemark, null); + Type localVarReturnType = new TypeToken(){}.getType(); + return localVarApiClient.execute(localVarCall, localVarReturnType); + } + + /** + * 获取好友列表 (asynchronously) + * 获取指定用户的好友列表。文档介绍:https://docs-im-beta.easemob.com/document/server-side/user_relationship.html#%E8%8E%B7%E5%8F%96%E5%A5%BD%E5%8F%8B%E5%88%97%E8%A1%A8 + * @param ownerUsername (required) + * @param limit 每次期望返回的好友数量,取值范围为 [1,50],默认值为 10 (optional) + * @param cursor 数据查询的起始位置 (optional) + * @param needReturnRemark 是否需要返回好友备注,默认为 true (optional) + * @param _callback The callback to be executed when the API call finishes + * @return The request call + * @throws ApiException If fail to process the API call, e.g. serializing the request body object + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public okhttp3.Call getContactListAsync(String ownerUsername, Integer limit, String cursor, Boolean needReturnRemark, final ApiCallback _callback) throws ApiException { + + okhttp3.Call localVarCall = getContactListValidateBeforeCall(ownerUsername, limit, cursor, needReturnRemark, _callback); + Type localVarReturnType = new TypeToken(){}.getType(); + localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); + return localVarCall; + } + /** + * Build call for removeContact + * @param ownerUsername (required) + * @param friendUsername (required) + * @param _callback Callback for upload/download progress + * @return Call to execute + * @throws ApiException If fail to serialize the request body object + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public okhttp3.Call removeContactCall(String ownerUsername, String friendUsername, final ApiCallback _callback) throws ApiException { + String basePath = null; + // Operation Servers + String[] localBasePaths = new String[] { }; + + // Determine Base Path to Use + if (localCustomBaseUrl != null){ + basePath = localCustomBaseUrl; + } else if ( localBasePaths.length > 0 ) { + basePath = localBasePaths[localHostIndex]; + } else { + basePath = null; + } + + Object localVarPostBody = null; + + // create path and map variables + String localVarPath = "/users/{owner_username}/contacts/users/{friend_username}" + .replace("{" + "owner_username" + "}", localVarApiClient.escapeString(ownerUsername.toString())) + .replace("{" + "friend_username" + "}", localVarApiClient.escapeString(friendUsername.toString())); + + List localVarQueryParams = new ArrayList(); + List localVarCollectionQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + Map localVarCookieParams = new HashMap(); + Map localVarFormParams = new HashMap(); + + final String[] localVarAccepts = { + "application/json" + }; + final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts); + if (localVarAccept != null) { + localVarHeaderParams.put("Accept", localVarAccept); + } + + final String[] localVarContentTypes = { + }; + final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); + if (localVarContentType != null) { + localVarHeaderParams.put("Content-Type", localVarContentType); + } + + String[] localVarAuthNames = new String[] { }; + return localVarApiClient.buildCall(basePath, localVarPath, "DELETE", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); + } + + @SuppressWarnings("rawtypes") + private okhttp3.Call removeContactValidateBeforeCall(String ownerUsername, String friendUsername, final ApiCallback _callback) throws ApiException { + // verify the required parameter 'ownerUsername' is set + if (ownerUsername == null) { + throw new ApiException("Missing the required parameter 'ownerUsername' when calling removeContact(Async)"); + } + + // verify the required parameter 'friendUsername' is set + if (friendUsername == null) { + throw new ApiException("Missing the required parameter 'friendUsername' when calling removeContact(Async)"); + } + + return removeContactCall(ownerUsername, friendUsername, _callback); + + } + + /** + * 移除好友 + * 从用户的好友列表中移除一个用户。文档介绍:https://docs-im-beta.easemob.com/document/server-side/user_relationship.html#%E7%A7%BB%E9%99%A4%E5%A5%BD%E5%8F%8B + * @param ownerUsername (required) + * @param friendUsername (required) + * @return EMRemoveContactResult + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public EMRemoveContactResult removeContact(String ownerUsername, String friendUsername) throws ApiException { + ApiResponse localVarResp = removeContactWithHttpInfo(ownerUsername, friendUsername); + return localVarResp.getData(); + } + + /** + * 移除好友 + * 从用户的好友列表中移除一个用户。文档介绍:https://docs-im-beta.easemob.com/document/server-side/user_relationship.html#%E7%A7%BB%E9%99%A4%E5%A5%BD%E5%8F%8B + * @param ownerUsername (required) + * @param friendUsername (required) + * @return ApiResponse<EMRemoveContactResult> + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public ApiResponse removeContactWithHttpInfo(String ownerUsername, String friendUsername) throws ApiException { + okhttp3.Call localVarCall = removeContactValidateBeforeCall(ownerUsername, friendUsername, null); + Type localVarReturnType = new TypeToken(){}.getType(); + return localVarApiClient.execute(localVarCall, localVarReturnType); + } + + /** + * 移除好友 (asynchronously) + * 从用户的好友列表中移除一个用户。文档介绍:https://docs-im-beta.easemob.com/document/server-side/user_relationship.html#%E7%A7%BB%E9%99%A4%E5%A5%BD%E5%8F%8B + * @param ownerUsername (required) + * @param friendUsername (required) + * @param _callback The callback to be executed when the API call finishes + * @return The request call + * @throws ApiException If fail to process the API call, e.g. serializing the request body object + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public okhttp3.Call removeContactAsync(String ownerUsername, String friendUsername, final ApiCallback _callback) throws ApiException { + + okhttp3.Call localVarCall = removeContactValidateBeforeCall(ownerUsername, friendUsername, _callback); + Type localVarReturnType = new TypeToken(){}.getType(); + localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); + return localVarCall; + } + /** + * Build call for setContactNote + * @param ownerUsername (required) + * @param friendUsername (required) + * @param emSetContactNote (optional) + * @param _callback Callback for upload/download progress + * @return Call to execute + * @throws ApiException If fail to serialize the request body object + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public okhttp3.Call setContactNoteCall(String ownerUsername, String friendUsername, EMSetContactNote emSetContactNote, final ApiCallback _callback) throws ApiException { + String basePath = null; + // Operation Servers + String[] localBasePaths = new String[] { }; + + // Determine Base Path to Use + if (localCustomBaseUrl != null){ + basePath = localCustomBaseUrl; + } else if ( localBasePaths.length > 0 ) { + basePath = localBasePaths[localHostIndex]; + } else { + basePath = null; + } + + Object localVarPostBody = emSetContactNote; + + // create path and map variables + String localVarPath = "/users/{owner_username}/contacts/users/{friend_username}" + .replace("{" + "owner_username" + "}", localVarApiClient.escapeString(ownerUsername.toString())) + .replace("{" + "friend_username" + "}", localVarApiClient.escapeString(friendUsername.toString())); + + List localVarQueryParams = new ArrayList(); + List localVarCollectionQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + Map localVarCookieParams = new HashMap(); + Map localVarFormParams = new HashMap(); + + final String[] localVarAccepts = { + "application/json" + }; + final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts); + if (localVarAccept != null) { + localVarHeaderParams.put("Accept", localVarAccept); + } + + final String[] localVarContentTypes = { + "application/json" + }; + final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); + if (localVarContentType != null) { + localVarHeaderParams.put("Content-Type", localVarContentType); + } + + String[] localVarAuthNames = new String[] { }; + return localVarApiClient.buildCall(basePath, localVarPath, "PUT", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); + } + + @SuppressWarnings("rawtypes") + private okhttp3.Call setContactNoteValidateBeforeCall(String ownerUsername, String friendUsername, EMSetContactNote emSetContactNote, final ApiCallback _callback) throws ApiException { + // verify the required parameter 'ownerUsername' is set + if (ownerUsername == null) { + throw new ApiException("Missing the required parameter 'ownerUsername' when calling setContactNote(Async)"); + } + + // verify the required parameter 'friendUsername' is set + if (friendUsername == null) { + throw new ApiException("Missing the required parameter 'friendUsername' when calling setContactNote(Async)"); + } + + return setContactNoteCall(ownerUsername, friendUsername, emSetContactNote, _callback); + + } + + /** + * 设置好友备注 + * 你可以调用该接口设置你在当前 app 下的好友的备注,即你和要设置备注的好友需在同一个 App Key 下。对于免费版即时通讯服务,单个 App Key 下的每个用户的好友数量上限为 100,不同服务套餐包的 App Key 的该数量上限不同。文档介绍:https://docs-im-beta.easemob.com/document/server-side/user_relationship.html#%E8%AE%BE%E7%BD%AE%E5%A5%BD%E5%8F%8B%E5%A4%87%E6%B3%A8 + * @param ownerUsername (required) + * @param friendUsername (required) + * @param emSetContactNote (optional) + * @return EMSetContactNoteResult + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public EMSetContactNoteResult setContactNote(String ownerUsername, String friendUsername, EMSetContactNote emSetContactNote) throws ApiException { + ApiResponse localVarResp = setContactNoteWithHttpInfo(ownerUsername, friendUsername, emSetContactNote); + return localVarResp.getData(); + } + + /** + * 设置好友备注 + * 你可以调用该接口设置你在当前 app 下的好友的备注,即你和要设置备注的好友需在同一个 App Key 下。对于免费版即时通讯服务,单个 App Key 下的每个用户的好友数量上限为 100,不同服务套餐包的 App Key 的该数量上限不同。文档介绍:https://docs-im-beta.easemob.com/document/server-side/user_relationship.html#%E8%AE%BE%E7%BD%AE%E5%A5%BD%E5%8F%8B%E5%A4%87%E6%B3%A8 + * @param ownerUsername (required) + * @param friendUsername (required) + * @param emSetContactNote (optional) + * @return ApiResponse<EMSetContactNoteResult> + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public ApiResponse setContactNoteWithHttpInfo(String ownerUsername, String friendUsername, EMSetContactNote emSetContactNote) throws ApiException { + okhttp3.Call localVarCall = setContactNoteValidateBeforeCall(ownerUsername, friendUsername, emSetContactNote, null); + Type localVarReturnType = new TypeToken(){}.getType(); + return localVarApiClient.execute(localVarCall, localVarReturnType); + } + + /** + * 设置好友备注 (asynchronously) + * 你可以调用该接口设置你在当前 app 下的好友的备注,即你和要设置备注的好友需在同一个 App Key 下。对于免费版即时通讯服务,单个 App Key 下的每个用户的好友数量上限为 100,不同服务套餐包的 App Key 的该数量上限不同。文档介绍:https://docs-im-beta.easemob.com/document/server-side/user_relationship.html#%E8%AE%BE%E7%BD%AE%E5%A5%BD%E5%8F%8B%E5%A4%87%E6%B3%A8 + * @param ownerUsername (required) + * @param friendUsername (required) + * @param emSetContactNote (optional) + * @param _callback The callback to be executed when the API call finishes + * @return The request call + * @throws ApiException If fail to process the API call, e.g. serializing the request body object + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public okhttp3.Call setContactNoteAsync(String ownerUsername, String friendUsername, EMSetContactNote emSetContactNote, final ApiCallback _callback) throws ApiException { + + okhttp3.Call localVarCall = setContactNoteValidateBeforeCall(ownerUsername, friendUsername, emSetContactNote, _callback); + Type localVarReturnType = new TypeToken(){}.getType(); + localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); + return localVarCall; + } +} diff --git a/src/main/java/com/easemob/im/api/GroupApi.java b/src/main/java/com/easemob/im/api/GroupApi.java new file mode 100644 index 000000000..d2718ae44 --- /dev/null +++ b/src/main/java/com/easemob/im/api/GroupApi.java @@ -0,0 +1,4768 @@ +/* + * EMService + * Easemob Rest API + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.easemob.im.api; + +import com.easemob.im.ApiCallback; +import com.easemob.im.ApiClient; +import com.easemob.im.ApiException; +import com.easemob.im.ApiResponse; +import com.easemob.im.Configuration; +import com.easemob.im.Pair; +import com.easemob.im.ProgressRequestBody; +import com.easemob.im.ProgressResponseBody; + +import com.google.gson.reflect.TypeToken; + +import java.io.IOException; + + +import com.easemob.im.api.model.EMAddGroupAdmin; +import com.easemob.im.api.model.EMAddGroupAdminResult; +import com.easemob.im.api.model.EMAddMultipleUserToGroup; +import com.easemob.im.api.model.EMAddMultipleUserToGroupBlockList; +import com.easemob.im.api.model.EMAddMultipleUserToGroupBlockListResult; +import com.easemob.im.api.model.EMAddMultipleUserToGroupResult; +import com.easemob.im.api.model.EMAddMultipleUserToGroupWhiteList; +import com.easemob.im.api.model.EMAddMultipleUserToGroupWhiteListResult; +import com.easemob.im.api.model.EMAddUserToGroupBlockListResult; +import com.easemob.im.api.model.EMAddUserToGroupResult; +import com.easemob.im.api.model.EMAddUserToGroupWhiteListResult; +import com.easemob.im.api.model.EMCheckUserJoinedGroupResult; +import com.easemob.im.api.model.EMCreateGroup; +import com.easemob.im.api.model.EMCreateGroupResult; +import com.easemob.im.api.model.EMDeleteGroupResult; +import com.easemob.im.api.model.EMDeleteGroupShareFileResult; +import com.easemob.im.api.model.EMDisableGroupResult; +import com.easemob.im.api.model.EMEnableGroupResult; +import com.easemob.im.api.model.EMGetAppGroupsResult; +import com.easemob.im.api.model.EMGetGroupAdminListResult; +import com.easemob.im.api.model.EMGetGroupAnnouncementResult; +import com.easemob.im.api.model.EMGetGroupBlockListResult; +import com.easemob.im.api.model.EMGetGroupInfoResult; +import com.easemob.im.api.model.EMGetGroupMemberListResult; +import com.easemob.im.api.model.EMGetGroupMuteListResult; +import com.easemob.im.api.model.EMGetGroupShareFileResult; +import com.easemob.im.api.model.EMGetGroupWhiteListResult; +import com.easemob.im.api.model.EMGetUserJoinedGroupsResult; +import com.easemob.im.api.model.EMModifyGroup; +import com.easemob.im.api.model.EMModifyGroupAnnouncement; +import com.easemob.im.api.model.EMModifyGroupAnnouncementResult; +import com.easemob.im.api.model.EMModifyGroupResult; +import com.easemob.im.api.model.EMMuteAllGroupMembersResult; +import com.easemob.im.api.model.EMMuteGroupMember; +import com.easemob.im.api.model.EMMuteGroupMemberResult; +import com.easemob.im.api.model.EMRemoveGroupAdminResult; +import com.easemob.im.api.model.EMRemoveUserFromGroupBlockListResult; +import com.easemob.im.api.model.EMRemoveUserFromGroupWhiteListResult; +import com.easemob.im.api.model.EMRemoveUserToGroupResult; +import com.easemob.im.api.model.EMUnmuteAllGroupMembersResult; +import com.easemob.im.api.model.EMUploadGroupShareFileResult; +import java.io.File; + +import java.lang.reflect.Type; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +public class GroupApi { + private ApiClient localVarApiClient; + private int localHostIndex; + private String localCustomBaseUrl; + + public GroupApi() { + this(Configuration.getDefaultApiClient()); + } + + public GroupApi(ApiClient apiClient) { + this.localVarApiClient = apiClient; + } + + public ApiClient getApiClient() { + return localVarApiClient; + } + + public void setApiClient(ApiClient apiClient) { + this.localVarApiClient = apiClient; + } + + public int getHostIndex() { + return localHostIndex; + } + + public void setHostIndex(int hostIndex) { + this.localHostIndex = hostIndex; + } + + public String getCustomBaseUrl() { + return localCustomBaseUrl; + } + + public void setCustomBaseUrl(String customBaseUrl) { + this.localCustomBaseUrl = customBaseUrl; + } + + /** + * Build call for addGroupAdmin + * @param groupId (required) + * @param emAddGroupAdmin (optional) + * @param _callback Callback for upload/download progress + * @return Call to execute + * @throws ApiException If fail to serialize the request body object + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public okhttp3.Call addGroupAdminCall(String groupId, EMAddGroupAdmin emAddGroupAdmin, final ApiCallback _callback) throws ApiException { + String basePath = null; + // Operation Servers + String[] localBasePaths = new String[] { }; + + // Determine Base Path to Use + if (localCustomBaseUrl != null){ + basePath = localCustomBaseUrl; + } else if ( localBasePaths.length > 0 ) { + basePath = localBasePaths[localHostIndex]; + } else { + basePath = null; + } + + Object localVarPostBody = emAddGroupAdmin; + + // create path and map variables + String localVarPath = "/chatgroups/{group_id}/admin" + .replace("{" + "group_id" + "}", localVarApiClient.escapeString(groupId.toString())); + + List localVarQueryParams = new ArrayList(); + List localVarCollectionQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + Map localVarCookieParams = new HashMap(); + Map localVarFormParams = new HashMap(); + + final String[] localVarAccepts = { + "application/json" + }; + final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts); + if (localVarAccept != null) { + localVarHeaderParams.put("Accept", localVarAccept); + } + + final String[] localVarContentTypes = { + "application/json" + }; + final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); + if (localVarContentType != null) { + localVarHeaderParams.put("Content-Type", localVarContentType); + } + + String[] localVarAuthNames = new String[] { }; + return localVarApiClient.buildCall(basePath, localVarPath, "POST", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); + } + + @SuppressWarnings("rawtypes") + private okhttp3.Call addGroupAdminValidateBeforeCall(String groupId, EMAddGroupAdmin emAddGroupAdmin, final ApiCallback _callback) throws ApiException { + // verify the required parameter 'groupId' is set + if (groupId == null) { + throw new ApiException("Missing the required parameter 'groupId' when calling addGroupAdmin(Async)"); + } + + return addGroupAdminCall(groupId, emAddGroupAdmin, _callback); + + } + + /** + * 添加群管理员 + * 将一个普通群成员设为为群管理员。群管理员有管理黑名单、禁言等权限。最多可以添加 99 个群管理员。文档介绍:https://docs-im-beta.easemob.com/document/server-side/group.html#%E6%B7%BB%E5%8A%A0%E7%BE%A4%E7%AE%A1%E7%90%86%E5%91%98 + * @param groupId (required) + * @param emAddGroupAdmin (optional) + * @return EMAddGroupAdminResult + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public EMAddGroupAdminResult addGroupAdmin(String groupId, EMAddGroupAdmin emAddGroupAdmin) throws ApiException { + ApiResponse localVarResp = addGroupAdminWithHttpInfo(groupId, emAddGroupAdmin); + return localVarResp.getData(); + } + + /** + * 添加群管理员 + * 将一个普通群成员设为为群管理员。群管理员有管理黑名单、禁言等权限。最多可以添加 99 个群管理员。文档介绍:https://docs-im-beta.easemob.com/document/server-side/group.html#%E6%B7%BB%E5%8A%A0%E7%BE%A4%E7%AE%A1%E7%90%86%E5%91%98 + * @param groupId (required) + * @param emAddGroupAdmin (optional) + * @return ApiResponse<EMAddGroupAdminResult> + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public ApiResponse addGroupAdminWithHttpInfo(String groupId, EMAddGroupAdmin emAddGroupAdmin) throws ApiException { + okhttp3.Call localVarCall = addGroupAdminValidateBeforeCall(groupId, emAddGroupAdmin, null); + Type localVarReturnType = new TypeToken(){}.getType(); + return localVarApiClient.execute(localVarCall, localVarReturnType); + } + + /** + * 添加群管理员 (asynchronously) + * 将一个普通群成员设为为群管理员。群管理员有管理黑名单、禁言等权限。最多可以添加 99 个群管理员。文档介绍:https://docs-im-beta.easemob.com/document/server-side/group.html#%E6%B7%BB%E5%8A%A0%E7%BE%A4%E7%AE%A1%E7%90%86%E5%91%98 + * @param groupId (required) + * @param emAddGroupAdmin (optional) + * @param _callback The callback to be executed when the API call finishes + * @return The request call + * @throws ApiException If fail to process the API call, e.g. serializing the request body object + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public okhttp3.Call addGroupAdminAsync(String groupId, EMAddGroupAdmin emAddGroupAdmin, final ApiCallback _callback) throws ApiException { + + okhttp3.Call localVarCall = addGroupAdminValidateBeforeCall(groupId, emAddGroupAdmin, _callback); + Type localVarReturnType = new TypeToken(){}.getType(); + localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); + return localVarCall; + } + /** + * Build call for addMultipleUserToGroup + * @param groupId (required) + * @param emAddMultipleUserToGroup (optional) + * @param _callback Callback for upload/download progress + * @return Call to execute + * @throws ApiException If fail to serialize the request body object + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public okhttp3.Call addMultipleUserToGroupCall(String groupId, EMAddMultipleUserToGroup emAddMultipleUserToGroup, final ApiCallback _callback) throws ApiException { + String basePath = null; + // Operation Servers + String[] localBasePaths = new String[] { }; + + // Determine Base Path to Use + if (localCustomBaseUrl != null){ + basePath = localCustomBaseUrl; + } else if ( localBasePaths.length > 0 ) { + basePath = localBasePaths[localHostIndex]; + } else { + basePath = null; + } + + Object localVarPostBody = emAddMultipleUserToGroup; + + // create path and map variables + String localVarPath = "/chatgroups/{group_id}/users" + .replace("{" + "group_id" + "}", localVarApiClient.escapeString(groupId.toString())); + + List localVarQueryParams = new ArrayList(); + List localVarCollectionQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + Map localVarCookieParams = new HashMap(); + Map localVarFormParams = new HashMap(); + + final String[] localVarAccepts = { + "application/json" + }; + final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts); + if (localVarAccept != null) { + localVarHeaderParams.put("Accept", localVarAccept); + } + + final String[] localVarContentTypes = { + "application/json" + }; + final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); + if (localVarContentType != null) { + localVarHeaderParams.put("Content-Type", localVarContentType); + } + + String[] localVarAuthNames = new String[] { }; + return localVarApiClient.buildCall(basePath, localVarPath, "POST", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); + } + + @SuppressWarnings("rawtypes") + private okhttp3.Call addMultipleUserToGroupValidateBeforeCall(String groupId, EMAddMultipleUserToGroup emAddMultipleUserToGroup, final ApiCallback _callback) throws ApiException { + // verify the required parameter 'groupId' is set + if (groupId == null) { + throw new ApiException("Missing the required parameter 'groupId' when calling addMultipleUserToGroup(Async)"); + } + + return addMultipleUserToGroupCall(groupId, emAddMultipleUserToGroup, _callback); + + } + + /** + * 批量添加群组成员 + * 一次为群组添加多个成员,每次最多可以添加 60 位成员。如果所有用户均已是群成员,添加失败,返回错误。文档介绍:https://docs-im-beta.easemob.com/document/server-side/group.html#%E6%89%B9%E9%87%8F%E6%B7%BB%E5%8A%A0%E7%BE%A4%E7%BB%84%E6%88%90%E5%91%98 + * @param groupId (required) + * @param emAddMultipleUserToGroup (optional) + * @return EMAddMultipleUserToGroupResult + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public EMAddMultipleUserToGroupResult addMultipleUserToGroup(String groupId, EMAddMultipleUserToGroup emAddMultipleUserToGroup) throws ApiException { + ApiResponse localVarResp = addMultipleUserToGroupWithHttpInfo(groupId, emAddMultipleUserToGroup); + return localVarResp.getData(); + } + + /** + * 批量添加群组成员 + * 一次为群组添加多个成员,每次最多可以添加 60 位成员。如果所有用户均已是群成员,添加失败,返回错误。文档介绍:https://docs-im-beta.easemob.com/document/server-side/group.html#%E6%89%B9%E9%87%8F%E6%B7%BB%E5%8A%A0%E7%BE%A4%E7%BB%84%E6%88%90%E5%91%98 + * @param groupId (required) + * @param emAddMultipleUserToGroup (optional) + * @return ApiResponse<EMAddMultipleUserToGroupResult> + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public ApiResponse addMultipleUserToGroupWithHttpInfo(String groupId, EMAddMultipleUserToGroup emAddMultipleUserToGroup) throws ApiException { + okhttp3.Call localVarCall = addMultipleUserToGroupValidateBeforeCall(groupId, emAddMultipleUserToGroup, null); + Type localVarReturnType = new TypeToken(){}.getType(); + return localVarApiClient.execute(localVarCall, localVarReturnType); + } + + /** + * 批量添加群组成员 (asynchronously) + * 一次为群组添加多个成员,每次最多可以添加 60 位成员。如果所有用户均已是群成员,添加失败,返回错误。文档介绍:https://docs-im-beta.easemob.com/document/server-side/group.html#%E6%89%B9%E9%87%8F%E6%B7%BB%E5%8A%A0%E7%BE%A4%E7%BB%84%E6%88%90%E5%91%98 + * @param groupId (required) + * @param emAddMultipleUserToGroup (optional) + * @param _callback The callback to be executed when the API call finishes + * @return The request call + * @throws ApiException If fail to process the API call, e.g. serializing the request body object + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public okhttp3.Call addMultipleUserToGroupAsync(String groupId, EMAddMultipleUserToGroup emAddMultipleUserToGroup, final ApiCallback _callback) throws ApiException { + + okhttp3.Call localVarCall = addMultipleUserToGroupValidateBeforeCall(groupId, emAddMultipleUserToGroup, _callback); + Type localVarReturnType = new TypeToken(){}.getType(); + localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); + return localVarCall; + } + /** + * Build call for addMultipleUserToGroupBlockList + * @param groupId (required) + * @param emAddMultipleUserToGroupBlockList (optional) + * @param _callback Callback for upload/download progress + * @return Call to execute + * @throws ApiException If fail to serialize the request body object + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public okhttp3.Call addMultipleUserToGroupBlockListCall(String groupId, EMAddMultipleUserToGroupBlockList emAddMultipleUserToGroupBlockList, final ApiCallback _callback) throws ApiException { + String basePath = null; + // Operation Servers + String[] localBasePaths = new String[] { }; + + // Determine Base Path to Use + if (localCustomBaseUrl != null){ + basePath = localCustomBaseUrl; + } else if ( localBasePaths.length > 0 ) { + basePath = localBasePaths[localHostIndex]; + } else { + basePath = null; + } + + Object localVarPostBody = emAddMultipleUserToGroupBlockList; + + // create path and map variables + String localVarPath = "/chatgroups/{group_id}/blocks/users" + .replace("{" + "group_id" + "}", localVarApiClient.escapeString(groupId.toString())); + + List localVarQueryParams = new ArrayList(); + List localVarCollectionQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + Map localVarCookieParams = new HashMap(); + Map localVarFormParams = new HashMap(); + + final String[] localVarAccepts = { + "application/json" + }; + final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts); + if (localVarAccept != null) { + localVarHeaderParams.put("Accept", localVarAccept); + } + + final String[] localVarContentTypes = { + "application/json" + }; + final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); + if (localVarContentType != null) { + localVarHeaderParams.put("Content-Type", localVarContentType); + } + + String[] localVarAuthNames = new String[] { }; + return localVarApiClient.buildCall(basePath, localVarPath, "POST", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); + } + + @SuppressWarnings("rawtypes") + private okhttp3.Call addMultipleUserToGroupBlockListValidateBeforeCall(String groupId, EMAddMultipleUserToGroupBlockList emAddMultipleUserToGroupBlockList, final ApiCallback _callback) throws ApiException { + // verify the required parameter 'groupId' is set + if (groupId == null) { + throw new ApiException("Missing the required parameter 'groupId' when calling addMultipleUserToGroupBlockList(Async)"); + } + + return addMultipleUserToGroupBlockListCall(groupId, emAddMultipleUserToGroupBlockList, _callback); + + } + + /** + * 批量添加用户至群组黑名单 + * 将多个用户添加至群组黑名单,一次最多可以添加 60 个用户。群主无法被加入群组的黑名单。用户进入群组黑名单后会收到加入黑名单的回调。黑名单上的用户无法查看该群组的信息,也收不到该群组的消息。文档介绍:https://docs-im-beta.easemob.com/document/server-side/group.html#%E6%89%B9%E9%87%8F%E6%B7%BB%E5%8A%A0%E7%94%A8%E6%88%B7%E8%87%B3%E7%BE%A4%E7%BB%84%E9%BB%91%E5%90%8D%E5%8D%95 + * @param groupId (required) + * @param emAddMultipleUserToGroupBlockList (optional) + * @return EMAddMultipleUserToGroupBlockListResult + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public EMAddMultipleUserToGroupBlockListResult addMultipleUserToGroupBlockList(String groupId, EMAddMultipleUserToGroupBlockList emAddMultipleUserToGroupBlockList) throws ApiException { + ApiResponse localVarResp = addMultipleUserToGroupBlockListWithHttpInfo(groupId, emAddMultipleUserToGroupBlockList); + return localVarResp.getData(); + } + + /** + * 批量添加用户至群组黑名单 + * 将多个用户添加至群组黑名单,一次最多可以添加 60 个用户。群主无法被加入群组的黑名单。用户进入群组黑名单后会收到加入黑名单的回调。黑名单上的用户无法查看该群组的信息,也收不到该群组的消息。文档介绍:https://docs-im-beta.easemob.com/document/server-side/group.html#%E6%89%B9%E9%87%8F%E6%B7%BB%E5%8A%A0%E7%94%A8%E6%88%B7%E8%87%B3%E7%BE%A4%E7%BB%84%E9%BB%91%E5%90%8D%E5%8D%95 + * @param groupId (required) + * @param emAddMultipleUserToGroupBlockList (optional) + * @return ApiResponse<EMAddMultipleUserToGroupBlockListResult> + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public ApiResponse addMultipleUserToGroupBlockListWithHttpInfo(String groupId, EMAddMultipleUserToGroupBlockList emAddMultipleUserToGroupBlockList) throws ApiException { + okhttp3.Call localVarCall = addMultipleUserToGroupBlockListValidateBeforeCall(groupId, emAddMultipleUserToGroupBlockList, null); + Type localVarReturnType = new TypeToken(){}.getType(); + return localVarApiClient.execute(localVarCall, localVarReturnType); + } + + /** + * 批量添加用户至群组黑名单 (asynchronously) + * 将多个用户添加至群组黑名单,一次最多可以添加 60 个用户。群主无法被加入群组的黑名单。用户进入群组黑名单后会收到加入黑名单的回调。黑名单上的用户无法查看该群组的信息,也收不到该群组的消息。文档介绍:https://docs-im-beta.easemob.com/document/server-side/group.html#%E6%89%B9%E9%87%8F%E6%B7%BB%E5%8A%A0%E7%94%A8%E6%88%B7%E8%87%B3%E7%BE%A4%E7%BB%84%E9%BB%91%E5%90%8D%E5%8D%95 + * @param groupId (required) + * @param emAddMultipleUserToGroupBlockList (optional) + * @param _callback The callback to be executed when the API call finishes + * @return The request call + * @throws ApiException If fail to process the API call, e.g. serializing the request body object + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public okhttp3.Call addMultipleUserToGroupBlockListAsync(String groupId, EMAddMultipleUserToGroupBlockList emAddMultipleUserToGroupBlockList, final ApiCallback _callback) throws ApiException { + + okhttp3.Call localVarCall = addMultipleUserToGroupBlockListValidateBeforeCall(groupId, emAddMultipleUserToGroupBlockList, _callback); + Type localVarReturnType = new TypeToken(){}.getType(); + localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); + return localVarCall; + } + /** + * Build call for addMultipleUserToGroupWhiteList + * @param groupId (required) + * @param emAddMultipleUserToGroupWhiteList (optional) + * @param _callback Callback for upload/download progress + * @return Call to execute + * @throws ApiException If fail to serialize the request body object + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public okhttp3.Call addMultipleUserToGroupWhiteListCall(String groupId, EMAddMultipleUserToGroupWhiteList emAddMultipleUserToGroupWhiteList, final ApiCallback _callback) throws ApiException { + String basePath = null; + // Operation Servers + String[] localBasePaths = new String[] { }; + + // Determine Base Path to Use + if (localCustomBaseUrl != null){ + basePath = localCustomBaseUrl; + } else if ( localBasePaths.length > 0 ) { + basePath = localBasePaths[localHostIndex]; + } else { + basePath = null; + } + + Object localVarPostBody = emAddMultipleUserToGroupWhiteList; + + // create path and map variables + String localVarPath = "/chatgroups/{group_id}/white/users" + .replace("{" + "group_id" + "}", localVarApiClient.escapeString(groupId.toString())); + + List localVarQueryParams = new ArrayList(); + List localVarCollectionQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + Map localVarCookieParams = new HashMap(); + Map localVarFormParams = new HashMap(); + + final String[] localVarAccepts = { + "application/json" + }; + final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts); + if (localVarAccept != null) { + localVarHeaderParams.put("Accept", localVarAccept); + } + + final String[] localVarContentTypes = { + "application/json" + }; + final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); + if (localVarContentType != null) { + localVarHeaderParams.put("Content-Type", localVarContentType); + } + + String[] localVarAuthNames = new String[] { }; + return localVarApiClient.buildCall(basePath, localVarPath, "POST", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); + } + + @SuppressWarnings("rawtypes") + private okhttp3.Call addMultipleUserToGroupWhiteListValidateBeforeCall(String groupId, EMAddMultipleUserToGroupWhiteList emAddMultipleUserToGroupWhiteList, final ApiCallback _callback) throws ApiException { + // verify the required parameter 'groupId' is set + if (groupId == null) { + throw new ApiException("Missing the required parameter 'groupId' when calling addMultipleUserToGroupWhiteList(Async)"); + } + + return addMultipleUserToGroupWhiteListCall(groupId, emAddMultipleUserToGroupWhiteList, _callback); + + } + + /** + * 批量添加用户至群组白名单 + * 添加多个用户至群组白名单。你一次最多可添加 60 个用户。用户添加至白名单后在群组全员禁言时仍可以在群组中发送消息。文档介绍:https://docs-im-beta.easemob.com/document/server-side/group.html#%E6%89%B9%E9%87%8F%E6%B7%BB%E5%8A%A0%E7%94%A8%E6%88%B7%E8%87%B3%E7%BE%A4%E7%BB%84%E7%99%BD%E5%90%8D%E5%8D%95 + * @param groupId (required) + * @param emAddMultipleUserToGroupWhiteList (optional) + * @return EMAddMultipleUserToGroupWhiteListResult + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public EMAddMultipleUserToGroupWhiteListResult addMultipleUserToGroupWhiteList(String groupId, EMAddMultipleUserToGroupWhiteList emAddMultipleUserToGroupWhiteList) throws ApiException { + ApiResponse localVarResp = addMultipleUserToGroupWhiteListWithHttpInfo(groupId, emAddMultipleUserToGroupWhiteList); + return localVarResp.getData(); + } + + /** + * 批量添加用户至群组白名单 + * 添加多个用户至群组白名单。你一次最多可添加 60 个用户。用户添加至白名单后在群组全员禁言时仍可以在群组中发送消息。文档介绍:https://docs-im-beta.easemob.com/document/server-side/group.html#%E6%89%B9%E9%87%8F%E6%B7%BB%E5%8A%A0%E7%94%A8%E6%88%B7%E8%87%B3%E7%BE%A4%E7%BB%84%E7%99%BD%E5%90%8D%E5%8D%95 + * @param groupId (required) + * @param emAddMultipleUserToGroupWhiteList (optional) + * @return ApiResponse<EMAddMultipleUserToGroupWhiteListResult> + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public ApiResponse addMultipleUserToGroupWhiteListWithHttpInfo(String groupId, EMAddMultipleUserToGroupWhiteList emAddMultipleUserToGroupWhiteList) throws ApiException { + okhttp3.Call localVarCall = addMultipleUserToGroupWhiteListValidateBeforeCall(groupId, emAddMultipleUserToGroupWhiteList, null); + Type localVarReturnType = new TypeToken(){}.getType(); + return localVarApiClient.execute(localVarCall, localVarReturnType); + } + + /** + * 批量添加用户至群组白名单 (asynchronously) + * 添加多个用户至群组白名单。你一次最多可添加 60 个用户。用户添加至白名单后在群组全员禁言时仍可以在群组中发送消息。文档介绍:https://docs-im-beta.easemob.com/document/server-side/group.html#%E6%89%B9%E9%87%8F%E6%B7%BB%E5%8A%A0%E7%94%A8%E6%88%B7%E8%87%B3%E7%BE%A4%E7%BB%84%E7%99%BD%E5%90%8D%E5%8D%95 + * @param groupId (required) + * @param emAddMultipleUserToGroupWhiteList (optional) + * @param _callback The callback to be executed when the API call finishes + * @return The request call + * @throws ApiException If fail to process the API call, e.g. serializing the request body object + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public okhttp3.Call addMultipleUserToGroupWhiteListAsync(String groupId, EMAddMultipleUserToGroupWhiteList emAddMultipleUserToGroupWhiteList, final ApiCallback _callback) throws ApiException { + + okhttp3.Call localVarCall = addMultipleUserToGroupWhiteListValidateBeforeCall(groupId, emAddMultipleUserToGroupWhiteList, _callback); + Type localVarReturnType = new TypeToken(){}.getType(); + localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); + return localVarCall; + } + /** + * Build call for addUserToGroup + * @param groupId (required) + * @param username (required) + * @param _callback Callback for upload/download progress + * @return Call to execute + * @throws ApiException If fail to serialize the request body object + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public okhttp3.Call addUserToGroupCall(String groupId, String username, final ApiCallback _callback) throws ApiException { + String basePath = null; + // Operation Servers + String[] localBasePaths = new String[] { }; + + // Determine Base Path to Use + if (localCustomBaseUrl != null){ + basePath = localCustomBaseUrl; + } else if ( localBasePaths.length > 0 ) { + basePath = localBasePaths[localHostIndex]; + } else { + basePath = null; + } + + Object localVarPostBody = null; + + // create path and map variables + String localVarPath = "/chatgroups/{group_id}/users/{username}" + .replace("{" + "group_id" + "}", localVarApiClient.escapeString(groupId.toString())) + .replace("{" + "username" + "}", localVarApiClient.escapeString(username.toString())); + + List localVarQueryParams = new ArrayList(); + List localVarCollectionQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + Map localVarCookieParams = new HashMap(); + Map localVarFormParams = new HashMap(); + + final String[] localVarAccepts = { + "application/json" + }; + final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts); + if (localVarAccept != null) { + localVarHeaderParams.put("Accept", localVarAccept); + } + + final String[] localVarContentTypes = { + }; + final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); + if (localVarContentType != null) { + localVarHeaderParams.put("Content-Type", localVarContentType); + } + + String[] localVarAuthNames = new String[] { }; + return localVarApiClient.buildCall(basePath, localVarPath, "POST", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); + } + + @SuppressWarnings("rawtypes") + private okhttp3.Call addUserToGroupValidateBeforeCall(String groupId, String username, final ApiCallback _callback) throws ApiException { + // verify the required parameter 'groupId' is set + if (groupId == null) { + throw new ApiException("Missing the required parameter 'groupId' when calling addUserToGroup(Async)"); + } + + // verify the required parameter 'username' is set + if (username == null) { + throw new ApiException("Missing the required parameter 'username' when calling addUserToGroup(Async)"); + } + + return addUserToGroupCall(groupId, username, _callback); + + } + + /** + * 添加单个群组成员 + * 每次添加一个群成员。若添加的用户已是群成员,则添加失败,返回错误。文档介绍:https://docs-im-beta.easemob.com/document/server-side/group.html#%E6%B7%BB%E5%8A%A0%E5%8D%95%E4%B8%AA%E7%BE%A4%E7%BB%84%E6%88%90%E5%91%98 + * @param groupId (required) + * @param username (required) + * @return EMAddUserToGroupResult + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public EMAddUserToGroupResult addUserToGroup(String groupId, String username) throws ApiException { + ApiResponse localVarResp = addUserToGroupWithHttpInfo(groupId, username); + return localVarResp.getData(); + } + + /** + * 添加单个群组成员 + * 每次添加一个群成员。若添加的用户已是群成员,则添加失败,返回错误。文档介绍:https://docs-im-beta.easemob.com/document/server-side/group.html#%E6%B7%BB%E5%8A%A0%E5%8D%95%E4%B8%AA%E7%BE%A4%E7%BB%84%E6%88%90%E5%91%98 + * @param groupId (required) + * @param username (required) + * @return ApiResponse<EMAddUserToGroupResult> + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public ApiResponse addUserToGroupWithHttpInfo(String groupId, String username) throws ApiException { + okhttp3.Call localVarCall = addUserToGroupValidateBeforeCall(groupId, username, null); + Type localVarReturnType = new TypeToken(){}.getType(); + return localVarApiClient.execute(localVarCall, localVarReturnType); + } + + /** + * 添加单个群组成员 (asynchronously) + * 每次添加一个群成员。若添加的用户已是群成员,则添加失败,返回错误。文档介绍:https://docs-im-beta.easemob.com/document/server-side/group.html#%E6%B7%BB%E5%8A%A0%E5%8D%95%E4%B8%AA%E7%BE%A4%E7%BB%84%E6%88%90%E5%91%98 + * @param groupId (required) + * @param username (required) + * @param _callback The callback to be executed when the API call finishes + * @return The request call + * @throws ApiException If fail to process the API call, e.g. serializing the request body object + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public okhttp3.Call addUserToGroupAsync(String groupId, String username, final ApiCallback _callback) throws ApiException { + + okhttp3.Call localVarCall = addUserToGroupValidateBeforeCall(groupId, username, _callback); + Type localVarReturnType = new TypeToken(){}.getType(); + localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); + return localVarCall; + } + /** + * Build call for addUserToGroupBlockList + * @param groupId (required) + * @param username (required) + * @param _callback Callback for upload/download progress + * @return Call to execute + * @throws ApiException If fail to serialize the request body object + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public okhttp3.Call addUserToGroupBlockListCall(String groupId, String username, final ApiCallback _callback) throws ApiException { + String basePath = null; + // Operation Servers + String[] localBasePaths = new String[] { }; + + // Determine Base Path to Use + if (localCustomBaseUrl != null){ + basePath = localCustomBaseUrl; + } else if ( localBasePaths.length > 0 ) { + basePath = localBasePaths[localHostIndex]; + } else { + basePath = null; + } + + Object localVarPostBody = null; + + // create path and map variables + String localVarPath = "/chatgroups/{group_id}/blocks/users/{username}" + .replace("{" + "group_id" + "}", localVarApiClient.escapeString(groupId.toString())) + .replace("{" + "username" + "}", localVarApiClient.escapeString(username.toString())); + + List localVarQueryParams = new ArrayList(); + List localVarCollectionQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + Map localVarCookieParams = new HashMap(); + Map localVarFormParams = new HashMap(); + + final String[] localVarAccepts = { + "application/json" + }; + final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts); + if (localVarAccept != null) { + localVarHeaderParams.put("Accept", localVarAccept); + } + + final String[] localVarContentTypes = { + }; + final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); + if (localVarContentType != null) { + localVarHeaderParams.put("Content-Type", localVarContentType); + } + + String[] localVarAuthNames = new String[] { }; + return localVarApiClient.buildCall(basePath, localVarPath, "POST", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); + } + + @SuppressWarnings("rawtypes") + private okhttp3.Call addUserToGroupBlockListValidateBeforeCall(String groupId, String username, final ApiCallback _callback) throws ApiException { + // verify the required parameter 'groupId' is set + if (groupId == null) { + throw new ApiException("Missing the required parameter 'groupId' when calling addUserToGroupBlockList(Async)"); + } + + // verify the required parameter 'username' is set + if (username == null) { + throw new ApiException("Missing the required parameter 'username' when calling addUserToGroupBlockList(Async)"); + } + + return addUserToGroupBlockListCall(groupId, username, _callback); + + } + + /** + * 添加单个用户至群组黑名单 + * 将单个用户添加至群组黑名单。群主无法被加入群组的黑名单。用户进入群组黑名单后会收到加入黑名单的回调。之后,该用户无法查看该群组的信息,也收不到该群组的消息。文档介绍:https://docs-im-beta.easemob.com/document/server-side/group.html#%E6%B7%BB%E5%8A%A0%E5%8D%95%E4%B8%AA%E7%94%A8%E6%88%B7%E8%87%B3%E7%BE%A4%E7%BB%84%E9%BB%91%E5%90%8D%E5%8D%95 + * @param groupId (required) + * @param username (required) + * @return EMAddUserToGroupBlockListResult + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public EMAddUserToGroupBlockListResult addUserToGroupBlockList(String groupId, String username) throws ApiException { + ApiResponse localVarResp = addUserToGroupBlockListWithHttpInfo(groupId, username); + return localVarResp.getData(); + } + + /** + * 添加单个用户至群组黑名单 + * 将单个用户添加至群组黑名单。群主无法被加入群组的黑名单。用户进入群组黑名单后会收到加入黑名单的回调。之后,该用户无法查看该群组的信息,也收不到该群组的消息。文档介绍:https://docs-im-beta.easemob.com/document/server-side/group.html#%E6%B7%BB%E5%8A%A0%E5%8D%95%E4%B8%AA%E7%94%A8%E6%88%B7%E8%87%B3%E7%BE%A4%E7%BB%84%E9%BB%91%E5%90%8D%E5%8D%95 + * @param groupId (required) + * @param username (required) + * @return ApiResponse<EMAddUserToGroupBlockListResult> + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public ApiResponse addUserToGroupBlockListWithHttpInfo(String groupId, String username) throws ApiException { + okhttp3.Call localVarCall = addUserToGroupBlockListValidateBeforeCall(groupId, username, null); + Type localVarReturnType = new TypeToken(){}.getType(); + return localVarApiClient.execute(localVarCall, localVarReturnType); + } + + /** + * 添加单个用户至群组黑名单 (asynchronously) + * 将单个用户添加至群组黑名单。群主无法被加入群组的黑名单。用户进入群组黑名单后会收到加入黑名单的回调。之后,该用户无法查看该群组的信息,也收不到该群组的消息。文档介绍:https://docs-im-beta.easemob.com/document/server-side/group.html#%E6%B7%BB%E5%8A%A0%E5%8D%95%E4%B8%AA%E7%94%A8%E6%88%B7%E8%87%B3%E7%BE%A4%E7%BB%84%E9%BB%91%E5%90%8D%E5%8D%95 + * @param groupId (required) + * @param username (required) + * @param _callback The callback to be executed when the API call finishes + * @return The request call + * @throws ApiException If fail to process the API call, e.g. serializing the request body object + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public okhttp3.Call addUserToGroupBlockListAsync(String groupId, String username, final ApiCallback _callback) throws ApiException { + + okhttp3.Call localVarCall = addUserToGroupBlockListValidateBeforeCall(groupId, username, _callback); + Type localVarReturnType = new TypeToken(){}.getType(); + localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); + return localVarCall; + } + /** + * Build call for addUserToGroupWhiteList + * @param groupId (required) + * @param username (required) + * @param _callback Callback for upload/download progress + * @return Call to execute + * @throws ApiException If fail to serialize the request body object + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public okhttp3.Call addUserToGroupWhiteListCall(String groupId, String username, final ApiCallback _callback) throws ApiException { + String basePath = null; + // Operation Servers + String[] localBasePaths = new String[] { }; + + // Determine Base Path to Use + if (localCustomBaseUrl != null){ + basePath = localCustomBaseUrl; + } else if ( localBasePaths.length > 0 ) { + basePath = localBasePaths[localHostIndex]; + } else { + basePath = null; + } + + Object localVarPostBody = null; + + // create path and map variables + String localVarPath = "/chatgroups/{group_id}/white/users/{username}" + .replace("{" + "group_id" + "}", localVarApiClient.escapeString(groupId.toString())) + .replace("{" + "username" + "}", localVarApiClient.escapeString(username.toString())); + + List localVarQueryParams = new ArrayList(); + List localVarCollectionQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + Map localVarCookieParams = new HashMap(); + Map localVarFormParams = new HashMap(); + + final String[] localVarAccepts = { + "application/json" + }; + final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts); + if (localVarAccept != null) { + localVarHeaderParams.put("Accept", localVarAccept); + } + + final String[] localVarContentTypes = { + }; + final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); + if (localVarContentType != null) { + localVarHeaderParams.put("Content-Type", localVarContentType); + } + + String[] localVarAuthNames = new String[] { }; + return localVarApiClient.buildCall(basePath, localVarPath, "POST", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); + } + + @SuppressWarnings("rawtypes") + private okhttp3.Call addUserToGroupWhiteListValidateBeforeCall(String groupId, String username, final ApiCallback _callback) throws ApiException { + // verify the required parameter 'groupId' is set + if (groupId == null) { + throw new ApiException("Missing the required parameter 'groupId' when calling addUserToGroupWhiteList(Async)"); + } + + // verify the required parameter 'username' is set + if (username == null) { + throw new ApiException("Missing the required parameter 'username' when calling addUserToGroupWhiteList(Async)"); + } + + return addUserToGroupWhiteListCall(groupId, username, _callback); + + } + + /** + * 添加单个用户至群组白名单 + * 将指定的单个用户添加至群组白名单。用户添加至群组白名单后,当群组全员被禁言时,仍可以在群组中发送消息。文档介绍:https://docs-im-beta.easemob.com/document/server-side/group.html#%E6%9F%A5%E8%AF%A2%E7%BE%A4%E7%BB%84%E7%99%BD%E5%90%8D%E5%8D%95 + * @param groupId (required) + * @param username (required) + * @return EMAddUserToGroupWhiteListResult + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public EMAddUserToGroupWhiteListResult addUserToGroupWhiteList(String groupId, String username) throws ApiException { + ApiResponse localVarResp = addUserToGroupWhiteListWithHttpInfo(groupId, username); + return localVarResp.getData(); + } + + /** + * 添加单个用户至群组白名单 + * 将指定的单个用户添加至群组白名单。用户添加至群组白名单后,当群组全员被禁言时,仍可以在群组中发送消息。文档介绍:https://docs-im-beta.easemob.com/document/server-side/group.html#%E6%9F%A5%E8%AF%A2%E7%BE%A4%E7%BB%84%E7%99%BD%E5%90%8D%E5%8D%95 + * @param groupId (required) + * @param username (required) + * @return ApiResponse<EMAddUserToGroupWhiteListResult> + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public ApiResponse addUserToGroupWhiteListWithHttpInfo(String groupId, String username) throws ApiException { + okhttp3.Call localVarCall = addUserToGroupWhiteListValidateBeforeCall(groupId, username, null); + Type localVarReturnType = new TypeToken(){}.getType(); + return localVarApiClient.execute(localVarCall, localVarReturnType); + } + + /** + * 添加单个用户至群组白名单 (asynchronously) + * 将指定的单个用户添加至群组白名单。用户添加至群组白名单后,当群组全员被禁言时,仍可以在群组中发送消息。文档介绍:https://docs-im-beta.easemob.com/document/server-side/group.html#%E6%9F%A5%E8%AF%A2%E7%BE%A4%E7%BB%84%E7%99%BD%E5%90%8D%E5%8D%95 + * @param groupId (required) + * @param username (required) + * @param _callback The callback to be executed when the API call finishes + * @return The request call + * @throws ApiException If fail to process the API call, e.g. serializing the request body object + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public okhttp3.Call addUserToGroupWhiteListAsync(String groupId, String username, final ApiCallback _callback) throws ApiException { + + okhttp3.Call localVarCall = addUserToGroupWhiteListValidateBeforeCall(groupId, username, _callback); + Type localVarReturnType = new TypeToken(){}.getType(); + localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); + return localVarCall; + } + /** + * Build call for checkUserJoinedGroup + * @param groupId (required) + * @param username (required) + * @param _callback Callback for upload/download progress + * @return Call to execute + * @throws ApiException If fail to serialize the request body object + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public okhttp3.Call checkUserJoinedGroupCall(String groupId, String username, final ApiCallback _callback) throws ApiException { + String basePath = null; + // Operation Servers + String[] localBasePaths = new String[] { }; + + // Determine Base Path to Use + if (localCustomBaseUrl != null){ + basePath = localCustomBaseUrl; + } else if ( localBasePaths.length > 0 ) { + basePath = localBasePaths[localHostIndex]; + } else { + basePath = null; + } + + Object localVarPostBody = null; + + // create path and map variables + String localVarPath = "/chatgroups/{group_id}/user/{username}/is_joined" + .replace("{" + "group_id" + "}", localVarApiClient.escapeString(groupId.toString())) + .replace("{" + "username" + "}", localVarApiClient.escapeString(username.toString())); + + List localVarQueryParams = new ArrayList(); + List localVarCollectionQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + Map localVarCookieParams = new HashMap(); + Map localVarFormParams = new HashMap(); + + final String[] localVarAccepts = { + "application/json" + }; + final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts); + if (localVarAccept != null) { + localVarHeaderParams.put("Accept", localVarAccept); + } + + final String[] localVarContentTypes = { + }; + final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); + if (localVarContentType != null) { + localVarHeaderParams.put("Content-Type", localVarContentType); + } + + String[] localVarAuthNames = new String[] { }; + return localVarApiClient.buildCall(basePath, localVarPath, "GET", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); + } + + @SuppressWarnings("rawtypes") + private okhttp3.Call checkUserJoinedGroupValidateBeforeCall(String groupId, String username, final ApiCallback _callback) throws ApiException { + // verify the required parameter 'groupId' is set + if (groupId == null) { + throw new ApiException("Missing the required parameter 'groupId' when calling checkUserJoinedGroup(Async)"); + } + + // verify the required parameter 'username' is set + if (username == null) { + throw new ApiException("Missing the required parameter 'username' when calling checkUserJoinedGroup(Async)"); + } + + return checkUserJoinedGroupCall(groupId, username, _callback); + + } + + /** + * 查看指定用户是否已加入群组 + * 查看单个用户是否已加入了指定的群组。文档介绍:https://docs-im-beta.easemob.com/document/server-side/group.html#%E6%9F%A5%E7%9C%8B%E6%8C%87%E5%AE%9A%E7%94%A8%E6%88%B7%E6%98%AF%E5%90%A6%E5%B7%B2%E5%8A%A0%E5%85%A5%E7%BE%A4%E7%BB%84 + * @param groupId (required) + * @param username (required) + * @return EMCheckUserJoinedGroupResult + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public EMCheckUserJoinedGroupResult checkUserJoinedGroup(String groupId, String username) throws ApiException { + ApiResponse localVarResp = checkUserJoinedGroupWithHttpInfo(groupId, username); + return localVarResp.getData(); + } + + /** + * 查看指定用户是否已加入群组 + * 查看单个用户是否已加入了指定的群组。文档介绍:https://docs-im-beta.easemob.com/document/server-side/group.html#%E6%9F%A5%E7%9C%8B%E6%8C%87%E5%AE%9A%E7%94%A8%E6%88%B7%E6%98%AF%E5%90%A6%E5%B7%B2%E5%8A%A0%E5%85%A5%E7%BE%A4%E7%BB%84 + * @param groupId (required) + * @param username (required) + * @return ApiResponse<EMCheckUserJoinedGroupResult> + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public ApiResponse checkUserJoinedGroupWithHttpInfo(String groupId, String username) throws ApiException { + okhttp3.Call localVarCall = checkUserJoinedGroupValidateBeforeCall(groupId, username, null); + Type localVarReturnType = new TypeToken(){}.getType(); + return localVarApiClient.execute(localVarCall, localVarReturnType); + } + + /** + * 查看指定用户是否已加入群组 (asynchronously) + * 查看单个用户是否已加入了指定的群组。文档介绍:https://docs-im-beta.easemob.com/document/server-side/group.html#%E6%9F%A5%E7%9C%8B%E6%8C%87%E5%AE%9A%E7%94%A8%E6%88%B7%E6%98%AF%E5%90%A6%E5%B7%B2%E5%8A%A0%E5%85%A5%E7%BE%A4%E7%BB%84 + * @param groupId (required) + * @param username (required) + * @param _callback The callback to be executed when the API call finishes + * @return The request call + * @throws ApiException If fail to process the API call, e.g. serializing the request body object + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public okhttp3.Call checkUserJoinedGroupAsync(String groupId, String username, final ApiCallback _callback) throws ApiException { + + okhttp3.Call localVarCall = checkUserJoinedGroupValidateBeforeCall(groupId, username, _callback); + Type localVarReturnType = new TypeToken(){}.getType(); + localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); + return localVarCall; + } + /** + * Build call for createGroup + * @param emCreateGroup (optional) + * @param _callback Callback for upload/download progress + * @return Call to execute + * @throws ApiException If fail to serialize the request body object + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public okhttp3.Call createGroupCall(EMCreateGroup emCreateGroup, final ApiCallback _callback) throws ApiException { + String basePath = null; + // Operation Servers + String[] localBasePaths = new String[] { }; + + // Determine Base Path to Use + if (localCustomBaseUrl != null){ + basePath = localCustomBaseUrl; + } else if ( localBasePaths.length > 0 ) { + basePath = localBasePaths[localHostIndex]; + } else { + basePath = null; + } + + Object localVarPostBody = emCreateGroup; + + // create path and map variables + String localVarPath = "/chatgroups"; + + List localVarQueryParams = new ArrayList(); + List localVarCollectionQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + Map localVarCookieParams = new HashMap(); + Map localVarFormParams = new HashMap(); + + final String[] localVarAccepts = { + "application/json" + }; + final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts); + if (localVarAccept != null) { + localVarHeaderParams.put("Accept", localVarAccept); + } + + final String[] localVarContentTypes = { + "application/json" + }; + final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); + if (localVarContentType != null) { + localVarHeaderParams.put("Content-Type", localVarContentType); + } + + String[] localVarAuthNames = new String[] { }; + return localVarApiClient.buildCall(basePath, localVarPath, "POST", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); + } + + @SuppressWarnings("rawtypes") + private okhttp3.Call createGroupValidateBeforeCall(EMCreateGroup emCreateGroup, final ApiCallback _callback) throws ApiException { + return createGroupCall(emCreateGroup, _callback); + + } + + /** + * 创建群组 + * 创建一个群组,并设置群组名称、群组描述、公开群/私有群属性、群成员最大人数(包括群主)、加入公开群是否需要批准、群主、群成员和群组扩展信息。文档介绍:https://docs-im-beta.easemob.com/document/server-side/group.html#%E5%88%9B%E5%BB%BA%E7%BE%A4%E7%BB%84 + * @param emCreateGroup (optional) + * @return EMCreateGroupResult + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public EMCreateGroupResult createGroup(EMCreateGroup emCreateGroup) throws ApiException { + ApiResponse localVarResp = createGroupWithHttpInfo(emCreateGroup); + return localVarResp.getData(); + } + + /** + * 创建群组 + * 创建一个群组,并设置群组名称、群组描述、公开群/私有群属性、群成员最大人数(包括群主)、加入公开群是否需要批准、群主、群成员和群组扩展信息。文档介绍:https://docs-im-beta.easemob.com/document/server-side/group.html#%E5%88%9B%E5%BB%BA%E7%BE%A4%E7%BB%84 + * @param emCreateGroup (optional) + * @return ApiResponse<EMCreateGroupResult> + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public ApiResponse createGroupWithHttpInfo(EMCreateGroup emCreateGroup) throws ApiException { + okhttp3.Call localVarCall = createGroupValidateBeforeCall(emCreateGroup, null); + Type localVarReturnType = new TypeToken(){}.getType(); + return localVarApiClient.execute(localVarCall, localVarReturnType); + } + + /** + * 创建群组 (asynchronously) + * 创建一个群组,并设置群组名称、群组描述、公开群/私有群属性、群成员最大人数(包括群主)、加入公开群是否需要批准、群主、群成员和群组扩展信息。文档介绍:https://docs-im-beta.easemob.com/document/server-side/group.html#%E5%88%9B%E5%BB%BA%E7%BE%A4%E7%BB%84 + * @param emCreateGroup (optional) + * @param _callback The callback to be executed when the API call finishes + * @return The request call + * @throws ApiException If fail to process the API call, e.g. serializing the request body object + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public okhttp3.Call createGroupAsync(EMCreateGroup emCreateGroup, final ApiCallback _callback) throws ApiException { + + okhttp3.Call localVarCall = createGroupValidateBeforeCall(emCreateGroup, _callback); + Type localVarReturnType = new TypeToken(){}.getType(); + localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); + return localVarCall; + } + /** + * Build call for deleteGroup + * @param groupId (required) + * @param _callback Callback for upload/download progress + * @return Call to execute + * @throws ApiException If fail to serialize the request body object + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public okhttp3.Call deleteGroupCall(String groupId, final ApiCallback _callback) throws ApiException { + String basePath = null; + // Operation Servers + String[] localBasePaths = new String[] { }; + + // Determine Base Path to Use + if (localCustomBaseUrl != null){ + basePath = localCustomBaseUrl; + } else if ( localBasePaths.length > 0 ) { + basePath = localBasePaths[localHostIndex]; + } else { + basePath = null; + } + + Object localVarPostBody = null; + + // create path and map variables + String localVarPath = "/chatgroups/{group_id}" + .replace("{" + "group_id" + "}", localVarApiClient.escapeString(groupId.toString())); + + List localVarQueryParams = new ArrayList(); + List localVarCollectionQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + Map localVarCookieParams = new HashMap(); + Map localVarFormParams = new HashMap(); + + final String[] localVarAccepts = { + "application/json" + }; + final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts); + if (localVarAccept != null) { + localVarHeaderParams.put("Accept", localVarAccept); + } + + final String[] localVarContentTypes = { + }; + final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); + if (localVarContentType != null) { + localVarHeaderParams.put("Content-Type", localVarContentType); + } + + String[] localVarAuthNames = new String[] { }; + return localVarApiClient.buildCall(basePath, localVarPath, "DELETE", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); + } + + @SuppressWarnings("rawtypes") + private okhttp3.Call deleteGroupValidateBeforeCall(String groupId, final ApiCallback _callback) throws ApiException { + // verify the required parameter 'groupId' is set + if (groupId == null) { + throw new ApiException("Missing the required parameter 'groupId' when calling deleteGroup(Async)"); + } + + return deleteGroupCall(groupId, _callback); + + } + + /** + * 删除群组 + * 删除指定的群组。删除群组时会同时删除群组下所有的子区(Thread)。文档介绍:https://docs-im-beta.easemob.com/document/server-side/group.html#%E5%88%A0%E9%99%A4%E7%BE%A4%E7%BB%84 + * @param groupId (required) + * @return EMDeleteGroupResult + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public EMDeleteGroupResult deleteGroup(String groupId) throws ApiException { + ApiResponse localVarResp = deleteGroupWithHttpInfo(groupId); + return localVarResp.getData(); + } + + /** + * 删除群组 + * 删除指定的群组。删除群组时会同时删除群组下所有的子区(Thread)。文档介绍:https://docs-im-beta.easemob.com/document/server-side/group.html#%E5%88%A0%E9%99%A4%E7%BE%A4%E7%BB%84 + * @param groupId (required) + * @return ApiResponse<EMDeleteGroupResult> + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public ApiResponse deleteGroupWithHttpInfo(String groupId) throws ApiException { + okhttp3.Call localVarCall = deleteGroupValidateBeforeCall(groupId, null); + Type localVarReturnType = new TypeToken(){}.getType(); + return localVarApiClient.execute(localVarCall, localVarReturnType); + } + + /** + * 删除群组 (asynchronously) + * 删除指定的群组。删除群组时会同时删除群组下所有的子区(Thread)。文档介绍:https://docs-im-beta.easemob.com/document/server-side/group.html#%E5%88%A0%E9%99%A4%E7%BE%A4%E7%BB%84 + * @param groupId (required) + * @param _callback The callback to be executed when the API call finishes + * @return The request call + * @throws ApiException If fail to process the API call, e.g. serializing the request body object + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public okhttp3.Call deleteGroupAsync(String groupId, final ApiCallback _callback) throws ApiException { + + okhttp3.Call localVarCall = deleteGroupValidateBeforeCall(groupId, _callback); + Type localVarReturnType = new TypeToken(){}.getType(); + localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); + return localVarCall; + } + /** + * Build call for deleteGroupShareFile + * @param groupId (required) + * @param fileId (required) + * @param _callback Callback for upload/download progress + * @return Call to execute + * @throws ApiException If fail to serialize the request body object + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public okhttp3.Call deleteGroupShareFileCall(String groupId, String fileId, final ApiCallback _callback) throws ApiException { + String basePath = null; + // Operation Servers + String[] localBasePaths = new String[] { }; + + // Determine Base Path to Use + if (localCustomBaseUrl != null){ + basePath = localCustomBaseUrl; + } else if ( localBasePaths.length > 0 ) { + basePath = localBasePaths[localHostIndex]; + } else { + basePath = null; + } + + Object localVarPostBody = null; + + // create path and map variables + String localVarPath = "/chatgroups/{group_id}/share_files/{file_id}" + .replace("{" + "group_id" + "}", localVarApiClient.escapeString(groupId.toString())) + .replace("{" + "file_id" + "}", localVarApiClient.escapeString(fileId.toString())); + + List localVarQueryParams = new ArrayList(); + List localVarCollectionQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + Map localVarCookieParams = new HashMap(); + Map localVarFormParams = new HashMap(); + + final String[] localVarAccepts = { + "application/json" + }; + final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts); + if (localVarAccept != null) { + localVarHeaderParams.put("Accept", localVarAccept); + } + + final String[] localVarContentTypes = { + }; + final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); + if (localVarContentType != null) { + localVarHeaderParams.put("Content-Type", localVarContentType); + } + + String[] localVarAuthNames = new String[] { }; + return localVarApiClient.buildCall(basePath, localVarPath, "DELETE", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); + } + + @SuppressWarnings("rawtypes") + private okhttp3.Call deleteGroupShareFileValidateBeforeCall(String groupId, String fileId, final ApiCallback _callback) throws ApiException { + // verify the required parameter 'groupId' is set + if (groupId == null) { + throw new ApiException("Missing the required parameter 'groupId' when calling deleteGroupShareFile(Async)"); + } + + // verify the required parameter 'fileId' is set + if (fileId == null) { + throw new ApiException("Missing the required parameter 'fileId' when calling deleteGroupShareFile(Async)"); + } + + return deleteGroupShareFileCall(groupId, fileId, _callback); + + } + + /** + * 删除群组共享文件 + * 根据指定的群组 ID 与 文件 ID(file_id)删除群组共享文件,文件 ID 可从 获取群组共享文件 接口的响应中获取。文档介绍:https://docs-im-beta.easemob.com/document/server-side/group.html#%E5%88%A0%E9%99%A4%E7%BE%A4%E7%BB%84%E5%85%B1%E4%BA%AB%E6%96%87%E4%BB%B6 + * @param groupId (required) + * @param fileId (required) + * @return EMDeleteGroupShareFileResult + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public EMDeleteGroupShareFileResult deleteGroupShareFile(String groupId, String fileId) throws ApiException { + ApiResponse localVarResp = deleteGroupShareFileWithHttpInfo(groupId, fileId); + return localVarResp.getData(); + } + + /** + * 删除群组共享文件 + * 根据指定的群组 ID 与 文件 ID(file_id)删除群组共享文件,文件 ID 可从 获取群组共享文件 接口的响应中获取。文档介绍:https://docs-im-beta.easemob.com/document/server-side/group.html#%E5%88%A0%E9%99%A4%E7%BE%A4%E7%BB%84%E5%85%B1%E4%BA%AB%E6%96%87%E4%BB%B6 + * @param groupId (required) + * @param fileId (required) + * @return ApiResponse<EMDeleteGroupShareFileResult> + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public ApiResponse deleteGroupShareFileWithHttpInfo(String groupId, String fileId) throws ApiException { + okhttp3.Call localVarCall = deleteGroupShareFileValidateBeforeCall(groupId, fileId, null); + Type localVarReturnType = new TypeToken(){}.getType(); + return localVarApiClient.execute(localVarCall, localVarReturnType); + } + + /** + * 删除群组共享文件 (asynchronously) + * 根据指定的群组 ID 与 文件 ID(file_id)删除群组共享文件,文件 ID 可从 获取群组共享文件 接口的响应中获取。文档介绍:https://docs-im-beta.easemob.com/document/server-side/group.html#%E5%88%A0%E9%99%A4%E7%BE%A4%E7%BB%84%E5%85%B1%E4%BA%AB%E6%96%87%E4%BB%B6 + * @param groupId (required) + * @param fileId (required) + * @param _callback The callback to be executed when the API call finishes + * @return The request call + * @throws ApiException If fail to process the API call, e.g. serializing the request body object + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public okhttp3.Call deleteGroupShareFileAsync(String groupId, String fileId, final ApiCallback _callback) throws ApiException { + + okhttp3.Call localVarCall = deleteGroupShareFileValidateBeforeCall(groupId, fileId, _callback); + Type localVarReturnType = new TypeToken(){}.getType(); + localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); + return localVarCall; + } + /** + * Build call for disableGroup + * @param groupId (required) + * @param _callback Callback for upload/download progress + * @return Call to execute + * @throws ApiException If fail to serialize the request body object + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public okhttp3.Call disableGroupCall(String groupId, final ApiCallback _callback) throws ApiException { + String basePath = null; + // Operation Servers + String[] localBasePaths = new String[] { }; + + // Determine Base Path to Use + if (localCustomBaseUrl != null){ + basePath = localCustomBaseUrl; + } else if ( localBasePaths.length > 0 ) { + basePath = localBasePaths[localHostIndex]; + } else { + basePath = null; + } + + Object localVarPostBody = null; + + // create path and map variables + String localVarPath = "/chatgroups/{group_id}/disable" + .replace("{" + "group_id" + "}", localVarApiClient.escapeString(groupId.toString())); + + List localVarQueryParams = new ArrayList(); + List localVarCollectionQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + Map localVarCookieParams = new HashMap(); + Map localVarFormParams = new HashMap(); + + final String[] localVarAccepts = { + "application/json" + }; + final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts); + if (localVarAccept != null) { + localVarHeaderParams.put("Accept", localVarAccept); + } + + final String[] localVarContentTypes = { + }; + final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); + if (localVarContentType != null) { + localVarHeaderParams.put("Content-Type", localVarContentType); + } + + String[] localVarAuthNames = new String[] { }; + return localVarApiClient.buildCall(basePath, localVarPath, "POST", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); + } + + @SuppressWarnings("rawtypes") + private okhttp3.Call disableGroupValidateBeforeCall(String groupId, final ApiCallback _callback) throws ApiException { + // verify the required parameter 'groupId' is set + if (groupId == null) { + throw new ApiException("Missing the required parameter 'groupId' when calling disableGroup(Async)"); + } + + return disableGroupCall(groupId, _callback); + + } + + /** + * 封禁群组 + * 封禁指定的群组。例如,群成员经常在群中发送违规消息,可以调用该 API 对该群进行封禁。群组被封禁后,群中任何成员均无法在群组以及该群组下的子区中发送和接收消息,也无法进行群组和子区管理操作。文档介绍:https://docs-im-beta.easemob.com/document/server-side/group.html#%E5%B0%81%E7%A6%81%E7%BE%A4%E7%BB%84 + * @param groupId (required) + * @return EMDisableGroupResult + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public EMDisableGroupResult disableGroup(String groupId) throws ApiException { + ApiResponse localVarResp = disableGroupWithHttpInfo(groupId); + return localVarResp.getData(); + } + + /** + * 封禁群组 + * 封禁指定的群组。例如,群成员经常在群中发送违规消息,可以调用该 API 对该群进行封禁。群组被封禁后,群中任何成员均无法在群组以及该群组下的子区中发送和接收消息,也无法进行群组和子区管理操作。文档介绍:https://docs-im-beta.easemob.com/document/server-side/group.html#%E5%B0%81%E7%A6%81%E7%BE%A4%E7%BB%84 + * @param groupId (required) + * @return ApiResponse<EMDisableGroupResult> + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public ApiResponse disableGroupWithHttpInfo(String groupId) throws ApiException { + okhttp3.Call localVarCall = disableGroupValidateBeforeCall(groupId, null); + Type localVarReturnType = new TypeToken(){}.getType(); + return localVarApiClient.execute(localVarCall, localVarReturnType); + } + + /** + * 封禁群组 (asynchronously) + * 封禁指定的群组。例如,群成员经常在群中发送违规消息,可以调用该 API 对该群进行封禁。群组被封禁后,群中任何成员均无法在群组以及该群组下的子区中发送和接收消息,也无法进行群组和子区管理操作。文档介绍:https://docs-im-beta.easemob.com/document/server-side/group.html#%E5%B0%81%E7%A6%81%E7%BE%A4%E7%BB%84 + * @param groupId (required) + * @param _callback The callback to be executed when the API call finishes + * @return The request call + * @throws ApiException If fail to process the API call, e.g. serializing the request body object + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public okhttp3.Call disableGroupAsync(String groupId, final ApiCallback _callback) throws ApiException { + + okhttp3.Call localVarCall = disableGroupValidateBeforeCall(groupId, _callback); + Type localVarReturnType = new TypeToken(){}.getType(); + localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); + return localVarCall; + } + /** + * Build call for downloadGroupShareFile + * @param groupId (required) + * @param fileId (required) + * @param _callback Callback for upload/download progress + * @return Call to execute + * @throws ApiException If fail to serialize the request body object + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public okhttp3.Call downloadGroupShareFileCall(String groupId, String fileId, final ApiCallback _callback) throws ApiException { + String basePath = null; + // Operation Servers + String[] localBasePaths = new String[] { }; + + // Determine Base Path to Use + if (localCustomBaseUrl != null){ + basePath = localCustomBaseUrl; + } else if ( localBasePaths.length > 0 ) { + basePath = localBasePaths[localHostIndex]; + } else { + basePath = null; + } + + Object localVarPostBody = null; + + // create path and map variables + String localVarPath = "/chatgroups/{group_id}/share_files/{file_id}" + .replace("{" + "group_id" + "}", localVarApiClient.escapeString(groupId.toString())) + .replace("{" + "file_id" + "}", localVarApiClient.escapeString(fileId.toString())); + + List localVarQueryParams = new ArrayList(); + List localVarCollectionQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + Map localVarCookieParams = new HashMap(); + Map localVarFormParams = new HashMap(); + + final String[] localVarAccepts = { + "application/octet-stream" + }; + final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts); + if (localVarAccept != null) { + localVarHeaderParams.put("Accept", localVarAccept); + } + + final String[] localVarContentTypes = { + }; + final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); + if (localVarContentType != null) { + localVarHeaderParams.put("Content-Type", localVarContentType); + } + + String[] localVarAuthNames = new String[] { }; + return localVarApiClient.buildCall(basePath, localVarPath, "GET", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); + } + + @SuppressWarnings("rawtypes") + private okhttp3.Call downloadGroupShareFileValidateBeforeCall(String groupId, String fileId, final ApiCallback _callback) throws ApiException { + // verify the required parameter 'groupId' is set + if (groupId == null) { + throw new ApiException("Missing the required parameter 'groupId' when calling downloadGroupShareFile(Async)"); + } + + // verify the required parameter 'fileId' is set + if (fileId == null) { + throw new ApiException("Missing the required parameter 'fileId' when calling downloadGroupShareFile(Async)"); + } + + return downloadGroupShareFileCall(groupId, fileId, _callback); + + } + + /** + * 下载群组共享文件 + * 根据指定的群组 ID 与文件 ID(file_id)下载群组共享文件,文件 ID 可从 获取群组共享文件 接口的响应中获取。文档介绍:https://docs-im-beta.easemob.com/document/server-side/group.html#%E4%B8%8B%E8%BD%BD%E7%BE%A4%E7%BB%84%E5%85%B1%E4%BA%AB%E6%96%87%E4%BB%B6 + * @param groupId (required) + * @param fileId (required) + * @return File + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public File downloadGroupShareFile(String groupId, String fileId) throws ApiException { + ApiResponse localVarResp = downloadGroupShareFileWithHttpInfo(groupId, fileId); + return localVarResp.getData(); + } + + /** + * 下载群组共享文件 + * 根据指定的群组 ID 与文件 ID(file_id)下载群组共享文件,文件 ID 可从 获取群组共享文件 接口的响应中获取。文档介绍:https://docs-im-beta.easemob.com/document/server-side/group.html#%E4%B8%8B%E8%BD%BD%E7%BE%A4%E7%BB%84%E5%85%B1%E4%BA%AB%E6%96%87%E4%BB%B6 + * @param groupId (required) + * @param fileId (required) + * @return ApiResponse<File> + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public ApiResponse downloadGroupShareFileWithHttpInfo(String groupId, String fileId) throws ApiException { + okhttp3.Call localVarCall = downloadGroupShareFileValidateBeforeCall(groupId, fileId, null); + Type localVarReturnType = new TypeToken(){}.getType(); + return localVarApiClient.execute(localVarCall, localVarReturnType); + } + + /** + * 下载群组共享文件 (asynchronously) + * 根据指定的群组 ID 与文件 ID(file_id)下载群组共享文件,文件 ID 可从 获取群组共享文件 接口的响应中获取。文档介绍:https://docs-im-beta.easemob.com/document/server-side/group.html#%E4%B8%8B%E8%BD%BD%E7%BE%A4%E7%BB%84%E5%85%B1%E4%BA%AB%E6%96%87%E4%BB%B6 + * @param groupId (required) + * @param fileId (required) + * @param _callback The callback to be executed when the API call finishes + * @return The request call + * @throws ApiException If fail to process the API call, e.g. serializing the request body object + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public okhttp3.Call downloadGroupShareFileAsync(String groupId, String fileId, final ApiCallback _callback) throws ApiException { + + okhttp3.Call localVarCall = downloadGroupShareFileValidateBeforeCall(groupId, fileId, _callback); + Type localVarReturnType = new TypeToken(){}.getType(); + localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); + return localVarCall; + } + /** + * Build call for enableGroup + * @param groupId (required) + * @param _callback Callback for upload/download progress + * @return Call to execute + * @throws ApiException If fail to serialize the request body object + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public okhttp3.Call enableGroupCall(String groupId, final ApiCallback _callback) throws ApiException { + String basePath = null; + // Operation Servers + String[] localBasePaths = new String[] { }; + + // Determine Base Path to Use + if (localCustomBaseUrl != null){ + basePath = localCustomBaseUrl; + } else if ( localBasePaths.length > 0 ) { + basePath = localBasePaths[localHostIndex]; + } else { + basePath = null; + } + + Object localVarPostBody = null; + + // create path and map variables + String localVarPath = "/chatgroups/{group_id}/enable" + .replace("{" + "group_id" + "}", localVarApiClient.escapeString(groupId.toString())); + + List localVarQueryParams = new ArrayList(); + List localVarCollectionQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + Map localVarCookieParams = new HashMap(); + Map localVarFormParams = new HashMap(); + + final String[] localVarAccepts = { + "application/json" + }; + final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts); + if (localVarAccept != null) { + localVarHeaderParams.put("Accept", localVarAccept); + } + + final String[] localVarContentTypes = { + }; + final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); + if (localVarContentType != null) { + localVarHeaderParams.put("Content-Type", localVarContentType); + } + + String[] localVarAuthNames = new String[] { }; + return localVarApiClient.buildCall(basePath, localVarPath, "POST", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); + } + + @SuppressWarnings("rawtypes") + private okhttp3.Call enableGroupValidateBeforeCall(String groupId, final ApiCallback _callback) throws ApiException { + // verify the required parameter 'groupId' is set + if (groupId == null) { + throw new ApiException("Missing the required parameter 'groupId' when calling enableGroup(Async)"); + } + + return enableGroupCall(groupId, _callback); + + } + + /** + * 封禁群组 + * 解除对指定群组的封禁。群组解禁后,群成员可以在该群组以及该群组下的子区中发送和接收消息并进行群组和子区管理相关操作。文档介绍:https://docs-im-beta.easemob.com/document/server-side/group.html#%E8%A7%A3%E7%A6%81%E7%BE%A4%E7%BB%84 + * @param groupId (required) + * @return EMEnableGroupResult + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public EMEnableGroupResult enableGroup(String groupId) throws ApiException { + ApiResponse localVarResp = enableGroupWithHttpInfo(groupId); + return localVarResp.getData(); + } + + /** + * 封禁群组 + * 解除对指定群组的封禁。群组解禁后,群成员可以在该群组以及该群组下的子区中发送和接收消息并进行群组和子区管理相关操作。文档介绍:https://docs-im-beta.easemob.com/document/server-side/group.html#%E8%A7%A3%E7%A6%81%E7%BE%A4%E7%BB%84 + * @param groupId (required) + * @return ApiResponse<EMEnableGroupResult> + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public ApiResponse enableGroupWithHttpInfo(String groupId) throws ApiException { + okhttp3.Call localVarCall = enableGroupValidateBeforeCall(groupId, null); + Type localVarReturnType = new TypeToken(){}.getType(); + return localVarApiClient.execute(localVarCall, localVarReturnType); + } + + /** + * 封禁群组 (asynchronously) + * 解除对指定群组的封禁。群组解禁后,群成员可以在该群组以及该群组下的子区中发送和接收消息并进行群组和子区管理相关操作。文档介绍:https://docs-im-beta.easemob.com/document/server-side/group.html#%E8%A7%A3%E7%A6%81%E7%BE%A4%E7%BB%84 + * @param groupId (required) + * @param _callback The callback to be executed when the API call finishes + * @return The request call + * @throws ApiException If fail to process the API call, e.g. serializing the request body object + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public okhttp3.Call enableGroupAsync(String groupId, final ApiCallback _callback) throws ApiException { + + okhttp3.Call localVarCall = enableGroupValidateBeforeCall(groupId, _callback); + Type localVarReturnType = new TypeToken(){}.getType(); + localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); + return localVarCall; + } + /** + * Build call for getAppGroups + * @param limit 每次期望返回的群组数量。取值范围为 [1,1000],默认值为 10 (optional) + * @param cursor 数据查询的起始位置 (optional) + * @param _callback Callback for upload/download progress + * @return Call to execute + * @throws ApiException If fail to serialize the request body object + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public okhttp3.Call getAppGroupsCall(Integer limit, String cursor, final ApiCallback _callback) throws ApiException { + String basePath = null; + // Operation Servers + String[] localBasePaths = new String[] { }; + + // Determine Base Path to Use + if (localCustomBaseUrl != null){ + basePath = localCustomBaseUrl; + } else if ( localBasePaths.length > 0 ) { + basePath = localBasePaths[localHostIndex]; + } else { + basePath = null; + } + + Object localVarPostBody = null; + + // create path and map variables + String localVarPath = "/chatgroups"; + + List localVarQueryParams = new ArrayList(); + List localVarCollectionQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + Map localVarCookieParams = new HashMap(); + Map localVarFormParams = new HashMap(); + + if (limit != null) { + localVarQueryParams.addAll(localVarApiClient.parameterToPair("limit", limit)); + } + + if (cursor != null) { + localVarQueryParams.addAll(localVarApiClient.parameterToPair("cursor", cursor)); + } + + final String[] localVarAccepts = { + "application/json" + }; + final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts); + if (localVarAccept != null) { + localVarHeaderParams.put("Accept", localVarAccept); + } + + final String[] localVarContentTypes = { + }; + final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); + if (localVarContentType != null) { + localVarHeaderParams.put("Content-Type", localVarContentType); + } + + String[] localVarAuthNames = new String[] { }; + return localVarApiClient.buildCall(basePath, localVarPath, "GET", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); + } + + @SuppressWarnings("rawtypes") + private okhttp3.Call getAppGroupsValidateBeforeCall(Integer limit, String cursor, final ApiCallback _callback) throws ApiException { + return getAppGroupsCall(limit, cursor, _callback); + + } + + /** + * 获取 App 中的群组 + * 分页获取应用下的群组的信息。文档介绍:https://docs-im-beta.easemob.com/document/server-side/group.html#%E8%8E%B7%E5%8F%96-app-%E4%B8%AD%E7%9A%84%E7%BE%A4%E7%BB%84 + * @param limit 每次期望返回的群组数量。取值范围为 [1,1000],默认值为 10 (optional) + * @param cursor 数据查询的起始位置 (optional) + * @return EMGetAppGroupsResult + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public EMGetAppGroupsResult getAppGroups(Integer limit, String cursor) throws ApiException { + ApiResponse localVarResp = getAppGroupsWithHttpInfo(limit, cursor); + return localVarResp.getData(); + } + + /** + * 获取 App 中的群组 + * 分页获取应用下的群组的信息。文档介绍:https://docs-im-beta.easemob.com/document/server-side/group.html#%E8%8E%B7%E5%8F%96-app-%E4%B8%AD%E7%9A%84%E7%BE%A4%E7%BB%84 + * @param limit 每次期望返回的群组数量。取值范围为 [1,1000],默认值为 10 (optional) + * @param cursor 数据查询的起始位置 (optional) + * @return ApiResponse<EMGetAppGroupsResult> + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public ApiResponse getAppGroupsWithHttpInfo(Integer limit, String cursor) throws ApiException { + okhttp3.Call localVarCall = getAppGroupsValidateBeforeCall(limit, cursor, null); + Type localVarReturnType = new TypeToken(){}.getType(); + return localVarApiClient.execute(localVarCall, localVarReturnType); + } + + /** + * 获取 App 中的群组 (asynchronously) + * 分页获取应用下的群组的信息。文档介绍:https://docs-im-beta.easemob.com/document/server-side/group.html#%E8%8E%B7%E5%8F%96-app-%E4%B8%AD%E7%9A%84%E7%BE%A4%E7%BB%84 + * @param limit 每次期望返回的群组数量。取值范围为 [1,1000],默认值为 10 (optional) + * @param cursor 数据查询的起始位置 (optional) + * @param _callback The callback to be executed when the API call finishes + * @return The request call + * @throws ApiException If fail to process the API call, e.g. serializing the request body object + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public okhttp3.Call getAppGroupsAsync(Integer limit, String cursor, final ApiCallback _callback) throws ApiException { + + okhttp3.Call localVarCall = getAppGroupsValidateBeforeCall(limit, cursor, _callback); + Type localVarReturnType = new TypeToken(){}.getType(); + localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); + return localVarCall; + } + /** + * Build call for getGroupAdminList + * @param groupId (required) + * @param _callback Callback for upload/download progress + * @return Call to execute + * @throws ApiException If fail to serialize the request body object + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public okhttp3.Call getGroupAdminListCall(String groupId, final ApiCallback _callback) throws ApiException { + String basePath = null; + // Operation Servers + String[] localBasePaths = new String[] { }; + + // Determine Base Path to Use + if (localCustomBaseUrl != null){ + basePath = localCustomBaseUrl; + } else if ( localBasePaths.length > 0 ) { + basePath = localBasePaths[localHostIndex]; + } else { + basePath = null; + } + + Object localVarPostBody = null; + + // create path and map variables + String localVarPath = "/chatgroups/{group_id}/admin" + .replace("{" + "group_id" + "}", localVarApiClient.escapeString(groupId.toString())); + + List localVarQueryParams = new ArrayList(); + List localVarCollectionQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + Map localVarCookieParams = new HashMap(); + Map localVarFormParams = new HashMap(); + + final String[] localVarAccepts = { + "application/json" + }; + final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts); + if (localVarAccept != null) { + localVarHeaderParams.put("Accept", localVarAccept); + } + + final String[] localVarContentTypes = { + }; + final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); + if (localVarContentType != null) { + localVarHeaderParams.put("Content-Type", localVarContentType); + } + + String[] localVarAuthNames = new String[] { }; + return localVarApiClient.buildCall(basePath, localVarPath, "GET", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); + } + + @SuppressWarnings("rawtypes") + private okhttp3.Call getGroupAdminListValidateBeforeCall(String groupId, final ApiCallback _callback) throws ApiException { + // verify the required parameter 'groupId' is set + if (groupId == null) { + throw new ApiException("Missing the required parameter 'groupId' when calling getGroupAdminList(Async)"); + } + + return getGroupAdminListCall(groupId, _callback); + + } + + /** + * 获取群管理员列表 + * 获取群组管理员列表。文档介绍:https://docs-im-beta.easemob.com/document/server-side/group.html#%E8%8E%B7%E5%8F%96%E7%BE%A4%E7%AE%A1%E7%90%86%E5%91%98%E5%88%97%E8%A1%A8 + * @param groupId (required) + * @return EMGetGroupAdminListResult + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public EMGetGroupAdminListResult getGroupAdminList(String groupId) throws ApiException { + ApiResponse localVarResp = getGroupAdminListWithHttpInfo(groupId); + return localVarResp.getData(); + } + + /** + * 获取群管理员列表 + * 获取群组管理员列表。文档介绍:https://docs-im-beta.easemob.com/document/server-side/group.html#%E8%8E%B7%E5%8F%96%E7%BE%A4%E7%AE%A1%E7%90%86%E5%91%98%E5%88%97%E8%A1%A8 + * @param groupId (required) + * @return ApiResponse<EMGetGroupAdminListResult> + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public ApiResponse getGroupAdminListWithHttpInfo(String groupId) throws ApiException { + okhttp3.Call localVarCall = getGroupAdminListValidateBeforeCall(groupId, null); + Type localVarReturnType = new TypeToken(){}.getType(); + return localVarApiClient.execute(localVarCall, localVarReturnType); + } + + /** + * 获取群管理员列表 (asynchronously) + * 获取群组管理员列表。文档介绍:https://docs-im-beta.easemob.com/document/server-side/group.html#%E8%8E%B7%E5%8F%96%E7%BE%A4%E7%AE%A1%E7%90%86%E5%91%98%E5%88%97%E8%A1%A8 + * @param groupId (required) + * @param _callback The callback to be executed when the API call finishes + * @return The request call + * @throws ApiException If fail to process the API call, e.g. serializing the request body object + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public okhttp3.Call getGroupAdminListAsync(String groupId, final ApiCallback _callback) throws ApiException { + + okhttp3.Call localVarCall = getGroupAdminListValidateBeforeCall(groupId, _callback); + Type localVarReturnType = new TypeToken(){}.getType(); + localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); + return localVarCall; + } + /** + * Build call for getGroupAnnouncement + * @param groupId (required) + * @param _callback Callback for upload/download progress + * @return Call to execute + * @throws ApiException If fail to serialize the request body object + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public okhttp3.Call getGroupAnnouncementCall(String groupId, final ApiCallback _callback) throws ApiException { + String basePath = null; + // Operation Servers + String[] localBasePaths = new String[] { }; + + // Determine Base Path to Use + if (localCustomBaseUrl != null){ + basePath = localCustomBaseUrl; + } else if ( localBasePaths.length > 0 ) { + basePath = localBasePaths[localHostIndex]; + } else { + basePath = null; + } + + Object localVarPostBody = null; + + // create path and map variables + String localVarPath = "/chatgroups/{group_id}/announcement" + .replace("{" + "group_id" + "}", localVarApiClient.escapeString(groupId.toString())); + + List localVarQueryParams = new ArrayList(); + List localVarCollectionQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + Map localVarCookieParams = new HashMap(); + Map localVarFormParams = new HashMap(); + + final String[] localVarAccepts = { + "application/json" + }; + final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts); + if (localVarAccept != null) { + localVarHeaderParams.put("Accept", localVarAccept); + } + + final String[] localVarContentTypes = { + }; + final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); + if (localVarContentType != null) { + localVarHeaderParams.put("Content-Type", localVarContentType); + } + + String[] localVarAuthNames = new String[] { }; + return localVarApiClient.buildCall(basePath, localVarPath, "GET", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); + } + + @SuppressWarnings("rawtypes") + private okhttp3.Call getGroupAnnouncementValidateBeforeCall(String groupId, final ApiCallback _callback) throws ApiException { + // verify the required parameter 'groupId' is set + if (groupId == null) { + throw new ApiException("Missing the required parameter 'groupId' when calling getGroupAnnouncement(Async)"); + } + + return getGroupAnnouncementCall(groupId, _callback); + + } + + /** + * 获取群组公告 + * 获取指定群组 ID 的群组公告。文档介绍:https://docs-im-beta.easemob.com/document/server-side/group.html#%E8%8E%B7%E5%8F%96%E7%BE%A4%E7%BB%84%E5%85%AC%E5%91%8A + * @param groupId (required) + * @return EMGetGroupAnnouncementResult + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public EMGetGroupAnnouncementResult getGroupAnnouncement(String groupId) throws ApiException { + ApiResponse localVarResp = getGroupAnnouncementWithHttpInfo(groupId); + return localVarResp.getData(); + } + + /** + * 获取群组公告 + * 获取指定群组 ID 的群组公告。文档介绍:https://docs-im-beta.easemob.com/document/server-side/group.html#%E8%8E%B7%E5%8F%96%E7%BE%A4%E7%BB%84%E5%85%AC%E5%91%8A + * @param groupId (required) + * @return ApiResponse<EMGetGroupAnnouncementResult> + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public ApiResponse getGroupAnnouncementWithHttpInfo(String groupId) throws ApiException { + okhttp3.Call localVarCall = getGroupAnnouncementValidateBeforeCall(groupId, null); + Type localVarReturnType = new TypeToken(){}.getType(); + return localVarApiClient.execute(localVarCall, localVarReturnType); + } + + /** + * 获取群组公告 (asynchronously) + * 获取指定群组 ID 的群组公告。文档介绍:https://docs-im-beta.easemob.com/document/server-side/group.html#%E8%8E%B7%E5%8F%96%E7%BE%A4%E7%BB%84%E5%85%AC%E5%91%8A + * @param groupId (required) + * @param _callback The callback to be executed when the API call finishes + * @return The request call + * @throws ApiException If fail to process the API call, e.g. serializing the request body object + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public okhttp3.Call getGroupAnnouncementAsync(String groupId, final ApiCallback _callback) throws ApiException { + + okhttp3.Call localVarCall = getGroupAnnouncementValidateBeforeCall(groupId, _callback); + Type localVarReturnType = new TypeToken(){}.getType(); + localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); + return localVarCall; + } + /** + * Build call for getGroupBlockList + * @param groupId (required) + * @param _callback Callback for upload/download progress + * @return Call to execute + * @throws ApiException If fail to serialize the request body object + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public okhttp3.Call getGroupBlockListCall(String groupId, final ApiCallback _callback) throws ApiException { + String basePath = null; + // Operation Servers + String[] localBasePaths = new String[] { }; + + // Determine Base Path to Use + if (localCustomBaseUrl != null){ + basePath = localCustomBaseUrl; + } else if ( localBasePaths.length > 0 ) { + basePath = localBasePaths[localHostIndex]; + } else { + basePath = null; + } + + Object localVarPostBody = null; + + // create path and map variables + String localVarPath = "/chatgroups/{group_id}/blocks/users" + .replace("{" + "group_id" + "}", localVarApiClient.escapeString(groupId.toString())); + + List localVarQueryParams = new ArrayList(); + List localVarCollectionQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + Map localVarCookieParams = new HashMap(); + Map localVarFormParams = new HashMap(); + + final String[] localVarAccepts = { + "application/json" + }; + final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts); + if (localVarAccept != null) { + localVarHeaderParams.put("Accept", localVarAccept); + } + + final String[] localVarContentTypes = { + }; + final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); + if (localVarContentType != null) { + localVarHeaderParams.put("Content-Type", localVarContentType); + } + + String[] localVarAuthNames = new String[] { }; + return localVarApiClient.buildCall(basePath, localVarPath, "GET", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); + } + + @SuppressWarnings("rawtypes") + private okhttp3.Call getGroupBlockListValidateBeforeCall(String groupId, final ApiCallback _callback) throws ApiException { + // verify the required parameter 'groupId' is set + if (groupId == null) { + throw new ApiException("Missing the required parameter 'groupId' when calling getGroupBlockList(Async)"); + } + + return getGroupBlockListCall(groupId, _callback); + + } + + /** + * 查询群组黑名单 + * 查询一个群组黑名单中的用户列表。黑名单中的用户无法查看该群组的信息,也无法收到该群组的消息。文档介绍:https://docs-im-beta.easemob.com/document/server-side/group.html#%E6%9F%A5%E8%AF%A2%E7%BE%A4%E7%BB%84%E9%BB%91%E5%90%8D%E5%8D%95 + * @param groupId (required) + * @return EMGetGroupBlockListResult + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public EMGetGroupBlockListResult getGroupBlockList(String groupId) throws ApiException { + ApiResponse localVarResp = getGroupBlockListWithHttpInfo(groupId); + return localVarResp.getData(); + } + + /** + * 查询群组黑名单 + * 查询一个群组黑名单中的用户列表。黑名单中的用户无法查看该群组的信息,也无法收到该群组的消息。文档介绍:https://docs-im-beta.easemob.com/document/server-side/group.html#%E6%9F%A5%E8%AF%A2%E7%BE%A4%E7%BB%84%E9%BB%91%E5%90%8D%E5%8D%95 + * @param groupId (required) + * @return ApiResponse<EMGetGroupBlockListResult> + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public ApiResponse getGroupBlockListWithHttpInfo(String groupId) throws ApiException { + okhttp3.Call localVarCall = getGroupBlockListValidateBeforeCall(groupId, null); + Type localVarReturnType = new TypeToken(){}.getType(); + return localVarApiClient.execute(localVarCall, localVarReturnType); + } + + /** + * 查询群组黑名单 (asynchronously) + * 查询一个群组黑名单中的用户列表。黑名单中的用户无法查看该群组的信息,也无法收到该群组的消息。文档介绍:https://docs-im-beta.easemob.com/document/server-side/group.html#%E6%9F%A5%E8%AF%A2%E7%BE%A4%E7%BB%84%E9%BB%91%E5%90%8D%E5%8D%95 + * @param groupId (required) + * @param _callback The callback to be executed when the API call finishes + * @return The request call + * @throws ApiException If fail to process the API call, e.g. serializing the request body object + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public okhttp3.Call getGroupBlockListAsync(String groupId, final ApiCallback _callback) throws ApiException { + + okhttp3.Call localVarCall = getGroupBlockListValidateBeforeCall(groupId, _callback); + Type localVarReturnType = new TypeToken(){}.getType(); + localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); + return localVarCall; + } + /** + * Build call for getGroupInfo + * @param groupId (required) + * @param _callback Callback for upload/download progress + * @return Call to execute + * @throws ApiException If fail to serialize the request body object + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public okhttp3.Call getGroupInfoCall(String groupId, final ApiCallback _callback) throws ApiException { + String basePath = null; + // Operation Servers + String[] localBasePaths = new String[] { }; + + // Determine Base Path to Use + if (localCustomBaseUrl != null){ + basePath = localCustomBaseUrl; + } else if ( localBasePaths.length > 0 ) { + basePath = localBasePaths[localHostIndex]; + } else { + basePath = null; + } + + Object localVarPostBody = null; + + // create path and map variables + String localVarPath = "/chatgroups/{group_id}" + .replace("{" + "group_id" + "}", localVarApiClient.escapeString(groupId.toString())); + + List localVarQueryParams = new ArrayList(); + List localVarCollectionQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + Map localVarCookieParams = new HashMap(); + Map localVarFormParams = new HashMap(); + + final String[] localVarAccepts = { + "application/json" + }; + final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts); + if (localVarAccept != null) { + localVarHeaderParams.put("Accept", localVarAccept); + } + + final String[] localVarContentTypes = { + }; + final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); + if (localVarContentType != null) { + localVarHeaderParams.put("Content-Type", localVarContentType); + } + + String[] localVarAuthNames = new String[] { }; + return localVarApiClient.buildCall(basePath, localVarPath, "GET", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); + } + + @SuppressWarnings("rawtypes") + private okhttp3.Call getGroupInfoValidateBeforeCall(String groupId, final ApiCallback _callback) throws ApiException { + // verify the required parameter 'groupId' is set + if (groupId == null) { + throw new ApiException("Missing the required parameter 'groupId' when calling getGroupInfo(Async)"); + } + + return getGroupInfoCall(groupId, _callback); + + } + + /** + * 获取群组详情 + * 可以获取一个或多个群组的详情,最多可获取 100 个群组的详情。当获取多个群组的详情时,返回所有存在的群组的详情;对于不存在的群组,返回 “group id doesn’t exist”。文档介绍:https://docs-im-beta.easemob.com/document/server-side/group.html#%E8%8E%B7%E5%8F%96%E7%BE%A4%E7%BB%84%E8%AF%A6%E6%83%85 + * @param groupId (required) + * @return EMGetGroupInfoResult + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public EMGetGroupInfoResult getGroupInfo(String groupId) throws ApiException { + ApiResponse localVarResp = getGroupInfoWithHttpInfo(groupId); + return localVarResp.getData(); + } + + /** + * 获取群组详情 + * 可以获取一个或多个群组的详情,最多可获取 100 个群组的详情。当获取多个群组的详情时,返回所有存在的群组的详情;对于不存在的群组,返回 “group id doesn’t exist”。文档介绍:https://docs-im-beta.easemob.com/document/server-side/group.html#%E8%8E%B7%E5%8F%96%E7%BE%A4%E7%BB%84%E8%AF%A6%E6%83%85 + * @param groupId (required) + * @return ApiResponse<EMGetGroupInfoResult> + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public ApiResponse getGroupInfoWithHttpInfo(String groupId) throws ApiException { + okhttp3.Call localVarCall = getGroupInfoValidateBeforeCall(groupId, null); + Type localVarReturnType = new TypeToken(){}.getType(); + return localVarApiClient.execute(localVarCall, localVarReturnType); + } + + /** + * 获取群组详情 (asynchronously) + * 可以获取一个或多个群组的详情,最多可获取 100 个群组的详情。当获取多个群组的详情时,返回所有存在的群组的详情;对于不存在的群组,返回 “group id doesn’t exist”。文档介绍:https://docs-im-beta.easemob.com/document/server-side/group.html#%E8%8E%B7%E5%8F%96%E7%BE%A4%E7%BB%84%E8%AF%A6%E6%83%85 + * @param groupId (required) + * @param _callback The callback to be executed when the API call finishes + * @return The request call + * @throws ApiException If fail to process the API call, e.g. serializing the request body object + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public okhttp3.Call getGroupInfoAsync(String groupId, final ApiCallback _callback) throws ApiException { + + okhttp3.Call localVarCall = getGroupInfoValidateBeforeCall(groupId, _callback); + Type localVarReturnType = new TypeToken(){}.getType(); + localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); + return localVarCall; + } + /** + * Build call for getGroupMemberList + * @param groupId (required) + * @param pagenum 当前页码。默认从第 1 页开始获取 (optional) + * @param pagesize 每页期望返回的群成员数。取值范围为 [1,1000],默认为 1000 (optional) + * @param _callback Callback for upload/download progress + * @return Call to execute + * @throws ApiException If fail to serialize the request body object + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public okhttp3.Call getGroupMemberListCall(String groupId, Integer pagenum, Integer pagesize, final ApiCallback _callback) throws ApiException { + String basePath = null; + // Operation Servers + String[] localBasePaths = new String[] { }; + + // Determine Base Path to Use + if (localCustomBaseUrl != null){ + basePath = localCustomBaseUrl; + } else if ( localBasePaths.length > 0 ) { + basePath = localBasePaths[localHostIndex]; + } else { + basePath = null; + } + + Object localVarPostBody = null; + + // create path and map variables + String localVarPath = "/chatgroups/{group_id}/users" + .replace("{" + "group_id" + "}", localVarApiClient.escapeString(groupId.toString())); + + List localVarQueryParams = new ArrayList(); + List localVarCollectionQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + Map localVarCookieParams = new HashMap(); + Map localVarFormParams = new HashMap(); + + if (pagenum != null) { + localVarQueryParams.addAll(localVarApiClient.parameterToPair("pagenum", pagenum)); + } + + if (pagesize != null) { + localVarQueryParams.addAll(localVarApiClient.parameterToPair("pagesize", pagesize)); + } + + final String[] localVarAccepts = { + "application/json" + }; + final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts); + if (localVarAccept != null) { + localVarHeaderParams.put("Accept", localVarAccept); + } + + final String[] localVarContentTypes = { + }; + final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); + if (localVarContentType != null) { + localVarHeaderParams.put("Content-Type", localVarContentType); + } + + String[] localVarAuthNames = new String[] { }; + return localVarApiClient.buildCall(basePath, localVarPath, "GET", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); + } + + @SuppressWarnings("rawtypes") + private okhttp3.Call getGroupMemberListValidateBeforeCall(String groupId, Integer pagenum, Integer pagesize, final ApiCallback _callback) throws ApiException { + // verify the required parameter 'groupId' is set + if (groupId == null) { + throw new ApiException("Missing the required parameter 'groupId' when calling getGroupMemberList(Async)"); + } + + return getGroupMemberListCall(groupId, pagenum, pagesize, _callback); + + } + + /** + * 分页获取群成员列表 + * 可以分页获取群组成员列表。文档介绍:https://docs-im-beta.easemob.com/document/server-side/group.html#%E7%AE%A1%E7%90%86%E7%BE%A4%E7%BB%84%E6%88%90%E5%91%98 + * @param groupId (required) + * @param pagenum 当前页码。默认从第 1 页开始获取 (optional) + * @param pagesize 每页期望返回的群成员数。取值范围为 [1,1000],默认为 1000 (optional) + * @return EMGetGroupMemberListResult + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public EMGetGroupMemberListResult getGroupMemberList(String groupId, Integer pagenum, Integer pagesize) throws ApiException { + ApiResponse localVarResp = getGroupMemberListWithHttpInfo(groupId, pagenum, pagesize); + return localVarResp.getData(); + } + + /** + * 分页获取群成员列表 + * 可以分页获取群组成员列表。文档介绍:https://docs-im-beta.easemob.com/document/server-side/group.html#%E7%AE%A1%E7%90%86%E7%BE%A4%E7%BB%84%E6%88%90%E5%91%98 + * @param groupId (required) + * @param pagenum 当前页码。默认从第 1 页开始获取 (optional) + * @param pagesize 每页期望返回的群成员数。取值范围为 [1,1000],默认为 1000 (optional) + * @return ApiResponse<EMGetGroupMemberListResult> + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public ApiResponse getGroupMemberListWithHttpInfo(String groupId, Integer pagenum, Integer pagesize) throws ApiException { + okhttp3.Call localVarCall = getGroupMemberListValidateBeforeCall(groupId, pagenum, pagesize, null); + Type localVarReturnType = new TypeToken(){}.getType(); + return localVarApiClient.execute(localVarCall, localVarReturnType); + } + + /** + * 分页获取群成员列表 (asynchronously) + * 可以分页获取群组成员列表。文档介绍:https://docs-im-beta.easemob.com/document/server-side/group.html#%E7%AE%A1%E7%90%86%E7%BE%A4%E7%BB%84%E6%88%90%E5%91%98 + * @param groupId (required) + * @param pagenum 当前页码。默认从第 1 页开始获取 (optional) + * @param pagesize 每页期望返回的群成员数。取值范围为 [1,1000],默认为 1000 (optional) + * @param _callback The callback to be executed when the API call finishes + * @return The request call + * @throws ApiException If fail to process the API call, e.g. serializing the request body object + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public okhttp3.Call getGroupMemberListAsync(String groupId, Integer pagenum, Integer pagesize, final ApiCallback _callback) throws ApiException { + + okhttp3.Call localVarCall = getGroupMemberListValidateBeforeCall(groupId, pagenum, pagesize, _callback); + Type localVarReturnType = new TypeToken(){}.getType(); + localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); + return localVarCall; + } + /** + * Build call for getGroupMuteList + * @param groupId (required) + * @param _callback Callback for upload/download progress + * @return Call to execute + * @throws ApiException If fail to serialize the request body object + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public okhttp3.Call getGroupMuteListCall(String groupId, final ApiCallback _callback) throws ApiException { + String basePath = null; + // Operation Servers + String[] localBasePaths = new String[] { }; + + // Determine Base Path to Use + if (localCustomBaseUrl != null){ + basePath = localCustomBaseUrl; + } else if ( localBasePaths.length > 0 ) { + basePath = localBasePaths[localHostIndex]; + } else { + basePath = null; + } + + Object localVarPostBody = null; + + // create path and map variables + String localVarPath = "/chatgroups/{group_id}/mute" + .replace("{" + "group_id" + "}", localVarApiClient.escapeString(groupId.toString())); + + List localVarQueryParams = new ArrayList(); + List localVarCollectionQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + Map localVarCookieParams = new HashMap(); + Map localVarFormParams = new HashMap(); + + final String[] localVarAccepts = { + "application/json" + }; + final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts); + if (localVarAccept != null) { + localVarHeaderParams.put("Accept", localVarAccept); + } + + final String[] localVarContentTypes = { + }; + final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); + if (localVarContentType != null) { + localVarHeaderParams.put("Content-Type", localVarContentType); + } + + String[] localVarAuthNames = new String[] { }; + return localVarApiClient.buildCall(basePath, localVarPath, "GET", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); + } + + @SuppressWarnings("rawtypes") + private okhttp3.Call getGroupMuteListValidateBeforeCall(String groupId, final ApiCallback _callback) throws ApiException { + // verify the required parameter 'groupId' is set + if (groupId == null) { + throw new ApiException("Missing the required parameter 'groupId' when calling getGroupMuteList(Async)"); + } + + return getGroupMuteListCall(groupId, _callback); + + } + + /** + * 获取禁言列表 + * 获取当前群组的禁言用户列表。文档介绍:https://docs-im-beta.easemob.com/document/server-side/group.html#%E8%8E%B7%E5%8F%96%E7%A6%81%E8%A8%80%E5%88%97%E8%A1%A8 + * @param groupId (required) + * @return EMGetGroupMuteListResult + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public EMGetGroupMuteListResult getGroupMuteList(String groupId) throws ApiException { + ApiResponse localVarResp = getGroupMuteListWithHttpInfo(groupId); + return localVarResp.getData(); + } + + /** + * 获取禁言列表 + * 获取当前群组的禁言用户列表。文档介绍:https://docs-im-beta.easemob.com/document/server-side/group.html#%E8%8E%B7%E5%8F%96%E7%A6%81%E8%A8%80%E5%88%97%E8%A1%A8 + * @param groupId (required) + * @return ApiResponse<EMGetGroupMuteListResult> + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public ApiResponse getGroupMuteListWithHttpInfo(String groupId) throws ApiException { + okhttp3.Call localVarCall = getGroupMuteListValidateBeforeCall(groupId, null); + Type localVarReturnType = new TypeToken(){}.getType(); + return localVarApiClient.execute(localVarCall, localVarReturnType); + } + + /** + * 获取禁言列表 (asynchronously) + * 获取当前群组的禁言用户列表。文档介绍:https://docs-im-beta.easemob.com/document/server-side/group.html#%E8%8E%B7%E5%8F%96%E7%A6%81%E8%A8%80%E5%88%97%E8%A1%A8 + * @param groupId (required) + * @param _callback The callback to be executed when the API call finishes + * @return The request call + * @throws ApiException If fail to process the API call, e.g. serializing the request body object + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public okhttp3.Call getGroupMuteListAsync(String groupId, final ApiCallback _callback) throws ApiException { + + okhttp3.Call localVarCall = getGroupMuteListValidateBeforeCall(groupId, _callback); + Type localVarReturnType = new TypeToken(){}.getType(); + localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); + return localVarCall; + } + /** + * Build call for getGroupShareFile + * @param groupId (required) + * @param pagenum 当前页码。默认从第 1 页开始获取 (optional) + * @param pagesize 每页期望返回的共享文件数。取值范围为 [1,1000],默认为 1000 (optional) + * @param _callback Callback for upload/download progress + * @return Call to execute + * @throws ApiException If fail to serialize the request body object + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public okhttp3.Call getGroupShareFileCall(String groupId, Integer pagenum, Integer pagesize, final ApiCallback _callback) throws ApiException { + String basePath = null; + // Operation Servers + String[] localBasePaths = new String[] { }; + + // Determine Base Path to Use + if (localCustomBaseUrl != null){ + basePath = localCustomBaseUrl; + } else if ( localBasePaths.length > 0 ) { + basePath = localBasePaths[localHostIndex]; + } else { + basePath = null; + } + + Object localVarPostBody = null; + + // create path and map variables + String localVarPath = "/chatgroups/{group_id}/share_files" + .replace("{" + "group_id" + "}", localVarApiClient.escapeString(groupId.toString())); + + List localVarQueryParams = new ArrayList(); + List localVarCollectionQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + Map localVarCookieParams = new HashMap(); + Map localVarFormParams = new HashMap(); + + if (pagenum != null) { + localVarQueryParams.addAll(localVarApiClient.parameterToPair("pagenum", pagenum)); + } + + if (pagesize != null) { + localVarQueryParams.addAll(localVarApiClient.parameterToPair("pagesize", pagesize)); + } + + final String[] localVarAccepts = { + "application/json" + }; + final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts); + if (localVarAccept != null) { + localVarHeaderParams.put("Accept", localVarAccept); + } + + final String[] localVarContentTypes = { + }; + final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); + if (localVarContentType != null) { + localVarHeaderParams.put("Content-Type", localVarContentType); + } + + String[] localVarAuthNames = new String[] { }; + return localVarApiClient.buildCall(basePath, localVarPath, "GET", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); + } + + @SuppressWarnings("rawtypes") + private okhttp3.Call getGroupShareFileValidateBeforeCall(String groupId, Integer pagenum, Integer pagesize, final ApiCallback _callback) throws ApiException { + // verify the required parameter 'groupId' is set + if (groupId == null) { + throw new ApiException("Missing the required parameter 'groupId' when calling getGroupShareFile(Async)"); + } + + return getGroupShareFileCall(groupId, pagenum, pagesize, _callback); + + } + + /** + * 获取群组共享文件 + * 可以分页获取指定群组 ID 的群组共享文件。获取文件后,你可以根据响应中返回的文件 ID(file_id)调用 下载群组共享文件 接口下载文件,或调用 删除群组共享文件 接口删除文件。文档介绍:https://docs-im-beta.easemob.com/document/server-side/group.html#%E8%8E%B7%E5%8F%96%E7%BE%A4%E7%BB%84%E5%85%B1%E4%BA%AB%E6%96%87%E4%BB%B6 + * @param groupId (required) + * @param pagenum 当前页码。默认从第 1 页开始获取 (optional) + * @param pagesize 每页期望返回的共享文件数。取值范围为 [1,1000],默认为 1000 (optional) + * @return EMGetGroupShareFileResult + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public EMGetGroupShareFileResult getGroupShareFile(String groupId, Integer pagenum, Integer pagesize) throws ApiException { + ApiResponse localVarResp = getGroupShareFileWithHttpInfo(groupId, pagenum, pagesize); + return localVarResp.getData(); + } + + /** + * 获取群组共享文件 + * 可以分页获取指定群组 ID 的群组共享文件。获取文件后,你可以根据响应中返回的文件 ID(file_id)调用 下载群组共享文件 接口下载文件,或调用 删除群组共享文件 接口删除文件。文档介绍:https://docs-im-beta.easemob.com/document/server-side/group.html#%E8%8E%B7%E5%8F%96%E7%BE%A4%E7%BB%84%E5%85%B1%E4%BA%AB%E6%96%87%E4%BB%B6 + * @param groupId (required) + * @param pagenum 当前页码。默认从第 1 页开始获取 (optional) + * @param pagesize 每页期望返回的共享文件数。取值范围为 [1,1000],默认为 1000 (optional) + * @return ApiResponse<EMGetGroupShareFileResult> + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public ApiResponse getGroupShareFileWithHttpInfo(String groupId, Integer pagenum, Integer pagesize) throws ApiException { + okhttp3.Call localVarCall = getGroupShareFileValidateBeforeCall(groupId, pagenum, pagesize, null); + Type localVarReturnType = new TypeToken(){}.getType(); + return localVarApiClient.execute(localVarCall, localVarReturnType); + } + + /** + * 获取群组共享文件 (asynchronously) + * 可以分页获取指定群组 ID 的群组共享文件。获取文件后,你可以根据响应中返回的文件 ID(file_id)调用 下载群组共享文件 接口下载文件,或调用 删除群组共享文件 接口删除文件。文档介绍:https://docs-im-beta.easemob.com/document/server-side/group.html#%E8%8E%B7%E5%8F%96%E7%BE%A4%E7%BB%84%E5%85%B1%E4%BA%AB%E6%96%87%E4%BB%B6 + * @param groupId (required) + * @param pagenum 当前页码。默认从第 1 页开始获取 (optional) + * @param pagesize 每页期望返回的共享文件数。取值范围为 [1,1000],默认为 1000 (optional) + * @param _callback The callback to be executed when the API call finishes + * @return The request call + * @throws ApiException If fail to process the API call, e.g. serializing the request body object + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public okhttp3.Call getGroupShareFileAsync(String groupId, Integer pagenum, Integer pagesize, final ApiCallback _callback) throws ApiException { + + okhttp3.Call localVarCall = getGroupShareFileValidateBeforeCall(groupId, pagenum, pagesize, _callback); + Type localVarReturnType = new TypeToken(){}.getType(); + localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); + return localVarCall; + } + /** + * Build call for getGroupWhiteList + * @param groupId (required) + * @param _callback Callback for upload/download progress + * @return Call to execute + * @throws ApiException If fail to serialize the request body object + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public okhttp3.Call getGroupWhiteListCall(String groupId, final ApiCallback _callback) throws ApiException { + String basePath = null; + // Operation Servers + String[] localBasePaths = new String[] { }; + + // Determine Base Path to Use + if (localCustomBaseUrl != null){ + basePath = localCustomBaseUrl; + } else if ( localBasePaths.length > 0 ) { + basePath = localBasePaths[localHostIndex]; + } else { + basePath = null; + } + + Object localVarPostBody = null; + + // create path and map variables + String localVarPath = "/chatgroups/{group_id}/white/users" + .replace("{" + "group_id" + "}", localVarApiClient.escapeString(groupId.toString())); + + List localVarQueryParams = new ArrayList(); + List localVarCollectionQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + Map localVarCookieParams = new HashMap(); + Map localVarFormParams = new HashMap(); + + final String[] localVarAccepts = { + "application/json" + }; + final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts); + if (localVarAccept != null) { + localVarHeaderParams.put("Accept", localVarAccept); + } + + final String[] localVarContentTypes = { + }; + final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); + if (localVarContentType != null) { + localVarHeaderParams.put("Content-Type", localVarContentType); + } + + String[] localVarAuthNames = new String[] { }; + return localVarApiClient.buildCall(basePath, localVarPath, "GET", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); + } + + @SuppressWarnings("rawtypes") + private okhttp3.Call getGroupWhiteListValidateBeforeCall(String groupId, final ApiCallback _callback) throws ApiException { + // verify the required parameter 'groupId' is set + if (groupId == null) { + throw new ApiException("Missing the required parameter 'groupId' when calling getGroupWhiteList(Async)"); + } + + return getGroupWhiteListCall(groupId, _callback); + + } + + /** + * 查询群组白名单 + * 查询群组白名单中的用户列表。文档介绍:https://docs-im-beta.easemob.com/document/server-side/group.html#%E6%9F%A5%E8%AF%A2%E7%BE%A4%E7%BB%84%E7%99%BD%E5%90%8D%E5%8D%95 + * @param groupId (required) + * @return EMGetGroupWhiteListResult + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public EMGetGroupWhiteListResult getGroupWhiteList(String groupId) throws ApiException { + ApiResponse localVarResp = getGroupWhiteListWithHttpInfo(groupId); + return localVarResp.getData(); + } + + /** + * 查询群组白名单 + * 查询群组白名单中的用户列表。文档介绍:https://docs-im-beta.easemob.com/document/server-side/group.html#%E6%9F%A5%E8%AF%A2%E7%BE%A4%E7%BB%84%E7%99%BD%E5%90%8D%E5%8D%95 + * @param groupId (required) + * @return ApiResponse<EMGetGroupWhiteListResult> + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public ApiResponse getGroupWhiteListWithHttpInfo(String groupId) throws ApiException { + okhttp3.Call localVarCall = getGroupWhiteListValidateBeforeCall(groupId, null); + Type localVarReturnType = new TypeToken(){}.getType(); + return localVarApiClient.execute(localVarCall, localVarReturnType); + } + + /** + * 查询群组白名单 (asynchronously) + * 查询群组白名单中的用户列表。文档介绍:https://docs-im-beta.easemob.com/document/server-side/group.html#%E6%9F%A5%E8%AF%A2%E7%BE%A4%E7%BB%84%E7%99%BD%E5%90%8D%E5%8D%95 + * @param groupId (required) + * @param _callback The callback to be executed when the API call finishes + * @return The request call + * @throws ApiException If fail to process the API call, e.g. serializing the request body object + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public okhttp3.Call getGroupWhiteListAsync(String groupId, final ApiCallback _callback) throws ApiException { + + okhttp3.Call localVarCall = getGroupWhiteListValidateBeforeCall(groupId, _callback); + Type localVarReturnType = new TypeToken(){}.getType(); + localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); + return localVarCall; + } + /** + * Build call for getUserJoinedGroups + * @param username (required) + * @param pagenum 当前页码。默认从第 0 页开始获取 (optional) + * @param pagesize 每页获取的群组数量。取值范围为 [1,20],默认值为 5 (optional) + * @param _callback Callback for upload/download progress + * @return Call to execute + * @throws ApiException If fail to serialize the request body object + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public okhttp3.Call getUserJoinedGroupsCall(String username, Integer pagenum, Integer pagesize, final ApiCallback _callback) throws ApiException { + String basePath = null; + // Operation Servers + String[] localBasePaths = new String[] { }; + + // Determine Base Path to Use + if (localCustomBaseUrl != null){ + basePath = localCustomBaseUrl; + } else if ( localBasePaths.length > 0 ) { + basePath = localBasePaths[localHostIndex]; + } else { + basePath = null; + } + + Object localVarPostBody = null; + + // create path and map variables + String localVarPath = "/chatgroups/user/{username}" + .replace("{" + "username" + "}", localVarApiClient.escapeString(username.toString())); + + List localVarQueryParams = new ArrayList(); + List localVarCollectionQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + Map localVarCookieParams = new HashMap(); + Map localVarFormParams = new HashMap(); + + if (pagenum != null) { + localVarQueryParams.addAll(localVarApiClient.parameterToPair("pagenum", pagenum)); + } + + if (pagesize != null) { + localVarQueryParams.addAll(localVarApiClient.parameterToPair("pagesize", pagesize)); + } + + final String[] localVarAccepts = { + "application/json" + }; + final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts); + if (localVarAccept != null) { + localVarHeaderParams.put("Accept", localVarAccept); + } + + final String[] localVarContentTypes = { + }; + final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); + if (localVarContentType != null) { + localVarHeaderParams.put("Content-Type", localVarContentType); + } + + String[] localVarAuthNames = new String[] { }; + return localVarApiClient.buildCall(basePath, localVarPath, "GET", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); + } + + @SuppressWarnings("rawtypes") + private okhttp3.Call getUserJoinedGroupsValidateBeforeCall(String username, Integer pagenum, Integer pagesize, final ApiCallback _callback) throws ApiException { + // verify the required parameter 'username' is set + if (username == null) { + throw new ApiException("Missing the required parameter 'username' when calling getUserJoinedGroups(Async)"); + } + + return getUserJoinedGroupsCall(username, pagenum, pagesize, _callback); + + } + + /** + * 获取单个用户加入的所有群组 + * 根据用户 ID 分页获取指定用户加入的所有群组。文档介绍:https://docs-im-beta.easemob.com/document/server-side/group.html#%E8%8E%B7%E5%8F%96%E5%8D%95%E4%B8%AA%E7%94%A8%E6%88%B7%E5%8A%A0%E5%85%A5%E7%9A%84%E6%89%80%E6%9C%89%E7%BE%A4%E7%BB%84 + * @param username (required) + * @param pagenum 当前页码。默认从第 0 页开始获取 (optional) + * @param pagesize 每页获取的群组数量。取值范围为 [1,20],默认值为 5 (optional) + * @return EMGetUserJoinedGroupsResult + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public EMGetUserJoinedGroupsResult getUserJoinedGroups(String username, Integer pagenum, Integer pagesize) throws ApiException { + ApiResponse localVarResp = getUserJoinedGroupsWithHttpInfo(username, pagenum, pagesize); + return localVarResp.getData(); + } + + /** + * 获取单个用户加入的所有群组 + * 根据用户 ID 分页获取指定用户加入的所有群组。文档介绍:https://docs-im-beta.easemob.com/document/server-side/group.html#%E8%8E%B7%E5%8F%96%E5%8D%95%E4%B8%AA%E7%94%A8%E6%88%B7%E5%8A%A0%E5%85%A5%E7%9A%84%E6%89%80%E6%9C%89%E7%BE%A4%E7%BB%84 + * @param username (required) + * @param pagenum 当前页码。默认从第 0 页开始获取 (optional) + * @param pagesize 每页获取的群组数量。取值范围为 [1,20],默认值为 5 (optional) + * @return ApiResponse<EMGetUserJoinedGroupsResult> + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public ApiResponse getUserJoinedGroupsWithHttpInfo(String username, Integer pagenum, Integer pagesize) throws ApiException { + okhttp3.Call localVarCall = getUserJoinedGroupsValidateBeforeCall(username, pagenum, pagesize, null); + Type localVarReturnType = new TypeToken(){}.getType(); + return localVarApiClient.execute(localVarCall, localVarReturnType); + } + + /** + * 获取单个用户加入的所有群组 (asynchronously) + * 根据用户 ID 分页获取指定用户加入的所有群组。文档介绍:https://docs-im-beta.easemob.com/document/server-side/group.html#%E8%8E%B7%E5%8F%96%E5%8D%95%E4%B8%AA%E7%94%A8%E6%88%B7%E5%8A%A0%E5%85%A5%E7%9A%84%E6%89%80%E6%9C%89%E7%BE%A4%E7%BB%84 + * @param username (required) + * @param pagenum 当前页码。默认从第 0 页开始获取 (optional) + * @param pagesize 每页获取的群组数量。取值范围为 [1,20],默认值为 5 (optional) + * @param _callback The callback to be executed when the API call finishes + * @return The request call + * @throws ApiException If fail to process the API call, e.g. serializing the request body object + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public okhttp3.Call getUserJoinedGroupsAsync(String username, Integer pagenum, Integer pagesize, final ApiCallback _callback) throws ApiException { + + okhttp3.Call localVarCall = getUserJoinedGroupsValidateBeforeCall(username, pagenum, pagesize, _callback); + Type localVarReturnType = new TypeToken(){}.getType(); + localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); + return localVarCall; + } + /** + * Build call for modifyGroup + * @param groupId (required) + * @param emModifyGroup (optional) + * @param _callback Callback for upload/download progress + * @return Call to execute + * @throws ApiException If fail to serialize the request body object + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public okhttp3.Call modifyGroupCall(String groupId, EMModifyGroup emModifyGroup, final ApiCallback _callback) throws ApiException { + String basePath = null; + // Operation Servers + String[] localBasePaths = new String[] { }; + + // Determine Base Path to Use + if (localCustomBaseUrl != null){ + basePath = localCustomBaseUrl; + } else if ( localBasePaths.length > 0 ) { + basePath = localBasePaths[localHostIndex]; + } else { + basePath = null; + } + + Object localVarPostBody = emModifyGroup; + + // create path and map variables + String localVarPath = "/chatgroups/{group_id}" + .replace("{" + "group_id" + "}", localVarApiClient.escapeString(groupId.toString())); + + List localVarQueryParams = new ArrayList(); + List localVarCollectionQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + Map localVarCookieParams = new HashMap(); + Map localVarFormParams = new HashMap(); + + final String[] localVarAccepts = { + "application/json" + }; + final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts); + if (localVarAccept != null) { + localVarHeaderParams.put("Accept", localVarAccept); + } + + final String[] localVarContentTypes = { + "application/json" + }; + final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); + if (localVarContentType != null) { + localVarHeaderParams.put("Content-Type", localVarContentType); + } + + String[] localVarAuthNames = new String[] { }; + return localVarApiClient.buildCall(basePath, localVarPath, "PUT", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); + } + + @SuppressWarnings("rawtypes") + private okhttp3.Call modifyGroupValidateBeforeCall(String groupId, EMModifyGroup emModifyGroup, final ApiCallback _callback) throws ApiException { + // verify the required parameter 'groupId' is set + if (groupId == null) { + throw new ApiException("Missing the required parameter 'groupId' when calling modifyGroup(Async)"); + } + + return modifyGroupCall(groupId, emModifyGroup, _callback); + + } + + /** + * 修改群组信息 + * 修改指定的群组信息,可修改 groupname、description、maxusers、membersonly、allowinvites、invite_need_confirm、public 和 custom 属性。也可以转让群组,如果转让群组,请在请求body中只设置 newowner 即可,newowner 为群组新所有者的用户 ID。如果传入其他字段,或传入的字段不存在,则不能修改的字段会抛出异常。文档介绍:https://docs-im-beta.easemob.com/document/server-side/group.html#%E4%BF%AE%E6%94%B9%E7%BE%A4%E7%BB%84%E4%BF%A1%E6%81%AF 和 + * @param groupId (required) + * @param emModifyGroup (optional) + * @return EMModifyGroupResult + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public EMModifyGroupResult modifyGroup(String groupId, EMModifyGroup emModifyGroup) throws ApiException { + ApiResponse localVarResp = modifyGroupWithHttpInfo(groupId, emModifyGroup); + return localVarResp.getData(); + } + + /** + * 修改群组信息 + * 修改指定的群组信息,可修改 groupname、description、maxusers、membersonly、allowinvites、invite_need_confirm、public 和 custom 属性。也可以转让群组,如果转让群组,请在请求body中只设置 newowner 即可,newowner 为群组新所有者的用户 ID。如果传入其他字段,或传入的字段不存在,则不能修改的字段会抛出异常。文档介绍:https://docs-im-beta.easemob.com/document/server-side/group.html#%E4%BF%AE%E6%94%B9%E7%BE%A4%E7%BB%84%E4%BF%A1%E6%81%AF 和 + * @param groupId (required) + * @param emModifyGroup (optional) + * @return ApiResponse<EMModifyGroupResult> + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public ApiResponse modifyGroupWithHttpInfo(String groupId, EMModifyGroup emModifyGroup) throws ApiException { + okhttp3.Call localVarCall = modifyGroupValidateBeforeCall(groupId, emModifyGroup, null); + Type localVarReturnType = new TypeToken(){}.getType(); + return localVarApiClient.execute(localVarCall, localVarReturnType); + } + + /** + * 修改群组信息 (asynchronously) + * 修改指定的群组信息,可修改 groupname、description、maxusers、membersonly、allowinvites、invite_need_confirm、public 和 custom 属性。也可以转让群组,如果转让群组,请在请求body中只设置 newowner 即可,newowner 为群组新所有者的用户 ID。如果传入其他字段,或传入的字段不存在,则不能修改的字段会抛出异常。文档介绍:https://docs-im-beta.easemob.com/document/server-side/group.html#%E4%BF%AE%E6%94%B9%E7%BE%A4%E7%BB%84%E4%BF%A1%E6%81%AF 和 + * @param groupId (required) + * @param emModifyGroup (optional) + * @param _callback The callback to be executed when the API call finishes + * @return The request call + * @throws ApiException If fail to process the API call, e.g. serializing the request body object + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public okhttp3.Call modifyGroupAsync(String groupId, EMModifyGroup emModifyGroup, final ApiCallback _callback) throws ApiException { + + okhttp3.Call localVarCall = modifyGroupValidateBeforeCall(groupId, emModifyGroup, _callback); + Type localVarReturnType = new TypeToken(){}.getType(); + localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); + return localVarCall; + } + /** + * Build call for modifyGroupAnnouncement + * @param groupId (required) + * @param emModifyGroupAnnouncement (optional) + * @param _callback Callback for upload/download progress + * @return Call to execute + * @throws ApiException If fail to serialize the request body object + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public okhttp3.Call modifyGroupAnnouncementCall(String groupId, EMModifyGroupAnnouncement emModifyGroupAnnouncement, final ApiCallback _callback) throws ApiException { + String basePath = null; + // Operation Servers + String[] localBasePaths = new String[] { }; + + // Determine Base Path to Use + if (localCustomBaseUrl != null){ + basePath = localCustomBaseUrl; + } else if ( localBasePaths.length > 0 ) { + basePath = localBasePaths[localHostIndex]; + } else { + basePath = null; + } + + Object localVarPostBody = emModifyGroupAnnouncement; + + // create path and map variables + String localVarPath = "/chatgroups/{group_id}/announcement" + .replace("{" + "group_id" + "}", localVarApiClient.escapeString(groupId.toString())); + + List localVarQueryParams = new ArrayList(); + List localVarCollectionQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + Map localVarCookieParams = new HashMap(); + Map localVarFormParams = new HashMap(); + + final String[] localVarAccepts = { + "application/json" + }; + final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts); + if (localVarAccept != null) { + localVarHeaderParams.put("Accept", localVarAccept); + } + + final String[] localVarContentTypes = { + "application/json" + }; + final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); + if (localVarContentType != null) { + localVarHeaderParams.put("Content-Type", localVarContentType); + } + + String[] localVarAuthNames = new String[] { }; + return localVarApiClient.buildCall(basePath, localVarPath, "POST", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); + } + + @SuppressWarnings("rawtypes") + private okhttp3.Call modifyGroupAnnouncementValidateBeforeCall(String groupId, EMModifyGroupAnnouncement emModifyGroupAnnouncement, final ApiCallback _callback) throws ApiException { + // verify the required parameter 'groupId' is set + if (groupId == null) { + throw new ApiException("Missing the required parameter 'groupId' when calling modifyGroupAnnouncement(Async)"); + } + + return modifyGroupAnnouncementCall(groupId, emModifyGroupAnnouncement, _callback); + + } + + /** + * 修改群组公告 + * 修改指定群组 ID 的群组公告。群组公告不能超过 512 个字符。文档介绍:https://docs-im-beta.easemob.com/document/server-side/group.html#%E4%BF%AE%E6%94%B9%E7%BE%A4%E7%BB%84%E5%85%AC%E5%91%8A + * @param groupId (required) + * @param emModifyGroupAnnouncement (optional) + * @return EMModifyGroupAnnouncementResult + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public EMModifyGroupAnnouncementResult modifyGroupAnnouncement(String groupId, EMModifyGroupAnnouncement emModifyGroupAnnouncement) throws ApiException { + ApiResponse localVarResp = modifyGroupAnnouncementWithHttpInfo(groupId, emModifyGroupAnnouncement); + return localVarResp.getData(); + } + + /** + * 修改群组公告 + * 修改指定群组 ID 的群组公告。群组公告不能超过 512 个字符。文档介绍:https://docs-im-beta.easemob.com/document/server-side/group.html#%E4%BF%AE%E6%94%B9%E7%BE%A4%E7%BB%84%E5%85%AC%E5%91%8A + * @param groupId (required) + * @param emModifyGroupAnnouncement (optional) + * @return ApiResponse<EMModifyGroupAnnouncementResult> + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public ApiResponse modifyGroupAnnouncementWithHttpInfo(String groupId, EMModifyGroupAnnouncement emModifyGroupAnnouncement) throws ApiException { + okhttp3.Call localVarCall = modifyGroupAnnouncementValidateBeforeCall(groupId, emModifyGroupAnnouncement, null); + Type localVarReturnType = new TypeToken(){}.getType(); + return localVarApiClient.execute(localVarCall, localVarReturnType); + } + + /** + * 修改群组公告 (asynchronously) + * 修改指定群组 ID 的群组公告。群组公告不能超过 512 个字符。文档介绍:https://docs-im-beta.easemob.com/document/server-side/group.html#%E4%BF%AE%E6%94%B9%E7%BE%A4%E7%BB%84%E5%85%AC%E5%91%8A + * @param groupId (required) + * @param emModifyGroupAnnouncement (optional) + * @param _callback The callback to be executed when the API call finishes + * @return The request call + * @throws ApiException If fail to process the API call, e.g. serializing the request body object + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public okhttp3.Call modifyGroupAnnouncementAsync(String groupId, EMModifyGroupAnnouncement emModifyGroupAnnouncement, final ApiCallback _callback) throws ApiException { + + okhttp3.Call localVarCall = modifyGroupAnnouncementValidateBeforeCall(groupId, emModifyGroupAnnouncement, _callback); + Type localVarReturnType = new TypeToken(){}.getType(); + localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); + return localVarCall; + } + /** + * Build call for muteAllGroupMembers + * @param groupId (required) + * @param _callback Callback for upload/download progress + * @return Call to execute + * @throws ApiException If fail to serialize the request body object + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public okhttp3.Call muteAllGroupMembersCall(String groupId, final ApiCallback _callback) throws ApiException { + String basePath = null; + // Operation Servers + String[] localBasePaths = new String[] { }; + + // Determine Base Path to Use + if (localCustomBaseUrl != null){ + basePath = localCustomBaseUrl; + } else if ( localBasePaths.length > 0 ) { + basePath = localBasePaths[localHostIndex]; + } else { + basePath = null; + } + + Object localVarPostBody = null; + + // create path and map variables + String localVarPath = "/chatgroups/{group_id}/ban" + .replace("{" + "group_id" + "}", localVarApiClient.escapeString(groupId.toString())); + + List localVarQueryParams = new ArrayList(); + List localVarCollectionQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + Map localVarCookieParams = new HashMap(); + Map localVarFormParams = new HashMap(); + + final String[] localVarAccepts = { + "application/json" + }; + final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts); + if (localVarAccept != null) { + localVarHeaderParams.put("Accept", localVarAccept); + } + + final String[] localVarContentTypes = { + }; + final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); + if (localVarContentType != null) { + localVarHeaderParams.put("Content-Type", localVarContentType); + } + + String[] localVarAuthNames = new String[] { }; + return localVarApiClient.buildCall(basePath, localVarPath, "POST", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); + } + + @SuppressWarnings("rawtypes") + private okhttp3.Call muteAllGroupMembersValidateBeforeCall(String groupId, final ApiCallback _callback) throws ApiException { + // verify the required parameter 'groupId' is set + if (groupId == null) { + throw new ApiException("Missing the required parameter 'groupId' when calling muteAllGroupMembers(Async)"); + } + + return muteAllGroupMembersCall(groupId, _callback); + + } + + /** + * 禁言全体群成员 + * 对所有群组成员一键禁言,即将群组的所有成员加入禁言列表。设置群组全员禁言后,仅群组白名单中的用户可在群组以及该群组下的子区内发送消息。文档介绍:https://docs-im-beta.easemob.com/document/server-side/group.html#%E7%A6%81%E8%A8%80%E5%85%A8%E4%BD%93%E7%BE%A4%E6%88%90%E5%91%98 + * @param groupId (required) + * @return EMMuteAllGroupMembersResult + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public EMMuteAllGroupMembersResult muteAllGroupMembers(String groupId) throws ApiException { + ApiResponse localVarResp = muteAllGroupMembersWithHttpInfo(groupId); + return localVarResp.getData(); + } + + /** + * 禁言全体群成员 + * 对所有群组成员一键禁言,即将群组的所有成员加入禁言列表。设置群组全员禁言后,仅群组白名单中的用户可在群组以及该群组下的子区内发送消息。文档介绍:https://docs-im-beta.easemob.com/document/server-side/group.html#%E7%A6%81%E8%A8%80%E5%85%A8%E4%BD%93%E7%BE%A4%E6%88%90%E5%91%98 + * @param groupId (required) + * @return ApiResponse<EMMuteAllGroupMembersResult> + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public ApiResponse muteAllGroupMembersWithHttpInfo(String groupId) throws ApiException { + okhttp3.Call localVarCall = muteAllGroupMembersValidateBeforeCall(groupId, null); + Type localVarReturnType = new TypeToken(){}.getType(); + return localVarApiClient.execute(localVarCall, localVarReturnType); + } + + /** + * 禁言全体群成员 (asynchronously) + * 对所有群组成员一键禁言,即将群组的所有成员加入禁言列表。设置群组全员禁言后,仅群组白名单中的用户可在群组以及该群组下的子区内发送消息。文档介绍:https://docs-im-beta.easemob.com/document/server-side/group.html#%E7%A6%81%E8%A8%80%E5%85%A8%E4%BD%93%E7%BE%A4%E6%88%90%E5%91%98 + * @param groupId (required) + * @param _callback The callback to be executed when the API call finishes + * @return The request call + * @throws ApiException If fail to process the API call, e.g. serializing the request body object + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public okhttp3.Call muteAllGroupMembersAsync(String groupId, final ApiCallback _callback) throws ApiException { + + okhttp3.Call localVarCall = muteAllGroupMembersValidateBeforeCall(groupId, _callback); + Type localVarReturnType = new TypeToken(){}.getType(); + localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); + return localVarCall; + } + /** + * Build call for muteGroupMember + * @param groupId (required) + * @param emMuteGroupMember (optional) + * @param _callback Callback for upload/download progress + * @return Call to execute + * @throws ApiException If fail to serialize the request body object + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public okhttp3.Call muteGroupMemberCall(String groupId, EMMuteGroupMember emMuteGroupMember, final ApiCallback _callback) throws ApiException { + String basePath = null; + // Operation Servers + String[] localBasePaths = new String[] { }; + + // Determine Base Path to Use + if (localCustomBaseUrl != null){ + basePath = localCustomBaseUrl; + } else if ( localBasePaths.length > 0 ) { + basePath = localBasePaths[localHostIndex]; + } else { + basePath = null; + } + + Object localVarPostBody = emMuteGroupMember; + + // create path and map variables + String localVarPath = "/chatgroups/{group_id}/mute" + .replace("{" + "group_id" + "}", localVarApiClient.escapeString(groupId.toString())); + + List localVarQueryParams = new ArrayList(); + List localVarCollectionQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + Map localVarCookieParams = new HashMap(); + Map localVarFormParams = new HashMap(); + + final String[] localVarAccepts = { + "application/json" + }; + final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts); + if (localVarAccept != null) { + localVarHeaderParams.put("Accept", localVarAccept); + } + + final String[] localVarContentTypes = { + "application/json" + }; + final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); + if (localVarContentType != null) { + localVarHeaderParams.put("Content-Type", localVarContentType); + } + + String[] localVarAuthNames = new String[] { }; + return localVarApiClient.buildCall(basePath, localVarPath, "POST", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); + } + + @SuppressWarnings("rawtypes") + private okhttp3.Call muteGroupMemberValidateBeforeCall(String groupId, EMMuteGroupMember emMuteGroupMember, final ApiCallback _callback) throws ApiException { + // verify the required parameter 'groupId' is set + if (groupId == null) { + throw new ApiException("Missing the required parameter 'groupId' when calling muteGroupMember(Async)"); + } + + return muteGroupMemberCall(groupId, emMuteGroupMember, _callback); + + } + + /** + * 禁言指定群成员 + * 对一个或多个群成员禁言。你一次最多可禁言 60 个群组成员。群成员被禁言后,将无法在群组中发送消息,也无法在该群组下的子区中发送消息。文档介绍:https://docs-im-beta.easemob.com/document/server-side/group.html#%E7%A6%81%E8%A8%80%E6%8C%87%E5%AE%9A%E7%BE%A4%E6%88%90%E5%91%98 + * @param groupId (required) + * @param emMuteGroupMember (optional) + * @return EMMuteGroupMemberResult + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public EMMuteGroupMemberResult muteGroupMember(String groupId, EMMuteGroupMember emMuteGroupMember) throws ApiException { + ApiResponse localVarResp = muteGroupMemberWithHttpInfo(groupId, emMuteGroupMember); + return localVarResp.getData(); + } + + /** + * 禁言指定群成员 + * 对一个或多个群成员禁言。你一次最多可禁言 60 个群组成员。群成员被禁言后,将无法在群组中发送消息,也无法在该群组下的子区中发送消息。文档介绍:https://docs-im-beta.easemob.com/document/server-side/group.html#%E7%A6%81%E8%A8%80%E6%8C%87%E5%AE%9A%E7%BE%A4%E6%88%90%E5%91%98 + * @param groupId (required) + * @param emMuteGroupMember (optional) + * @return ApiResponse<EMMuteGroupMemberResult> + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public ApiResponse muteGroupMemberWithHttpInfo(String groupId, EMMuteGroupMember emMuteGroupMember) throws ApiException { + okhttp3.Call localVarCall = muteGroupMemberValidateBeforeCall(groupId, emMuteGroupMember, null); + Type localVarReturnType = new TypeToken(){}.getType(); + return localVarApiClient.execute(localVarCall, localVarReturnType); + } + + /** + * 禁言指定群成员 (asynchronously) + * 对一个或多个群成员禁言。你一次最多可禁言 60 个群组成员。群成员被禁言后,将无法在群组中发送消息,也无法在该群组下的子区中发送消息。文档介绍:https://docs-im-beta.easemob.com/document/server-side/group.html#%E7%A6%81%E8%A8%80%E6%8C%87%E5%AE%9A%E7%BE%A4%E6%88%90%E5%91%98 + * @param groupId (required) + * @param emMuteGroupMember (optional) + * @param _callback The callback to be executed when the API call finishes + * @return The request call + * @throws ApiException If fail to process the API call, e.g. serializing the request body object + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public okhttp3.Call muteGroupMemberAsync(String groupId, EMMuteGroupMember emMuteGroupMember, final ApiCallback _callback) throws ApiException { + + okhttp3.Call localVarCall = muteGroupMemberValidateBeforeCall(groupId, emMuteGroupMember, _callback); + Type localVarReturnType = new TypeToken(){}.getType(); + localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); + return localVarCall; + } + /** + * Build call for removeGroupAdmin + * @param groupId (required) + * @param username (required) + * @param _callback Callback for upload/download progress + * @return Call to execute + * @throws ApiException If fail to serialize the request body object + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public okhttp3.Call removeGroupAdminCall(String groupId, String username, final ApiCallback _callback) throws ApiException { + String basePath = null; + // Operation Servers + String[] localBasePaths = new String[] { }; + + // Determine Base Path to Use + if (localCustomBaseUrl != null){ + basePath = localCustomBaseUrl; + } else if ( localBasePaths.length > 0 ) { + basePath = localBasePaths[localHostIndex]; + } else { + basePath = null; + } + + Object localVarPostBody = null; + + // create path and map variables + String localVarPath = "/chatgroups/{group_id}/admin/{username}" + .replace("{" + "group_id" + "}", localVarApiClient.escapeString(groupId.toString())) + .replace("{" + "username" + "}", localVarApiClient.escapeString(username.toString())); + + List localVarQueryParams = new ArrayList(); + List localVarCollectionQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + Map localVarCookieParams = new HashMap(); + Map localVarFormParams = new HashMap(); + + final String[] localVarAccepts = { + "application/json" + }; + final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts); + if (localVarAccept != null) { + localVarHeaderParams.put("Accept", localVarAccept); + } + + final String[] localVarContentTypes = { + }; + final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); + if (localVarContentType != null) { + localVarHeaderParams.put("Content-Type", localVarContentType); + } + + String[] localVarAuthNames = new String[] { }; + return localVarApiClient.buildCall(basePath, localVarPath, "DELETE", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); + } + + @SuppressWarnings("rawtypes") + private okhttp3.Call removeGroupAdminValidateBeforeCall(String groupId, String username, final ApiCallback _callback) throws ApiException { + // verify the required parameter 'groupId' is set + if (groupId == null) { + throw new ApiException("Missing the required parameter 'groupId' when calling removeGroupAdmin(Async)"); + } + + // verify the required parameter 'username' is set + if (username == null) { + throw new ApiException("Missing the required parameter 'username' when calling removeGroupAdmin(Async)"); + } + + return removeGroupAdminCall(groupId, username, _callback); + + } + + /** + * 移除群管理员 + * 将用户的角色从群管理员降为群普通成员。文档介绍:https://docs-im-beta.easemob.com/document/server-side/group.html#%E7%A7%BB%E9%99%A4%E7%BE%A4%E7%AE%A1%E7%90%86%E5%91%98 + * @param groupId (required) + * @param username (required) + * @return EMRemoveGroupAdminResult + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public EMRemoveGroupAdminResult removeGroupAdmin(String groupId, String username) throws ApiException { + ApiResponse localVarResp = removeGroupAdminWithHttpInfo(groupId, username); + return localVarResp.getData(); + } + + /** + * 移除群管理员 + * 将用户的角色从群管理员降为群普通成员。文档介绍:https://docs-im-beta.easemob.com/document/server-side/group.html#%E7%A7%BB%E9%99%A4%E7%BE%A4%E7%AE%A1%E7%90%86%E5%91%98 + * @param groupId (required) + * @param username (required) + * @return ApiResponse<EMRemoveGroupAdminResult> + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public ApiResponse removeGroupAdminWithHttpInfo(String groupId, String username) throws ApiException { + okhttp3.Call localVarCall = removeGroupAdminValidateBeforeCall(groupId, username, null); + Type localVarReturnType = new TypeToken(){}.getType(); + return localVarApiClient.execute(localVarCall, localVarReturnType); + } + + /** + * 移除群管理员 (asynchronously) + * 将用户的角色从群管理员降为群普通成员。文档介绍:https://docs-im-beta.easemob.com/document/server-side/group.html#%E7%A7%BB%E9%99%A4%E7%BE%A4%E7%AE%A1%E7%90%86%E5%91%98 + * @param groupId (required) + * @param username (required) + * @param _callback The callback to be executed when the API call finishes + * @return The request call + * @throws ApiException If fail to process the API call, e.g. serializing the request body object + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public okhttp3.Call removeGroupAdminAsync(String groupId, String username, final ApiCallback _callback) throws ApiException { + + okhttp3.Call localVarCall = removeGroupAdminValidateBeforeCall(groupId, username, _callback); + Type localVarReturnType = new TypeToken(){}.getType(); + localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); + return localVarCall; + } + /** + * Build call for removeUserFromGroupBlockList + * @param groupId (required) + * @param username (required) + * @param _callback Callback for upload/download progress + * @return Call to execute + * @throws ApiException If fail to serialize the request body object + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public okhttp3.Call removeUserFromGroupBlockListCall(String groupId, String username, final ApiCallback _callback) throws ApiException { + String basePath = null; + // Operation Servers + String[] localBasePaths = new String[] { }; + + // Determine Base Path to Use + if (localCustomBaseUrl != null){ + basePath = localCustomBaseUrl; + } else if ( localBasePaths.length > 0 ) { + basePath = localBasePaths[localHostIndex]; + } else { + basePath = null; + } + + Object localVarPostBody = null; + + // create path and map variables + String localVarPath = "/chatgroups/{group_id}/blocks/users/{username}" + .replace("{" + "group_id" + "}", localVarApiClient.escapeString(groupId.toString())) + .replace("{" + "username" + "}", localVarApiClient.escapeString(username.toString())); + + List localVarQueryParams = new ArrayList(); + List localVarCollectionQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + Map localVarCookieParams = new HashMap(); + Map localVarFormParams = new HashMap(); + + final String[] localVarAccepts = { + "application/json" + }; + final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts); + if (localVarAccept != null) { + localVarHeaderParams.put("Accept", localVarAccept); + } + + final String[] localVarContentTypes = { + }; + final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); + if (localVarContentType != null) { + localVarHeaderParams.put("Content-Type", localVarContentType); + } + + String[] localVarAuthNames = new String[] { }; + return localVarApiClient.buildCall(basePath, localVarPath, "DELETE", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); + } + + @SuppressWarnings("rawtypes") + private okhttp3.Call removeUserFromGroupBlockListValidateBeforeCall(String groupId, String username, final ApiCallback _callback) throws ApiException { + // verify the required parameter 'groupId' is set + if (groupId == null) { + throw new ApiException("Missing the required parameter 'groupId' when calling removeUserFromGroupBlockList(Async)"); + } + + // verify the required parameter 'username' is set + if (username == null) { + throw new ApiException("Missing the required parameter 'username' when calling removeUserFromGroupBlockList(Async)"); + } + + return removeUserFromGroupBlockListCall(groupId, username, _callback); + + } + + /** + * 从群组黑名单移除单个用户 + * 将指定用户移出群组黑名单。对于群组黑名单中的用户,如果需要将其再次加入群组,需要先将其从群组黑名单中移除。文档介绍:https://docs-im-beta.easemob.com/document/server-side/group.html#%E4%BB%8E%E7%BE%A4%E7%BB%84%E9%BB%91%E5%90%8D%E5%8D%95%E7%A7%BB%E9%99%A4%E5%8D%95%E4%B8%AA%E7%94%A8%E6%88%B7 + * @param groupId (required) + * @param username (required) + * @return EMRemoveUserFromGroupBlockListResult + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public EMRemoveUserFromGroupBlockListResult removeUserFromGroupBlockList(String groupId, String username) throws ApiException { + ApiResponse localVarResp = removeUserFromGroupBlockListWithHttpInfo(groupId, username); + return localVarResp.getData(); + } + + /** + * 从群组黑名单移除单个用户 + * 将指定用户移出群组黑名单。对于群组黑名单中的用户,如果需要将其再次加入群组,需要先将其从群组黑名单中移除。文档介绍:https://docs-im-beta.easemob.com/document/server-side/group.html#%E4%BB%8E%E7%BE%A4%E7%BB%84%E9%BB%91%E5%90%8D%E5%8D%95%E7%A7%BB%E9%99%A4%E5%8D%95%E4%B8%AA%E7%94%A8%E6%88%B7 + * @param groupId (required) + * @param username (required) + * @return ApiResponse<EMRemoveUserFromGroupBlockListResult> + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public ApiResponse removeUserFromGroupBlockListWithHttpInfo(String groupId, String username) throws ApiException { + okhttp3.Call localVarCall = removeUserFromGroupBlockListValidateBeforeCall(groupId, username, null); + Type localVarReturnType = new TypeToken(){}.getType(); + return localVarApiClient.execute(localVarCall, localVarReturnType); + } + + /** + * 从群组黑名单移除单个用户 (asynchronously) + * 将指定用户移出群组黑名单。对于群组黑名单中的用户,如果需要将其再次加入群组,需要先将其从群组黑名单中移除。文档介绍:https://docs-im-beta.easemob.com/document/server-side/group.html#%E4%BB%8E%E7%BE%A4%E7%BB%84%E9%BB%91%E5%90%8D%E5%8D%95%E7%A7%BB%E9%99%A4%E5%8D%95%E4%B8%AA%E7%94%A8%E6%88%B7 + * @param groupId (required) + * @param username (required) + * @param _callback The callback to be executed when the API call finishes + * @return The request call + * @throws ApiException If fail to process the API call, e.g. serializing the request body object + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public okhttp3.Call removeUserFromGroupBlockListAsync(String groupId, String username, final ApiCallback _callback) throws ApiException { + + okhttp3.Call localVarCall = removeUserFromGroupBlockListValidateBeforeCall(groupId, username, _callback); + Type localVarReturnType = new TypeToken(){}.getType(); + localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); + return localVarCall; + } + /** + * Build call for removeUserFromGroupWhiteList + * @param groupId (required) + * @param username (required) + * @param _callback Callback for upload/download progress + * @return Call to execute + * @throws ApiException If fail to serialize the request body object + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public okhttp3.Call removeUserFromGroupWhiteListCall(String groupId, String username, final ApiCallback _callback) throws ApiException { + String basePath = null; + // Operation Servers + String[] localBasePaths = new String[] { }; + + // Determine Base Path to Use + if (localCustomBaseUrl != null){ + basePath = localCustomBaseUrl; + } else if ( localBasePaths.length > 0 ) { + basePath = localBasePaths[localHostIndex]; + } else { + basePath = null; + } + + Object localVarPostBody = null; + + // create path and map variables + String localVarPath = "/chatgroups/{group_id}/white/users/{username}" + .replace("{" + "group_id" + "}", localVarApiClient.escapeString(groupId.toString())) + .replace("{" + "username" + "}", localVarApiClient.escapeString(username.toString())); + + List localVarQueryParams = new ArrayList(); + List localVarCollectionQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + Map localVarCookieParams = new HashMap(); + Map localVarFormParams = new HashMap(); + + final String[] localVarAccepts = { + "application/json" + }; + final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts); + if (localVarAccept != null) { + localVarHeaderParams.put("Accept", localVarAccept); + } + + final String[] localVarContentTypes = { + }; + final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); + if (localVarContentType != null) { + localVarHeaderParams.put("Content-Type", localVarContentType); + } + + String[] localVarAuthNames = new String[] { }; + return localVarApiClient.buildCall(basePath, localVarPath, "DELETE", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); + } + + @SuppressWarnings("rawtypes") + private okhttp3.Call removeUserFromGroupWhiteListValidateBeforeCall(String groupId, String username, final ApiCallback _callback) throws ApiException { + // verify the required parameter 'groupId' is set + if (groupId == null) { + throw new ApiException("Missing the required parameter 'groupId' when calling removeUserFromGroupWhiteList(Async)"); + } + + // verify the required parameter 'username' is set + if (username == null) { + throw new ApiException("Missing the required parameter 'username' when calling removeUserFromGroupWhiteList(Async)"); + } + + return removeUserFromGroupWhiteListCall(groupId, username, _callback); + + } + + /** + * 从群组白名单移除用户 + * 将指定用户从群组白名单中移除。文档介绍:https://docs-im-beta.easemob.com/document/server-side/group.html#%E4%BB%8E%E7%BE%A4%E7%BB%84%E7%99%BD%E5%90%8D%E5%8D%95%E7%A7%BB%E9%99%A4%E7%94%A8%E6%88%B7 + * @param groupId (required) + * @param username (required) + * @return EMRemoveUserFromGroupWhiteListResult + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public EMRemoveUserFromGroupWhiteListResult removeUserFromGroupWhiteList(String groupId, String username) throws ApiException { + ApiResponse localVarResp = removeUserFromGroupWhiteListWithHttpInfo(groupId, username); + return localVarResp.getData(); + } + + /** + * 从群组白名单移除用户 + * 将指定用户从群组白名单中移除。文档介绍:https://docs-im-beta.easemob.com/document/server-side/group.html#%E4%BB%8E%E7%BE%A4%E7%BB%84%E7%99%BD%E5%90%8D%E5%8D%95%E7%A7%BB%E9%99%A4%E7%94%A8%E6%88%B7 + * @param groupId (required) + * @param username (required) + * @return ApiResponse<EMRemoveUserFromGroupWhiteListResult> + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public ApiResponse removeUserFromGroupWhiteListWithHttpInfo(String groupId, String username) throws ApiException { + okhttp3.Call localVarCall = removeUserFromGroupWhiteListValidateBeforeCall(groupId, username, null); + Type localVarReturnType = new TypeToken(){}.getType(); + return localVarApiClient.execute(localVarCall, localVarReturnType); + } + + /** + * 从群组白名单移除用户 (asynchronously) + * 将指定用户从群组白名单中移除。文档介绍:https://docs-im-beta.easemob.com/document/server-side/group.html#%E4%BB%8E%E7%BE%A4%E7%BB%84%E7%99%BD%E5%90%8D%E5%8D%95%E7%A7%BB%E9%99%A4%E7%94%A8%E6%88%B7 + * @param groupId (required) + * @param username (required) + * @param _callback The callback to be executed when the API call finishes + * @return The request call + * @throws ApiException If fail to process the API call, e.g. serializing the request body object + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public okhttp3.Call removeUserFromGroupWhiteListAsync(String groupId, String username, final ApiCallback _callback) throws ApiException { + + okhttp3.Call localVarCall = removeUserFromGroupWhiteListValidateBeforeCall(groupId, username, _callback); + Type localVarReturnType = new TypeToken(){}.getType(); + localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); + return localVarCall; + } + /** + * Build call for removeUserToGroup + * @param groupId (required) + * @param username (required) + * @param _callback Callback for upload/download progress + * @return Call to execute + * @throws ApiException If fail to serialize the request body object + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public okhttp3.Call removeUserToGroupCall(String groupId, String username, final ApiCallback _callback) throws ApiException { + String basePath = null; + // Operation Servers + String[] localBasePaths = new String[] { }; + + // Determine Base Path to Use + if (localCustomBaseUrl != null){ + basePath = localCustomBaseUrl; + } else if ( localBasePaths.length > 0 ) { + basePath = localBasePaths[localHostIndex]; + } else { + basePath = null; + } + + Object localVarPostBody = null; + + // create path and map variables + String localVarPath = "/chatgroups/{group_id}/users/{username}" + .replace("{" + "group_id" + "}", localVarApiClient.escapeString(groupId.toString())) + .replace("{" + "username" + "}", localVarApiClient.escapeString(username.toString())); + + List localVarQueryParams = new ArrayList(); + List localVarCollectionQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + Map localVarCookieParams = new HashMap(); + Map localVarFormParams = new HashMap(); + + final String[] localVarAccepts = { + "application/json" + }; + final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts); + if (localVarAccept != null) { + localVarHeaderParams.put("Accept", localVarAccept); + } + + final String[] localVarContentTypes = { + }; + final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); + if (localVarContentType != null) { + localVarHeaderParams.put("Content-Type", localVarContentType); + } + + String[] localVarAuthNames = new String[] { }; + return localVarApiClient.buildCall(basePath, localVarPath, "DELETE", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); + } + + @SuppressWarnings("rawtypes") + private okhttp3.Call removeUserToGroupValidateBeforeCall(String groupId, String username, final ApiCallback _callback) throws ApiException { + // verify the required parameter 'groupId' is set + if (groupId == null) { + throw new ApiException("Missing the required parameter 'groupId' when calling removeUserToGroup(Async)"); + } + + // verify the required parameter 'username' is set + if (username == null) { + throw new ApiException("Missing the required parameter 'username' when calling removeUserToGroup(Async)"); + } + + return removeUserToGroupCall(groupId, username, _callback); + + } + + /** + * 移除单个群组成员 + * 从群中移除指定成员。如果被移除用户不是群成员,将移除失败,并返回错误。移除后,该成员也会被移除其在该群组中加入的子区。文档介绍:https://docs-im-beta.easemob.com/document/server-side/group.html#%E7%A7%BB%E9%99%A4%E5%8D%95%E4%B8%AA%E7%BE%A4%E7%BB%84%E6%88%90%E5%91%98 + * @param groupId (required) + * @param username (required) + * @return EMRemoveUserToGroupResult + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public EMRemoveUserToGroupResult removeUserToGroup(String groupId, String username) throws ApiException { + ApiResponse localVarResp = removeUserToGroupWithHttpInfo(groupId, username); + return localVarResp.getData(); + } + + /** + * 移除单个群组成员 + * 从群中移除指定成员。如果被移除用户不是群成员,将移除失败,并返回错误。移除后,该成员也会被移除其在该群组中加入的子区。文档介绍:https://docs-im-beta.easemob.com/document/server-side/group.html#%E7%A7%BB%E9%99%A4%E5%8D%95%E4%B8%AA%E7%BE%A4%E7%BB%84%E6%88%90%E5%91%98 + * @param groupId (required) + * @param username (required) + * @return ApiResponse<EMRemoveUserToGroupResult> + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public ApiResponse removeUserToGroupWithHttpInfo(String groupId, String username) throws ApiException { + okhttp3.Call localVarCall = removeUserToGroupValidateBeforeCall(groupId, username, null); + Type localVarReturnType = new TypeToken(){}.getType(); + return localVarApiClient.execute(localVarCall, localVarReturnType); + } + + /** + * 移除单个群组成员 (asynchronously) + * 从群中移除指定成员。如果被移除用户不是群成员,将移除失败,并返回错误。移除后,该成员也会被移除其在该群组中加入的子区。文档介绍:https://docs-im-beta.easemob.com/document/server-side/group.html#%E7%A7%BB%E9%99%A4%E5%8D%95%E4%B8%AA%E7%BE%A4%E7%BB%84%E6%88%90%E5%91%98 + * @param groupId (required) + * @param username (required) + * @param _callback The callback to be executed when the API call finishes + * @return The request call + * @throws ApiException If fail to process the API call, e.g. serializing the request body object + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public okhttp3.Call removeUserToGroupAsync(String groupId, String username, final ApiCallback _callback) throws ApiException { + + okhttp3.Call localVarCall = removeUserToGroupValidateBeforeCall(groupId, username, _callback); + Type localVarReturnType = new TypeToken(){}.getType(); + localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); + return localVarCall; + } + /** + * Build call for unmuteAllGroupMembers + * @param groupId (required) + * @param _callback Callback for upload/download progress + * @return Call to execute + * @throws ApiException If fail to serialize the request body object + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public okhttp3.Call unmuteAllGroupMembersCall(String groupId, final ApiCallback _callback) throws ApiException { + String basePath = null; + // Operation Servers + String[] localBasePaths = new String[] { }; + + // Determine Base Path to Use + if (localCustomBaseUrl != null){ + basePath = localCustomBaseUrl; + } else if ( localBasePaths.length > 0 ) { + basePath = localBasePaths[localHostIndex]; + } else { + basePath = null; + } + + Object localVarPostBody = null; + + // create path and map variables + String localVarPath = "/chatgroups/{group_id}/ban" + .replace("{" + "group_id" + "}", localVarApiClient.escapeString(groupId.toString())); + + List localVarQueryParams = new ArrayList(); + List localVarCollectionQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + Map localVarCookieParams = new HashMap(); + Map localVarFormParams = new HashMap(); + + final String[] localVarAccepts = { + "application/json" + }; + final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts); + if (localVarAccept != null) { + localVarHeaderParams.put("Accept", localVarAccept); + } + + final String[] localVarContentTypes = { + }; + final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); + if (localVarContentType != null) { + localVarHeaderParams.put("Content-Type", localVarContentType); + } + + String[] localVarAuthNames = new String[] { }; + return localVarApiClient.buildCall(basePath, localVarPath, "DELETE", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); + } + + @SuppressWarnings("rawtypes") + private okhttp3.Call unmuteAllGroupMembersValidateBeforeCall(String groupId, final ApiCallback _callback) throws ApiException { + // verify the required parameter 'groupId' is set + if (groupId == null) { + throw new ApiException("Missing the required parameter 'groupId' when calling unmuteAllGroupMembers(Async)"); + } + + return unmuteAllGroupMembersCall(groupId, _callback); + + } + + /** + * 解除全员禁言 + * 一键取消对群组全体成员的禁言。解除禁言后,群成员可以在群组和该群组下的子区中正常发送消息。文档介绍:https://docs-im-beta.easemob.com/document/server-side/group.html#%E8%A7%A3%E9%99%A4%E5%85%A8%E5%91%98%E7%A6%81%E8%A8%80 + * @param groupId (required) + * @return EMUnmuteAllGroupMembersResult + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public EMUnmuteAllGroupMembersResult unmuteAllGroupMembers(String groupId) throws ApiException { + ApiResponse localVarResp = unmuteAllGroupMembersWithHttpInfo(groupId); + return localVarResp.getData(); + } + + /** + * 解除全员禁言 + * 一键取消对群组全体成员的禁言。解除禁言后,群成员可以在群组和该群组下的子区中正常发送消息。文档介绍:https://docs-im-beta.easemob.com/document/server-side/group.html#%E8%A7%A3%E9%99%A4%E5%85%A8%E5%91%98%E7%A6%81%E8%A8%80 + * @param groupId (required) + * @return ApiResponse<EMUnmuteAllGroupMembersResult> + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public ApiResponse unmuteAllGroupMembersWithHttpInfo(String groupId) throws ApiException { + okhttp3.Call localVarCall = unmuteAllGroupMembersValidateBeforeCall(groupId, null); + Type localVarReturnType = new TypeToken(){}.getType(); + return localVarApiClient.execute(localVarCall, localVarReturnType); + } + + /** + * 解除全员禁言 (asynchronously) + * 一键取消对群组全体成员的禁言。解除禁言后,群成员可以在群组和该群组下的子区中正常发送消息。文档介绍:https://docs-im-beta.easemob.com/document/server-side/group.html#%E8%A7%A3%E9%99%A4%E5%85%A8%E5%91%98%E7%A6%81%E8%A8%80 + * @param groupId (required) + * @param _callback The callback to be executed when the API call finishes + * @return The request call + * @throws ApiException If fail to process the API call, e.g. serializing the request body object + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public okhttp3.Call unmuteAllGroupMembersAsync(String groupId, final ApiCallback _callback) throws ApiException { + + okhttp3.Call localVarCall = unmuteAllGroupMembersValidateBeforeCall(groupId, _callback); + Type localVarReturnType = new TypeToken(){}.getType(); + localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); + return localVarCall; + } + /** + * Build call for uploadGroupShareFile + * @param groupId (required) + * @param _file 文件本地路径 (required) + * @param _callback Callback for upload/download progress + * @return Call to execute + * @throws ApiException If fail to serialize the request body object + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public okhttp3.Call uploadGroupShareFileCall(String groupId, File _file, final ApiCallback _callback) throws ApiException { + String basePath = null; + // Operation Servers + String[] localBasePaths = new String[] { }; + + // Determine Base Path to Use + if (localCustomBaseUrl != null){ + basePath = localCustomBaseUrl; + } else if ( localBasePaths.length > 0 ) { + basePath = localBasePaths[localHostIndex]; + } else { + basePath = null; + } + + Object localVarPostBody = null; + + // create path and map variables + String localVarPath = "/chatgroups/{group_id}/share_files" + .replace("{" + "group_id" + "}", localVarApiClient.escapeString(groupId.toString())); + + List localVarQueryParams = new ArrayList(); + List localVarCollectionQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + Map localVarCookieParams = new HashMap(); + Map localVarFormParams = new HashMap(); + + if (_file != null) { + localVarFormParams.put("file", _file); + } + + final String[] localVarAccepts = { + "application/json" + }; + final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts); + if (localVarAccept != null) { + localVarHeaderParams.put("Accept", localVarAccept); + } + + final String[] localVarContentTypes = { + "multipart/form-data" + }; + final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); + if (localVarContentType != null) { + localVarHeaderParams.put("Content-Type", localVarContentType); + } + + String[] localVarAuthNames = new String[] { }; + return localVarApiClient.buildCall(basePath, localVarPath, "POST", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); + } + + @SuppressWarnings("rawtypes") + private okhttp3.Call uploadGroupShareFileValidateBeforeCall(String groupId, File _file, final ApiCallback _callback) throws ApiException { + // verify the required parameter 'groupId' is set + if (groupId == null) { + throw new ApiException("Missing the required parameter 'groupId' when calling uploadGroupShareFile(Async)"); + } + + // verify the required parameter '_file' is set + if (_file == null) { + throw new ApiException("Missing the required parameter '_file' when calling uploadGroupShareFile(Async)"); + } + + return uploadGroupShareFileCall(groupId, _file, _callback); + + } + + /** + * 上传群组共享文件 + * 上传指定群组 ID 的群组共享文件。注意上传的文件大小不能超过 10 MB。分页获取指定群组 ID 的群组共享文件,然后可以根据响应中返回的文件 ID(file_id)调用 下载群组共享文件 接口下载该文件,或调用 删除群组共享文件 接口删除该文件。文档介绍:https://docs-im-beta.easemob.com/document/server-side/group.html#%E4%B8%8A%E4%BC%A0%E7%BE%A4%E7%BB%84%E5%85%B1%E4%BA%AB%E6%96%87%E4%BB%B6 + * @param groupId (required) + * @param _file 文件本地路径 (required) + * @return EMUploadGroupShareFileResult + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public EMUploadGroupShareFileResult uploadGroupShareFile(String groupId, File _file) throws ApiException { + ApiResponse localVarResp = uploadGroupShareFileWithHttpInfo(groupId, _file); + return localVarResp.getData(); + } + + /** + * 上传群组共享文件 + * 上传指定群组 ID 的群组共享文件。注意上传的文件大小不能超过 10 MB。分页获取指定群组 ID 的群组共享文件,然后可以根据响应中返回的文件 ID(file_id)调用 下载群组共享文件 接口下载该文件,或调用 删除群组共享文件 接口删除该文件。文档介绍:https://docs-im-beta.easemob.com/document/server-side/group.html#%E4%B8%8A%E4%BC%A0%E7%BE%A4%E7%BB%84%E5%85%B1%E4%BA%AB%E6%96%87%E4%BB%B6 + * @param groupId (required) + * @param _file 文件本地路径 (required) + * @return ApiResponse<EMUploadGroupShareFileResult> + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public ApiResponse uploadGroupShareFileWithHttpInfo(String groupId, File _file) throws ApiException { + okhttp3.Call localVarCall = uploadGroupShareFileValidateBeforeCall(groupId, _file, null); + Type localVarReturnType = new TypeToken(){}.getType(); + return localVarApiClient.execute(localVarCall, localVarReturnType); + } + + /** + * 上传群组共享文件 (asynchronously) + * 上传指定群组 ID 的群组共享文件。注意上传的文件大小不能超过 10 MB。分页获取指定群组 ID 的群组共享文件,然后可以根据响应中返回的文件 ID(file_id)调用 下载群组共享文件 接口下载该文件,或调用 删除群组共享文件 接口删除该文件。文档介绍:https://docs-im-beta.easemob.com/document/server-side/group.html#%E4%B8%8A%E4%BC%A0%E7%BE%A4%E7%BB%84%E5%85%B1%E4%BA%AB%E6%96%87%E4%BB%B6 + * @param groupId (required) + * @param _file 文件本地路径 (required) + * @param _callback The callback to be executed when the API call finishes + * @return The request call + * @throws ApiException If fail to process the API call, e.g. serializing the request body object + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public okhttp3.Call uploadGroupShareFileAsync(String groupId, File _file, final ApiCallback _callback) throws ApiException { + + okhttp3.Call localVarCall = uploadGroupShareFileValidateBeforeCall(groupId, _file, _callback); + Type localVarReturnType = new TypeToken(){}.getType(); + localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); + return localVarCall; + } +} diff --git a/src/main/java/com/easemob/im/api/HistoryMessageApi.java b/src/main/java/com/easemob/im/api/HistoryMessageApi.java new file mode 100644 index 000000000..90cfbc34d --- /dev/null +++ b/src/main/java/com/easemob/im/api/HistoryMessageApi.java @@ -0,0 +1,206 @@ +/* + * EMService + * Easemob Rest API + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.easemob.im.api; + +import com.easemob.im.ApiCallback; +import com.easemob.im.ApiClient; +import com.easemob.im.ApiException; +import com.easemob.im.ApiResponse; +import com.easemob.im.Configuration; +import com.easemob.im.Pair; +import com.easemob.im.ProgressRequestBody; +import com.easemob.im.ProgressResponseBody; + +import com.google.gson.reflect.TypeToken; + +import java.io.IOException; + + +import com.easemob.im.api.model.EMGetHistoryMessageResult; + +import java.lang.reflect.Type; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +public class HistoryMessageApi { + private ApiClient localVarApiClient; + private int localHostIndex; + private String localCustomBaseUrl; + + public HistoryMessageApi() { + this(Configuration.getDefaultApiClient()); + } + + public HistoryMessageApi(ApiClient apiClient) { + this.localVarApiClient = apiClient; + } + + public ApiClient getApiClient() { + return localVarApiClient; + } + + public void setApiClient(ApiClient apiClient) { + this.localVarApiClient = apiClient; + } + + public int getHostIndex() { + return localHostIndex; + } + + public void setHostIndex(int hostIndex) { + this.localHostIndex = hostIndex; + } + + public String getCustomBaseUrl() { + return localCustomBaseUrl; + } + + public void setCustomBaseUrl(String customBaseUrl) { + this.localCustomBaseUrl = customBaseUrl; + } + + /** + * Build call for historyMessage + * @param time 历史消息记录查询的起始时间。UTC 时间,使用 ISO8601 标准,格式为 yyyyMMddHH。例如 time 为 2018112717,则表示查询 2018 年 11 月 27 日 17 时至 2018 年 11 月 27 日 18 时期间的历史消息。若海外集群为 UTC 时区,需要根据自己所在的时区进行时间转换。 (required) + * @param _callback Callback for upload/download progress + * @return Call to execute + * @throws ApiException If fail to serialize the request body object + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public okhttp3.Call historyMessageCall(String time, final ApiCallback _callback) throws ApiException { + String basePath = null; + // Operation Servers + String[] localBasePaths = new String[] { }; + + // Determine Base Path to Use + if (localCustomBaseUrl != null){ + basePath = localCustomBaseUrl; + } else if ( localBasePaths.length > 0 ) { + basePath = localBasePaths[localHostIndex]; + } else { + basePath = null; + } + + Object localVarPostBody = null; + + // create path and map variables + String localVarPath = "/chatmessages/{time}" + .replace("{" + "time" + "}", localVarApiClient.escapeString(time.toString())); + + List localVarQueryParams = new ArrayList(); + List localVarCollectionQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + Map localVarCookieParams = new HashMap(); + Map localVarFormParams = new HashMap(); + + final String[] localVarAccepts = { + "application/json" + }; + final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts); + if (localVarAccept != null) { + localVarHeaderParams.put("Accept", localVarAccept); + } + + final String[] localVarContentTypes = { + }; + final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); + if (localVarContentType != null) { + localVarHeaderParams.put("Content-Type", localVarContentType); + } + + String[] localVarAuthNames = new String[] { }; + return localVarApiClient.buildCall(basePath, localVarPath, "GET", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); + } + + @SuppressWarnings("rawtypes") + private okhttp3.Call historyMessageValidateBeforeCall(String time, final ApiCallback _callback) throws ApiException { + // verify the required parameter 'time' is set + if (time == null) { + throw new ApiException("Missing the required parameter 'time' when calling historyMessage(Async)"); + } + + return historyMessageCall(time, _callback); + + } + + /** + * 获取历史消息记录 + * 你可以从服务端获取用户发送的历史消息的记录。单次请求获取从指定起始时间开始一小时内的发送的历史消息记录。查询历史消息记录时存在一定延时,无法实时获取。过期的历史消息记录无法获取。文档介绍:https://docs-im-beta.easemob.com/document/server-side/message_historical.html + * @param time 历史消息记录查询的起始时间。UTC 时间,使用 ISO8601 标准,格式为 yyyyMMddHH。例如 time 为 2018112717,则表示查询 2018 年 11 月 27 日 17 时至 2018 年 11 月 27 日 18 时期间的历史消息。若海外集群为 UTC 时区,需要根据自己所在的时区进行时间转换。 (required) + * @return EMGetHistoryMessageResult + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public EMGetHistoryMessageResult historyMessage(String time) throws ApiException { + ApiResponse localVarResp = historyMessageWithHttpInfo(time); + return localVarResp.getData(); + } + + /** + * 获取历史消息记录 + * 你可以从服务端获取用户发送的历史消息的记录。单次请求获取从指定起始时间开始一小时内的发送的历史消息记录。查询历史消息记录时存在一定延时,无法实时获取。过期的历史消息记录无法获取。文档介绍:https://docs-im-beta.easemob.com/document/server-side/message_historical.html + * @param time 历史消息记录查询的起始时间。UTC 时间,使用 ISO8601 标准,格式为 yyyyMMddHH。例如 time 为 2018112717,则表示查询 2018 年 11 月 27 日 17 时至 2018 年 11 月 27 日 18 时期间的历史消息。若海外集群为 UTC 时区,需要根据自己所在的时区进行时间转换。 (required) + * @return ApiResponse<EMGetHistoryMessageResult> + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public ApiResponse historyMessageWithHttpInfo(String time) throws ApiException { + okhttp3.Call localVarCall = historyMessageValidateBeforeCall(time, null); + Type localVarReturnType = new TypeToken(){}.getType(); + return localVarApiClient.execute(localVarCall, localVarReturnType); + } + + /** + * 获取历史消息记录 (asynchronously) + * 你可以从服务端获取用户发送的历史消息的记录。单次请求获取从指定起始时间开始一小时内的发送的历史消息记录。查询历史消息记录时存在一定延时,无法实时获取。过期的历史消息记录无法获取。文档介绍:https://docs-im-beta.easemob.com/document/server-side/message_historical.html + * @param time 历史消息记录查询的起始时间。UTC 时间,使用 ISO8601 标准,格式为 yyyyMMddHH。例如 time 为 2018112717,则表示查询 2018 年 11 月 27 日 17 时至 2018 年 11 月 27 日 18 时期间的历史消息。若海外集群为 UTC 时区,需要根据自己所在的时区进行时间转换。 (required) + * @param _callback The callback to be executed when the API call finishes + * @return The request call + * @throws ApiException If fail to process the API call, e.g. serializing the request body object + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public okhttp3.Call historyMessageAsync(String time, final ApiCallback _callback) throws ApiException { + + okhttp3.Call localVarCall = historyMessageValidateBeforeCall(time, _callback); + Type localVarReturnType = new TypeToken(){}.getType(); + localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); + return localVarCall; + } +} diff --git a/src/main/java/com/easemob/im/api/MessageApi.java b/src/main/java/com/easemob/im/api/MessageApi.java new file mode 100644 index 000000000..622086df1 --- /dev/null +++ b/src/main/java/com/easemob/im/api/MessageApi.java @@ -0,0 +1,976 @@ +/* + * EMService + * Easemob Rest API + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.easemob.im.api; + +import com.easemob.im.ApiCallback; +import com.easemob.im.ApiClient; +import com.easemob.im.ApiException; +import com.easemob.im.ApiResponse; +import com.easemob.im.Configuration; +import com.easemob.im.Pair; +import com.easemob.im.ProgressRequestBody; +import com.easemob.im.ProgressResponseBody; + +import com.google.gson.reflect.TypeToken; + +import java.io.IOException; + + +import com.easemob.im.api.model.EMCreateMessage; +import com.easemob.im.api.model.EMImportChatGroupMessage; +import com.easemob.im.api.model.EMImportChatGroupMessageResult; +import com.easemob.im.api.model.EMImportChatUserMessage; +import com.easemob.im.api.model.EMImportChatUserMessageResult; +import com.easemob.im.api.model.EMOneWayDeleteConversation; +import com.easemob.im.api.model.EMOneWayDeleteConversationResult; +import com.easemob.im.api.model.EMRecallMessage; +import com.easemob.im.api.model.EMRecallMessageResult; +import com.easemob.im.api.model.EMSendMessageResult; + +import java.lang.reflect.Type; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +public class MessageApi { + private ApiClient localVarApiClient; + private int localHostIndex; + private String localCustomBaseUrl; + + public MessageApi() { + this(Configuration.getDefaultApiClient()); + } + + public MessageApi(ApiClient apiClient) { + this.localVarApiClient = apiClient; + } + + public ApiClient getApiClient() { + return localVarApiClient; + } + + public void setApiClient(ApiClient apiClient) { + this.localVarApiClient = apiClient; + } + + public int getHostIndex() { + return localHostIndex; + } + + public void setHostIndex(int hostIndex) { + this.localHostIndex = hostIndex; + } + + public String getCustomBaseUrl() { + return localCustomBaseUrl; + } + + public void setCustomBaseUrl(String customBaseUrl) { + this.localCustomBaseUrl = customBaseUrl; + } + + /** + * Build call for importChatGroupMessage + * @param emImportChatGroupMessage (optional) + * @param _callback Callback for upload/download progress + * @return Call to execute + * @throws ApiException If fail to serialize the request body object + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public okhttp3.Call importChatGroupMessageCall(EMImportChatGroupMessage emImportChatGroupMessage, final ApiCallback _callback) throws ApiException { + String basePath = null; + // Operation Servers + String[] localBasePaths = new String[] { }; + + // Determine Base Path to Use + if (localCustomBaseUrl != null){ + basePath = localCustomBaseUrl; + } else if ( localBasePaths.length > 0 ) { + basePath = localBasePaths[localHostIndex]; + } else { + basePath = null; + } + + Object localVarPostBody = emImportChatGroupMessage; + + // create path and map variables + String localVarPath = "/messages/chatgroups/import"; + + List localVarQueryParams = new ArrayList(); + List localVarCollectionQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + Map localVarCookieParams = new HashMap(); + Map localVarFormParams = new HashMap(); + + final String[] localVarAccepts = { + "application/json" + }; + final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts); + if (localVarAccept != null) { + localVarHeaderParams.put("Accept", localVarAccept); + } + + final String[] localVarContentTypes = { + "application/json" + }; + final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); + if (localVarContentType != null) { + localVarHeaderParams.put("Content-Type", localVarContentType); + } + + String[] localVarAuthNames = new String[] { }; + return localVarApiClient.buildCall(basePath, localVarPath, "POST", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); + } + + @SuppressWarnings("rawtypes") + private okhttp3.Call importChatGroupMessageValidateBeforeCall(EMImportChatGroupMessage emImportChatGroupMessage, final ApiCallback _callback) throws ApiException { + return importChatGroupMessageCall(emImportChatGroupMessage, _callback); + + } + + /** + * 导入群聊消息 + * 你可以在数据迁移时导入群聊消息。每次调用该接口只能导入一条消息。文档介绍:https://docs-im-beta.easemob.com/document/server-side/message_import.html#%E5%AF%BC%E5%85%A5%E7%BE%A4%E8%81%8A%E6%B6%88%E6%81%AF + * @param emImportChatGroupMessage (optional) + * @return EMImportChatGroupMessageResult + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public EMImportChatGroupMessageResult importChatGroupMessage(EMImportChatGroupMessage emImportChatGroupMessage) throws ApiException { + ApiResponse localVarResp = importChatGroupMessageWithHttpInfo(emImportChatGroupMessage); + return localVarResp.getData(); + } + + /** + * 导入群聊消息 + * 你可以在数据迁移时导入群聊消息。每次调用该接口只能导入一条消息。文档介绍:https://docs-im-beta.easemob.com/document/server-side/message_import.html#%E5%AF%BC%E5%85%A5%E7%BE%A4%E8%81%8A%E6%B6%88%E6%81%AF + * @param emImportChatGroupMessage (optional) + * @return ApiResponse<EMImportChatGroupMessageResult> + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public ApiResponse importChatGroupMessageWithHttpInfo(EMImportChatGroupMessage emImportChatGroupMessage) throws ApiException { + okhttp3.Call localVarCall = importChatGroupMessageValidateBeforeCall(emImportChatGroupMessage, null); + Type localVarReturnType = new TypeToken(){}.getType(); + return localVarApiClient.execute(localVarCall, localVarReturnType); + } + + /** + * 导入群聊消息 (asynchronously) + * 你可以在数据迁移时导入群聊消息。每次调用该接口只能导入一条消息。文档介绍:https://docs-im-beta.easemob.com/document/server-side/message_import.html#%E5%AF%BC%E5%85%A5%E7%BE%A4%E8%81%8A%E6%B6%88%E6%81%AF + * @param emImportChatGroupMessage (optional) + * @param _callback The callback to be executed when the API call finishes + * @return The request call + * @throws ApiException If fail to process the API call, e.g. serializing the request body object + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public okhttp3.Call importChatGroupMessageAsync(EMImportChatGroupMessage emImportChatGroupMessage, final ApiCallback _callback) throws ApiException { + + okhttp3.Call localVarCall = importChatGroupMessageValidateBeforeCall(emImportChatGroupMessage, _callback); + Type localVarReturnType = new TypeToken(){}.getType(); + localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); + return localVarCall; + } + /** + * Build call for importChatUserMessage + * @param emImportChatUserMessage (optional) + * @param _callback Callback for upload/download progress + * @return Call to execute + * @throws ApiException If fail to serialize the request body object + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public okhttp3.Call importChatUserMessageCall(EMImportChatUserMessage emImportChatUserMessage, final ApiCallback _callback) throws ApiException { + String basePath = null; + // Operation Servers + String[] localBasePaths = new String[] { }; + + // Determine Base Path to Use + if (localCustomBaseUrl != null){ + basePath = localCustomBaseUrl; + } else if ( localBasePaths.length > 0 ) { + basePath = localBasePaths[localHostIndex]; + } else { + basePath = null; + } + + Object localVarPostBody = emImportChatUserMessage; + + // create path and map variables + String localVarPath = "/messages/users/import"; + + List localVarQueryParams = new ArrayList(); + List localVarCollectionQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + Map localVarCookieParams = new HashMap(); + Map localVarFormParams = new HashMap(); + + final String[] localVarAccepts = { + "application/json" + }; + final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts); + if (localVarAccept != null) { + localVarHeaderParams.put("Accept", localVarAccept); + } + + final String[] localVarContentTypes = { + "application/json" + }; + final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); + if (localVarContentType != null) { + localVarHeaderParams.put("Content-Type", localVarContentType); + } + + String[] localVarAuthNames = new String[] { }; + return localVarApiClient.buildCall(basePath, localVarPath, "POST", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); + } + + @SuppressWarnings("rawtypes") + private okhttp3.Call importChatUserMessageValidateBeforeCall(EMImportChatUserMessage emImportChatUserMessage, final ApiCallback _callback) throws ApiException { + return importChatUserMessageCall(emImportChatUserMessage, _callback); + + } + + /** + * 导入单聊消息 + * 你可以在数据迁移时导入单聊消息。每次调用该接口只能导入一条消息。文档介绍:https://docs-im-beta.easemob.com/document/server-side/message_import.html#%E5%AF%BC%E5%85%A5%E5%8D%95%E8%81%8A%E6%B6%88%E6%81%AF + * @param emImportChatUserMessage (optional) + * @return EMImportChatUserMessageResult + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public EMImportChatUserMessageResult importChatUserMessage(EMImportChatUserMessage emImportChatUserMessage) throws ApiException { + ApiResponse localVarResp = importChatUserMessageWithHttpInfo(emImportChatUserMessage); + return localVarResp.getData(); + } + + /** + * 导入单聊消息 + * 你可以在数据迁移时导入单聊消息。每次调用该接口只能导入一条消息。文档介绍:https://docs-im-beta.easemob.com/document/server-side/message_import.html#%E5%AF%BC%E5%85%A5%E5%8D%95%E8%81%8A%E6%B6%88%E6%81%AF + * @param emImportChatUserMessage (optional) + * @return ApiResponse<EMImportChatUserMessageResult> + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public ApiResponse importChatUserMessageWithHttpInfo(EMImportChatUserMessage emImportChatUserMessage) throws ApiException { + okhttp3.Call localVarCall = importChatUserMessageValidateBeforeCall(emImportChatUserMessage, null); + Type localVarReturnType = new TypeToken(){}.getType(); + return localVarApiClient.execute(localVarCall, localVarReturnType); + } + + /** + * 导入单聊消息 (asynchronously) + * 你可以在数据迁移时导入单聊消息。每次调用该接口只能导入一条消息。文档介绍:https://docs-im-beta.easemob.com/document/server-side/message_import.html#%E5%AF%BC%E5%85%A5%E5%8D%95%E8%81%8A%E6%B6%88%E6%81%AF + * @param emImportChatUserMessage (optional) + * @param _callback The callback to be executed when the API call finishes + * @return The request call + * @throws ApiException If fail to process the API call, e.g. serializing the request body object + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public okhttp3.Call importChatUserMessageAsync(EMImportChatUserMessage emImportChatUserMessage, final ApiCallback _callback) throws ApiException { + + okhttp3.Call localVarCall = importChatUserMessageValidateBeforeCall(emImportChatUserMessage, _callback); + Type localVarReturnType = new TypeToken(){}.getType(); + localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); + return localVarCall; + } + /** + * Build call for oneWayDeleteConversation + * @param username 要删除会话的用户的唯一标识符,即用户 ID (required) + * @param emOneWayDeleteConversation (optional) + * @param _callback Callback for upload/download progress + * @return Call to execute + * @throws ApiException If fail to serialize the request body object + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public okhttp3.Call oneWayDeleteConversationCall(String username, EMOneWayDeleteConversation emOneWayDeleteConversation, final ApiCallback _callback) throws ApiException { + String basePath = null; + // Operation Servers + String[] localBasePaths = new String[] { }; + + // Determine Base Path to Use + if (localCustomBaseUrl != null){ + basePath = localCustomBaseUrl; + } else if ( localBasePaths.length > 0 ) { + basePath = localBasePaths[localHostIndex]; + } else { + basePath = null; + } + + Object localVarPostBody = emOneWayDeleteConversation; + + // create path and map variables + String localVarPath = "/users/{username}/user_channel" + .replace("{" + "username" + "}", localVarApiClient.escapeString(username.toString())); + + List localVarQueryParams = new ArrayList(); + List localVarCollectionQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + Map localVarCookieParams = new HashMap(); + Map localVarFormParams = new HashMap(); + + final String[] localVarAccepts = { + "application/json" + }; + final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts); + if (localVarAccept != null) { + localVarHeaderParams.put("Accept", localVarAccept); + } + + final String[] localVarContentTypes = { + "application/json" + }; + final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); + if (localVarContentType != null) { + localVarHeaderParams.put("Content-Type", localVarContentType); + } + + String[] localVarAuthNames = new String[] { }; + return localVarApiClient.buildCall(basePath, localVarPath, "DELETE", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); + } + + @SuppressWarnings("rawtypes") + private okhttp3.Call oneWayDeleteConversationValidateBeforeCall(String username, EMOneWayDeleteConversation emOneWayDeleteConversation, final ApiCallback _callback) throws ApiException { + // verify the required parameter 'username' is set + if (username == null) { + throw new ApiException("Missing the required parameter 'username' when calling oneWayDeleteConversation(Async)"); + } + + return oneWayDeleteConversationCall(username, emOneWayDeleteConversation, _callback); + + } + + /** + * 单向删除会话 + * 该方法使聊天用户能够从服务器中删除会话。删除会话后,该用户将从服务器获取不到该会话。该会话的其他参与聊天用户仍然可以从服务器获取会话内容。文档介绍:https://docs-im-beta.easemob.com/document/server-side/message_recall.html#%E5%8D%95%E5%90%91%E5%88%A0%E9%99%A4%E4%BC%9A%E8%AF%9D + * @param username 要删除会话的用户的唯一标识符,即用户 ID (required) + * @param emOneWayDeleteConversation (optional) + * @return EMOneWayDeleteConversationResult + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public EMOneWayDeleteConversationResult oneWayDeleteConversation(String username, EMOneWayDeleteConversation emOneWayDeleteConversation) throws ApiException { + ApiResponse localVarResp = oneWayDeleteConversationWithHttpInfo(username, emOneWayDeleteConversation); + return localVarResp.getData(); + } + + /** + * 单向删除会话 + * 该方法使聊天用户能够从服务器中删除会话。删除会话后,该用户将从服务器获取不到该会话。该会话的其他参与聊天用户仍然可以从服务器获取会话内容。文档介绍:https://docs-im-beta.easemob.com/document/server-side/message_recall.html#%E5%8D%95%E5%90%91%E5%88%A0%E9%99%A4%E4%BC%9A%E8%AF%9D + * @param username 要删除会话的用户的唯一标识符,即用户 ID (required) + * @param emOneWayDeleteConversation (optional) + * @return ApiResponse<EMOneWayDeleteConversationResult> + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public ApiResponse oneWayDeleteConversationWithHttpInfo(String username, EMOneWayDeleteConversation emOneWayDeleteConversation) throws ApiException { + okhttp3.Call localVarCall = oneWayDeleteConversationValidateBeforeCall(username, emOneWayDeleteConversation, null); + Type localVarReturnType = new TypeToken(){}.getType(); + return localVarApiClient.execute(localVarCall, localVarReturnType); + } + + /** + * 单向删除会话 (asynchronously) + * 该方法使聊天用户能够从服务器中删除会话。删除会话后,该用户将从服务器获取不到该会话。该会话的其他参与聊天用户仍然可以从服务器获取会话内容。文档介绍:https://docs-im-beta.easemob.com/document/server-side/message_recall.html#%E5%8D%95%E5%90%91%E5%88%A0%E9%99%A4%E4%BC%9A%E8%AF%9D + * @param username 要删除会话的用户的唯一标识符,即用户 ID (required) + * @param emOneWayDeleteConversation (optional) + * @param _callback The callback to be executed when the API call finishes + * @return The request call + * @throws ApiException If fail to process the API call, e.g. serializing the request body object + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public okhttp3.Call oneWayDeleteConversationAsync(String username, EMOneWayDeleteConversation emOneWayDeleteConversation, final ApiCallback _callback) throws ApiException { + + okhttp3.Call localVarCall = oneWayDeleteConversationValidateBeforeCall(username, emOneWayDeleteConversation, _callback); + Type localVarReturnType = new TypeToken(){}.getType(); + localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); + return localVarCall; + } + /** + * Build call for recallMessage + * @param emRecallMessage (optional) + * @param _callback Callback for upload/download progress + * @return Call to execute + * @throws ApiException If fail to serialize the request body object + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public okhttp3.Call recallMessageCall(EMRecallMessage emRecallMessage, final ApiCallback _callback) throws ApiException { + String basePath = null; + // Operation Servers + String[] localBasePaths = new String[] { }; + + // Determine Base Path to Use + if (localCustomBaseUrl != null){ + basePath = localCustomBaseUrl; + } else if ( localBasePaths.length > 0 ) { + basePath = localBasePaths[localHostIndex]; + } else { + basePath = null; + } + + Object localVarPostBody = emRecallMessage; + + // create path and map variables + String localVarPath = "/messages/msg_recall"; + + List localVarQueryParams = new ArrayList(); + List localVarCollectionQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + Map localVarCookieParams = new HashMap(); + Map localVarFormParams = new HashMap(); + + final String[] localVarAccepts = { + "application/json" + }; + final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts); + if (localVarAccept != null) { + localVarHeaderParams.put("Accept", localVarAccept); + } + + final String[] localVarContentTypes = { + "application/json" + }; + final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); + if (localVarContentType != null) { + localVarHeaderParams.put("Content-Type", localVarContentType); + } + + String[] localVarAuthNames = new String[] { }; + return localVarApiClient.buildCall(basePath, localVarPath, "POST", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); + } + + @SuppressWarnings("rawtypes") + private okhttp3.Call recallMessageValidateBeforeCall(EMRecallMessage emRecallMessage, final ApiCallback _callback) throws ApiException { + return recallMessageCall(emRecallMessage, _callback); + + } + + /** + * 撤回消息 + * 发送方可以撤回一条发送成功的消息。默认情况下,发送方可撤回发出 2 分钟内的消息。文档介绍:https://docs-im-beta.easemob.com/document/server-side/message_recall.html#%E6%92%A4%E5%9B%9E%E6%B6%88%E6%81%AF + * @param emRecallMessage (optional) + * @return EMRecallMessageResult + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public EMRecallMessageResult recallMessage(EMRecallMessage emRecallMessage) throws ApiException { + ApiResponse localVarResp = recallMessageWithHttpInfo(emRecallMessage); + return localVarResp.getData(); + } + + /** + * 撤回消息 + * 发送方可以撤回一条发送成功的消息。默认情况下,发送方可撤回发出 2 分钟内的消息。文档介绍:https://docs-im-beta.easemob.com/document/server-side/message_recall.html#%E6%92%A4%E5%9B%9E%E6%B6%88%E6%81%AF + * @param emRecallMessage (optional) + * @return ApiResponse<EMRecallMessageResult> + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public ApiResponse recallMessageWithHttpInfo(EMRecallMessage emRecallMessage) throws ApiException { + okhttp3.Call localVarCall = recallMessageValidateBeforeCall(emRecallMessage, null); + Type localVarReturnType = new TypeToken(){}.getType(); + return localVarApiClient.execute(localVarCall, localVarReturnType); + } + + /** + * 撤回消息 (asynchronously) + * 发送方可以撤回一条发送成功的消息。默认情况下,发送方可撤回发出 2 分钟内的消息。文档介绍:https://docs-im-beta.easemob.com/document/server-side/message_recall.html#%E6%92%A4%E5%9B%9E%E6%B6%88%E6%81%AF + * @param emRecallMessage (optional) + * @param _callback The callback to be executed when the API call finishes + * @return The request call + * @throws ApiException If fail to process the API call, e.g. serializing the request body object + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public okhttp3.Call recallMessageAsync(EMRecallMessage emRecallMessage, final ApiCallback _callback) throws ApiException { + + okhttp3.Call localVarCall = recallMessageValidateBeforeCall(emRecallMessage, _callback); + Type localVarReturnType = new TypeToken(){}.getType(); + localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); + return localVarCall; + } + /** + * Build call for sendMessagesToGroup + * @param emCreateMessage (optional) + * @param _callback Callback for upload/download progress + * @return Call to execute + * @throws ApiException If fail to serialize the request body object + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public okhttp3.Call sendMessagesToGroupCall(EMCreateMessage emCreateMessage, final ApiCallback _callback) throws ApiException { + String basePath = null; + // Operation Servers + String[] localBasePaths = new String[] { }; + + // Determine Base Path to Use + if (localCustomBaseUrl != null){ + basePath = localCustomBaseUrl; + } else if ( localBasePaths.length > 0 ) { + basePath = localBasePaths[localHostIndex]; + } else { + basePath = null; + } + + Object localVarPostBody = emCreateMessage; + + // create path and map variables + String localVarPath = "/messages/chatgroups"; + + List localVarQueryParams = new ArrayList(); + List localVarCollectionQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + Map localVarCookieParams = new HashMap(); + Map localVarFormParams = new HashMap(); + + final String[] localVarAccepts = { + "application/json" + }; + final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts); + if (localVarAccept != null) { + localVarHeaderParams.put("Accept", localVarAccept); + } + + final String[] localVarContentTypes = { + "application/json" + }; + final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); + if (localVarContentType != null) { + localVarHeaderParams.put("Content-Type", localVarContentType); + } + + String[] localVarAuthNames = new String[] { }; + return localVarApiClient.buildCall(basePath, localVarPath, "POST", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); + } + + @SuppressWarnings("rawtypes") + private okhttp3.Call sendMessagesToGroupValidateBeforeCall(EMCreateMessage emCreateMessage, final ApiCallback _callback) throws ApiException { + return sendMessagesToGroupCall(emCreateMessage, _callback); + + } + + /** + * 发送群聊消息 + * 向群组发送消息。文档介绍:https://docs-im-beta.easemob.com/document/server-side/message_group.html + * @param emCreateMessage (optional) + * @return EMSendMessageResult + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public EMSendMessageResult sendMessagesToGroup(EMCreateMessage emCreateMessage) throws ApiException { + ApiResponse localVarResp = sendMessagesToGroupWithHttpInfo(emCreateMessage); + return localVarResp.getData(); + } + + /** + * 发送群聊消息 + * 向群组发送消息。文档介绍:https://docs-im-beta.easemob.com/document/server-side/message_group.html + * @param emCreateMessage (optional) + * @return ApiResponse<EMSendMessageResult> + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public ApiResponse sendMessagesToGroupWithHttpInfo(EMCreateMessage emCreateMessage) throws ApiException { + okhttp3.Call localVarCall = sendMessagesToGroupValidateBeforeCall(emCreateMessage, null); + Type localVarReturnType = new TypeToken(){}.getType(); + return localVarApiClient.execute(localVarCall, localVarReturnType); + } + + /** + * 发送群聊消息 (asynchronously) + * 向群组发送消息。文档介绍:https://docs-im-beta.easemob.com/document/server-side/message_group.html + * @param emCreateMessage (optional) + * @param _callback The callback to be executed when the API call finishes + * @return The request call + * @throws ApiException If fail to process the API call, e.g. serializing the request body object + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public okhttp3.Call sendMessagesToGroupAsync(EMCreateMessage emCreateMessage, final ApiCallback _callback) throws ApiException { + + okhttp3.Call localVarCall = sendMessagesToGroupValidateBeforeCall(emCreateMessage, _callback); + Type localVarReturnType = new TypeToken(){}.getType(); + localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); + return localVarCall; + } + /** + * Build call for sendMessagesToRoom + * @param emCreateMessage (optional) + * @param _callback Callback for upload/download progress + * @return Call to execute + * @throws ApiException If fail to serialize the request body object + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public okhttp3.Call sendMessagesToRoomCall(EMCreateMessage emCreateMessage, final ApiCallback _callback) throws ApiException { + String basePath = null; + // Operation Servers + String[] localBasePaths = new String[] { }; + + // Determine Base Path to Use + if (localCustomBaseUrl != null){ + basePath = localCustomBaseUrl; + } else if ( localBasePaths.length > 0 ) { + basePath = localBasePaths[localHostIndex]; + } else { + basePath = null; + } + + Object localVarPostBody = emCreateMessage; + + // create path and map variables + String localVarPath = "/messages/chatrooms"; + + List localVarQueryParams = new ArrayList(); + List localVarCollectionQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + Map localVarCookieParams = new HashMap(); + Map localVarFormParams = new HashMap(); + + final String[] localVarAccepts = { + "application/json" + }; + final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts); + if (localVarAccept != null) { + localVarHeaderParams.put("Accept", localVarAccept); + } + + final String[] localVarContentTypes = { + "application/json" + }; + final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); + if (localVarContentType != null) { + localVarHeaderParams.put("Content-Type", localVarContentType); + } + + String[] localVarAuthNames = new String[] { }; + return localVarApiClient.buildCall(basePath, localVarPath, "POST", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); + } + + @SuppressWarnings("rawtypes") + private okhttp3.Call sendMessagesToRoomValidateBeforeCall(EMCreateMessage emCreateMessage, final ApiCallback _callback) throws ApiException { + return sendMessagesToRoomCall(emCreateMessage, _callback); + + } + + /** + * 发送聊天室消息 + * 向群组发送消息。文档介绍:https://docs-im-beta.easemob.com/document/server-side/message_chatroom.html + * @param emCreateMessage (optional) + * @return EMSendMessageResult + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public EMSendMessageResult sendMessagesToRoom(EMCreateMessage emCreateMessage) throws ApiException { + ApiResponse localVarResp = sendMessagesToRoomWithHttpInfo(emCreateMessage); + return localVarResp.getData(); + } + + /** + * 发送聊天室消息 + * 向群组发送消息。文档介绍:https://docs-im-beta.easemob.com/document/server-side/message_chatroom.html + * @param emCreateMessage (optional) + * @return ApiResponse<EMSendMessageResult> + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public ApiResponse sendMessagesToRoomWithHttpInfo(EMCreateMessage emCreateMessage) throws ApiException { + okhttp3.Call localVarCall = sendMessagesToRoomValidateBeforeCall(emCreateMessage, null); + Type localVarReturnType = new TypeToken(){}.getType(); + return localVarApiClient.execute(localVarCall, localVarReturnType); + } + + /** + * 发送聊天室消息 (asynchronously) + * 向群组发送消息。文档介绍:https://docs-im-beta.easemob.com/document/server-side/message_chatroom.html + * @param emCreateMessage (optional) + * @param _callback The callback to be executed when the API call finishes + * @return The request call + * @throws ApiException If fail to process the API call, e.g. serializing the request body object + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public okhttp3.Call sendMessagesToRoomAsync(EMCreateMessage emCreateMessage, final ApiCallback _callback) throws ApiException { + + okhttp3.Call localVarCall = sendMessagesToRoomValidateBeforeCall(emCreateMessage, _callback); + Type localVarReturnType = new TypeToken(){}.getType(); + localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); + return localVarCall; + } + /** + * Build call for sendMessagesToUser + * @param emCreateMessage (optional) + * @param _callback Callback for upload/download progress + * @return Call to execute + * @throws ApiException If fail to serialize the request body object + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public okhttp3.Call sendMessagesToUserCall(EMCreateMessage emCreateMessage, final ApiCallback _callback) throws ApiException { + String basePath = null; + // Operation Servers + String[] localBasePaths = new String[] { }; + + // Determine Base Path to Use + if (localCustomBaseUrl != null){ + basePath = localCustomBaseUrl; + } else if ( localBasePaths.length > 0 ) { + basePath = localBasePaths[localHostIndex]; + } else { + basePath = null; + } + + Object localVarPostBody = emCreateMessage; + + // create path and map variables + String localVarPath = "/messages/users"; + + List localVarQueryParams = new ArrayList(); + List localVarCollectionQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + Map localVarCookieParams = new HashMap(); + Map localVarFormParams = new HashMap(); + + final String[] localVarAccepts = { + "application/json" + }; + final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts); + if (localVarAccept != null) { + localVarHeaderParams.put("Accept", localVarAccept); + } + + final String[] localVarContentTypes = { + "application/json" + }; + final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); + if (localVarContentType != null) { + localVarHeaderParams.put("Content-Type", localVarContentType); + } + + String[] localVarAuthNames = new String[] { }; + return localVarApiClient.buildCall(basePath, localVarPath, "POST", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); + } + + @SuppressWarnings("rawtypes") + private okhttp3.Call sendMessagesToUserValidateBeforeCall(EMCreateMessage emCreateMessage, final ApiCallback _callback) throws ApiException { + return sendMessagesToUserCall(emCreateMessage, _callback); + + } + + /** + * 发送单聊消息 + * 给用户发送消息。文档介绍:https://docs-im-beta.easemob.com/document/server-side/message_single.html + * @param emCreateMessage (optional) + * @return EMSendMessageResult + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public EMSendMessageResult sendMessagesToUser(EMCreateMessage emCreateMessage) throws ApiException { + ApiResponse localVarResp = sendMessagesToUserWithHttpInfo(emCreateMessage); + return localVarResp.getData(); + } + + /** + * 发送单聊消息 + * 给用户发送消息。文档介绍:https://docs-im-beta.easemob.com/document/server-side/message_single.html + * @param emCreateMessage (optional) + * @return ApiResponse<EMSendMessageResult> + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public ApiResponse sendMessagesToUserWithHttpInfo(EMCreateMessage emCreateMessage) throws ApiException { + okhttp3.Call localVarCall = sendMessagesToUserValidateBeforeCall(emCreateMessage, null); + Type localVarReturnType = new TypeToken(){}.getType(); + return localVarApiClient.execute(localVarCall, localVarReturnType); + } + + /** + * 发送单聊消息 (asynchronously) + * 给用户发送消息。文档介绍:https://docs-im-beta.easemob.com/document/server-side/message_single.html + * @param emCreateMessage (optional) + * @param _callback The callback to be executed when the API call finishes + * @return The request call + * @throws ApiException If fail to process the API call, e.g. serializing the request body object + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public okhttp3.Call sendMessagesToUserAsync(EMCreateMessage emCreateMessage, final ApiCallback _callback) throws ApiException { + + okhttp3.Call localVarCall = sendMessagesToUserValidateBeforeCall(emCreateMessage, _callback); + Type localVarReturnType = new TypeToken(){}.getType(); + localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); + return localVarCall; + } +} diff --git a/src/main/java/com/easemob/im/api/MetadataApi.java b/src/main/java/com/easemob/im/api/MetadataApi.java new file mode 100644 index 000000000..5c5b72c3e --- /dev/null +++ b/src/main/java/com/easemob/im/api/MetadataApi.java @@ -0,0 +1,1014 @@ +/* + * EMService + * Easemob Rest API + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.easemob.im.api; + +import com.easemob.im.ApiCallback; +import com.easemob.im.ApiClient; +import com.easemob.im.ApiException; +import com.easemob.im.ApiResponse; +import com.easemob.im.Configuration; +import com.easemob.im.Pair; + +import com.easemob.im.api.model.*; +import com.google.gson.reflect.TypeToken; + +import java.lang.reflect.Type; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +public class MetadataApi { + private ApiClient localVarApiClient; + private int localHostIndex; + private String localCustomBaseUrl; + + public MetadataApi() { + this(Configuration.getDefaultApiClient()); + } + + public MetadataApi(ApiClient apiClient) { + this.localVarApiClient = apiClient; + } + + public ApiClient getApiClient() { + return localVarApiClient; + } + + public void setApiClient(ApiClient apiClient) { + this.localVarApiClient = apiClient; + } + + public int getHostIndex() { + return localHostIndex; + } + + public void setHostIndex(int hostIndex) { + this.localHostIndex = hostIndex; + } + + public String getCustomBaseUrl() { + return localCustomBaseUrl; + } + + public void setCustomBaseUrl(String customBaseUrl) { + this.localCustomBaseUrl = customBaseUrl; + } + + /** + * Build call for customGroupMemberAttribute + * @param groupId (required) + * @param username (required) + * @param emCustomGroupMemberAttribute (optional) + * @param _callback Callback for upload/download progress + * @return Call to execute + * @throws ApiException If fail to serialize the request body object + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public okhttp3.Call customGroupMemberAttributeCall(String groupId, String username, EMCustomGroupMemberAttribute emCustomGroupMemberAttribute, final ApiCallback _callback) throws ApiException { + String basePath = null; + // Operation Servers + String[] localBasePaths = new String[] { }; + + // Determine Base Path to Use + if (localCustomBaseUrl != null){ + basePath = localCustomBaseUrl; + } else if ( localBasePaths.length > 0 ) { + basePath = localBasePaths[localHostIndex]; + } else { + basePath = null; + } + + Object localVarPostBody = emCustomGroupMemberAttribute; + + // create path and map variables + String localVarPath = "/metadata/chatgroup/{group_id}/user/{username}" + .replace("{" + "group_id" + "}", localVarApiClient.escapeString(groupId.toString())) + .replace("{" + "username" + "}", localVarApiClient.escapeString(username.toString())); + + List localVarQueryParams = new ArrayList(); + List localVarCollectionQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + Map localVarCookieParams = new HashMap(); + Map localVarFormParams = new HashMap(); + + final String[] localVarAccepts = { + "application/json" + }; + final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts); + if (localVarAccept != null) { + localVarHeaderParams.put("Accept", localVarAccept); + } + + final String[] localVarContentTypes = { + "application/json" + }; + final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); + if (localVarContentType != null) { + localVarHeaderParams.put("Content-Type", localVarContentType); + } + + String[] localVarAuthNames = new String[] { }; + return localVarApiClient.buildCall(basePath, localVarPath, "PUT", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); + } + + @SuppressWarnings("rawtypes") + private okhttp3.Call customGroupMemberAttributeValidateBeforeCall(String groupId, String username, EMCustomGroupMemberAttribute emCustomGroupMemberAttribute, final ApiCallback _callback) throws ApiException { + // verify the required parameter 'groupId' is set + if (groupId == null) { + throw new ApiException("Missing the required parameter 'groupId' when calling customGroupMemberAttribute(Async)"); + } + + // verify the required parameter 'username' is set + if (username == null) { + throw new ApiException("Missing the required parameter 'username' when calling customGroupMemberAttribute(Async)"); + } + + return customGroupMemberAttributeCall(groupId, username, emCustomGroupMemberAttribute, _callback); + + } + + /** + * 设置群成员自定义属性 + * 设置群成员自定义属性。群成员可设置自定义属性(key-value),例如在群组中的昵称和头像等。群主可修改所有群成员的自定义属性,其他群成员只能修改自己的自定义属性。文档介绍:https://docs-im-beta.easemob.com/document/server-side/group.html#%E8%AE%BE%E7%BD%AE%E7%BE%A4%E6%88%90%E5%91%98%E8%87%AA%E5%AE%9A%E4%B9%89%E5%B1%9E%E6%80%A7 + * @param groupId (required) + * @param username (required) + * @param emCustomGroupMemberAttribute (optional) + * @return EMCustomGroupMemberAttributeResult + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public EMCustomGroupMemberAttributeResult customGroupMemberAttribute(String groupId, String username, EMCustomGroupMemberAttribute emCustomGroupMemberAttribute) throws ApiException { + ApiResponse localVarResp = customGroupMemberAttributeWithHttpInfo(groupId, username, emCustomGroupMemberAttribute); + return localVarResp.getData(); + } + + /** + * 设置群成员自定义属性 + * 设置群成员自定义属性。群成员可设置自定义属性(key-value),例如在群组中的昵称和头像等。群主可修改所有群成员的自定义属性,其他群成员只能修改自己的自定义属性。文档介绍:https://docs-im-beta.easemob.com/document/server-side/group.html#%E8%AE%BE%E7%BD%AE%E7%BE%A4%E6%88%90%E5%91%98%E8%87%AA%E5%AE%9A%E4%B9%89%E5%B1%9E%E6%80%A7 + * @param groupId (required) + * @param username (required) + * @param emCustomGroupMemberAttribute (optional) + * @return ApiResponse<EMCustomGroupMemberAttributeResult> + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public ApiResponse customGroupMemberAttributeWithHttpInfo(String groupId, String username, EMCustomGroupMemberAttribute emCustomGroupMemberAttribute) throws ApiException { + okhttp3.Call localVarCall = customGroupMemberAttributeValidateBeforeCall(groupId, username, emCustomGroupMemberAttribute, null); + Type localVarReturnType = new TypeToken(){}.getType(); + return localVarApiClient.execute(localVarCall, localVarReturnType); + } + + /** + * 设置群成员自定义属性 (asynchronously) + * 设置群成员自定义属性。群成员可设置自定义属性(key-value),例如在群组中的昵称和头像等。群主可修改所有群成员的自定义属性,其他群成员只能修改自己的自定义属性。文档介绍:https://docs-im-beta.easemob.com/document/server-side/group.html#%E8%AE%BE%E7%BD%AE%E7%BE%A4%E6%88%90%E5%91%98%E8%87%AA%E5%AE%9A%E4%B9%89%E5%B1%9E%E6%80%A7 + * @param groupId (required) + * @param username (required) + * @param emCustomGroupMemberAttribute (optional) + * @param _callback The callback to be executed when the API call finishes + * @return The request call + * @throws ApiException If fail to process the API call, e.g. serializing the request body object + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public okhttp3.Call customGroupMemberAttributeAsync(String groupId, String username, EMCustomGroupMemberAttribute emCustomGroupMemberAttribute, final ApiCallback _callback) throws ApiException { + + okhttp3.Call localVarCall = customGroupMemberAttributeValidateBeforeCall(groupId, username, emCustomGroupMemberAttribute, _callback); + Type localVarReturnType = new TypeToken(){}.getType(); + localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); + return localVarCall; + } + /** + * Build call for deleteUserMetadata + * @param username (required) + * @param _callback Callback for upload/download progress + * @return Call to execute + * @throws ApiException If fail to serialize the request body object + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public okhttp3.Call deleteUserMetadataCall(String username, final ApiCallback _callback) throws ApiException { + String basePath = null; + // Operation Servers + String[] localBasePaths = new String[] { }; + + // Determine Base Path to Use + if (localCustomBaseUrl != null){ + basePath = localCustomBaseUrl; + } else if ( localBasePaths.length > 0 ) { + basePath = localBasePaths[localHostIndex]; + } else { + basePath = null; + } + + Object localVarPostBody = null; + + // create path and map variables + String localVarPath = "/metadata/user/{username}" + .replace("{" + "username" + "}", localVarApiClient.escapeString(username.toString())); + + List localVarQueryParams = new ArrayList(); + List localVarCollectionQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + Map localVarCookieParams = new HashMap(); + Map localVarFormParams = new HashMap(); + + final String[] localVarAccepts = { + "application/json" + }; + final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts); + if (localVarAccept != null) { + localVarHeaderParams.put("Accept", localVarAccept); + } + + final String[] localVarContentTypes = { + }; + final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); + if (localVarContentType != null) { + localVarHeaderParams.put("Content-Type", localVarContentType); + } + + String[] localVarAuthNames = new String[] { }; + return localVarApiClient.buildCall(basePath, localVarPath, "DELETE", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); + } + + @SuppressWarnings("rawtypes") + private okhttp3.Call deleteUserMetadataValidateBeforeCall(String username, final ApiCallback _callback) throws ApiException { + // verify the required parameter 'username' is set + if (username == null) { + throw new ApiException("Missing the required parameter 'username' when calling deleteUserMetadata(Async)"); + } + + return deleteUserMetadataCall(username, _callback); + + } + + /** + * 删除用户属性 + * 删除单个用户的所有属性。如果指定的用户或用户属性不存在(可能已删除),也视为删除成功。文档介绍:https://docs-im-beta.easemob.com/document/server-side/userprofile.html#%E5%88%A0%E9%99%A4%E7%94%A8%E6%88%B7%E5%B1%9E%E6%80%A7 + * @param username (required) + * @return EMDeleteUserMetadataResult + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public EMDeleteUserMetadataResult deleteUserMetadata(String username) throws ApiException { + ApiResponse localVarResp = deleteUserMetadataWithHttpInfo(username); + return localVarResp.getData(); + } + + /** + * 删除用户属性 + * 删除单个用户的所有属性。如果指定的用户或用户属性不存在(可能已删除),也视为删除成功。文档介绍:https://docs-im-beta.easemob.com/document/server-side/userprofile.html#%E5%88%A0%E9%99%A4%E7%94%A8%E6%88%B7%E5%B1%9E%E6%80%A7 + * @param username (required) + * @return ApiResponse<EMDeleteUserMetadataResult> + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public ApiResponse deleteUserMetadataWithHttpInfo(String username) throws ApiException { + okhttp3.Call localVarCall = deleteUserMetadataValidateBeforeCall(username, null); + Type localVarReturnType = new TypeToken(){}.getType(); + return localVarApiClient.execute(localVarCall, localVarReturnType); + } + + /** + * 删除用户属性 (asynchronously) + * 删除单个用户的所有属性。如果指定的用户或用户属性不存在(可能已删除),也视为删除成功。文档介绍:https://docs-im-beta.easemob.com/document/server-side/userprofile.html#%E5%88%A0%E9%99%A4%E7%94%A8%E6%88%B7%E5%B1%9E%E6%80%A7 + * @param username (required) + * @param _callback The callback to be executed when the API call finishes + * @return The request call + * @throws ApiException If fail to process the API call, e.g. serializing the request body object + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public okhttp3.Call deleteUserMetadataAsync(String username, final ApiCallback _callback) throws ApiException { + + okhttp3.Call localVarCall = deleteUserMetadataValidateBeforeCall(username, _callback); + Type localVarReturnType = new TypeToken(){}.getType(); + localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); + return localVarCall; + } + /** + * Build call for getGroupMemberAllCustomAttribute + * @param groupId (required) + * @param username (required) + * @param _callback Callback for upload/download progress + * @return Call to execute + * @throws ApiException If fail to serialize the request body object + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public okhttp3.Call getGroupMemberAllCustomAttributeCall(String groupId, String username, final ApiCallback _callback) throws ApiException { + String basePath = null; + // Operation Servers + String[] localBasePaths = new String[] { }; + + // Determine Base Path to Use + if (localCustomBaseUrl != null){ + basePath = localCustomBaseUrl; + } else if ( localBasePaths.length > 0 ) { + basePath = localBasePaths[localHostIndex]; + } else { + basePath = null; + } + + Object localVarPostBody = null; + + // create path and map variables + String localVarPath = "/metadata/chatgroup/{group_id}/user/{username}" + .replace("{" + "group_id" + "}", localVarApiClient.escapeString(groupId.toString())) + .replace("{" + "username" + "}", localVarApiClient.escapeString(username.toString())); + + List localVarQueryParams = new ArrayList(); + List localVarCollectionQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + Map localVarCookieParams = new HashMap(); + Map localVarFormParams = new HashMap(); + + final String[] localVarAccepts = { + "application/json" + }; + final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts); + if (localVarAccept != null) { + localVarHeaderParams.put("Accept", localVarAccept); + } + + final String[] localVarContentTypes = { + }; + final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); + if (localVarContentType != null) { + localVarHeaderParams.put("Content-Type", localVarContentType); + } + + String[] localVarAuthNames = new String[] { }; + return localVarApiClient.buildCall(basePath, localVarPath, "GET", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); + } + + @SuppressWarnings("rawtypes") + private okhttp3.Call getGroupMemberAllCustomAttributeValidateBeforeCall(String groupId, String username, final ApiCallback _callback) throws ApiException { + // verify the required parameter 'groupId' is set + if (groupId == null) { + throw new ApiException("Missing the required parameter 'groupId' when calling getGroupMemberAllCustomAttribute(Async)"); + } + + // verify the required parameter 'username' is set + if (username == null) { + throw new ApiException("Missing the required parameter 'username' when calling getGroupMemberAllCustomAttribute(Async)"); + } + + return getGroupMemberAllCustomAttributeCall(groupId, username, _callback); + + } + + /** + * 获取单个群成员的所有自定义属性 + * 获取单个群成员的所有自定义属性。文档介绍:https://docs-im-beta.easemob.com/document/server-side/group.html#%E8%8E%B7%E5%8F%96%E5%8D%95%E4%B8%AA%E7%BE%A4%E6%88%90%E5%91%98%E7%9A%84%E6%89%80%E6%9C%89%E8%87%AA%E5%AE%9A%E4%B9%89%E5%B1%9E%E6%80%A7 + * @param groupId (required) + * @param username (required) + * @return EMGetGroupMemberAllCustomAttributeResult + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public EMGetGroupMemberAllCustomAttributeResult getGroupMemberAllCustomAttribute(String groupId, String username) throws ApiException { + ApiResponse localVarResp = getGroupMemberAllCustomAttributeWithHttpInfo(groupId, username); + return localVarResp.getData(); + } + + /** + * 获取单个群成员的所有自定义属性 + * 获取单个群成员的所有自定义属性。文档介绍:https://docs-im-beta.easemob.com/document/server-side/group.html#%E8%8E%B7%E5%8F%96%E5%8D%95%E4%B8%AA%E7%BE%A4%E6%88%90%E5%91%98%E7%9A%84%E6%89%80%E6%9C%89%E8%87%AA%E5%AE%9A%E4%B9%89%E5%B1%9E%E6%80%A7 + * @param groupId (required) + * @param username (required) + * @return ApiResponse<EMGetGroupMemberAllCustomAttributeResult> + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public ApiResponse getGroupMemberAllCustomAttributeWithHttpInfo(String groupId, String username) throws ApiException { + okhttp3.Call localVarCall = getGroupMemberAllCustomAttributeValidateBeforeCall(groupId, username, null); + Type localVarReturnType = new TypeToken(){}.getType(); + return localVarApiClient.execute(localVarCall, localVarReturnType); + } + + /** + * 获取单个群成员的所有自定义属性 (asynchronously) + * 获取单个群成员的所有自定义属性。文档介绍:https://docs-im-beta.easemob.com/document/server-side/group.html#%E8%8E%B7%E5%8F%96%E5%8D%95%E4%B8%AA%E7%BE%A4%E6%88%90%E5%91%98%E7%9A%84%E6%89%80%E6%9C%89%E8%87%AA%E5%AE%9A%E4%B9%89%E5%B1%9E%E6%80%A7 + * @param groupId (required) + * @param username (required) + * @param _callback The callback to be executed when the API call finishes + * @return The request call + * @throws ApiException If fail to process the API call, e.g. serializing the request body object + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public okhttp3.Call getGroupMemberAllCustomAttributeAsync(String groupId, String username, final ApiCallback _callback) throws ApiException { + + okhttp3.Call localVarCall = getGroupMemberAllCustomAttributeValidateBeforeCall(groupId, username, _callback); + Type localVarReturnType = new TypeToken(){}.getType(); + localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); + return localVarCall; + } + /** + * Build call for getMultipleGroupMembersAttributes + * @param groupId (required) + * @param emGetMultipleGroupMembersAttributes (optional) + * @param _callback Callback for upload/download progress + * @return Call to execute + * @throws ApiException If fail to serialize the request body object + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public okhttp3.Call getMultipleGroupMembersAttributesCall(String groupId, EMGetMultipleGroupMembersAttributes emGetMultipleGroupMembersAttributes, final ApiCallback _callback) throws ApiException { + String basePath = null; + // Operation Servers + String[] localBasePaths = new String[] { }; + + // Determine Base Path to Use + if (localCustomBaseUrl != null){ + basePath = localCustomBaseUrl; + } else if ( localBasePaths.length > 0 ) { + basePath = localBasePaths[localHostIndex]; + } else { + basePath = null; + } + + Object localVarPostBody = emGetMultipleGroupMembersAttributes; + + // create path and map variables + String localVarPath = "/metadata/chatgroup/{group_id}/get" + .replace("{" + "group_id" + "}", localVarApiClient.escapeString(groupId.toString())); + + List localVarQueryParams = new ArrayList(); + List localVarCollectionQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + Map localVarCookieParams = new HashMap(); + Map localVarFormParams = new HashMap(); + + final String[] localVarAccepts = { + "application/json" + }; + final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts); + if (localVarAccept != null) { + localVarHeaderParams.put("Accept", localVarAccept); + } + + final String[] localVarContentTypes = { + "application/json" + }; + final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); + if (localVarContentType != null) { + localVarHeaderParams.put("Content-Type", localVarContentType); + } + + String[] localVarAuthNames = new String[] { }; + return localVarApiClient.buildCall(basePath, localVarPath, "POST", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); + } + + @SuppressWarnings("rawtypes") + private okhttp3.Call getMultipleGroupMembersAttributesValidateBeforeCall(String groupId, EMGetMultipleGroupMembersAttributes emGetMultipleGroupMembersAttributes, final ApiCallback _callback) throws ApiException { + // verify the required parameter 'groupId' is set + if (groupId == null) { + throw new ApiException("Missing the required parameter 'groupId' when calling getMultipleGroupMembersAttributes(Async)"); + } + + return getMultipleGroupMembersAttributesCall(groupId, emGetMultipleGroupMembersAttributes, _callback); + + } + + /** + * 根据属性 key 获取多个群成员的自定义属性 + * 根据指定的属性 key 获取多个群成员的自定义属性。每次最多可获取 10 个群成员的自定义属性。文档介绍:https://docs-im-beta.easemob.com/document/server-side/group.html#%E6%A0%B9%E6%8D%AE%E5%B1%9E%E6%80%A7-key-%E8%8E%B7%E5%8F%96%E5%A4%9A%E4%B8%AA%E7%BE%A4%E6%88%90%E5%91%98%E7%9A%84%E8%87%AA%E5%AE%9A%E4%B9%89%E5%B1%9E%E6%80%A7 + * @param groupId (required) + * @param emGetMultipleGroupMembersAttributes (optional) + * @return EMGetMultipleGroupMembersAttributes + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public EMGetMultipleGroupMembersAttributesResult getMultipleGroupMembersAttributes(String groupId, EMGetMultipleGroupMembersAttributes emGetMultipleGroupMembersAttributes) throws ApiException { + ApiResponse localVarResp = getMultipleGroupMembersAttributesWithHttpInfo(groupId, emGetMultipleGroupMembersAttributes); + return localVarResp.getData(); + } + + /** + * 根据属性 key 获取多个群成员的自定义属性 + * 根据指定的属性 key 获取多个群成员的自定义属性。每次最多可获取 10 个群成员的自定义属性。文档介绍:https://docs-im-beta.easemob.com/document/server-side/group.html#%E6%A0%B9%E6%8D%AE%E5%B1%9E%E6%80%A7-key-%E8%8E%B7%E5%8F%96%E5%A4%9A%E4%B8%AA%E7%BE%A4%E6%88%90%E5%91%98%E7%9A%84%E8%87%AA%E5%AE%9A%E4%B9%89%E5%B1%9E%E6%80%A7 + * @param groupId (required) + * @param emGetMultipleGroupMembersAttributes (optional) + * @return ApiResponse<EMGetMultipleGroupMembersAttributesResult> + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public ApiResponse getMultipleGroupMembersAttributesWithHttpInfo(String groupId, EMGetMultipleGroupMembersAttributes emGetMultipleGroupMembersAttributes) throws ApiException { + okhttp3.Call localVarCall = getMultipleGroupMembersAttributesValidateBeforeCall(groupId, emGetMultipleGroupMembersAttributes, null); + Type localVarReturnType = new TypeToken(){}.getType(); + return localVarApiClient.execute(localVarCall, localVarReturnType); + } + + /** + * 根据属性 key 获取多个群成员的自定义属性 (asynchronously) + * 根据指定的属性 key 获取多个群成员的自定义属性。每次最多可获取 10 个群成员的自定义属性。文档介绍:https://docs-im-beta.easemob.com/document/server-side/group.html#%E6%A0%B9%E6%8D%AE%E5%B1%9E%E6%80%A7-key-%E8%8E%B7%E5%8F%96%E5%A4%9A%E4%B8%AA%E7%BE%A4%E6%88%90%E5%91%98%E7%9A%84%E8%87%AA%E5%AE%9A%E4%B9%89%E5%B1%9E%E6%80%A7 + * @param groupId (required) + * @param emGetMultipleGroupMembersAttributes (optional) + * @param _callback The callback to be executed when the API call finishes + * @return The request call + * @throws ApiException If fail to process the API call, e.g. serializing the request body object + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public okhttp3.Call getMultipleGroupMembersAttributesAsync(String groupId, EMGetMultipleGroupMembersAttributes emGetMultipleGroupMembersAttributes, final ApiCallback _callback) throws ApiException { + + okhttp3.Call localVarCall = getMultipleGroupMembersAttributesValidateBeforeCall(groupId, emGetMultipleGroupMembersAttributes, _callback); + Type localVarReturnType = new TypeToken(){}.getType(); + localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); + return localVarCall; + } + /** + * Build call for getUserMetadata + * @param username (required) + * @param _callback Callback for upload/download progress + * @return Call to execute + * @throws ApiException If fail to serialize the request body object + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public okhttp3.Call getUserMetadataCall(String username, final ApiCallback _callback) throws ApiException { + String basePath = null; + // Operation Servers + String[] localBasePaths = new String[] { }; + + // Determine Base Path to Use + if (localCustomBaseUrl != null){ + basePath = localCustomBaseUrl; + } else if ( localBasePaths.length > 0 ) { + basePath = localBasePaths[localHostIndex]; + } else { + basePath = null; + } + + Object localVarPostBody = null; + + // create path and map variables + String localVarPath = "/metadata/user/{username}" + .replace("{" + "username" + "}", localVarApiClient.escapeString(username.toString())); + + List localVarQueryParams = new ArrayList(); + List localVarCollectionQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + Map localVarCookieParams = new HashMap(); + Map localVarFormParams = new HashMap(); + + final String[] localVarAccepts = { + "application/json" + }; + final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts); + if (localVarAccept != null) { + localVarHeaderParams.put("Accept", localVarAccept); + } + + final String[] localVarContentTypes = { + }; + final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); + if (localVarContentType != null) { + localVarHeaderParams.put("Content-Type", localVarContentType); + } + + String[] localVarAuthNames = new String[] { }; + return localVarApiClient.buildCall(basePath, localVarPath, "GET", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); + } + + @SuppressWarnings("rawtypes") + private okhttp3.Call getUserMetadataValidateBeforeCall(String username, final ApiCallback _callback) throws ApiException { + // verify the required parameter 'username' is set + if (username == null) { + throw new ApiException("Missing the required parameter 'username' when calling getUserMetadata(Async)"); + } + + return getUserMetadataCall(username, _callback); + + } + + /** + * 获取用户属性 + * 获取单个用户的全部用户属性键值对。需要在请求中填写 {username},指定获取用户属性的用户 ID。如果指定的用户或用户属性不存在,返回空数据{}。文档介绍:https://docs-im-beta.easemob.com/document/server-side/userprofile.html#%E8%8E%B7%E5%8F%96%E7%94%A8%E6%88%B7%E5%B1%9E%E6%80%A7 + * @param username (required) + * @return EMGetUserMetadataResult + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public EMGetUserMetadataResult getUserMetadata(String username) throws ApiException { + ApiResponse localVarResp = getUserMetadataWithHttpInfo(username); + return localVarResp.getData(); + } + + /** + * 获取用户属性 + * 获取单个用户的全部用户属性键值对。需要在请求中填写 {username},指定获取用户属性的用户 ID。如果指定的用户或用户属性不存在,返回空数据{}。文档介绍:https://docs-im-beta.easemob.com/document/server-side/userprofile.html#%E8%8E%B7%E5%8F%96%E7%94%A8%E6%88%B7%E5%B1%9E%E6%80%A7 + * @param username (required) + * @return ApiResponse<EMGetUserMetadataResult> + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public ApiResponse getUserMetadataWithHttpInfo(String username) throws ApiException { + okhttp3.Call localVarCall = getUserMetadataValidateBeforeCall(username, null); + Type localVarReturnType = new TypeToken(){}.getType(); + return localVarApiClient.execute(localVarCall, localVarReturnType); + } + + /** + * 获取用户属性 (asynchronously) + * 获取单个用户的全部用户属性键值对。需要在请求中填写 {username},指定获取用户属性的用户 ID。如果指定的用户或用户属性不存在,返回空数据{}。文档介绍:https://docs-im-beta.easemob.com/document/server-side/userprofile.html#%E8%8E%B7%E5%8F%96%E7%94%A8%E6%88%B7%E5%B1%9E%E6%80%A7 + * @param username (required) + * @param _callback The callback to be executed when the API call finishes + * @return The request call + * @throws ApiException If fail to process the API call, e.g. serializing the request body object + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public okhttp3.Call getUserMetadataAsync(String username, final ApiCallback _callback) throws ApiException { + + okhttp3.Call localVarCall = getUserMetadataValidateBeforeCall(username, _callback); + Type localVarReturnType = new TypeToken(){}.getType(); + localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); + return localVarCall; + } + /** + * Build call for getUserMetadataCapacity + * @param _callback Callback for upload/download progress + * @return Call to execute + * @throws ApiException If fail to serialize the request body object + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public okhttp3.Call getUserMetadataCapacityCall(final ApiCallback _callback) throws ApiException { + String basePath = null; + // Operation Servers + String[] localBasePaths = new String[] { }; + + // Determine Base Path to Use + if (localCustomBaseUrl != null){ + basePath = localCustomBaseUrl; + } else if ( localBasePaths.length > 0 ) { + basePath = localBasePaths[localHostIndex]; + } else { + basePath = null; + } + + Object localVarPostBody = null; + + // create path and map variables + String localVarPath = "/metadata/user/capacity"; + + List localVarQueryParams = new ArrayList(); + List localVarCollectionQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + Map localVarCookieParams = new HashMap(); + Map localVarFormParams = new HashMap(); + + final String[] localVarAccepts = { + "application/json" + }; + final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts); + if (localVarAccept != null) { + localVarHeaderParams.put("Accept", localVarAccept); + } + + final String[] localVarContentTypes = { + }; + final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); + if (localVarContentType != null) { + localVarHeaderParams.put("Content-Type", localVarContentType); + } + + String[] localVarAuthNames = new String[] { }; + return localVarApiClient.buildCall(basePath, localVarPath, "GET", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); + } + + @SuppressWarnings("rawtypes") + private okhttp3.Call getUserMetadataCapacityValidateBeforeCall(final ApiCallback _callback) throws ApiException { + return getUserMetadataCapacityCall(_callback); + + } + + /** + * 设置用户属性 + * 取该 app 下所有用户的属性数据大小,单位为字节。文档介绍:https://docs-im-beta.easemob.com/document/server-side/userprofile.html#%E8%8E%B7%E5%8F%96-app-%E4%B8%8B%E7%94%A8%E6%88%B7%E5%B1%9E%E6%80%A7%E6%80%BB%E5%A4%A7%E5%B0%8F + * @return EMGetUserMetadataCapacityResult + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public EMGetUserMetadataCapacityResult getUserMetadataCapacity() throws ApiException { + ApiResponse localVarResp = getUserMetadataCapacityWithHttpInfo(); + return localVarResp.getData(); + } + + /** + * 设置用户属性 + * 取该 app 下所有用户的属性数据大小,单位为字节。文档介绍:https://docs-im-beta.easemob.com/document/server-side/userprofile.html#%E8%8E%B7%E5%8F%96-app-%E4%B8%8B%E7%94%A8%E6%88%B7%E5%B1%9E%E6%80%A7%E6%80%BB%E5%A4%A7%E5%B0%8F + * @return ApiResponse<EMGetUserMetadataCapacityResult> + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public ApiResponse getUserMetadataCapacityWithHttpInfo() throws ApiException { + okhttp3.Call localVarCall = getUserMetadataCapacityValidateBeforeCall(null); + Type localVarReturnType = new TypeToken(){}.getType(); + return localVarApiClient.execute(localVarCall, localVarReturnType); + } + + /** + * 设置用户属性 (asynchronously) + * 取该 app 下所有用户的属性数据大小,单位为字节。文档介绍:https://docs-im-beta.easemob.com/document/server-side/userprofile.html#%E8%8E%B7%E5%8F%96-app-%E4%B8%8B%E7%94%A8%E6%88%B7%E5%B1%9E%E6%80%A7%E6%80%BB%E5%A4%A7%E5%B0%8F + * @param _callback The callback to be executed when the API call finishes + * @return The request call + * @throws ApiException If fail to process the API call, e.g. serializing the request body object + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public okhttp3.Call getUserMetadataCapacityAsync(final ApiCallback _callback) throws ApiException { + + okhttp3.Call localVarCall = getUserMetadataCapacityValidateBeforeCall(_callback); + Type localVarReturnType = new TypeToken(){}.getType(); + localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); + return localVarCall; + } + /** + * Build call for setUserMetadata + * @param username (required) + * @param metadata (required) + * @param _callback Callback for upload/download progress + * @return Call to execute + * @throws ApiException If fail to serialize the request body object + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public okhttp3.Call setUserMetadataCall(String username, Map metadata, final ApiCallback _callback) throws ApiException { + String basePath = null; + // Operation Servers + String[] localBasePaths = new String[] { }; + + // Determine Base Path to Use + if (localCustomBaseUrl != null){ + basePath = localCustomBaseUrl; + } else if ( localBasePaths.length > 0 ) { + basePath = localBasePaths[localHostIndex]; + } else { + basePath = null; + } + + Object localVarPostBody = null; + + // create path and map variables + String localVarPath = "/metadata/user/{username}" + .replace("{" + "username" + "}", localVarApiClient.escapeString(username.toString())); + + List localVarQueryParams = new ArrayList(); + List localVarCollectionQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + Map localVarCookieParams = new HashMap(); + Map localVarFormParams = new HashMap(); + + for (Map.Entry entry : metadata.entrySet()) { + localVarFormParams.put(entry.getKey(), entry.getValue()); + } + + final String[] localVarAccepts = { + "application/json" + }; + final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts); + if (localVarAccept != null) { + localVarHeaderParams.put("Accept", localVarAccept); + } + + final String[] localVarContentTypes = { + "application/x-www-form-urlencoded" + }; + final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); + if (localVarContentType != null) { + localVarHeaderParams.put("Content-Type", localVarContentType); + } + + String[] localVarAuthNames = new String[] { }; + return localVarApiClient.buildCall(basePath, localVarPath, "PUT", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); + } + + @SuppressWarnings("rawtypes") + private okhttp3.Call setUserMetadataValidateBeforeCall(String username, Map metadata, final ApiCallback _callback) throws ApiException { + // verify the required parameter 'username' is set + if (username == null) { + throw new ApiException("Missing the required parameter 'username' when calling setUserMetadata(Async)"); + } + + return setUserMetadataCall(username, metadata, _callback); + + } + + /** + * 设置用户属性 + * 用户属性的内容为一个或多个纯文本键值对,默认单个用户的属性总长度不能超过 2 KB,默认单个 app 下所有用户的属性总长度不能超过 10 GB。利用该 API,每次只能设置一个用户的用户属性。文档介绍:https://docs-im-beta.easemob.com/document/server-side/userprofile.html#%E8%AE%BE%E7%BD%AE%E7%94%A8%E6%88%B7%E5%B1%9E%E6%80%A7 + * @param username (required) + * @param metadata (required) + * @return EMSetUserMetadataResult + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public EMSetUserMetadataResult setUserMetadata(String username, Map metadata) throws ApiException { + ApiResponse localVarResp = setUserMetadataWithHttpInfo(username, metadata); + return localVarResp.getData(); + } + + /** + * 设置用户属性 + * 用户属性的内容为一个或多个纯文本键值对,默认单个用户的属性总长度不能超过 2 KB,默认单个 app 下所有用户的属性总长度不能超过 10 GB。利用该 API,每次只能设置一个用户的用户属性。文档介绍:https://docs-im-beta.easemob.com/document/server-side/userprofile.html#%E8%AE%BE%E7%BD%AE%E7%94%A8%E6%88%B7%E5%B1%9E%E6%80%A7 + * @param username (required) + * @return ApiResponse<EMSetUserMetadataResult> + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public ApiResponse setUserMetadataWithHttpInfo(String username, Map metadata) throws ApiException { + okhttp3.Call localVarCall = setUserMetadataValidateBeforeCall(username, metadata, null); + Type localVarReturnType = new TypeToken(){}.getType(); + return localVarApiClient.execute(localVarCall, localVarReturnType); + } + + /** + * 设置用户属性 (asynchronously) + * 用户属性的内容为一个或多个纯文本键值对,默认单个用户的属性总长度不能超过 2 KB,默认单个 app 下所有用户的属性总长度不能超过 10 GB。利用该 API,每次只能设置一个用户的用户属性。文档介绍:https://docs-im-beta.easemob.com/document/server-side/userprofile.html#%E8%AE%BE%E7%BD%AE%E7%94%A8%E6%88%B7%E5%B1%9E%E6%80%A7 + * @param username (required) + * @param metadata (required) + * @param _callback The callback to be executed when the API call finishes + * @return The request call + * @throws ApiException If fail to process the API call, e.g. serializing the request body object + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public okhttp3.Call setUserMetadataAsync(String username, Map metadata, final ApiCallback _callback) throws ApiException { + + okhttp3.Call localVarCall = setUserMetadataValidateBeforeCall(username, metadata, _callback); + Type localVarReturnType = new TypeToken(){}.getType(); + localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); + return localVarCall; + } +} diff --git a/src/main/java/com/easemob/im/api/RoomApi.java b/src/main/java/com/easemob/im/api/RoomApi.java new file mode 100644 index 000000000..a7beb6954 --- /dev/null +++ b/src/main/java/com/easemob/im/api/RoomApi.java @@ -0,0 +1,5048 @@ +/* + * EMService + * Easemob Rest API + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.easemob.im.api; + +import com.easemob.im.ApiCallback; +import com.easemob.im.ApiClient; +import com.easemob.im.ApiException; +import com.easemob.im.ApiResponse; +import com.easemob.im.Configuration; +import com.easemob.im.Pair; +import com.easemob.im.ProgressRequestBody; +import com.easemob.im.ProgressResponseBody; + +import com.google.gson.reflect.TypeToken; + +import java.io.IOException; + + +import com.easemob.im.api.model.EMAddMultipleUserToRoom; +import com.easemob.im.api.model.EMAddMultipleUserToRoomBlockList; +import com.easemob.im.api.model.EMAddMultipleUserToRoomBlockListResult; +import com.easemob.im.api.model.EMAddMultipleUserToRoomWhiteList; +import com.easemob.im.api.model.EMAddMultipleUserToRoomWhiteListResult; +import com.easemob.im.api.model.EMAddRoomAdmin; +import com.easemob.im.api.model.EMAddRoomAdminResult; +import com.easemob.im.api.model.EMAddRoomSuperAdmin; +import com.easemob.im.api.model.EMAddRoomSuperAdminResult; +import com.easemob.im.api.model.EMAddUserToRoomBlockListResult; +import com.easemob.im.api.model.EMAddUserToRoomResult; +import com.easemob.im.api.model.EMAddUserToRoomWhiteListResult; +import com.easemob.im.api.model.EMCreateRoom; +import com.easemob.im.api.model.EMCreateRoomResult; +import com.easemob.im.api.model.EMDeleteRoomCustomAttributes; +import com.easemob.im.api.model.EMDeleteRoomCustomAttributesResult; +import com.easemob.im.api.model.EMDeleteRoomResult; +import com.easemob.im.api.model.EMForceDeleteRoomCustomAttributes; +import com.easemob.im.api.model.EMForceDeleteRoomCustomAttributesResult; +import com.easemob.im.api.model.EMForceSetRoomCustomAttributes; +import com.easemob.im.api.model.EMForceSetRoomCustomAttributesResult; +import com.easemob.im.api.model.EMGetMuteRoomMemberListResult; +import com.easemob.im.api.model.EMGetRoomAdminListResult; +import com.easemob.im.api.model.EMGetRoomAnnouncementResult; +import com.easemob.im.api.model.EMGetRoomBlockListResult; +import com.easemob.im.api.model.EMGetRoomCustomAttributes; +import com.easemob.im.api.model.EMGetRoomCustomAttributesResult; +import com.easemob.im.api.model.EMGetRoomInfoResult; +import com.easemob.im.api.model.EMGetRoomListResult; +import com.easemob.im.api.model.EMGetRoomMemberListResult; +import com.easemob.im.api.model.EMGetRoomSuperAdminListResult; +import com.easemob.im.api.model.EMGetRoomWhiteListResult; +import com.easemob.im.api.model.EMGetUserJoinedRoomListResult; +import com.easemob.im.api.model.EMModifyRoom; +import com.easemob.im.api.model.EMModifyRoomAnnouncement; +import com.easemob.im.api.model.EMModifyRoomAnnouncementResult; +import com.easemob.im.api.model.EMModifyRoomResult; +import com.easemob.im.api.model.EMMuteAllRoomMemberResult; +import com.easemob.im.api.model.EMMuteRoomMember; +import com.easemob.im.api.model.EMMuteRoomMemberResult; +import com.easemob.im.api.model.EMRemoveRoomAdminResult; +import com.easemob.im.api.model.EMRemoveRoomSuperAdminResult; +import com.easemob.im.api.model.EMRemoveUserFromRoomBlockListResult; +import com.easemob.im.api.model.EMRemoveUserFromRoomResult; +import com.easemob.im.api.model.EMRemoveUserFromRoomWhiteListResult; +import com.easemob.im.api.model.EMSetRoomCustomAttributes; +import com.easemob.im.api.model.EMSetRoomCustomAttributesResult; +import com.easemob.im.api.model.EMUnmuteAllRoomMemberResult; +import com.easemob.im.api.model.EMUnmuteRoomMemberResult; + +import java.lang.reflect.Type; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +public class RoomApi { + private ApiClient localVarApiClient; + private int localHostIndex; + private String localCustomBaseUrl; + + public RoomApi() { + this(Configuration.getDefaultApiClient()); + } + + public RoomApi(ApiClient apiClient) { + this.localVarApiClient = apiClient; + } + + public ApiClient getApiClient() { + return localVarApiClient; + } + + public void setApiClient(ApiClient apiClient) { + this.localVarApiClient = apiClient; + } + + public int getHostIndex() { + return localHostIndex; + } + + public void setHostIndex(int hostIndex) { + this.localHostIndex = hostIndex; + } + + public String getCustomBaseUrl() { + return localCustomBaseUrl; + } + + public void setCustomBaseUrl(String customBaseUrl) { + this.localCustomBaseUrl = customBaseUrl; + } + + /** + * Build call for addMultipleUserToRoom + * @param chatroomId (required) + * @param emAddMultipleUserToRoom (optional) + * @param _callback Callback for upload/download progress + * @return Call to execute + * @throws ApiException If fail to serialize the request body object + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public okhttp3.Call addMultipleUserToRoomCall(String chatroomId, EMAddMultipleUserToRoom emAddMultipleUserToRoom, final ApiCallback _callback) throws ApiException { + String basePath = null; + // Operation Servers + String[] localBasePaths = new String[] { }; + + // Determine Base Path to Use + if (localCustomBaseUrl != null){ + basePath = localCustomBaseUrl; + } else if ( localBasePaths.length > 0 ) { + basePath = localBasePaths[localHostIndex]; + } else { + basePath = null; + } + + Object localVarPostBody = emAddMultipleUserToRoom; + + // create path and map variables + String localVarPath = "/chatrooms/{chatroom_id}/users" + .replace("{" + "chatroom_id" + "}", localVarApiClient.escapeString(chatroomId.toString())); + + List localVarQueryParams = new ArrayList(); + List localVarCollectionQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + Map localVarCookieParams = new HashMap(); + Map localVarFormParams = new HashMap(); + + final String[] localVarAccepts = { + }; + final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts); + if (localVarAccept != null) { + localVarHeaderParams.put("Accept", localVarAccept); + } + + final String[] localVarContentTypes = { + "application/json" + }; + final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); + if (localVarContentType != null) { + localVarHeaderParams.put("Content-Type", localVarContentType); + } + + String[] localVarAuthNames = new String[] { }; + return localVarApiClient.buildCall(basePath, localVarPath, "POST", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); + } + + @SuppressWarnings("rawtypes") + private okhttp3.Call addMultipleUserToRoomValidateBeforeCall(String chatroomId, EMAddMultipleUserToRoom emAddMultipleUserToRoom, final ApiCallback _callback) throws ApiException { + // verify the required parameter 'chatroomId' is set + if (chatroomId == null) { + throw new ApiException("Missing the required parameter 'chatroomId' when calling addMultipleUserToRoom(Async)"); + } + + return addMultipleUserToRoomCall(chatroomId, emAddMultipleUserToRoom, _callback); + + } + + /** + * 批量添加聊天室成员 + * 向聊天室添加多位用户,一次性最多可添加 60 位用户。文档介绍:https://docs-im-beta.easemob.com/document/server-side/chatroom.html#%E6%89%B9%E9%87%8F%E6%B7%BB%E5%8A%A0%E8%81%8A%E5%A4%A9%E5%AE%A4%E6%88%90%E5%91%98 + * @param chatroomId (required) + * @param emAddMultipleUserToRoom (optional) + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public void addMultipleUserToRoom(String chatroomId, EMAddMultipleUserToRoom emAddMultipleUserToRoom) throws ApiException { + addMultipleUserToRoomWithHttpInfo(chatroomId, emAddMultipleUserToRoom); + } + + /** + * 批量添加聊天室成员 + * 向聊天室添加多位用户,一次性最多可添加 60 位用户。文档介绍:https://docs-im-beta.easemob.com/document/server-side/chatroom.html#%E6%89%B9%E9%87%8F%E6%B7%BB%E5%8A%A0%E8%81%8A%E5%A4%A9%E5%AE%A4%E6%88%90%E5%91%98 + * @param chatroomId (required) + * @param emAddMultipleUserToRoom (optional) + * @return ApiResponse<Void> + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public ApiResponse addMultipleUserToRoomWithHttpInfo(String chatroomId, EMAddMultipleUserToRoom emAddMultipleUserToRoom) throws ApiException { + okhttp3.Call localVarCall = addMultipleUserToRoomValidateBeforeCall(chatroomId, emAddMultipleUserToRoom, null); + return localVarApiClient.execute(localVarCall); + } + + /** + * 批量添加聊天室成员 (asynchronously) + * 向聊天室添加多位用户,一次性最多可添加 60 位用户。文档介绍:https://docs-im-beta.easemob.com/document/server-side/chatroom.html#%E6%89%B9%E9%87%8F%E6%B7%BB%E5%8A%A0%E8%81%8A%E5%A4%A9%E5%AE%A4%E6%88%90%E5%91%98 + * @param chatroomId (required) + * @param emAddMultipleUserToRoom (optional) + * @param _callback The callback to be executed when the API call finishes + * @return The request call + * @throws ApiException If fail to process the API call, e.g. serializing the request body object + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public okhttp3.Call addMultipleUserToRoomAsync(String chatroomId, EMAddMultipleUserToRoom emAddMultipleUserToRoom, final ApiCallback _callback) throws ApiException { + + okhttp3.Call localVarCall = addMultipleUserToRoomValidateBeforeCall(chatroomId, emAddMultipleUserToRoom, _callback); + localVarApiClient.executeAsync(localVarCall, _callback); + return localVarCall; + } + /** + * Build call for addMultipleUserToRoomBlockList + * @param chatroomId (required) + * @param emAddMultipleUserToRoomBlockList (optional) + * @param _callback Callback for upload/download progress + * @return Call to execute + * @throws ApiException If fail to serialize the request body object + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public okhttp3.Call addMultipleUserToRoomBlockListCall(String chatroomId, EMAddMultipleUserToRoomBlockList emAddMultipleUserToRoomBlockList, final ApiCallback _callback) throws ApiException { + String basePath = null; + // Operation Servers + String[] localBasePaths = new String[] { }; + + // Determine Base Path to Use + if (localCustomBaseUrl != null){ + basePath = localCustomBaseUrl; + } else if ( localBasePaths.length > 0 ) { + basePath = localBasePaths[localHostIndex]; + } else { + basePath = null; + } + + Object localVarPostBody = emAddMultipleUserToRoomBlockList; + + // create path and map variables + String localVarPath = "/chatrooms/{chatroom_id}/blocks/users" + .replace("{" + "chatroom_id" + "}", localVarApiClient.escapeString(chatroomId.toString())); + + List localVarQueryParams = new ArrayList(); + List localVarCollectionQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + Map localVarCookieParams = new HashMap(); + Map localVarFormParams = new HashMap(); + + final String[] localVarAccepts = { + "application/json" + }; + final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts); + if (localVarAccept != null) { + localVarHeaderParams.put("Accept", localVarAccept); + } + + final String[] localVarContentTypes = { + "application/json" + }; + final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); + if (localVarContentType != null) { + localVarHeaderParams.put("Content-Type", localVarContentType); + } + + String[] localVarAuthNames = new String[] { }; + return localVarApiClient.buildCall(basePath, localVarPath, "POST", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); + } + + @SuppressWarnings("rawtypes") + private okhttp3.Call addMultipleUserToRoomBlockListValidateBeforeCall(String chatroomId, EMAddMultipleUserToRoomBlockList emAddMultipleUserToRoomBlockList, final ApiCallback _callback) throws ApiException { + // verify the required parameter 'chatroomId' is set + if (chatroomId == null) { + throw new ApiException("Missing the required parameter 'chatroomId' when calling addMultipleUserToRoomBlockList(Async)"); + } + + return addMultipleUserToRoomBlockListCall(chatroomId, emAddMultipleUserToRoomBlockList, _callback); + + } + + /** + * 批量添加用户至聊天室黑名单 + * 将多个用户加入指定聊天室的黑名单。你一次最多可以添加 60 个用户至聊天室黑名单。聊天室所有者无法被加入聊天室的黑名单。用户进入聊天室黑名单后,无法查看和收发该聊天室的信息。文档介绍:https://docs-im-beta.easemob.com/document/server-side/chatroom.html#%E6%89%B9%E9%87%8F%E6%B7%BB%E5%8A%A0%E7%94%A8%E6%88%B7%E8%87%B3%E8%81%8A%E5%A4%A9%E5%AE%A4%E9%BB%91%E5%90%8D%E5%8D%95 + * @param chatroomId (required) + * @param emAddMultipleUserToRoomBlockList (optional) + * @return EMAddMultipleUserToRoomBlockListResult + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public EMAddMultipleUserToRoomBlockListResult addMultipleUserToRoomBlockList(String chatroomId, EMAddMultipleUserToRoomBlockList emAddMultipleUserToRoomBlockList) throws ApiException { + ApiResponse localVarResp = addMultipleUserToRoomBlockListWithHttpInfo(chatroomId, emAddMultipleUserToRoomBlockList); + return localVarResp.getData(); + } + + /** + * 批量添加用户至聊天室黑名单 + * 将多个用户加入指定聊天室的黑名单。你一次最多可以添加 60 个用户至聊天室黑名单。聊天室所有者无法被加入聊天室的黑名单。用户进入聊天室黑名单后,无法查看和收发该聊天室的信息。文档介绍:https://docs-im-beta.easemob.com/document/server-side/chatroom.html#%E6%89%B9%E9%87%8F%E6%B7%BB%E5%8A%A0%E7%94%A8%E6%88%B7%E8%87%B3%E8%81%8A%E5%A4%A9%E5%AE%A4%E9%BB%91%E5%90%8D%E5%8D%95 + * @param chatroomId (required) + * @param emAddMultipleUserToRoomBlockList (optional) + * @return ApiResponse<EMAddMultipleUserToRoomBlockListResult> + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public ApiResponse addMultipleUserToRoomBlockListWithHttpInfo(String chatroomId, EMAddMultipleUserToRoomBlockList emAddMultipleUserToRoomBlockList) throws ApiException { + okhttp3.Call localVarCall = addMultipleUserToRoomBlockListValidateBeforeCall(chatroomId, emAddMultipleUserToRoomBlockList, null); + Type localVarReturnType = new TypeToken(){}.getType(); + return localVarApiClient.execute(localVarCall, localVarReturnType); + } + + /** + * 批量添加用户至聊天室黑名单 (asynchronously) + * 将多个用户加入指定聊天室的黑名单。你一次最多可以添加 60 个用户至聊天室黑名单。聊天室所有者无法被加入聊天室的黑名单。用户进入聊天室黑名单后,无法查看和收发该聊天室的信息。文档介绍:https://docs-im-beta.easemob.com/document/server-side/chatroom.html#%E6%89%B9%E9%87%8F%E6%B7%BB%E5%8A%A0%E7%94%A8%E6%88%B7%E8%87%B3%E8%81%8A%E5%A4%A9%E5%AE%A4%E9%BB%91%E5%90%8D%E5%8D%95 + * @param chatroomId (required) + * @param emAddMultipleUserToRoomBlockList (optional) + * @param _callback The callback to be executed when the API call finishes + * @return The request call + * @throws ApiException If fail to process the API call, e.g. serializing the request body object + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public okhttp3.Call addMultipleUserToRoomBlockListAsync(String chatroomId, EMAddMultipleUserToRoomBlockList emAddMultipleUserToRoomBlockList, final ApiCallback _callback) throws ApiException { + + okhttp3.Call localVarCall = addMultipleUserToRoomBlockListValidateBeforeCall(chatroomId, emAddMultipleUserToRoomBlockList, _callback); + Type localVarReturnType = new TypeToken(){}.getType(); + localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); + return localVarCall; + } + /** + * Build call for addMultipleUserToRoomWhiteList + * @param chatroomId (required) + * @param emAddMultipleUserToRoomWhiteList (optional) + * @param _callback Callback for upload/download progress + * @return Call to execute + * @throws ApiException If fail to serialize the request body object + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public okhttp3.Call addMultipleUserToRoomWhiteListCall(String chatroomId, EMAddMultipleUserToRoomWhiteList emAddMultipleUserToRoomWhiteList, final ApiCallback _callback) throws ApiException { + String basePath = null; + // Operation Servers + String[] localBasePaths = new String[] { }; + + // Determine Base Path to Use + if (localCustomBaseUrl != null){ + basePath = localCustomBaseUrl; + } else if ( localBasePaths.length > 0 ) { + basePath = localBasePaths[localHostIndex]; + } else { + basePath = null; + } + + Object localVarPostBody = emAddMultipleUserToRoomWhiteList; + + // create path and map variables + String localVarPath = "/chatrooms/{chatroom_id}/white/users" + .replace("{" + "chatroom_id" + "}", localVarApiClient.escapeString(chatroomId.toString())); + + List localVarQueryParams = new ArrayList(); + List localVarCollectionQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + Map localVarCookieParams = new HashMap(); + Map localVarFormParams = new HashMap(); + + final String[] localVarAccepts = { + "application/json" + }; + final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts); + if (localVarAccept != null) { + localVarHeaderParams.put("Accept", localVarAccept); + } + + final String[] localVarContentTypes = { + "application/json" + }; + final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); + if (localVarContentType != null) { + localVarHeaderParams.put("Content-Type", localVarContentType); + } + + String[] localVarAuthNames = new String[] { }; + return localVarApiClient.buildCall(basePath, localVarPath, "POST", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); + } + + @SuppressWarnings("rawtypes") + private okhttp3.Call addMultipleUserToRoomWhiteListValidateBeforeCall(String chatroomId, EMAddMultipleUserToRoomWhiteList emAddMultipleUserToRoomWhiteList, final ApiCallback _callback) throws ApiException { + // verify the required parameter 'chatroomId' is set + if (chatroomId == null) { + throw new ApiException("Missing the required parameter 'chatroomId' when calling addMultipleUserToRoomWhiteList(Async)"); + } + + return addMultipleUserToRoomWhiteListCall(chatroomId, emAddMultipleUserToRoomWhiteList, _callback); + + } + + /** + * 批量添加用户至聊天室白名单 + * 添加多个用户至聊天室白名单。你一次最多可添加 60 个用户。用户添加至聊天室白名单后,在聊天室全员禁言时,仍可以在聊天室中发送消息。文档介绍:https://docs-im-beta.easemob.com/document/server-side/chatroom.html#%E6%89%B9%E9%87%8F%E6%B7%BB%E5%8A%A0%E7%94%A8%E6%88%B7%E8%87%B3%E8%81%8A%E5%A4%A9%E5%AE%A4%E7%99%BD%E5%90%8D%E5%8D%95 + * @param chatroomId (required) + * @param emAddMultipleUserToRoomWhiteList (optional) + * @return EMAddMultipleUserToRoomWhiteListResult + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public EMAddMultipleUserToRoomWhiteListResult addMultipleUserToRoomWhiteList(String chatroomId, EMAddMultipleUserToRoomWhiteList emAddMultipleUserToRoomWhiteList) throws ApiException { + ApiResponse localVarResp = addMultipleUserToRoomWhiteListWithHttpInfo(chatroomId, emAddMultipleUserToRoomWhiteList); + return localVarResp.getData(); + } + + /** + * 批量添加用户至聊天室白名单 + * 添加多个用户至聊天室白名单。你一次最多可添加 60 个用户。用户添加至聊天室白名单后,在聊天室全员禁言时,仍可以在聊天室中发送消息。文档介绍:https://docs-im-beta.easemob.com/document/server-side/chatroom.html#%E6%89%B9%E9%87%8F%E6%B7%BB%E5%8A%A0%E7%94%A8%E6%88%B7%E8%87%B3%E8%81%8A%E5%A4%A9%E5%AE%A4%E7%99%BD%E5%90%8D%E5%8D%95 + * @param chatroomId (required) + * @param emAddMultipleUserToRoomWhiteList (optional) + * @return ApiResponse<EMAddMultipleUserToRoomWhiteListResult> + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public ApiResponse addMultipleUserToRoomWhiteListWithHttpInfo(String chatroomId, EMAddMultipleUserToRoomWhiteList emAddMultipleUserToRoomWhiteList) throws ApiException { + okhttp3.Call localVarCall = addMultipleUserToRoomWhiteListValidateBeforeCall(chatroomId, emAddMultipleUserToRoomWhiteList, null); + Type localVarReturnType = new TypeToken(){}.getType(); + return localVarApiClient.execute(localVarCall, localVarReturnType); + } + + /** + * 批量添加用户至聊天室白名单 (asynchronously) + * 添加多个用户至聊天室白名单。你一次最多可添加 60 个用户。用户添加至聊天室白名单后,在聊天室全员禁言时,仍可以在聊天室中发送消息。文档介绍:https://docs-im-beta.easemob.com/document/server-side/chatroom.html#%E6%89%B9%E9%87%8F%E6%B7%BB%E5%8A%A0%E7%94%A8%E6%88%B7%E8%87%B3%E8%81%8A%E5%A4%A9%E5%AE%A4%E7%99%BD%E5%90%8D%E5%8D%95 + * @param chatroomId (required) + * @param emAddMultipleUserToRoomWhiteList (optional) + * @param _callback The callback to be executed when the API call finishes + * @return The request call + * @throws ApiException If fail to process the API call, e.g. serializing the request body object + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public okhttp3.Call addMultipleUserToRoomWhiteListAsync(String chatroomId, EMAddMultipleUserToRoomWhiteList emAddMultipleUserToRoomWhiteList, final ApiCallback _callback) throws ApiException { + + okhttp3.Call localVarCall = addMultipleUserToRoomWhiteListValidateBeforeCall(chatroomId, emAddMultipleUserToRoomWhiteList, _callback); + Type localVarReturnType = new TypeToken(){}.getType(); + localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); + return localVarCall; + } + /** + * Build call for addRoomAdmin + * @param chatroomId (required) + * @param emAddRoomAdmin (optional) + * @param _callback Callback for upload/download progress + * @return Call to execute + * @throws ApiException If fail to serialize the request body object + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public okhttp3.Call addRoomAdminCall(String chatroomId, EMAddRoomAdmin emAddRoomAdmin, final ApiCallback _callback) throws ApiException { + String basePath = null; + // Operation Servers + String[] localBasePaths = new String[] { }; + + // Determine Base Path to Use + if (localCustomBaseUrl != null){ + basePath = localCustomBaseUrl; + } else if ( localBasePaths.length > 0 ) { + basePath = localBasePaths[localHostIndex]; + } else { + basePath = null; + } + + Object localVarPostBody = emAddRoomAdmin; + + // create path and map variables + String localVarPath = "/chatrooms/{chatroom_id}/admin" + .replace("{" + "chatroom_id" + "}", localVarApiClient.escapeString(chatroomId.toString())); + + List localVarQueryParams = new ArrayList(); + List localVarCollectionQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + Map localVarCookieParams = new HashMap(); + Map localVarFormParams = new HashMap(); + + final String[] localVarAccepts = { + "application/json" + }; + final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts); + if (localVarAccept != null) { + localVarHeaderParams.put("Accept", localVarAccept); + } + + final String[] localVarContentTypes = { + "application/json" + }; + final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); + if (localVarContentType != null) { + localVarHeaderParams.put("Content-Type", localVarContentType); + } + + String[] localVarAuthNames = new String[] { }; + return localVarApiClient.buildCall(basePath, localVarPath, "POST", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); + } + + @SuppressWarnings("rawtypes") + private okhttp3.Call addRoomAdminValidateBeforeCall(String chatroomId, EMAddRoomAdmin emAddRoomAdmin, final ApiCallback _callback) throws ApiException { + // verify the required parameter 'chatroomId' is set + if (chatroomId == null) { + throw new ApiException("Missing the required parameter 'chatroomId' when calling addRoomAdmin(Async)"); + } + + return addRoomAdminCall(chatroomId, emAddRoomAdmin, _callback); + + } + + /** + * 添加聊天室管理员 + * 将一个聊天室成员设置为聊天室管理员。文档介绍:https://docs-im-beta.easemob.com/document/server-side/chatroom.html#%E6%B7%BB%E5%8A%A0%E8%81%8A%E5%A4%A9%E5%AE%A4%E7%AE%A1%E7%90%86%E5%91%98 + * @param chatroomId (required) + * @param emAddRoomAdmin (optional) + * @return EMAddRoomAdminResult + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public EMAddRoomAdminResult addRoomAdmin(String chatroomId, EMAddRoomAdmin emAddRoomAdmin) throws ApiException { + ApiResponse localVarResp = addRoomAdminWithHttpInfo(chatroomId, emAddRoomAdmin); + return localVarResp.getData(); + } + + /** + * 添加聊天室管理员 + * 将一个聊天室成员设置为聊天室管理员。文档介绍:https://docs-im-beta.easemob.com/document/server-side/chatroom.html#%E6%B7%BB%E5%8A%A0%E8%81%8A%E5%A4%A9%E5%AE%A4%E7%AE%A1%E7%90%86%E5%91%98 + * @param chatroomId (required) + * @param emAddRoomAdmin (optional) + * @return ApiResponse<EMAddRoomAdminResult> + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public ApiResponse addRoomAdminWithHttpInfo(String chatroomId, EMAddRoomAdmin emAddRoomAdmin) throws ApiException { + okhttp3.Call localVarCall = addRoomAdminValidateBeforeCall(chatroomId, emAddRoomAdmin, null); + Type localVarReturnType = new TypeToken(){}.getType(); + return localVarApiClient.execute(localVarCall, localVarReturnType); + } + + /** + * 添加聊天室管理员 (asynchronously) + * 将一个聊天室成员设置为聊天室管理员。文档介绍:https://docs-im-beta.easemob.com/document/server-side/chatroom.html#%E6%B7%BB%E5%8A%A0%E8%81%8A%E5%A4%A9%E5%AE%A4%E7%AE%A1%E7%90%86%E5%91%98 + * @param chatroomId (required) + * @param emAddRoomAdmin (optional) + * @param _callback The callback to be executed when the API call finishes + * @return The request call + * @throws ApiException If fail to process the API call, e.g. serializing the request body object + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public okhttp3.Call addRoomAdminAsync(String chatroomId, EMAddRoomAdmin emAddRoomAdmin, final ApiCallback _callback) throws ApiException { + + okhttp3.Call localVarCall = addRoomAdminValidateBeforeCall(chatroomId, emAddRoomAdmin, _callback); + Type localVarReturnType = new TypeToken(){}.getType(); + localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); + return localVarCall; + } + /** + * Build call for addRoomSuperAdmin + * @param emAddRoomSuperAdmin (optional) + * @param _callback Callback for upload/download progress + * @return Call to execute + * @throws ApiException If fail to serialize the request body object + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public okhttp3.Call addRoomSuperAdminCall(EMAddRoomSuperAdmin emAddRoomSuperAdmin, final ApiCallback _callback) throws ApiException { + String basePath = null; + // Operation Servers + String[] localBasePaths = new String[] { }; + + // Determine Base Path to Use + if (localCustomBaseUrl != null){ + basePath = localCustomBaseUrl; + } else if ( localBasePaths.length > 0 ) { + basePath = localBasePaths[localHostIndex]; + } else { + basePath = null; + } + + Object localVarPostBody = emAddRoomSuperAdmin; + + // create path and map variables + String localVarPath = "/chatrooms/super_admin"; + + List localVarQueryParams = new ArrayList(); + List localVarCollectionQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + Map localVarCookieParams = new HashMap(); + Map localVarFormParams = new HashMap(); + + final String[] localVarAccepts = { + "application/json" + }; + final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts); + if (localVarAccept != null) { + localVarHeaderParams.put("Accept", localVarAccept); + } + + final String[] localVarContentTypes = { + "application/json" + }; + final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); + if (localVarContentType != null) { + localVarHeaderParams.put("Content-Type", localVarContentType); + } + + String[] localVarAuthNames = new String[] { }; + return localVarApiClient.buildCall(basePath, localVarPath, "POST", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); + } + + @SuppressWarnings("rawtypes") + private okhttp3.Call addRoomSuperAdminValidateBeforeCall(EMAddRoomSuperAdmin emAddRoomSuperAdmin, final ApiCallback _callback) throws ApiException { + return addRoomSuperAdminCall(emAddRoomSuperAdmin, _callback); + + } + + /** + * 添加超级管理员 + * 添加一个聊天室超级管理员。文档介绍:https://docs-im-beta.easemob.com/document/server-side/chatroom.html#%E6%B7%BB%E5%8A%A0%E8%B6%85%E7%BA%A7%E7%AE%A1%E7%90%86%E5%91%98 + * @param emAddRoomSuperAdmin (optional) + * @return EMAddRoomSuperAdminResult + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public EMAddRoomSuperAdminResult addRoomSuperAdmin(EMAddRoomSuperAdmin emAddRoomSuperAdmin) throws ApiException { + ApiResponse localVarResp = addRoomSuperAdminWithHttpInfo(emAddRoomSuperAdmin); + return localVarResp.getData(); + } + + /** + * 添加超级管理员 + * 添加一个聊天室超级管理员。文档介绍:https://docs-im-beta.easemob.com/document/server-side/chatroom.html#%E6%B7%BB%E5%8A%A0%E8%B6%85%E7%BA%A7%E7%AE%A1%E7%90%86%E5%91%98 + * @param emAddRoomSuperAdmin (optional) + * @return ApiResponse<EMAddRoomSuperAdminResult> + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public ApiResponse addRoomSuperAdminWithHttpInfo(EMAddRoomSuperAdmin emAddRoomSuperAdmin) throws ApiException { + okhttp3.Call localVarCall = addRoomSuperAdminValidateBeforeCall(emAddRoomSuperAdmin, null); + Type localVarReturnType = new TypeToken(){}.getType(); + return localVarApiClient.execute(localVarCall, localVarReturnType); + } + + /** + * 添加超级管理员 (asynchronously) + * 添加一个聊天室超级管理员。文档介绍:https://docs-im-beta.easemob.com/document/server-side/chatroom.html#%E6%B7%BB%E5%8A%A0%E8%B6%85%E7%BA%A7%E7%AE%A1%E7%90%86%E5%91%98 + * @param emAddRoomSuperAdmin (optional) + * @param _callback The callback to be executed when the API call finishes + * @return The request call + * @throws ApiException If fail to process the API call, e.g. serializing the request body object + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public okhttp3.Call addRoomSuperAdminAsync(EMAddRoomSuperAdmin emAddRoomSuperAdmin, final ApiCallback _callback) throws ApiException { + + okhttp3.Call localVarCall = addRoomSuperAdminValidateBeforeCall(emAddRoomSuperAdmin, _callback); + Type localVarReturnType = new TypeToken(){}.getType(); + localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); + return localVarCall; + } + /** + * Build call for addUserToRoom + * @param chatroomId (required) + * @param username (required) + * @param _callback Callback for upload/download progress + * @return Call to execute + * @throws ApiException If fail to serialize the request body object + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public okhttp3.Call addUserToRoomCall(String chatroomId, String username, final ApiCallback _callback) throws ApiException { + String basePath = null; + // Operation Servers + String[] localBasePaths = new String[] { }; + + // Determine Base Path to Use + if (localCustomBaseUrl != null){ + basePath = localCustomBaseUrl; + } else if ( localBasePaths.length > 0 ) { + basePath = localBasePaths[localHostIndex]; + } else { + basePath = null; + } + + Object localVarPostBody = null; + + // create path and map variables + String localVarPath = "/chatrooms/{chatroom_id}/users/{username}" + .replace("{" + "chatroom_id" + "}", localVarApiClient.escapeString(chatroomId.toString())) + .replace("{" + "username" + "}", localVarApiClient.escapeString(username.toString())); + + List localVarQueryParams = new ArrayList(); + List localVarCollectionQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + Map localVarCookieParams = new HashMap(); + Map localVarFormParams = new HashMap(); + + final String[] localVarAccepts = { + "application/json" + }; + final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts); + if (localVarAccept != null) { + localVarHeaderParams.put("Accept", localVarAccept); + } + + final String[] localVarContentTypes = { + }; + final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); + if (localVarContentType != null) { + localVarHeaderParams.put("Content-Type", localVarContentType); + } + + String[] localVarAuthNames = new String[] { }; + return localVarApiClient.buildCall(basePath, localVarPath, "POST", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); + } + + @SuppressWarnings("rawtypes") + private okhttp3.Call addUserToRoomValidateBeforeCall(String chatroomId, String username, final ApiCallback _callback) throws ApiException { + // verify the required parameter 'chatroomId' is set + if (chatroomId == null) { + throw new ApiException("Missing the required parameter 'chatroomId' when calling addUserToRoom(Async)"); + } + + // verify the required parameter 'username' is set + if (username == null) { + throw new ApiException("Missing the required parameter 'username' when calling addUserToRoom(Async)"); + } + + return addUserToRoomCall(chatroomId, username, _callback); + + } + + /** + * 添加单个聊天室成员 + * 向聊天室添加一个成员。如果待添加的用户在 app 中不存在或已经在聊天室中,则请求失败并返回错误码 400。文档介绍:https://docs-im-beta.easemob.com/document/server-side/chatroom.html#%E6%B7%BB%E5%8A%A0%E5%8D%95%E4%B8%AA%E8%81%8A%E5%A4%A9%E5%AE%A4%E6%88%90%E5%91%98 + * @param chatroomId (required) + * @param username (required) + * @return EMAddUserToRoomResult + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public EMAddUserToRoomResult addUserToRoom(String chatroomId, String username) throws ApiException { + ApiResponse localVarResp = addUserToRoomWithHttpInfo(chatroomId, username); + return localVarResp.getData(); + } + + /** + * 添加单个聊天室成员 + * 向聊天室添加一个成员。如果待添加的用户在 app 中不存在或已经在聊天室中,则请求失败并返回错误码 400。文档介绍:https://docs-im-beta.easemob.com/document/server-side/chatroom.html#%E6%B7%BB%E5%8A%A0%E5%8D%95%E4%B8%AA%E8%81%8A%E5%A4%A9%E5%AE%A4%E6%88%90%E5%91%98 + * @param chatroomId (required) + * @param username (required) + * @return ApiResponse<EMAddUserToRoomResult> + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public ApiResponse addUserToRoomWithHttpInfo(String chatroomId, String username) throws ApiException { + okhttp3.Call localVarCall = addUserToRoomValidateBeforeCall(chatroomId, username, null); + Type localVarReturnType = new TypeToken(){}.getType(); + return localVarApiClient.execute(localVarCall, localVarReturnType); + } + + /** + * 添加单个聊天室成员 (asynchronously) + * 向聊天室添加一个成员。如果待添加的用户在 app 中不存在或已经在聊天室中,则请求失败并返回错误码 400。文档介绍:https://docs-im-beta.easemob.com/document/server-side/chatroom.html#%E6%B7%BB%E5%8A%A0%E5%8D%95%E4%B8%AA%E8%81%8A%E5%A4%A9%E5%AE%A4%E6%88%90%E5%91%98 + * @param chatroomId (required) + * @param username (required) + * @param _callback The callback to be executed when the API call finishes + * @return The request call + * @throws ApiException If fail to process the API call, e.g. serializing the request body object + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public okhttp3.Call addUserToRoomAsync(String chatroomId, String username, final ApiCallback _callback) throws ApiException { + + okhttp3.Call localVarCall = addUserToRoomValidateBeforeCall(chatroomId, username, _callback); + Type localVarReturnType = new TypeToken(){}.getType(); + localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); + return localVarCall; + } + /** + * Build call for addUserToRoomBlockList + * @param chatroomId (required) + * @param username (required) + * @param _callback Callback for upload/download progress + * @return Call to execute + * @throws ApiException If fail to serialize the request body object + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public okhttp3.Call addUserToRoomBlockListCall(String chatroomId, String username, final ApiCallback _callback) throws ApiException { + String basePath = null; + // Operation Servers + String[] localBasePaths = new String[] { }; + + // Determine Base Path to Use + if (localCustomBaseUrl != null){ + basePath = localCustomBaseUrl; + } else if ( localBasePaths.length > 0 ) { + basePath = localBasePaths[localHostIndex]; + } else { + basePath = null; + } + + Object localVarPostBody = null; + + // create path and map variables + String localVarPath = "/chatrooms/{chatroom_id}/blocks/users/{username}" + .replace("{" + "chatroom_id" + "}", localVarApiClient.escapeString(chatroomId.toString())) + .replace("{" + "username" + "}", localVarApiClient.escapeString(username.toString())); + + List localVarQueryParams = new ArrayList(); + List localVarCollectionQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + Map localVarCookieParams = new HashMap(); + Map localVarFormParams = new HashMap(); + + final String[] localVarAccepts = { + "application/json" + }; + final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts); + if (localVarAccept != null) { + localVarHeaderParams.put("Accept", localVarAccept); + } + + final String[] localVarContentTypes = { + }; + final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); + if (localVarContentType != null) { + localVarHeaderParams.put("Content-Type", localVarContentType); + } + + String[] localVarAuthNames = new String[] { }; + return localVarApiClient.buildCall(basePath, localVarPath, "POST", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); + } + + @SuppressWarnings("rawtypes") + private okhttp3.Call addUserToRoomBlockListValidateBeforeCall(String chatroomId, String username, final ApiCallback _callback) throws ApiException { + // verify the required parameter 'chatroomId' is set + if (chatroomId == null) { + throw new ApiException("Missing the required parameter 'chatroomId' when calling addUserToRoomBlockList(Async)"); + } + + // verify the required parameter 'username' is set + if (username == null) { + throw new ApiException("Missing the required parameter 'username' when calling addUserToRoomBlockList(Async)"); + } + + return addUserToRoomBlockListCall(chatroomId, username, _callback); + + } + + /** + * 添加单个用户至聊天室黑名单 + * 查询一个聊天室黑名单中的用户列表。黑名单中的用户无法查看或收到该聊天室的信息。文档介绍:https://docs-im-beta.easemob.com/document/server-side/chatroom.html#%E6%B7%BB%E5%8A%A0%E5%8D%95%E4%B8%AA%E7%94%A8%E6%88%B7%E8%87%B3%E8%81%8A%E5%A4%A9%E5%AE%A4%E9%BB%91%E5%90%8D%E5%8D%95 + * @param chatroomId (required) + * @param username (required) + * @return EMAddUserToRoomBlockListResult + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public EMAddUserToRoomBlockListResult addUserToRoomBlockList(String chatroomId, String username) throws ApiException { + ApiResponse localVarResp = addUserToRoomBlockListWithHttpInfo(chatroomId, username); + return localVarResp.getData(); + } + + /** + * 添加单个用户至聊天室黑名单 + * 查询一个聊天室黑名单中的用户列表。黑名单中的用户无法查看或收到该聊天室的信息。文档介绍:https://docs-im-beta.easemob.com/document/server-side/chatroom.html#%E6%B7%BB%E5%8A%A0%E5%8D%95%E4%B8%AA%E7%94%A8%E6%88%B7%E8%87%B3%E8%81%8A%E5%A4%A9%E5%AE%A4%E9%BB%91%E5%90%8D%E5%8D%95 + * @param chatroomId (required) + * @param username (required) + * @return ApiResponse<EMAddUserToRoomBlockListResult> + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public ApiResponse addUserToRoomBlockListWithHttpInfo(String chatroomId, String username) throws ApiException { + okhttp3.Call localVarCall = addUserToRoomBlockListValidateBeforeCall(chatroomId, username, null); + Type localVarReturnType = new TypeToken(){}.getType(); + return localVarApiClient.execute(localVarCall, localVarReturnType); + } + + /** + * 添加单个用户至聊天室黑名单 (asynchronously) + * 查询一个聊天室黑名单中的用户列表。黑名单中的用户无法查看或收到该聊天室的信息。文档介绍:https://docs-im-beta.easemob.com/document/server-side/chatroom.html#%E6%B7%BB%E5%8A%A0%E5%8D%95%E4%B8%AA%E7%94%A8%E6%88%B7%E8%87%B3%E8%81%8A%E5%A4%A9%E5%AE%A4%E9%BB%91%E5%90%8D%E5%8D%95 + * @param chatroomId (required) + * @param username (required) + * @param _callback The callback to be executed when the API call finishes + * @return The request call + * @throws ApiException If fail to process the API call, e.g. serializing the request body object + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public okhttp3.Call addUserToRoomBlockListAsync(String chatroomId, String username, final ApiCallback _callback) throws ApiException { + + okhttp3.Call localVarCall = addUserToRoomBlockListValidateBeforeCall(chatroomId, username, _callback); + Type localVarReturnType = new TypeToken(){}.getType(); + localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); + return localVarCall; + } + /** + * Build call for addUserToRoomWhiteList + * @param chatroomId (required) + * @param username (required) + * @param _callback Callback for upload/download progress + * @return Call to execute + * @throws ApiException If fail to serialize the request body object + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public okhttp3.Call addUserToRoomWhiteListCall(String chatroomId, String username, final ApiCallback _callback) throws ApiException { + String basePath = null; + // Operation Servers + String[] localBasePaths = new String[] { }; + + // Determine Base Path to Use + if (localCustomBaseUrl != null){ + basePath = localCustomBaseUrl; + } else if ( localBasePaths.length > 0 ) { + basePath = localBasePaths[localHostIndex]; + } else { + basePath = null; + } + + Object localVarPostBody = null; + + // create path and map variables + String localVarPath = "/chatrooms/{chatroom_id}/white/users/{username}" + .replace("{" + "chatroom_id" + "}", localVarApiClient.escapeString(chatroomId.toString())) + .replace("{" + "username" + "}", localVarApiClient.escapeString(username.toString())); + + List localVarQueryParams = new ArrayList(); + List localVarCollectionQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + Map localVarCookieParams = new HashMap(); + Map localVarFormParams = new HashMap(); + + final String[] localVarAccepts = { + "application/json" + }; + final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts); + if (localVarAccept != null) { + localVarHeaderParams.put("Accept", localVarAccept); + } + + final String[] localVarContentTypes = { + }; + final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); + if (localVarContentType != null) { + localVarHeaderParams.put("Content-Type", localVarContentType); + } + + String[] localVarAuthNames = new String[] { }; + return localVarApiClient.buildCall(basePath, localVarPath, "POST", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); + } + + @SuppressWarnings("rawtypes") + private okhttp3.Call addUserToRoomWhiteListValidateBeforeCall(String chatroomId, String username, final ApiCallback _callback) throws ApiException { + // verify the required parameter 'chatroomId' is set + if (chatroomId == null) { + throw new ApiException("Missing the required parameter 'chatroomId' when calling addUserToRoomWhiteList(Async)"); + } + + // verify the required parameter 'username' is set + if (username == null) { + throw new ApiException("Missing the required parameter 'username' when calling addUserToRoomWhiteList(Async)"); + } + + return addUserToRoomWhiteListCall(chatroomId, username, _callback); + + } + + /** + * 添加单个用户至聊天室白名单 + * 将单个用户添加至聊天室白名单。用户添加至聊天室白名单后,当聊天室全员禁言时,仍可以在聊天室中发送消息。文档介绍:https://docs-im-beta.easemob.com/document/server-side/chatroom.html#%E6%B7%BB%E5%8A%A0%E5%8D%95%E4%B8%AA%E7%94%A8%E6%88%B7%E8%87%B3%E8%81%8A%E5%A4%A9%E5%AE%A4%E7%99%BD%E5%90%8D%E5%8D%95 + * @param chatroomId (required) + * @param username (required) + * @return EMAddUserToRoomWhiteListResult + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public EMAddUserToRoomWhiteListResult addUserToRoomWhiteList(String chatroomId, String username) throws ApiException { + ApiResponse localVarResp = addUserToRoomWhiteListWithHttpInfo(chatroomId, username); + return localVarResp.getData(); + } + + /** + * 添加单个用户至聊天室白名单 + * 将单个用户添加至聊天室白名单。用户添加至聊天室白名单后,当聊天室全员禁言时,仍可以在聊天室中发送消息。文档介绍:https://docs-im-beta.easemob.com/document/server-side/chatroom.html#%E6%B7%BB%E5%8A%A0%E5%8D%95%E4%B8%AA%E7%94%A8%E6%88%B7%E8%87%B3%E8%81%8A%E5%A4%A9%E5%AE%A4%E7%99%BD%E5%90%8D%E5%8D%95 + * @param chatroomId (required) + * @param username (required) + * @return ApiResponse<EMAddUserToRoomWhiteListResult> + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public ApiResponse addUserToRoomWhiteListWithHttpInfo(String chatroomId, String username) throws ApiException { + okhttp3.Call localVarCall = addUserToRoomWhiteListValidateBeforeCall(chatroomId, username, null); + Type localVarReturnType = new TypeToken(){}.getType(); + return localVarApiClient.execute(localVarCall, localVarReturnType); + } + + /** + * 添加单个用户至聊天室白名单 (asynchronously) + * 将单个用户添加至聊天室白名单。用户添加至聊天室白名单后,当聊天室全员禁言时,仍可以在聊天室中发送消息。文档介绍:https://docs-im-beta.easemob.com/document/server-side/chatroom.html#%E6%B7%BB%E5%8A%A0%E5%8D%95%E4%B8%AA%E7%94%A8%E6%88%B7%E8%87%B3%E8%81%8A%E5%A4%A9%E5%AE%A4%E7%99%BD%E5%90%8D%E5%8D%95 + * @param chatroomId (required) + * @param username (required) + * @param _callback The callback to be executed when the API call finishes + * @return The request call + * @throws ApiException If fail to process the API call, e.g. serializing the request body object + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public okhttp3.Call addUserToRoomWhiteListAsync(String chatroomId, String username, final ApiCallback _callback) throws ApiException { + + okhttp3.Call localVarCall = addUserToRoomWhiteListValidateBeforeCall(chatroomId, username, _callback); + Type localVarReturnType = new TypeToken(){}.getType(); + localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); + return localVarCall; + } + /** + * Build call for createRoom + * @param emCreateRoom (optional) + * @param _callback Callback for upload/download progress + * @return Call to execute + * @throws ApiException If fail to serialize the request body object + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public okhttp3.Call createRoomCall(EMCreateRoom emCreateRoom, final ApiCallback _callback) throws ApiException { + String basePath = null; + // Operation Servers + String[] localBasePaths = new String[] { }; + + // Determine Base Path to Use + if (localCustomBaseUrl != null){ + basePath = localCustomBaseUrl; + } else if ( localBasePaths.length > 0 ) { + basePath = localBasePaths[localHostIndex]; + } else { + basePath = null; + } + + Object localVarPostBody = emCreateRoom; + + // create path and map variables + String localVarPath = "/chatrooms"; + + List localVarQueryParams = new ArrayList(); + List localVarCollectionQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + Map localVarCookieParams = new HashMap(); + Map localVarFormParams = new HashMap(); + + final String[] localVarAccepts = { + "application/json" + }; + final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts); + if (localVarAccept != null) { + localVarHeaderParams.put("Accept", localVarAccept); + } + + final String[] localVarContentTypes = { + "application/json" + }; + final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); + if (localVarContentType != null) { + localVarHeaderParams.put("Content-Type", localVarContentType); + } + + String[] localVarAuthNames = new String[] { }; + return localVarApiClient.buildCall(basePath, localVarPath, "POST", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); + } + + @SuppressWarnings("rawtypes") + private okhttp3.Call createRoomValidateBeforeCall(EMCreateRoom emCreateRoom, final ApiCallback _callback) throws ApiException { + return createRoomCall(emCreateRoom, _callback); + + } + + /** + * 创建聊天室 + * 创建一个聊天室,需设置聊天室名称、聊天室描述、聊天室成员最大人数(包括管理员)、聊天室管理员和普通成员以及聊天室扩展信息。文档介绍:https://docs-im-beta.easemob.com/document/server-side/chatroom.html#%E5%88%9B%E5%BB%BA%E8%81%8A%E5%A4%A9%E5%AE%A4 + * @param emCreateRoom (optional) + * @return EMCreateRoomResult + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public EMCreateRoomResult createRoom(EMCreateRoom emCreateRoom) throws ApiException { + ApiResponse localVarResp = createRoomWithHttpInfo(emCreateRoom); + return localVarResp.getData(); + } + + /** + * 创建聊天室 + * 创建一个聊天室,需设置聊天室名称、聊天室描述、聊天室成员最大人数(包括管理员)、聊天室管理员和普通成员以及聊天室扩展信息。文档介绍:https://docs-im-beta.easemob.com/document/server-side/chatroom.html#%E5%88%9B%E5%BB%BA%E8%81%8A%E5%A4%A9%E5%AE%A4 + * @param emCreateRoom (optional) + * @return ApiResponse<EMCreateRoomResult> + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public ApiResponse createRoomWithHttpInfo(EMCreateRoom emCreateRoom) throws ApiException { + okhttp3.Call localVarCall = createRoomValidateBeforeCall(emCreateRoom, null); + Type localVarReturnType = new TypeToken(){}.getType(); + return localVarApiClient.execute(localVarCall, localVarReturnType); + } + + /** + * 创建聊天室 (asynchronously) + * 创建一个聊天室,需设置聊天室名称、聊天室描述、聊天室成员最大人数(包括管理员)、聊天室管理员和普通成员以及聊天室扩展信息。文档介绍:https://docs-im-beta.easemob.com/document/server-side/chatroom.html#%E5%88%9B%E5%BB%BA%E8%81%8A%E5%A4%A9%E5%AE%A4 + * @param emCreateRoom (optional) + * @param _callback The callback to be executed when the API call finishes + * @return The request call + * @throws ApiException If fail to process the API call, e.g. serializing the request body object + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public okhttp3.Call createRoomAsync(EMCreateRoom emCreateRoom, final ApiCallback _callback) throws ApiException { + + okhttp3.Call localVarCall = createRoomValidateBeforeCall(emCreateRoom, _callback); + Type localVarReturnType = new TypeToken(){}.getType(); + localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); + return localVarCall; + } + /** + * Build call for deleteRoom + * @param chatroomId (required) + * @param _callback Callback for upload/download progress + * @return Call to execute + * @throws ApiException If fail to serialize the request body object + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public okhttp3.Call deleteRoomCall(String chatroomId, final ApiCallback _callback) throws ApiException { + String basePath = null; + // Operation Servers + String[] localBasePaths = new String[] { }; + + // Determine Base Path to Use + if (localCustomBaseUrl != null){ + basePath = localCustomBaseUrl; + } else if ( localBasePaths.length > 0 ) { + basePath = localBasePaths[localHostIndex]; + } else { + basePath = null; + } + + Object localVarPostBody = null; + + // create path and map variables + String localVarPath = "/chatrooms/{chatroom_id}" + .replace("{" + "chatroom_id" + "}", localVarApiClient.escapeString(chatroomId.toString())); + + List localVarQueryParams = new ArrayList(); + List localVarCollectionQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + Map localVarCookieParams = new HashMap(); + Map localVarFormParams = new HashMap(); + + final String[] localVarAccepts = { + "application/json" + }; + final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts); + if (localVarAccept != null) { + localVarHeaderParams.put("Accept", localVarAccept); + } + + final String[] localVarContentTypes = { + }; + final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); + if (localVarContentType != null) { + localVarHeaderParams.put("Content-Type", localVarContentType); + } + + String[] localVarAuthNames = new String[] { }; + return localVarApiClient.buildCall(basePath, localVarPath, "DELETE", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); + } + + @SuppressWarnings("rawtypes") + private okhttp3.Call deleteRoomValidateBeforeCall(String chatroomId, final ApiCallback _callback) throws ApiException { + // verify the required parameter 'chatroomId' is set + if (chatroomId == null) { + throw new ApiException("Missing the required parameter 'chatroomId' when calling deleteRoom(Async)"); + } + + return deleteRoomCall(chatroomId, _callback); + + } + + /** + * 删除聊天室 + * 删除单个聊天室。如果要删除的聊天室不存在,会返回错误。文档介绍:https://docs-im-beta.easemob.com/document/server-side/chatroom.html#%E5%88%A0%E9%99%A4%E8%81%8A%E5%A4%A9%E5%AE%A4 + * @param chatroomId (required) + * @return EMDeleteRoomResult + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public EMDeleteRoomResult deleteRoom(String chatroomId) throws ApiException { + ApiResponse localVarResp = deleteRoomWithHttpInfo(chatroomId); + return localVarResp.getData(); + } + + /** + * 删除聊天室 + * 删除单个聊天室。如果要删除的聊天室不存在,会返回错误。文档介绍:https://docs-im-beta.easemob.com/document/server-side/chatroom.html#%E5%88%A0%E9%99%A4%E8%81%8A%E5%A4%A9%E5%AE%A4 + * @param chatroomId (required) + * @return ApiResponse<EMDeleteRoomResult> + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public ApiResponse deleteRoomWithHttpInfo(String chatroomId) throws ApiException { + okhttp3.Call localVarCall = deleteRoomValidateBeforeCall(chatroomId, null); + Type localVarReturnType = new TypeToken(){}.getType(); + return localVarApiClient.execute(localVarCall, localVarReturnType); + } + + /** + * 删除聊天室 (asynchronously) + * 删除单个聊天室。如果要删除的聊天室不存在,会返回错误。文档介绍:https://docs-im-beta.easemob.com/document/server-side/chatroom.html#%E5%88%A0%E9%99%A4%E8%81%8A%E5%A4%A9%E5%AE%A4 + * @param chatroomId (required) + * @param _callback The callback to be executed when the API call finishes + * @return The request call + * @throws ApiException If fail to process the API call, e.g. serializing the request body object + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public okhttp3.Call deleteRoomAsync(String chatroomId, final ApiCallback _callback) throws ApiException { + + okhttp3.Call localVarCall = deleteRoomValidateBeforeCall(chatroomId, _callback); + Type localVarReturnType = new TypeToken(){}.getType(); + localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); + return localVarCall; + } + /** + * Build call for deleteRoomCustomAttributes + * @param chatroomId (required) + * @param username (required) + * @param emDeleteRoomCustomAttributes (optional) + * @param _callback Callback for upload/download progress + * @return Call to execute + * @throws ApiException If fail to serialize the request body object + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public okhttp3.Call deleteRoomCustomAttributesCall(String chatroomId, String username, EMDeleteRoomCustomAttributes emDeleteRoomCustomAttributes, final ApiCallback _callback) throws ApiException { + String basePath = null; + // Operation Servers + String[] localBasePaths = new String[] { }; + + // Determine Base Path to Use + if (localCustomBaseUrl != null){ + basePath = localCustomBaseUrl; + } else if ( localBasePaths.length > 0 ) { + basePath = localBasePaths[localHostIndex]; + } else { + basePath = null; + } + + Object localVarPostBody = emDeleteRoomCustomAttributes; + + // create path and map variables + String localVarPath = "/metadata/chatroom/{chatroom_id}/user/{username}" + .replace("{" + "chatroom_id" + "}", localVarApiClient.escapeString(chatroomId.toString())) + .replace("{" + "username" + "}", localVarApiClient.escapeString(username.toString())); + + List localVarQueryParams = new ArrayList(); + List localVarCollectionQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + Map localVarCookieParams = new HashMap(); + Map localVarFormParams = new HashMap(); + + final String[] localVarAccepts = { + "application/json" + }; + final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts); + if (localVarAccept != null) { + localVarHeaderParams.put("Accept", localVarAccept); + } + + final String[] localVarContentTypes = { + "application/json" + }; + final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); + if (localVarContentType != null) { + localVarHeaderParams.put("Content-Type", localVarContentType); + } + + String[] localVarAuthNames = new String[] { }; + return localVarApiClient.buildCall(basePath, localVarPath, "DELETE", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); + } + + @SuppressWarnings("rawtypes") + private okhttp3.Call deleteRoomCustomAttributesValidateBeforeCall(String chatroomId, String username, EMDeleteRoomCustomAttributes emDeleteRoomCustomAttributes, final ApiCallback _callback) throws ApiException { + // verify the required parameter 'chatroomId' is set + if (chatroomId == null) { + throw new ApiException("Missing the required parameter 'chatroomId' when calling deleteRoomCustomAttributes(Async)"); + } + + // verify the required parameter 'username' is set + if (username == null) { + throw new ApiException("Missing the required parameter 'username' when calling deleteRoomCustomAttributes(Async)"); + } + + return deleteRoomCustomAttributesCall(chatroomId, username, emDeleteRoomCustomAttributes, _callback); + + } + + /** + * 删除聊天室自定义属性 + * 用户删除其设置的聊天室自定义属性。该方法只能删除当前用户设置的聊天室自定义属性,不能删除其他成员设置的自定义属性。该方法每次最多可删除 10 个自定义属性。文档介绍:https://docs-im-beta.easemob.com/document/server-side/chatroom.html#%E5%88%A0%E9%99%A4%E8%81%8A%E5%A4%A9%E5%AE%A4%E8%87%AA%E5%AE%9A%E4%B9%89%E5%B1%9E%E6%80%A7 + * @param chatroomId (required) + * @param username (required) + * @param emDeleteRoomCustomAttributes (optional) + * @return EMDeleteRoomCustomAttributesResult + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public EMDeleteRoomCustomAttributesResult deleteRoomCustomAttributes(String chatroomId, String username, EMDeleteRoomCustomAttributes emDeleteRoomCustomAttributes) throws ApiException { + ApiResponse localVarResp = deleteRoomCustomAttributesWithHttpInfo(chatroomId, username, emDeleteRoomCustomAttributes); + return localVarResp.getData(); + } + + /** + * 删除聊天室自定义属性 + * 用户删除其设置的聊天室自定义属性。该方法只能删除当前用户设置的聊天室自定义属性,不能删除其他成员设置的自定义属性。该方法每次最多可删除 10 个自定义属性。文档介绍:https://docs-im-beta.easemob.com/document/server-side/chatroom.html#%E5%88%A0%E9%99%A4%E8%81%8A%E5%A4%A9%E5%AE%A4%E8%87%AA%E5%AE%9A%E4%B9%89%E5%B1%9E%E6%80%A7 + * @param chatroomId (required) + * @param username (required) + * @param emDeleteRoomCustomAttributes (optional) + * @return ApiResponse<EMDeleteRoomCustomAttributesResult> + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public ApiResponse deleteRoomCustomAttributesWithHttpInfo(String chatroomId, String username, EMDeleteRoomCustomAttributes emDeleteRoomCustomAttributes) throws ApiException { + okhttp3.Call localVarCall = deleteRoomCustomAttributesValidateBeforeCall(chatroomId, username, emDeleteRoomCustomAttributes, null); + Type localVarReturnType = new TypeToken(){}.getType(); + return localVarApiClient.execute(localVarCall, localVarReturnType); + } + + /** + * 删除聊天室自定义属性 (asynchronously) + * 用户删除其设置的聊天室自定义属性。该方法只能删除当前用户设置的聊天室自定义属性,不能删除其他成员设置的自定义属性。该方法每次最多可删除 10 个自定义属性。文档介绍:https://docs-im-beta.easemob.com/document/server-side/chatroom.html#%E5%88%A0%E9%99%A4%E8%81%8A%E5%A4%A9%E5%AE%A4%E8%87%AA%E5%AE%9A%E4%B9%89%E5%B1%9E%E6%80%A7 + * @param chatroomId (required) + * @param username (required) + * @param emDeleteRoomCustomAttributes (optional) + * @param _callback The callback to be executed when the API call finishes + * @return The request call + * @throws ApiException If fail to process the API call, e.g. serializing the request body object + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public okhttp3.Call deleteRoomCustomAttributesAsync(String chatroomId, String username, EMDeleteRoomCustomAttributes emDeleteRoomCustomAttributes, final ApiCallback _callback) throws ApiException { + + okhttp3.Call localVarCall = deleteRoomCustomAttributesValidateBeforeCall(chatroomId, username, emDeleteRoomCustomAttributes, _callback); + Type localVarReturnType = new TypeToken(){}.getType(); + localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); + return localVarCall; + } + /** + * Build call for forceDeleteRoomCustomAttributes + * @param chatroomId (required) + * @param username (required) + * @param emForceDeleteRoomCustomAttributes (optional) + * @param _callback Callback for upload/download progress + * @return Call to execute + * @throws ApiException If fail to serialize the request body object + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public okhttp3.Call forceDeleteRoomCustomAttributesCall(String chatroomId, String username, EMForceDeleteRoomCustomAttributes emForceDeleteRoomCustomAttributes, final ApiCallback _callback) throws ApiException { + String basePath = null; + // Operation Servers + String[] localBasePaths = new String[] { }; + + // Determine Base Path to Use + if (localCustomBaseUrl != null){ + basePath = localCustomBaseUrl; + } else if ( localBasePaths.length > 0 ) { + basePath = localBasePaths[localHostIndex]; + } else { + basePath = null; + } + + Object localVarPostBody = emForceDeleteRoomCustomAttributes; + + // create path and map variables + String localVarPath = "/metadata/chatroom/{chatroom_id}/user/{username}/forced" + .replace("{" + "chatroom_id" + "}", localVarApiClient.escapeString(chatroomId.toString())) + .replace("{" + "username" + "}", localVarApiClient.escapeString(username.toString())); + + List localVarQueryParams = new ArrayList(); + List localVarCollectionQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + Map localVarCookieParams = new HashMap(); + Map localVarFormParams = new HashMap(); + + final String[] localVarAccepts = { + "application/json" + }; + final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts); + if (localVarAccept != null) { + localVarHeaderParams.put("Accept", localVarAccept); + } + + final String[] localVarContentTypes = { + "application/json" + }; + final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); + if (localVarContentType != null) { + localVarHeaderParams.put("Content-Type", localVarContentType); + } + + String[] localVarAuthNames = new String[] { }; + return localVarApiClient.buildCall(basePath, localVarPath, "DELETE", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); + } + + @SuppressWarnings("rawtypes") + private okhttp3.Call forceDeleteRoomCustomAttributesValidateBeforeCall(String chatroomId, String username, EMForceDeleteRoomCustomAttributes emForceDeleteRoomCustomAttributes, final ApiCallback _callback) throws ApiException { + // verify the required parameter 'chatroomId' is set + if (chatroomId == null) { + throw new ApiException("Missing the required parameter 'chatroomId' when calling forceDeleteRoomCustomAttributes(Async)"); + } + + // verify the required parameter 'username' is set + if (username == null) { + throw new ApiException("Missing the required parameter 'username' when calling forceDeleteRoomCustomAttributes(Async)"); + } + + return forceDeleteRoomCustomAttributesCall(chatroomId, username, emForceDeleteRoomCustomAttributes, _callback); + + } + + /** + * 强制删除聊天室自定义属性 + * 用户强制删除聊天室的自定义属性信息,即该方法除了会删除当前用户设置的聊天室自定义属性,还可以删除其他用户设置的自定义属性。该方法每次最多可删除 10 个自定义属性。文档介绍:https://docs-im-beta.easemob.com/document/server-side/chatroom.html#%E5%BC%BA%E5%88%B6%E5%88%A0%E9%99%A4%E8%81%8A%E5%A4%A9%E5%AE%A4%E8%87%AA%E5%AE%9A%E4%B9%89%E5%B1%9E%E6%80%A7 + * @param chatroomId (required) + * @param username (required) + * @param emForceDeleteRoomCustomAttributes (optional) + * @return EMForceDeleteRoomCustomAttributesResult + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public EMForceDeleteRoomCustomAttributesResult forceDeleteRoomCustomAttributes(String chatroomId, String username, EMForceDeleteRoomCustomAttributes emForceDeleteRoomCustomAttributes) throws ApiException { + ApiResponse localVarResp = forceDeleteRoomCustomAttributesWithHttpInfo(chatroomId, username, emForceDeleteRoomCustomAttributes); + return localVarResp.getData(); + } + + /** + * 强制删除聊天室自定义属性 + * 用户强制删除聊天室的自定义属性信息,即该方法除了会删除当前用户设置的聊天室自定义属性,还可以删除其他用户设置的自定义属性。该方法每次最多可删除 10 个自定义属性。文档介绍:https://docs-im-beta.easemob.com/document/server-side/chatroom.html#%E5%BC%BA%E5%88%B6%E5%88%A0%E9%99%A4%E8%81%8A%E5%A4%A9%E5%AE%A4%E8%87%AA%E5%AE%9A%E4%B9%89%E5%B1%9E%E6%80%A7 + * @param chatroomId (required) + * @param username (required) + * @param emForceDeleteRoomCustomAttributes (optional) + * @return ApiResponse<EMForceDeleteRoomCustomAttributesResult> + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public ApiResponse forceDeleteRoomCustomAttributesWithHttpInfo(String chatroomId, String username, EMForceDeleteRoomCustomAttributes emForceDeleteRoomCustomAttributes) throws ApiException { + okhttp3.Call localVarCall = forceDeleteRoomCustomAttributesValidateBeforeCall(chatroomId, username, emForceDeleteRoomCustomAttributes, null); + Type localVarReturnType = new TypeToken(){}.getType(); + return localVarApiClient.execute(localVarCall, localVarReturnType); + } + + /** + * 强制删除聊天室自定义属性 (asynchronously) + * 用户强制删除聊天室的自定义属性信息,即该方法除了会删除当前用户设置的聊天室自定义属性,还可以删除其他用户设置的自定义属性。该方法每次最多可删除 10 个自定义属性。文档介绍:https://docs-im-beta.easemob.com/document/server-side/chatroom.html#%E5%BC%BA%E5%88%B6%E5%88%A0%E9%99%A4%E8%81%8A%E5%A4%A9%E5%AE%A4%E8%87%AA%E5%AE%9A%E4%B9%89%E5%B1%9E%E6%80%A7 + * @param chatroomId (required) + * @param username (required) + * @param emForceDeleteRoomCustomAttributes (optional) + * @param _callback The callback to be executed when the API call finishes + * @return The request call + * @throws ApiException If fail to process the API call, e.g. serializing the request body object + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public okhttp3.Call forceDeleteRoomCustomAttributesAsync(String chatroomId, String username, EMForceDeleteRoomCustomAttributes emForceDeleteRoomCustomAttributes, final ApiCallback _callback) throws ApiException { + + okhttp3.Call localVarCall = forceDeleteRoomCustomAttributesValidateBeforeCall(chatroomId, username, emForceDeleteRoomCustomAttributes, _callback); + Type localVarReturnType = new TypeToken(){}.getType(); + localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); + return localVarCall; + } + /** + * Build call for forceSetRoomCustomAttributes + * @param chatroomId (required) + * @param username (required) + * @param emForceSetRoomCustomAttributes (optional) + * @param _callback Callback for upload/download progress + * @return Call to execute + * @throws ApiException If fail to serialize the request body object + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public okhttp3.Call forceSetRoomCustomAttributesCall(String chatroomId, String username, EMForceSetRoomCustomAttributes emForceSetRoomCustomAttributes, final ApiCallback _callback) throws ApiException { + String basePath = null; + // Operation Servers + String[] localBasePaths = new String[] { }; + + // Determine Base Path to Use + if (localCustomBaseUrl != null){ + basePath = localCustomBaseUrl; + } else if ( localBasePaths.length > 0 ) { + basePath = localBasePaths[localHostIndex]; + } else { + basePath = null; + } + + Object localVarPostBody = emForceSetRoomCustomAttributes; + + // create path and map variables + String localVarPath = "/metadata/chatroom/{chatroom_id}/user/{username}/forced" + .replace("{" + "chatroom_id" + "}", localVarApiClient.escapeString(chatroomId.toString())) + .replace("{" + "username" + "}", localVarApiClient.escapeString(username.toString())); + + List localVarQueryParams = new ArrayList(); + List localVarCollectionQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + Map localVarCookieParams = new HashMap(); + Map localVarFormParams = new HashMap(); + + final String[] localVarAccepts = { + "application/json" + }; + final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts); + if (localVarAccept != null) { + localVarHeaderParams.put("Accept", localVarAccept); + } + + final String[] localVarContentTypes = { + "application/json" + }; + final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); + if (localVarContentType != null) { + localVarHeaderParams.put("Content-Type", localVarContentType); + } + + String[] localVarAuthNames = new String[] { }; + return localVarApiClient.buildCall(basePath, localVarPath, "PUT", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); + } + + @SuppressWarnings("rawtypes") + private okhttp3.Call forceSetRoomCustomAttributesValidateBeforeCall(String chatroomId, String username, EMForceSetRoomCustomAttributes emForceSetRoomCustomAttributes, final ApiCallback _callback) throws ApiException { + // verify the required parameter 'chatroomId' is set + if (chatroomId == null) { + throw new ApiException("Missing the required parameter 'chatroomId' when calling forceSetRoomCustomAttributes(Async)"); + } + + // verify the required parameter 'username' is set + if (username == null) { + throw new ApiException("Missing the required parameter 'username' when calling forceSetRoomCustomAttributes(Async)"); + } + + return forceSetRoomCustomAttributesCall(chatroomId, username, emForceSetRoomCustomAttributes, _callback); + + } + + /** + * 强制设置聊天室自定义属性 + * 用户强制设置指定聊天室的自定义属性信息,即该方法可覆盖其他用户设置的聊天室自定义属性。文档介绍:https://docs-im-beta.easemob.com/document/server-side/chatroom.html#%E5%BC%BA%E5%88%B6%E8%AE%BE%E7%BD%AE%E8%81%8A%E5%A4%A9%E5%AE%A4%E8%87%AA%E5%AE%9A%E4%B9%89%E5%B1%9E%E6%80%A7 + * @param chatroomId (required) + * @param username (required) + * @param emForceSetRoomCustomAttributes (optional) + * @return EMForceSetRoomCustomAttributesResult + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public EMForceSetRoomCustomAttributesResult forceSetRoomCustomAttributes(String chatroomId, String username, EMForceSetRoomCustomAttributes emForceSetRoomCustomAttributes) throws ApiException { + ApiResponse localVarResp = forceSetRoomCustomAttributesWithHttpInfo(chatroomId, username, emForceSetRoomCustomAttributes); + return localVarResp.getData(); + } + + /** + * 强制设置聊天室自定义属性 + * 用户强制设置指定聊天室的自定义属性信息,即该方法可覆盖其他用户设置的聊天室自定义属性。文档介绍:https://docs-im-beta.easemob.com/document/server-side/chatroom.html#%E5%BC%BA%E5%88%B6%E8%AE%BE%E7%BD%AE%E8%81%8A%E5%A4%A9%E5%AE%A4%E8%87%AA%E5%AE%9A%E4%B9%89%E5%B1%9E%E6%80%A7 + * @param chatroomId (required) + * @param username (required) + * @param emForceSetRoomCustomAttributes (optional) + * @return ApiResponse<EMForceSetRoomCustomAttributesResult> + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public ApiResponse forceSetRoomCustomAttributesWithHttpInfo(String chatroomId, String username, EMForceSetRoomCustomAttributes emForceSetRoomCustomAttributes) throws ApiException { + okhttp3.Call localVarCall = forceSetRoomCustomAttributesValidateBeforeCall(chatroomId, username, emForceSetRoomCustomAttributes, null); + Type localVarReturnType = new TypeToken(){}.getType(); + return localVarApiClient.execute(localVarCall, localVarReturnType); + } + + /** + * 强制设置聊天室自定义属性 (asynchronously) + * 用户强制设置指定聊天室的自定义属性信息,即该方法可覆盖其他用户设置的聊天室自定义属性。文档介绍:https://docs-im-beta.easemob.com/document/server-side/chatroom.html#%E5%BC%BA%E5%88%B6%E8%AE%BE%E7%BD%AE%E8%81%8A%E5%A4%A9%E5%AE%A4%E8%87%AA%E5%AE%9A%E4%B9%89%E5%B1%9E%E6%80%A7 + * @param chatroomId (required) + * @param username (required) + * @param emForceSetRoomCustomAttributes (optional) + * @param _callback The callback to be executed when the API call finishes + * @return The request call + * @throws ApiException If fail to process the API call, e.g. serializing the request body object + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public okhttp3.Call forceSetRoomCustomAttributesAsync(String chatroomId, String username, EMForceSetRoomCustomAttributes emForceSetRoomCustomAttributes, final ApiCallback _callback) throws ApiException { + + okhttp3.Call localVarCall = forceSetRoomCustomAttributesValidateBeforeCall(chatroomId, username, emForceSetRoomCustomAttributes, _callback); + Type localVarReturnType = new TypeToken(){}.getType(); + localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); + return localVarCall; + } + /** + * Build call for getMuteRoomMemberList + * @param chatroomId (required) + * @param _callback Callback for upload/download progress + * @return Call to execute + * @throws ApiException If fail to serialize the request body object + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public okhttp3.Call getMuteRoomMemberListCall(String chatroomId, final ApiCallback _callback) throws ApiException { + String basePath = null; + // Operation Servers + String[] localBasePaths = new String[] { }; + + // Determine Base Path to Use + if (localCustomBaseUrl != null){ + basePath = localCustomBaseUrl; + } else if ( localBasePaths.length > 0 ) { + basePath = localBasePaths[localHostIndex]; + } else { + basePath = null; + } + + Object localVarPostBody = null; + + // create path and map variables + String localVarPath = "/chatrooms/{chatroom_id}/mute" + .replace("{" + "chatroom_id" + "}", localVarApiClient.escapeString(chatroomId.toString())); + + List localVarQueryParams = new ArrayList(); + List localVarCollectionQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + Map localVarCookieParams = new HashMap(); + Map localVarFormParams = new HashMap(); + + final String[] localVarAccepts = { + "application/json" + }; + final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts); + if (localVarAccept != null) { + localVarHeaderParams.put("Accept", localVarAccept); + } + + final String[] localVarContentTypes = { + }; + final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); + if (localVarContentType != null) { + localVarHeaderParams.put("Content-Type", localVarContentType); + } + + String[] localVarAuthNames = new String[] { }; + return localVarApiClient.buildCall(basePath, localVarPath, "GET", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); + } + + @SuppressWarnings("rawtypes") + private okhttp3.Call getMuteRoomMemberListValidateBeforeCall(String chatroomId, final ApiCallback _callback) throws ApiException { + // verify the required parameter 'chatroomId' is set + if (chatroomId == null) { + throw new ApiException("Missing the required parameter 'chatroomId' when calling getMuteRoomMemberList(Async)"); + } + + return getMuteRoomMemberListCall(chatroomId, _callback); + + } + + /** + * 获取禁言列表 + * 获取当前聊天室的禁言用户列表。文档介绍:https://docs-im-beta.easemob.com/document/server-side/chatroom.html#%E8%8E%B7%E5%8F%96%E7%A6%81%E8%A8%80%E5%88%97%E8%A1%A8 + * @param chatroomId (required) + * @return EMGetMuteRoomMemberListResult + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public EMGetMuteRoomMemberListResult getMuteRoomMemberList(String chatroomId) throws ApiException { + ApiResponse localVarResp = getMuteRoomMemberListWithHttpInfo(chatroomId); + return localVarResp.getData(); + } + + /** + * 获取禁言列表 + * 获取当前聊天室的禁言用户列表。文档介绍:https://docs-im-beta.easemob.com/document/server-side/chatroom.html#%E8%8E%B7%E5%8F%96%E7%A6%81%E8%A8%80%E5%88%97%E8%A1%A8 + * @param chatroomId (required) + * @return ApiResponse<EMGetMuteRoomMemberListResult> + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public ApiResponse getMuteRoomMemberListWithHttpInfo(String chatroomId) throws ApiException { + okhttp3.Call localVarCall = getMuteRoomMemberListValidateBeforeCall(chatroomId, null); + Type localVarReturnType = new TypeToken(){}.getType(); + return localVarApiClient.execute(localVarCall, localVarReturnType); + } + + /** + * 获取禁言列表 (asynchronously) + * 获取当前聊天室的禁言用户列表。文档介绍:https://docs-im-beta.easemob.com/document/server-side/chatroom.html#%E8%8E%B7%E5%8F%96%E7%A6%81%E8%A8%80%E5%88%97%E8%A1%A8 + * @param chatroomId (required) + * @param _callback The callback to be executed when the API call finishes + * @return The request call + * @throws ApiException If fail to process the API call, e.g. serializing the request body object + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public okhttp3.Call getMuteRoomMemberListAsync(String chatroomId, final ApiCallback _callback) throws ApiException { + + okhttp3.Call localVarCall = getMuteRoomMemberListValidateBeforeCall(chatroomId, _callback); + Type localVarReturnType = new TypeToken(){}.getType(); + localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); + return localVarCall; + } + /** + * Build call for getRoomAdminList + * @param chatroomId (required) + * @param _callback Callback for upload/download progress + * @return Call to execute + * @throws ApiException If fail to serialize the request body object + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public okhttp3.Call getRoomAdminListCall(String chatroomId, final ApiCallback _callback) throws ApiException { + String basePath = null; + // Operation Servers + String[] localBasePaths = new String[] { }; + + // Determine Base Path to Use + if (localCustomBaseUrl != null){ + basePath = localCustomBaseUrl; + } else if ( localBasePaths.length > 0 ) { + basePath = localBasePaths[localHostIndex]; + } else { + basePath = null; + } + + Object localVarPostBody = null; + + // create path and map variables + String localVarPath = "/chatrooms/{chatroom_id}/admin" + .replace("{" + "chatroom_id" + "}", localVarApiClient.escapeString(chatroomId.toString())); + + List localVarQueryParams = new ArrayList(); + List localVarCollectionQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + Map localVarCookieParams = new HashMap(); + Map localVarFormParams = new HashMap(); + + final String[] localVarAccepts = { + "application/json" + }; + final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts); + if (localVarAccept != null) { + localVarHeaderParams.put("Accept", localVarAccept); + } + + final String[] localVarContentTypes = { + }; + final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); + if (localVarContentType != null) { + localVarHeaderParams.put("Content-Type", localVarContentType); + } + + String[] localVarAuthNames = new String[] { }; + return localVarApiClient.buildCall(basePath, localVarPath, "GET", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); + } + + @SuppressWarnings("rawtypes") + private okhttp3.Call getRoomAdminListValidateBeforeCall(String chatroomId, final ApiCallback _callback) throws ApiException { + // verify the required parameter 'chatroomId' is set + if (chatroomId == null) { + throw new ApiException("Missing the required parameter 'chatroomId' when calling getRoomAdminList(Async)"); + } + + return getRoomAdminListCall(chatroomId, _callback); + + } + + /** + * 获取聊天室管理员列表 + * 获取聊天室管理员列表的接口。文档介绍:https://docs-im-beta.easemob.com/document/server-side/chatroom.html#%E8%8E%B7%E5%8F%96%E8%81%8A%E5%A4%A9%E5%AE%A4%E7%AE%A1%E7%90%86%E5%91%98%E5%88%97%E8%A1%A8 + * @param chatroomId (required) + * @return EMGetRoomAdminListResult + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public EMGetRoomAdminListResult getRoomAdminList(String chatroomId) throws ApiException { + ApiResponse localVarResp = getRoomAdminListWithHttpInfo(chatroomId); + return localVarResp.getData(); + } + + /** + * 获取聊天室管理员列表 + * 获取聊天室管理员列表的接口。文档介绍:https://docs-im-beta.easemob.com/document/server-side/chatroom.html#%E8%8E%B7%E5%8F%96%E8%81%8A%E5%A4%A9%E5%AE%A4%E7%AE%A1%E7%90%86%E5%91%98%E5%88%97%E8%A1%A8 + * @param chatroomId (required) + * @return ApiResponse<EMGetRoomAdminListResult> + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public ApiResponse getRoomAdminListWithHttpInfo(String chatroomId) throws ApiException { + okhttp3.Call localVarCall = getRoomAdminListValidateBeforeCall(chatroomId, null); + Type localVarReturnType = new TypeToken(){}.getType(); + return localVarApiClient.execute(localVarCall, localVarReturnType); + } + + /** + * 获取聊天室管理员列表 (asynchronously) + * 获取聊天室管理员列表的接口。文档介绍:https://docs-im-beta.easemob.com/document/server-side/chatroom.html#%E8%8E%B7%E5%8F%96%E8%81%8A%E5%A4%A9%E5%AE%A4%E7%AE%A1%E7%90%86%E5%91%98%E5%88%97%E8%A1%A8 + * @param chatroomId (required) + * @param _callback The callback to be executed when the API call finishes + * @return The request call + * @throws ApiException If fail to process the API call, e.g. serializing the request body object + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public okhttp3.Call getRoomAdminListAsync(String chatroomId, final ApiCallback _callback) throws ApiException { + + okhttp3.Call localVarCall = getRoomAdminListValidateBeforeCall(chatroomId, _callback); + Type localVarReturnType = new TypeToken(){}.getType(); + localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); + return localVarCall; + } + /** + * Build call for getRoomAnnouncement + * @param chatroomId (required) + * @param _callback Callback for upload/download progress + * @return Call to execute + * @throws ApiException If fail to serialize the request body object + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public okhttp3.Call getRoomAnnouncementCall(String chatroomId, final ApiCallback _callback) throws ApiException { + String basePath = null; + // Operation Servers + String[] localBasePaths = new String[] { }; + + // Determine Base Path to Use + if (localCustomBaseUrl != null){ + basePath = localCustomBaseUrl; + } else if ( localBasePaths.length > 0 ) { + basePath = localBasePaths[localHostIndex]; + } else { + basePath = null; + } + + Object localVarPostBody = null; + + // create path and map variables + String localVarPath = "/chatrooms/{chatroom_id}/announcement" + .replace("{" + "chatroom_id" + "}", localVarApiClient.escapeString(chatroomId.toString())); + + List localVarQueryParams = new ArrayList(); + List localVarCollectionQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + Map localVarCookieParams = new HashMap(); + Map localVarFormParams = new HashMap(); + + final String[] localVarAccepts = { + "application/json" + }; + final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts); + if (localVarAccept != null) { + localVarHeaderParams.put("Accept", localVarAccept); + } + + final String[] localVarContentTypes = { + }; + final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); + if (localVarContentType != null) { + localVarHeaderParams.put("Content-Type", localVarContentType); + } + + String[] localVarAuthNames = new String[] { }; + return localVarApiClient.buildCall(basePath, localVarPath, "GET", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); + } + + @SuppressWarnings("rawtypes") + private okhttp3.Call getRoomAnnouncementValidateBeforeCall(String chatroomId, final ApiCallback _callback) throws ApiException { + // verify the required parameter 'chatroomId' is set + if (chatroomId == null) { + throw new ApiException("Missing the required parameter 'chatroomId' when calling getRoomAnnouncement(Async)"); + } + + return getRoomAnnouncementCall(chatroomId, _callback); + + } + + /** + * 获取聊天室公告 + * 获取指定聊天室 ID 的聊天室公告。文档介绍:https://docs-im-beta.easemob.com/document/server-side/chatroom.html#%E8%8E%B7%E5%8F%96%E8%81%8A%E5%A4%A9%E5%AE%A4%E5%85%AC%E5%91%8A + * @param chatroomId (required) + * @return EMGetRoomAnnouncementResult + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public EMGetRoomAnnouncementResult getRoomAnnouncement(String chatroomId) throws ApiException { + ApiResponse localVarResp = getRoomAnnouncementWithHttpInfo(chatroomId); + return localVarResp.getData(); + } + + /** + * 获取聊天室公告 + * 获取指定聊天室 ID 的聊天室公告。文档介绍:https://docs-im-beta.easemob.com/document/server-side/chatroom.html#%E8%8E%B7%E5%8F%96%E8%81%8A%E5%A4%A9%E5%AE%A4%E5%85%AC%E5%91%8A + * @param chatroomId (required) + * @return ApiResponse<EMGetRoomAnnouncementResult> + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public ApiResponse getRoomAnnouncementWithHttpInfo(String chatroomId) throws ApiException { + okhttp3.Call localVarCall = getRoomAnnouncementValidateBeforeCall(chatroomId, null); + Type localVarReturnType = new TypeToken(){}.getType(); + return localVarApiClient.execute(localVarCall, localVarReturnType); + } + + /** + * 获取聊天室公告 (asynchronously) + * 获取指定聊天室 ID 的聊天室公告。文档介绍:https://docs-im-beta.easemob.com/document/server-side/chatroom.html#%E8%8E%B7%E5%8F%96%E8%81%8A%E5%A4%A9%E5%AE%A4%E5%85%AC%E5%91%8A + * @param chatroomId (required) + * @param _callback The callback to be executed when the API call finishes + * @return The request call + * @throws ApiException If fail to process the API call, e.g. serializing the request body object + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public okhttp3.Call getRoomAnnouncementAsync(String chatroomId, final ApiCallback _callback) throws ApiException { + + okhttp3.Call localVarCall = getRoomAnnouncementValidateBeforeCall(chatroomId, _callback); + Type localVarReturnType = new TypeToken(){}.getType(); + localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); + return localVarCall; + } + /** + * Build call for getRoomBlockList + * @param chatroomId (required) + * @param _callback Callback for upload/download progress + * @return Call to execute + * @throws ApiException If fail to serialize the request body object + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public okhttp3.Call getRoomBlockListCall(String chatroomId, final ApiCallback _callback) throws ApiException { + String basePath = null; + // Operation Servers + String[] localBasePaths = new String[] { }; + + // Determine Base Path to Use + if (localCustomBaseUrl != null){ + basePath = localCustomBaseUrl; + } else if ( localBasePaths.length > 0 ) { + basePath = localBasePaths[localHostIndex]; + } else { + basePath = null; + } + + Object localVarPostBody = null; + + // create path and map variables + String localVarPath = "/chatrooms/{chatroom_id}/blocks/users" + .replace("{" + "chatroom_id" + "}", localVarApiClient.escapeString(chatroomId.toString())); + + List localVarQueryParams = new ArrayList(); + List localVarCollectionQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + Map localVarCookieParams = new HashMap(); + Map localVarFormParams = new HashMap(); + + final String[] localVarAccepts = { + "application/json" + }; + final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts); + if (localVarAccept != null) { + localVarHeaderParams.put("Accept", localVarAccept); + } + + final String[] localVarContentTypes = { + }; + final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); + if (localVarContentType != null) { + localVarHeaderParams.put("Content-Type", localVarContentType); + } + + String[] localVarAuthNames = new String[] { }; + return localVarApiClient.buildCall(basePath, localVarPath, "GET", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); + } + + @SuppressWarnings("rawtypes") + private okhttp3.Call getRoomBlockListValidateBeforeCall(String chatroomId, final ApiCallback _callback) throws ApiException { + // verify the required parameter 'chatroomId' is set + if (chatroomId == null) { + throw new ApiException("Missing the required parameter 'chatroomId' when calling getRoomBlockList(Async)"); + } + + return getRoomBlockListCall(chatroomId, _callback); + + } + + /** + * 查询聊天室黑名单 + * 查询一个聊天室黑名单中的用户列表。黑名单中的用户无法查看或收到该聊天室的信息。文档介绍:https://docs-im-beta.easemob.com/document/server-side/chatroom.html#%E6%9F%A5%E8%AF%A2%E8%81%8A%E5%A4%A9%E5%AE%A4%E9%BB%91%E5%90%8D%E5%8D%95 + * @param chatroomId (required) + * @return EMGetRoomBlockListResult + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public EMGetRoomBlockListResult getRoomBlockList(String chatroomId) throws ApiException { + ApiResponse localVarResp = getRoomBlockListWithHttpInfo(chatroomId); + return localVarResp.getData(); + } + + /** + * 查询聊天室黑名单 + * 查询一个聊天室黑名单中的用户列表。黑名单中的用户无法查看或收到该聊天室的信息。文档介绍:https://docs-im-beta.easemob.com/document/server-side/chatroom.html#%E6%9F%A5%E8%AF%A2%E8%81%8A%E5%A4%A9%E5%AE%A4%E9%BB%91%E5%90%8D%E5%8D%95 + * @param chatroomId (required) + * @return ApiResponse<EMGetRoomBlockListResult> + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public ApiResponse getRoomBlockListWithHttpInfo(String chatroomId) throws ApiException { + okhttp3.Call localVarCall = getRoomBlockListValidateBeforeCall(chatroomId, null); + Type localVarReturnType = new TypeToken(){}.getType(); + return localVarApiClient.execute(localVarCall, localVarReturnType); + } + + /** + * 查询聊天室黑名单 (asynchronously) + * 查询一个聊天室黑名单中的用户列表。黑名单中的用户无法查看或收到该聊天室的信息。文档介绍:https://docs-im-beta.easemob.com/document/server-side/chatroom.html#%E6%9F%A5%E8%AF%A2%E8%81%8A%E5%A4%A9%E5%AE%A4%E9%BB%91%E5%90%8D%E5%8D%95 + * @param chatroomId (required) + * @param _callback The callback to be executed when the API call finishes + * @return The request call + * @throws ApiException If fail to process the API call, e.g. serializing the request body object + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public okhttp3.Call getRoomBlockListAsync(String chatroomId, final ApiCallback _callback) throws ApiException { + + okhttp3.Call localVarCall = getRoomBlockListValidateBeforeCall(chatroomId, _callback); + Type localVarReturnType = new TypeToken(){}.getType(); + localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); + return localVarCall; + } + /** + * Build call for getRoomCustomAttributes + * @param chatroomId (required) + * @param emGetRoomCustomAttributes (optional) + * @param _callback Callback for upload/download progress + * @return Call to execute + * @throws ApiException If fail to serialize the request body object + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public okhttp3.Call getRoomCustomAttributesCall(String chatroomId, EMGetRoomCustomAttributes emGetRoomCustomAttributes, final ApiCallback _callback) throws ApiException { + String basePath = null; + // Operation Servers + String[] localBasePaths = new String[] { }; + + // Determine Base Path to Use + if (localCustomBaseUrl != null){ + basePath = localCustomBaseUrl; + } else if ( localBasePaths.length > 0 ) { + basePath = localBasePaths[localHostIndex]; + } else { + basePath = null; + } + + Object localVarPostBody = emGetRoomCustomAttributes; + + // create path and map variables + String localVarPath = "/metadata/chatroom/{chatroom_id}" + .replace("{" + "chatroom_id" + "}", localVarApiClient.escapeString(chatroomId.toString())); + + List localVarQueryParams = new ArrayList(); + List localVarCollectionQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + Map localVarCookieParams = new HashMap(); + Map localVarFormParams = new HashMap(); + + final String[] localVarAccepts = { + "application/json" + }; + final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts); + if (localVarAccept != null) { + localVarHeaderParams.put("Accept", localVarAccept); + } + + final String[] localVarContentTypes = { + "application/json" + }; + final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); + if (localVarContentType != null) { + localVarHeaderParams.put("Content-Type", localVarContentType); + } + + String[] localVarAuthNames = new String[] { }; + return localVarApiClient.buildCall(basePath, localVarPath, "POST", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); + } + + @SuppressWarnings("rawtypes") + private okhttp3.Call getRoomCustomAttributesValidateBeforeCall(String chatroomId, EMGetRoomCustomAttributes emGetRoomCustomAttributes, final ApiCallback _callback) throws ApiException { + // verify the required parameter 'chatroomId' is set + if (chatroomId == null) { + throw new ApiException("Missing the required parameter 'chatroomId' when calling getRoomCustomAttributes(Async)"); + } + + return getRoomCustomAttributesCall(chatroomId, emGetRoomCustomAttributes, _callback); + + } + + /** + * 获取聊天室自定义属性 + * 获取指定聊天室的自定义属性信息。文档介绍:https://docs-im-beta.easemob.com/document/server-side/chatroom.html#%E8%8E%B7%E5%8F%96%E8%81%8A%E5%A4%A9%E5%AE%A4%E8%87%AA%E5%AE%9A%E4%B9%89%E5%B1%9E%E6%80%A7 + * @param chatroomId (required) + * @param emGetRoomCustomAttributes (optional) + * @return EMGetRoomCustomAttributesResult + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public EMGetRoomCustomAttributesResult getRoomCustomAttributes(String chatroomId, EMGetRoomCustomAttributes emGetRoomCustomAttributes) throws ApiException { + ApiResponse localVarResp = getRoomCustomAttributesWithHttpInfo(chatroomId, emGetRoomCustomAttributes); + return localVarResp.getData(); + } + + /** + * 获取聊天室自定义属性 + * 获取指定聊天室的自定义属性信息。文档介绍:https://docs-im-beta.easemob.com/document/server-side/chatroom.html#%E8%8E%B7%E5%8F%96%E8%81%8A%E5%A4%A9%E5%AE%A4%E8%87%AA%E5%AE%9A%E4%B9%89%E5%B1%9E%E6%80%A7 + * @param chatroomId (required) + * @param emGetRoomCustomAttributes (optional) + * @return ApiResponse<EMGetRoomCustomAttributesResult> + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public ApiResponse getRoomCustomAttributesWithHttpInfo(String chatroomId, EMGetRoomCustomAttributes emGetRoomCustomAttributes) throws ApiException { + okhttp3.Call localVarCall = getRoomCustomAttributesValidateBeforeCall(chatroomId, emGetRoomCustomAttributes, null); + Type localVarReturnType = new TypeToken(){}.getType(); + return localVarApiClient.execute(localVarCall, localVarReturnType); + } + + /** + * 获取聊天室自定义属性 (asynchronously) + * 获取指定聊天室的自定义属性信息。文档介绍:https://docs-im-beta.easemob.com/document/server-side/chatroom.html#%E8%8E%B7%E5%8F%96%E8%81%8A%E5%A4%A9%E5%AE%A4%E8%87%AA%E5%AE%9A%E4%B9%89%E5%B1%9E%E6%80%A7 + * @param chatroomId (required) + * @param emGetRoomCustomAttributes (optional) + * @param _callback The callback to be executed when the API call finishes + * @return The request call + * @throws ApiException If fail to process the API call, e.g. serializing the request body object + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public okhttp3.Call getRoomCustomAttributesAsync(String chatroomId, EMGetRoomCustomAttributes emGetRoomCustomAttributes, final ApiCallback _callback) throws ApiException { + + okhttp3.Call localVarCall = getRoomCustomAttributesValidateBeforeCall(chatroomId, emGetRoomCustomAttributes, _callback); + Type localVarReturnType = new TypeToken(){}.getType(); + localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); + return localVarCall; + } + /** + * Build call for getRoomInfo + * @param chatroomId (required) + * @param _callback Callback for upload/download progress + * @return Call to execute + * @throws ApiException If fail to serialize the request body object + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public okhttp3.Call getRoomInfoCall(String chatroomId, final ApiCallback _callback) throws ApiException { + String basePath = null; + // Operation Servers + String[] localBasePaths = new String[] { }; + + // Determine Base Path to Use + if (localCustomBaseUrl != null){ + basePath = localCustomBaseUrl; + } else if ( localBasePaths.length > 0 ) { + basePath = localBasePaths[localHostIndex]; + } else { + basePath = null; + } + + Object localVarPostBody = null; + + // create path and map variables + String localVarPath = "/chatrooms/{chatroom_id}" + .replace("{" + "chatroom_id" + "}", localVarApiClient.escapeString(chatroomId.toString())); + + List localVarQueryParams = new ArrayList(); + List localVarCollectionQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + Map localVarCookieParams = new HashMap(); + Map localVarFormParams = new HashMap(); + + final String[] localVarAccepts = { + "application/json" + }; + final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts); + if (localVarAccept != null) { + localVarHeaderParams.put("Accept", localVarAccept); + } + + final String[] localVarContentTypes = { + }; + final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); + if (localVarContentType != null) { + localVarHeaderParams.put("Content-Type", localVarContentType); + } + + String[] localVarAuthNames = new String[] { }; + return localVarApiClient.buildCall(basePath, localVarPath, "GET", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); + } + + @SuppressWarnings("rawtypes") + private okhttp3.Call getRoomInfoValidateBeforeCall(String chatroomId, final ApiCallback _callback) throws ApiException { + // verify the required parameter 'chatroomId' is set + if (chatroomId == null) { + throw new ApiException("Missing the required parameter 'chatroomId' when calling getRoomInfo(Async)"); + } + + return getRoomInfoCall(chatroomId, _callback); + + } + + /** + * 查询聊天室详情 + * 查询一个聊天室的详情。文档介绍:https://docs-im-beta.easemob.com/document/server-side/chatroom.html#%E6%9F%A5%E8%AF%A2%E8%81%8A%E5%A4%A9%E5%AE%A4%E8%AF%A6%E6%83%85 + * @param chatroomId (required) + * @return EMGetRoomInfoResult + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public EMGetRoomInfoResult getRoomInfo(String chatroomId) throws ApiException { + ApiResponse localVarResp = getRoomInfoWithHttpInfo(chatroomId); + return localVarResp.getData(); + } + + /** + * 查询聊天室详情 + * 查询一个聊天室的详情。文档介绍:https://docs-im-beta.easemob.com/document/server-side/chatroom.html#%E6%9F%A5%E8%AF%A2%E8%81%8A%E5%A4%A9%E5%AE%A4%E8%AF%A6%E6%83%85 + * @param chatroomId (required) + * @return ApiResponse<EMGetRoomInfoResult> + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public ApiResponse getRoomInfoWithHttpInfo(String chatroomId) throws ApiException { + okhttp3.Call localVarCall = getRoomInfoValidateBeforeCall(chatroomId, null); + Type localVarReturnType = new TypeToken(){}.getType(); + return localVarApiClient.execute(localVarCall, localVarReturnType); + } + + /** + * 查询聊天室详情 (asynchronously) + * 查询一个聊天室的详情。文档介绍:https://docs-im-beta.easemob.com/document/server-side/chatroom.html#%E6%9F%A5%E8%AF%A2%E8%81%8A%E5%A4%A9%E5%AE%A4%E8%AF%A6%E6%83%85 + * @param chatroomId (required) + * @param _callback The callback to be executed when the API call finishes + * @return The request call + * @throws ApiException If fail to process the API call, e.g. serializing the request body object + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public okhttp3.Call getRoomInfoAsync(String chatroomId, final ApiCallback _callback) throws ApiException { + + okhttp3.Call localVarCall = getRoomInfoValidateBeforeCall(chatroomId, _callback); + Type localVarReturnType = new TypeToken(){}.getType(); + localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); + return localVarCall; + } + /** + * Build call for getRoomList + * @param limit 每次期望返回的聊天室数量。取值范围为 [1,100],默认值为 10 (optional) + * @param cursor 数据查询的起始位置 (optional) + * @param _callback Callback for upload/download progress + * @return Call to execute + * @throws ApiException If fail to serialize the request body object + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public okhttp3.Call getRoomListCall(Integer limit, String cursor, final ApiCallback _callback) throws ApiException { + String basePath = null; + // Operation Servers + String[] localBasePaths = new String[] { }; + + // Determine Base Path to Use + if (localCustomBaseUrl != null){ + basePath = localCustomBaseUrl; + } else if ( localBasePaths.length > 0 ) { + basePath = localBasePaths[localHostIndex]; + } else { + basePath = null; + } + + Object localVarPostBody = null; + + // create path and map variables + String localVarPath = "/chatrooms"; + + List localVarQueryParams = new ArrayList(); + List localVarCollectionQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + Map localVarCookieParams = new HashMap(); + Map localVarFormParams = new HashMap(); + + if (limit != null) { + localVarQueryParams.addAll(localVarApiClient.parameterToPair("limit", limit)); + } + + if (cursor != null) { + localVarQueryParams.addAll(localVarApiClient.parameterToPair("cursor", cursor)); + } + + final String[] localVarAccepts = { + "application/json" + }; + final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts); + if (localVarAccept != null) { + localVarHeaderParams.put("Accept", localVarAccept); + } + + final String[] localVarContentTypes = { + }; + final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); + if (localVarContentType != null) { + localVarHeaderParams.put("Content-Type", localVarContentType); + } + + String[] localVarAuthNames = new String[] { }; + return localVarApiClient.buildCall(basePath, localVarPath, "GET", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); + } + + @SuppressWarnings("rawtypes") + private okhttp3.Call getRoomListValidateBeforeCall(Integer limit, String cursor, final ApiCallback _callback) throws ApiException { + return getRoomListCall(limit, cursor, _callback); + + } + + /** + * 获取 app 中的聊天室 + * 分页获取应用下的聊天室列表和信息。文档介绍:https://docs-im-beta.easemob.com/document/server-side/chatroom.html#%E8%8E%B7%E5%8F%96-app-%E4%B8%AD%E7%9A%84%E8%81%8A%E5%A4%A9%E5%AE%A4 + * @param limit 每次期望返回的聊天室数量。取值范围为 [1,100],默认值为 10 (optional) + * @param cursor 数据查询的起始位置 (optional) + * @return EMGetRoomListResult + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public EMGetRoomListResult getRoomList(Integer limit, String cursor) throws ApiException { + ApiResponse localVarResp = getRoomListWithHttpInfo(limit, cursor); + return localVarResp.getData(); + } + + /** + * 获取 app 中的聊天室 + * 分页获取应用下的聊天室列表和信息。文档介绍:https://docs-im-beta.easemob.com/document/server-side/chatroom.html#%E8%8E%B7%E5%8F%96-app-%E4%B8%AD%E7%9A%84%E8%81%8A%E5%A4%A9%E5%AE%A4 + * @param limit 每次期望返回的聊天室数量。取值范围为 [1,100],默认值为 10 (optional) + * @param cursor 数据查询的起始位置 (optional) + * @return ApiResponse<EMGetRoomListResult> + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public ApiResponse getRoomListWithHttpInfo(Integer limit, String cursor) throws ApiException { + okhttp3.Call localVarCall = getRoomListValidateBeforeCall(limit, cursor, null); + Type localVarReturnType = new TypeToken(){}.getType(); + return localVarApiClient.execute(localVarCall, localVarReturnType); + } + + /** + * 获取 app 中的聊天室 (asynchronously) + * 分页获取应用下的聊天室列表和信息。文档介绍:https://docs-im-beta.easemob.com/document/server-side/chatroom.html#%E8%8E%B7%E5%8F%96-app-%E4%B8%AD%E7%9A%84%E8%81%8A%E5%A4%A9%E5%AE%A4 + * @param limit 每次期望返回的聊天室数量。取值范围为 [1,100],默认值为 10 (optional) + * @param cursor 数据查询的起始位置 (optional) + * @param _callback The callback to be executed when the API call finishes + * @return The request call + * @throws ApiException If fail to process the API call, e.g. serializing the request body object + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public okhttp3.Call getRoomListAsync(Integer limit, String cursor, final ApiCallback _callback) throws ApiException { + + okhttp3.Call localVarCall = getRoomListValidateBeforeCall(limit, cursor, _callback); + Type localVarReturnType = new TypeToken(){}.getType(); + localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); + return localVarCall; + } + /** + * Build call for getRoomMemberList + * @param chatroomId (required) + * @param pagenum 查询页码。默认值为 1 (optional) + * @param pagesize 每页显示的聊天室成员数量。默认值为 1000。取值范围为 [0,1000] (optional) + * @param _callback Callback for upload/download progress + * @return Call to execute + * @throws ApiException If fail to serialize the request body object + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public okhttp3.Call getRoomMemberListCall(String chatroomId, Integer pagenum, Integer pagesize, final ApiCallback _callback) throws ApiException { + String basePath = null; + // Operation Servers + String[] localBasePaths = new String[] { }; + + // Determine Base Path to Use + if (localCustomBaseUrl != null){ + basePath = localCustomBaseUrl; + } else if ( localBasePaths.length > 0 ) { + basePath = localBasePaths[localHostIndex]; + } else { + basePath = null; + } + + Object localVarPostBody = null; + + // create path and map variables + String localVarPath = "/chatrooms/{chatroom_id}/users" + .replace("{" + "chatroom_id" + "}", localVarApiClient.escapeString(chatroomId.toString())); + + List localVarQueryParams = new ArrayList(); + List localVarCollectionQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + Map localVarCookieParams = new HashMap(); + Map localVarFormParams = new HashMap(); + + if (pagenum != null) { + localVarQueryParams.addAll(localVarApiClient.parameterToPair("pagenum", pagenum)); + } + + if (pagesize != null) { + localVarQueryParams.addAll(localVarApiClient.parameterToPair("pagesize", pagesize)); + } + + final String[] localVarAccepts = { + "application/json" + }; + final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts); + if (localVarAccept != null) { + localVarHeaderParams.put("Accept", localVarAccept); + } + + final String[] localVarContentTypes = { + }; + final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); + if (localVarContentType != null) { + localVarHeaderParams.put("Content-Type", localVarContentType); + } + + String[] localVarAuthNames = new String[] { }; + return localVarApiClient.buildCall(basePath, localVarPath, "GET", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); + } + + @SuppressWarnings("rawtypes") + private okhttp3.Call getRoomMemberListValidateBeforeCall(String chatroomId, Integer pagenum, Integer pagesize, final ApiCallback _callback) throws ApiException { + // verify the required parameter 'chatroomId' is set + if (chatroomId == null) { + throw new ApiException("Missing the required parameter 'chatroomId' when calling getRoomMemberList(Async)"); + } + + return getRoomMemberListCall(chatroomId, pagenum, pagesize, _callback); + + } + + /** + * 分页获取聊天室成员列表 + * 可以分页获取聊天室成员列表。文档介绍:https://docs-im-beta.easemob.com/document/server-side/chatroom.html#%E5%88%86%E9%A1%B5%E8%8E%B7%E5%8F%96%E8%81%8A%E5%A4%A9%E5%AE%A4%E6%88%90%E5%91%98%E5%88%97%E8%A1%A8 + * @param chatroomId (required) + * @param pagenum 查询页码。默认值为 1 (optional) + * @param pagesize 每页显示的聊天室成员数量。默认值为 1000。取值范围为 [0,1000] (optional) + * @return EMGetRoomMemberListResult + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public EMGetRoomMemberListResult getRoomMemberList(String chatroomId, Integer pagenum, Integer pagesize) throws ApiException { + ApiResponse localVarResp = getRoomMemberListWithHttpInfo(chatroomId, pagenum, pagesize); + return localVarResp.getData(); + } + + /** + * 分页获取聊天室成员列表 + * 可以分页获取聊天室成员列表。文档介绍:https://docs-im-beta.easemob.com/document/server-side/chatroom.html#%E5%88%86%E9%A1%B5%E8%8E%B7%E5%8F%96%E8%81%8A%E5%A4%A9%E5%AE%A4%E6%88%90%E5%91%98%E5%88%97%E8%A1%A8 + * @param chatroomId (required) + * @param pagenum 查询页码。默认值为 1 (optional) + * @param pagesize 每页显示的聊天室成员数量。默认值为 1000。取值范围为 [0,1000] (optional) + * @return ApiResponse<EMGetRoomMemberListResult> + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public ApiResponse getRoomMemberListWithHttpInfo(String chatroomId, Integer pagenum, Integer pagesize) throws ApiException { + okhttp3.Call localVarCall = getRoomMemberListValidateBeforeCall(chatroomId, pagenum, pagesize, null); + Type localVarReturnType = new TypeToken(){}.getType(); + return localVarApiClient.execute(localVarCall, localVarReturnType); + } + + /** + * 分页获取聊天室成员列表 (asynchronously) + * 可以分页获取聊天室成员列表。文档介绍:https://docs-im-beta.easemob.com/document/server-side/chatroom.html#%E5%88%86%E9%A1%B5%E8%8E%B7%E5%8F%96%E8%81%8A%E5%A4%A9%E5%AE%A4%E6%88%90%E5%91%98%E5%88%97%E8%A1%A8 + * @param chatroomId (required) + * @param pagenum 查询页码。默认值为 1 (optional) + * @param pagesize 每页显示的聊天室成员数量。默认值为 1000。取值范围为 [0,1000] (optional) + * @param _callback The callback to be executed when the API call finishes + * @return The request call + * @throws ApiException If fail to process the API call, e.g. serializing the request body object + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public okhttp3.Call getRoomMemberListAsync(String chatroomId, Integer pagenum, Integer pagesize, final ApiCallback _callback) throws ApiException { + + okhttp3.Call localVarCall = getRoomMemberListValidateBeforeCall(chatroomId, pagenum, pagesize, _callback); + Type localVarReturnType = new TypeToken(){}.getType(); + localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); + return localVarCall; + } + /** + * Build call for getRoomSuperAdminList + * @param pagenum 当前页码,默认值为 1 (optional) + * @param pagesize 每页返回的超级管理员数量,默认值为 10 (optional) + * @param _callback Callback for upload/download progress + * @return Call to execute + * @throws ApiException If fail to serialize the request body object + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public okhttp3.Call getRoomSuperAdminListCall(Integer pagenum, Integer pagesize, final ApiCallback _callback) throws ApiException { + String basePath = null; + // Operation Servers + String[] localBasePaths = new String[] { }; + + // Determine Base Path to Use + if (localCustomBaseUrl != null){ + basePath = localCustomBaseUrl; + } else if ( localBasePaths.length > 0 ) { + basePath = localBasePaths[localHostIndex]; + } else { + basePath = null; + } + + Object localVarPostBody = null; + + // create path and map variables + String localVarPath = "/chatrooms/super_admin"; + + List localVarQueryParams = new ArrayList(); + List localVarCollectionQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + Map localVarCookieParams = new HashMap(); + Map localVarFormParams = new HashMap(); + + if (pagenum != null) { + localVarQueryParams.addAll(localVarApiClient.parameterToPair("pagenum", pagenum)); + } + + if (pagesize != null) { + localVarQueryParams.addAll(localVarApiClient.parameterToPair("pagesize", pagesize)); + } + + final String[] localVarAccepts = { + "application/json" + }; + final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts); + if (localVarAccept != null) { + localVarHeaderParams.put("Accept", localVarAccept); + } + + final String[] localVarContentTypes = { + }; + final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); + if (localVarContentType != null) { + localVarHeaderParams.put("Content-Type", localVarContentType); + } + + String[] localVarAuthNames = new String[] { }; + return localVarApiClient.buildCall(basePath, localVarPath, "GET", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); + } + + @SuppressWarnings("rawtypes") + private okhttp3.Call getRoomSuperAdminListValidateBeforeCall(Integer pagenum, Integer pagesize, final ApiCallback _callback) throws ApiException { + return getRoomSuperAdminListCall(pagenum, pagesize, _callback); + + } + + /** + * 分页获取超级管理员列表 + * 可以分页获取超级管理员列表的接口。文档介绍:https://docs-im-beta.easemob.com/document/server-side/chatroom.html#%E5%88%86%E9%A1%B5%E8%8E%B7%E5%8F%96%E8%B6%85%E7%BA%A7%E7%AE%A1%E7%90%86%E5%91%98%E5%88%97%E8%A1%A8 + * @param pagenum 当前页码,默认值为 1 (optional) + * @param pagesize 每页返回的超级管理员数量,默认值为 10 (optional) + * @return EMGetRoomSuperAdminListResult + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public EMGetRoomSuperAdminListResult getRoomSuperAdminList(Integer pagenum, Integer pagesize) throws ApiException { + ApiResponse localVarResp = getRoomSuperAdminListWithHttpInfo(pagenum, pagesize); + return localVarResp.getData(); + } + + /** + * 分页获取超级管理员列表 + * 可以分页获取超级管理员列表的接口。文档介绍:https://docs-im-beta.easemob.com/document/server-side/chatroom.html#%E5%88%86%E9%A1%B5%E8%8E%B7%E5%8F%96%E8%B6%85%E7%BA%A7%E7%AE%A1%E7%90%86%E5%91%98%E5%88%97%E8%A1%A8 + * @param pagenum 当前页码,默认值为 1 (optional) + * @param pagesize 每页返回的超级管理员数量,默认值为 10 (optional) + * @return ApiResponse<EMGetRoomSuperAdminListResult> + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public ApiResponse getRoomSuperAdminListWithHttpInfo(Integer pagenum, Integer pagesize) throws ApiException { + okhttp3.Call localVarCall = getRoomSuperAdminListValidateBeforeCall(pagenum, pagesize, null); + Type localVarReturnType = new TypeToken(){}.getType(); + return localVarApiClient.execute(localVarCall, localVarReturnType); + } + + /** + * 分页获取超级管理员列表 (asynchronously) + * 可以分页获取超级管理员列表的接口。文档介绍:https://docs-im-beta.easemob.com/document/server-side/chatroom.html#%E5%88%86%E9%A1%B5%E8%8E%B7%E5%8F%96%E8%B6%85%E7%BA%A7%E7%AE%A1%E7%90%86%E5%91%98%E5%88%97%E8%A1%A8 + * @param pagenum 当前页码,默认值为 1 (optional) + * @param pagesize 每页返回的超级管理员数量,默认值为 10 (optional) + * @param _callback The callback to be executed when the API call finishes + * @return The request call + * @throws ApiException If fail to process the API call, e.g. serializing the request body object + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public okhttp3.Call getRoomSuperAdminListAsync(Integer pagenum, Integer pagesize, final ApiCallback _callback) throws ApiException { + + okhttp3.Call localVarCall = getRoomSuperAdminListValidateBeforeCall(pagenum, pagesize, _callback); + Type localVarReturnType = new TypeToken(){}.getType(); + localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); + return localVarCall; + } + /** + * Build call for getRoomWhiteList + * @param chatroomId (required) + * @param _callback Callback for upload/download progress + * @return Call to execute + * @throws ApiException If fail to serialize the request body object + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public okhttp3.Call getRoomWhiteListCall(String chatroomId, final ApiCallback _callback) throws ApiException { + String basePath = null; + // Operation Servers + String[] localBasePaths = new String[] { }; + + // Determine Base Path to Use + if (localCustomBaseUrl != null){ + basePath = localCustomBaseUrl; + } else if ( localBasePaths.length > 0 ) { + basePath = localBasePaths[localHostIndex]; + } else { + basePath = null; + } + + Object localVarPostBody = null; + + // create path and map variables + String localVarPath = "/chatrooms/{chatroom_id}/white/users" + .replace("{" + "chatroom_id" + "}", localVarApiClient.escapeString(chatroomId.toString())); + + List localVarQueryParams = new ArrayList(); + List localVarCollectionQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + Map localVarCookieParams = new HashMap(); + Map localVarFormParams = new HashMap(); + + final String[] localVarAccepts = { + "application/json" + }; + final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts); + if (localVarAccept != null) { + localVarHeaderParams.put("Accept", localVarAccept); + } + + final String[] localVarContentTypes = { + }; + final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); + if (localVarContentType != null) { + localVarHeaderParams.put("Content-Type", localVarContentType); + } + + String[] localVarAuthNames = new String[] { }; + return localVarApiClient.buildCall(basePath, localVarPath, "GET", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); + } + + @SuppressWarnings("rawtypes") + private okhttp3.Call getRoomWhiteListValidateBeforeCall(String chatroomId, final ApiCallback _callback) throws ApiException { + // verify the required parameter 'chatroomId' is set + if (chatroomId == null) { + throw new ApiException("Missing the required parameter 'chatroomId' when calling getRoomWhiteList(Async)"); + } + + return getRoomWhiteListCall(chatroomId, _callback); + + } + + /** + * 查询聊天室白名单 + * 查询一个聊天室白名单中的用户列表。文档介绍:https://docs-im-beta.easemob.com/document/server-side/chatroom.html#%E6%9F%A5%E8%AF%A2%E8%81%8A%E5%A4%A9%E5%AE%A4%E7%99%BD%E5%90%8D%E5%8D%95 + * @param chatroomId (required) + * @return EMGetRoomWhiteListResult + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public EMGetRoomWhiteListResult getRoomWhiteList(String chatroomId) throws ApiException { + ApiResponse localVarResp = getRoomWhiteListWithHttpInfo(chatroomId); + return localVarResp.getData(); + } + + /** + * 查询聊天室白名单 + * 查询一个聊天室白名单中的用户列表。文档介绍:https://docs-im-beta.easemob.com/document/server-side/chatroom.html#%E6%9F%A5%E8%AF%A2%E8%81%8A%E5%A4%A9%E5%AE%A4%E7%99%BD%E5%90%8D%E5%8D%95 + * @param chatroomId (required) + * @return ApiResponse<EMGetRoomWhiteListResult> + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public ApiResponse getRoomWhiteListWithHttpInfo(String chatroomId) throws ApiException { + okhttp3.Call localVarCall = getRoomWhiteListValidateBeforeCall(chatroomId, null); + Type localVarReturnType = new TypeToken(){}.getType(); + return localVarApiClient.execute(localVarCall, localVarReturnType); + } + + /** + * 查询聊天室白名单 (asynchronously) + * 查询一个聊天室白名单中的用户列表。文档介绍:https://docs-im-beta.easemob.com/document/server-side/chatroom.html#%E6%9F%A5%E8%AF%A2%E8%81%8A%E5%A4%A9%E5%AE%A4%E7%99%BD%E5%90%8D%E5%8D%95 + * @param chatroomId (required) + * @param _callback The callback to be executed when the API call finishes + * @return The request call + * @throws ApiException If fail to process the API call, e.g. serializing the request body object + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public okhttp3.Call getRoomWhiteListAsync(String chatroomId, final ApiCallback _callback) throws ApiException { + + okhttp3.Call localVarCall = getRoomWhiteListValidateBeforeCall(chatroomId, _callback); + Type localVarReturnType = new TypeToken(){}.getType(); + localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); + return localVarCall; + } + /** + * Build call for getUserJoinedRoomList + * @param username (required) + * @param pagenum 每次期望返回的聊天室数量。取值范围为 [1,100],默认值为 10 (optional) + * @param pagesize 数据查询的起始位置 (optional) + * @param _callback Callback for upload/download progress + * @return Call to execute + * @throws ApiException If fail to serialize the request body object + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public okhttp3.Call getUserJoinedRoomListCall(String username, Integer pagenum, Integer pagesize, final ApiCallback _callback) throws ApiException { + String basePath = null; + // Operation Servers + String[] localBasePaths = new String[] { }; + + // Determine Base Path to Use + if (localCustomBaseUrl != null){ + basePath = localCustomBaseUrl; + } else if ( localBasePaths.length > 0 ) { + basePath = localBasePaths[localHostIndex]; + } else { + basePath = null; + } + + Object localVarPostBody = null; + + // create path and map variables + String localVarPath = "/users/{username}/joined_chatrooms" + .replace("{" + "username" + "}", localVarApiClient.escapeString(username.toString())); + + List localVarQueryParams = new ArrayList(); + List localVarCollectionQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + Map localVarCookieParams = new HashMap(); + Map localVarFormParams = new HashMap(); + + if (pagenum != null) { + localVarQueryParams.addAll(localVarApiClient.parameterToPair("pagenum", pagenum)); + } + + if (pagesize != null) { + localVarQueryParams.addAll(localVarApiClient.parameterToPair("pagesize", pagesize)); + } + + final String[] localVarAccepts = { + "application/json" + }; + final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts); + if (localVarAccept != null) { + localVarHeaderParams.put("Accept", localVarAccept); + } + + final String[] localVarContentTypes = { + }; + final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); + if (localVarContentType != null) { + localVarHeaderParams.put("Content-Type", localVarContentType); + } + + String[] localVarAuthNames = new String[] { }; + return localVarApiClient.buildCall(basePath, localVarPath, "GET", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); + } + + @SuppressWarnings("rawtypes") + private okhttp3.Call getUserJoinedRoomListValidateBeforeCall(String username, Integer pagenum, Integer pagesize, final ApiCallback _callback) throws ApiException { + // verify the required parameter 'username' is set + if (username == null) { + throw new ApiException("Missing the required parameter 'username' when calling getUserJoinedRoomList(Async)"); + } + + return getUserJoinedRoomListCall(username, pagenum, pagesize, _callback); + + } + + /** + * 获取用户加入的聊天室 + * 根据用户 ID 分页获取该用户加入的聊天室。文档介绍:https://docs-im-beta.easemob.com/document/server-side/chatroom.html#%E8%8E%B7%E5%8F%96%E7%94%A8%E6%88%B7%E5%8A%A0%E5%85%A5%E7%9A%84%E8%81%8A%E5%A4%A9%E5%AE%A4 + * @param username (required) + * @param pagenum 每次期望返回的聊天室数量。取值范围为 [1,100],默认值为 10 (optional) + * @param pagesize 数据查询的起始位置 (optional) + * @return EMGetUserJoinedRoomListResult + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public EMGetUserJoinedRoomListResult getUserJoinedRoomList(String username, Integer pagenum, Integer pagesize) throws ApiException { + ApiResponse localVarResp = getUserJoinedRoomListWithHttpInfo(username, pagenum, pagesize); + return localVarResp.getData(); + } + + /** + * 获取用户加入的聊天室 + * 根据用户 ID 分页获取该用户加入的聊天室。文档介绍:https://docs-im-beta.easemob.com/document/server-side/chatroom.html#%E8%8E%B7%E5%8F%96%E7%94%A8%E6%88%B7%E5%8A%A0%E5%85%A5%E7%9A%84%E8%81%8A%E5%A4%A9%E5%AE%A4 + * @param username (required) + * @param pagenum 每次期望返回的聊天室数量。取值范围为 [1,100],默认值为 10 (optional) + * @param pagesize 数据查询的起始位置 (optional) + * @return ApiResponse<EMGetUserJoinedRoomListResult> + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public ApiResponse getUserJoinedRoomListWithHttpInfo(String username, Integer pagenum, Integer pagesize) throws ApiException { + okhttp3.Call localVarCall = getUserJoinedRoomListValidateBeforeCall(username, pagenum, pagesize, null); + Type localVarReturnType = new TypeToken(){}.getType(); + return localVarApiClient.execute(localVarCall, localVarReturnType); + } + + /** + * 获取用户加入的聊天室 (asynchronously) + * 根据用户 ID 分页获取该用户加入的聊天室。文档介绍:https://docs-im-beta.easemob.com/document/server-side/chatroom.html#%E8%8E%B7%E5%8F%96%E7%94%A8%E6%88%B7%E5%8A%A0%E5%85%A5%E7%9A%84%E8%81%8A%E5%A4%A9%E5%AE%A4 + * @param username (required) + * @param pagenum 每次期望返回的聊天室数量。取值范围为 [1,100],默认值为 10 (optional) + * @param pagesize 数据查询的起始位置 (optional) + * @param _callback The callback to be executed when the API call finishes + * @return The request call + * @throws ApiException If fail to process the API call, e.g. serializing the request body object + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public okhttp3.Call getUserJoinedRoomListAsync(String username, Integer pagenum, Integer pagesize, final ApiCallback _callback) throws ApiException { + + okhttp3.Call localVarCall = getUserJoinedRoomListValidateBeforeCall(username, pagenum, pagesize, _callback); + Type localVarReturnType = new TypeToken(){}.getType(); + localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); + return localVarCall; + } + /** + * Build call for modifyRoom + * @param chatroomId (required) + * @param emModifyRoom (optional) + * @param _callback Callback for upload/download progress + * @return Call to execute + * @throws ApiException If fail to serialize the request body object + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public okhttp3.Call modifyRoomCall(String chatroomId, EMModifyRoom emModifyRoom, final ApiCallback _callback) throws ApiException { + String basePath = null; + // Operation Servers + String[] localBasePaths = new String[] { }; + + // Determine Base Path to Use + if (localCustomBaseUrl != null){ + basePath = localCustomBaseUrl; + } else if ( localBasePaths.length > 0 ) { + basePath = localBasePaths[localHostIndex]; + } else { + basePath = null; + } + + Object localVarPostBody = emModifyRoom; + + // create path and map variables + String localVarPath = "/chatrooms/{chatroom_id}" + .replace("{" + "chatroom_id" + "}", localVarApiClient.escapeString(chatroomId.toString())); + + List localVarQueryParams = new ArrayList(); + List localVarCollectionQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + Map localVarCookieParams = new HashMap(); + Map localVarFormParams = new HashMap(); + + final String[] localVarAccepts = { + "application/json" + }; + final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts); + if (localVarAccept != null) { + localVarHeaderParams.put("Accept", localVarAccept); + } + + final String[] localVarContentTypes = { + "application/json" + }; + final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); + if (localVarContentType != null) { + localVarHeaderParams.put("Content-Type", localVarContentType); + } + + String[] localVarAuthNames = new String[] { }; + return localVarApiClient.buildCall(basePath, localVarPath, "PUT", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); + } + + @SuppressWarnings("rawtypes") + private okhttp3.Call modifyRoomValidateBeforeCall(String chatroomId, EMModifyRoom emModifyRoom, final ApiCallback _callback) throws ApiException { + // verify the required parameter 'chatroomId' is set + if (chatroomId == null) { + throw new ApiException("Missing the required parameter 'chatroomId' when calling modifyRoom(Async)"); + } + + return modifyRoomCall(chatroomId, emModifyRoom, _callback); + + } + + /** + * 修改聊天室信息 + * 修改指定聊天室的信息。仅支持修改聊天室名称、聊天室描述和聊天室最大成员数。文档介绍:https://docs-im-beta.easemob.com/document/server-side/chatroom.html#%E4%BF%AE%E6%94%B9%E8%81%8A%E5%A4%A9%E5%AE%A4%E4%BF%A1%E6%81%AF + * @param chatroomId (required) + * @param emModifyRoom (optional) + * @return EMModifyRoomResult + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public EMModifyRoomResult modifyRoom(String chatroomId, EMModifyRoom emModifyRoom) throws ApiException { + ApiResponse localVarResp = modifyRoomWithHttpInfo(chatroomId, emModifyRoom); + return localVarResp.getData(); + } + + /** + * 修改聊天室信息 + * 修改指定聊天室的信息。仅支持修改聊天室名称、聊天室描述和聊天室最大成员数。文档介绍:https://docs-im-beta.easemob.com/document/server-side/chatroom.html#%E4%BF%AE%E6%94%B9%E8%81%8A%E5%A4%A9%E5%AE%A4%E4%BF%A1%E6%81%AF + * @param chatroomId (required) + * @param emModifyRoom (optional) + * @return ApiResponse<EMModifyRoomResult> + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public ApiResponse modifyRoomWithHttpInfo(String chatroomId, EMModifyRoom emModifyRoom) throws ApiException { + okhttp3.Call localVarCall = modifyRoomValidateBeforeCall(chatroomId, emModifyRoom, null); + Type localVarReturnType = new TypeToken(){}.getType(); + return localVarApiClient.execute(localVarCall, localVarReturnType); + } + + /** + * 修改聊天室信息 (asynchronously) + * 修改指定聊天室的信息。仅支持修改聊天室名称、聊天室描述和聊天室最大成员数。文档介绍:https://docs-im-beta.easemob.com/document/server-side/chatroom.html#%E4%BF%AE%E6%94%B9%E8%81%8A%E5%A4%A9%E5%AE%A4%E4%BF%A1%E6%81%AF + * @param chatroomId (required) + * @param emModifyRoom (optional) + * @param _callback The callback to be executed when the API call finishes + * @return The request call + * @throws ApiException If fail to process the API call, e.g. serializing the request body object + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public okhttp3.Call modifyRoomAsync(String chatroomId, EMModifyRoom emModifyRoom, final ApiCallback _callback) throws ApiException { + + okhttp3.Call localVarCall = modifyRoomValidateBeforeCall(chatroomId, emModifyRoom, _callback); + Type localVarReturnType = new TypeToken(){}.getType(); + localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); + return localVarCall; + } + /** + * Build call for modifyRoomAnnouncement + * @param chatroomId (required) + * @param emModifyRoomAnnouncement (optional) + * @param _callback Callback for upload/download progress + * @return Call to execute + * @throws ApiException If fail to serialize the request body object + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public okhttp3.Call modifyRoomAnnouncementCall(String chatroomId, EMModifyRoomAnnouncement emModifyRoomAnnouncement, final ApiCallback _callback) throws ApiException { + String basePath = null; + // Operation Servers + String[] localBasePaths = new String[] { }; + + // Determine Base Path to Use + if (localCustomBaseUrl != null){ + basePath = localCustomBaseUrl; + } else if ( localBasePaths.length > 0 ) { + basePath = localBasePaths[localHostIndex]; + } else { + basePath = null; + } + + Object localVarPostBody = emModifyRoomAnnouncement; + + // create path and map variables + String localVarPath = "/chatrooms/{chatroom_id}/announcement" + .replace("{" + "chatroom_id" + "}", localVarApiClient.escapeString(chatroomId.toString())); + + List localVarQueryParams = new ArrayList(); + List localVarCollectionQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + Map localVarCookieParams = new HashMap(); + Map localVarFormParams = new HashMap(); + + final String[] localVarAccepts = { + "application/json" + }; + final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts); + if (localVarAccept != null) { + localVarHeaderParams.put("Accept", localVarAccept); + } + + final String[] localVarContentTypes = { + "application/json" + }; + final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); + if (localVarContentType != null) { + localVarHeaderParams.put("Content-Type", localVarContentType); + } + + String[] localVarAuthNames = new String[] { }; + return localVarApiClient.buildCall(basePath, localVarPath, "POST", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); + } + + @SuppressWarnings("rawtypes") + private okhttp3.Call modifyRoomAnnouncementValidateBeforeCall(String chatroomId, EMModifyRoomAnnouncement emModifyRoomAnnouncement, final ApiCallback _callback) throws ApiException { + // verify the required parameter 'chatroomId' is set + if (chatroomId == null) { + throw new ApiException("Missing the required parameter 'chatroomId' when calling modifyRoomAnnouncement(Async)"); + } + + return modifyRoomAnnouncementCall(chatroomId, emModifyRoomAnnouncement, _callback); + + } + + /** + * 修改聊天室公告 + * 修改指定聊天室 ID 的聊天室公告。聊天室公告内容不能超过 512 个字符。文档介绍:https://docs-im-beta.easemob.com/document/server-side/chatroom.html#%E4%BF%AE%E6%94%B9%E8%81%8A%E5%A4%A9%E5%AE%A4%E5%85%AC%E5%91%8A + * @param chatroomId (required) + * @param emModifyRoomAnnouncement (optional) + * @return EMModifyRoomAnnouncementResult + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public EMModifyRoomAnnouncementResult modifyRoomAnnouncement(String chatroomId, EMModifyRoomAnnouncement emModifyRoomAnnouncement) throws ApiException { + ApiResponse localVarResp = modifyRoomAnnouncementWithHttpInfo(chatroomId, emModifyRoomAnnouncement); + return localVarResp.getData(); + } + + /** + * 修改聊天室公告 + * 修改指定聊天室 ID 的聊天室公告。聊天室公告内容不能超过 512 个字符。文档介绍:https://docs-im-beta.easemob.com/document/server-side/chatroom.html#%E4%BF%AE%E6%94%B9%E8%81%8A%E5%A4%A9%E5%AE%A4%E5%85%AC%E5%91%8A + * @param chatroomId (required) + * @param emModifyRoomAnnouncement (optional) + * @return ApiResponse<EMModifyRoomAnnouncementResult> + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public ApiResponse modifyRoomAnnouncementWithHttpInfo(String chatroomId, EMModifyRoomAnnouncement emModifyRoomAnnouncement) throws ApiException { + okhttp3.Call localVarCall = modifyRoomAnnouncementValidateBeforeCall(chatroomId, emModifyRoomAnnouncement, null); + Type localVarReturnType = new TypeToken(){}.getType(); + return localVarApiClient.execute(localVarCall, localVarReturnType); + } + + /** + * 修改聊天室公告 (asynchronously) + * 修改指定聊天室 ID 的聊天室公告。聊天室公告内容不能超过 512 个字符。文档介绍:https://docs-im-beta.easemob.com/document/server-side/chatroom.html#%E4%BF%AE%E6%94%B9%E8%81%8A%E5%A4%A9%E5%AE%A4%E5%85%AC%E5%91%8A + * @param chatroomId (required) + * @param emModifyRoomAnnouncement (optional) + * @param _callback The callback to be executed when the API call finishes + * @return The request call + * @throws ApiException If fail to process the API call, e.g. serializing the request body object + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public okhttp3.Call modifyRoomAnnouncementAsync(String chatroomId, EMModifyRoomAnnouncement emModifyRoomAnnouncement, final ApiCallback _callback) throws ApiException { + + okhttp3.Call localVarCall = modifyRoomAnnouncementValidateBeforeCall(chatroomId, emModifyRoomAnnouncement, _callback); + Type localVarReturnType = new TypeToken(){}.getType(); + localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); + return localVarCall; + } + /** + * Build call for muteAllRoomMember + * @param chatroomId (required) + * @param _callback Callback for upload/download progress + * @return Call to execute + * @throws ApiException If fail to serialize the request body object + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public okhttp3.Call muteAllRoomMemberCall(String chatroomId, final ApiCallback _callback) throws ApiException { + String basePath = null; + // Operation Servers + String[] localBasePaths = new String[] { }; + + // Determine Base Path to Use + if (localCustomBaseUrl != null){ + basePath = localCustomBaseUrl; + } else if ( localBasePaths.length > 0 ) { + basePath = localBasePaths[localHostIndex]; + } else { + basePath = null; + } + + Object localVarPostBody = null; + + // create path and map variables + String localVarPath = "/chatrooms/{chatroom_id}/ban" + .replace("{" + "chatroom_id" + "}", localVarApiClient.escapeString(chatroomId.toString())); + + List localVarQueryParams = new ArrayList(); + List localVarCollectionQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + Map localVarCookieParams = new HashMap(); + Map localVarFormParams = new HashMap(); + + final String[] localVarAccepts = { + "application/json" + }; + final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts); + if (localVarAccept != null) { + localVarHeaderParams.put("Accept", localVarAccept); + } + + final String[] localVarContentTypes = { + }; + final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); + if (localVarContentType != null) { + localVarHeaderParams.put("Content-Type", localVarContentType); + } + + String[] localVarAuthNames = new String[] { }; + return localVarApiClient.buildCall(basePath, localVarPath, "POST", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); + } + + @SuppressWarnings("rawtypes") + private okhttp3.Call muteAllRoomMemberValidateBeforeCall(String chatroomId, final ApiCallback _callback) throws ApiException { + // verify the required parameter 'chatroomId' is set + if (chatroomId == null) { + throw new ApiException("Missing the required parameter 'chatroomId' when calling muteAllRoomMember(Async)"); + } + + return muteAllRoomMemberCall(chatroomId, _callback); + + } + + /** + * 禁言聊天室全体成员 + * 对所有聊天室成员一键禁言。该操作不影响聊天室禁言列表,即一键禁言不会将聊天室所有成员加入聊天室禁言列表。设置聊天室全员禁言后,仅聊天室白名单中的用户可在聊天室内发消息。文档介绍:https://docs-im-beta.easemob.com/document/server-side/chatroom.html#%E7%A6%81%E8%A8%80%E8%81%8A%E5%A4%A9%E5%AE%A4%E5%85%A8%E4%BD%93%E6%88%90%E5%91%98 + * @param chatroomId (required) + * @return EMMuteAllRoomMemberResult + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public EMMuteAllRoomMemberResult muteAllRoomMember(String chatroomId) throws ApiException { + ApiResponse localVarResp = muteAllRoomMemberWithHttpInfo(chatroomId); + return localVarResp.getData(); + } + + /** + * 禁言聊天室全体成员 + * 对所有聊天室成员一键禁言。该操作不影响聊天室禁言列表,即一键禁言不会将聊天室所有成员加入聊天室禁言列表。设置聊天室全员禁言后,仅聊天室白名单中的用户可在聊天室内发消息。文档介绍:https://docs-im-beta.easemob.com/document/server-side/chatroom.html#%E7%A6%81%E8%A8%80%E8%81%8A%E5%A4%A9%E5%AE%A4%E5%85%A8%E4%BD%93%E6%88%90%E5%91%98 + * @param chatroomId (required) + * @return ApiResponse<EMMuteAllRoomMemberResult> + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public ApiResponse muteAllRoomMemberWithHttpInfo(String chatroomId) throws ApiException { + okhttp3.Call localVarCall = muteAllRoomMemberValidateBeforeCall(chatroomId, null); + Type localVarReturnType = new TypeToken(){}.getType(); + return localVarApiClient.execute(localVarCall, localVarReturnType); + } + + /** + * 禁言聊天室全体成员 (asynchronously) + * 对所有聊天室成员一键禁言。该操作不影响聊天室禁言列表,即一键禁言不会将聊天室所有成员加入聊天室禁言列表。设置聊天室全员禁言后,仅聊天室白名单中的用户可在聊天室内发消息。文档介绍:https://docs-im-beta.easemob.com/document/server-side/chatroom.html#%E7%A6%81%E8%A8%80%E8%81%8A%E5%A4%A9%E5%AE%A4%E5%85%A8%E4%BD%93%E6%88%90%E5%91%98 + * @param chatroomId (required) + * @param _callback The callback to be executed when the API call finishes + * @return The request call + * @throws ApiException If fail to process the API call, e.g. serializing the request body object + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public okhttp3.Call muteAllRoomMemberAsync(String chatroomId, final ApiCallback _callback) throws ApiException { + + okhttp3.Call localVarCall = muteAllRoomMemberValidateBeforeCall(chatroomId, _callback); + Type localVarReturnType = new TypeToken(){}.getType(); + localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); + return localVarCall; + } + /** + * Build call for muteRoomMember + * @param chatroomId (required) + * @param emMuteRoomMember (optional) + * @param _callback Callback for upload/download progress + * @return Call to execute + * @throws ApiException If fail to serialize the request body object + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public okhttp3.Call muteRoomMemberCall(String chatroomId, EMMuteRoomMember emMuteRoomMember, final ApiCallback _callback) throws ApiException { + String basePath = null; + // Operation Servers + String[] localBasePaths = new String[] { }; + + // Determine Base Path to Use + if (localCustomBaseUrl != null){ + basePath = localCustomBaseUrl; + } else if ( localBasePaths.length > 0 ) { + basePath = localBasePaths[localHostIndex]; + } else { + basePath = null; + } + + Object localVarPostBody = emMuteRoomMember; + + // create path and map variables + String localVarPath = "/chatrooms/{chatroom_id}/mute" + .replace("{" + "chatroom_id" + "}", localVarApiClient.escapeString(chatroomId.toString())); + + List localVarQueryParams = new ArrayList(); + List localVarCollectionQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + Map localVarCookieParams = new HashMap(); + Map localVarFormParams = new HashMap(); + + final String[] localVarAccepts = { + "application/json" + }; + final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts); + if (localVarAccept != null) { + localVarHeaderParams.put("Accept", localVarAccept); + } + + final String[] localVarContentTypes = { + "application/json" + }; + final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); + if (localVarContentType != null) { + localVarHeaderParams.put("Content-Type", localVarContentType); + } + + String[] localVarAuthNames = new String[] { }; + return localVarApiClient.buildCall(basePath, localVarPath, "POST", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); + } + + @SuppressWarnings("rawtypes") + private okhttp3.Call muteRoomMemberValidateBeforeCall(String chatroomId, EMMuteRoomMember emMuteRoomMember, final ApiCallback _callback) throws ApiException { + // verify the required parameter 'chatroomId' is set + if (chatroomId == null) { + throw new ApiException("Missing the required parameter 'chatroomId' when calling muteRoomMember(Async)"); + } + + return muteRoomMemberCall(chatroomId, emMuteRoomMember, _callback); + + } + + /** + * 禁言聊天室成员 + * 禁言单个或多个聊天室成员。你一次最多可禁言 60 个成员。用户被禁言后,将无法在聊天室中发送消息。文档介绍:https://docs-im-beta.easemob.com/document/server-side/chatroom.html#%E7%A6%81%E8%A8%80%E8%81%8A%E5%A4%A9%E5%AE%A4%E6%88%90%E5%91%98 + * @param chatroomId (required) + * @param emMuteRoomMember (optional) + * @return EMMuteRoomMemberResult + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public EMMuteRoomMemberResult muteRoomMember(String chatroomId, EMMuteRoomMember emMuteRoomMember) throws ApiException { + ApiResponse localVarResp = muteRoomMemberWithHttpInfo(chatroomId, emMuteRoomMember); + return localVarResp.getData(); + } + + /** + * 禁言聊天室成员 + * 禁言单个或多个聊天室成员。你一次最多可禁言 60 个成员。用户被禁言后,将无法在聊天室中发送消息。文档介绍:https://docs-im-beta.easemob.com/document/server-side/chatroom.html#%E7%A6%81%E8%A8%80%E8%81%8A%E5%A4%A9%E5%AE%A4%E6%88%90%E5%91%98 + * @param chatroomId (required) + * @param emMuteRoomMember (optional) + * @return ApiResponse<EMMuteRoomMemberResult> + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public ApiResponse muteRoomMemberWithHttpInfo(String chatroomId, EMMuteRoomMember emMuteRoomMember) throws ApiException { + okhttp3.Call localVarCall = muteRoomMemberValidateBeforeCall(chatroomId, emMuteRoomMember, null); + Type localVarReturnType = new TypeToken(){}.getType(); + return localVarApiClient.execute(localVarCall, localVarReturnType); + } + + /** + * 禁言聊天室成员 (asynchronously) + * 禁言单个或多个聊天室成员。你一次最多可禁言 60 个成员。用户被禁言后,将无法在聊天室中发送消息。文档介绍:https://docs-im-beta.easemob.com/document/server-side/chatroom.html#%E7%A6%81%E8%A8%80%E8%81%8A%E5%A4%A9%E5%AE%A4%E6%88%90%E5%91%98 + * @param chatroomId (required) + * @param emMuteRoomMember (optional) + * @param _callback The callback to be executed when the API call finishes + * @return The request call + * @throws ApiException If fail to process the API call, e.g. serializing the request body object + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public okhttp3.Call muteRoomMemberAsync(String chatroomId, EMMuteRoomMember emMuteRoomMember, final ApiCallback _callback) throws ApiException { + + okhttp3.Call localVarCall = muteRoomMemberValidateBeforeCall(chatroomId, emMuteRoomMember, _callback); + Type localVarReturnType = new TypeToken(){}.getType(); + localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); + return localVarCall; + } + /** + * Build call for removeRoomAdmin + * @param chatroomId (required) + * @param oldAdmin (required) + * @param _callback Callback for upload/download progress + * @return Call to execute + * @throws ApiException If fail to serialize the request body object + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public okhttp3.Call removeRoomAdminCall(String chatroomId, String oldAdmin, final ApiCallback _callback) throws ApiException { + String basePath = null; + // Operation Servers + String[] localBasePaths = new String[] { }; + + // Determine Base Path to Use + if (localCustomBaseUrl != null){ + basePath = localCustomBaseUrl; + } else if ( localBasePaths.length > 0 ) { + basePath = localBasePaths[localHostIndex]; + } else { + basePath = null; + } + + Object localVarPostBody = null; + + // create path and map variables + String localVarPath = "/chatrooms/{chatroom_id}/admin/{oldAdmin}" + .replace("{" + "chatroom_id" + "}", localVarApiClient.escapeString(chatroomId.toString())) + .replace("{" + "oldAdmin" + "}", localVarApiClient.escapeString(oldAdmin.toString())); + + List localVarQueryParams = new ArrayList(); + List localVarCollectionQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + Map localVarCookieParams = new HashMap(); + Map localVarFormParams = new HashMap(); + + final String[] localVarAccepts = { + "application/json" + }; + final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts); + if (localVarAccept != null) { + localVarHeaderParams.put("Accept", localVarAccept); + } + + final String[] localVarContentTypes = { + }; + final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); + if (localVarContentType != null) { + localVarHeaderParams.put("Content-Type", localVarContentType); + } + + String[] localVarAuthNames = new String[] { }; + return localVarApiClient.buildCall(basePath, localVarPath, "DELETE", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); + } + + @SuppressWarnings("rawtypes") + private okhttp3.Call removeRoomAdminValidateBeforeCall(String chatroomId, String oldAdmin, final ApiCallback _callback) throws ApiException { + // verify the required parameter 'chatroomId' is set + if (chatroomId == null) { + throw new ApiException("Missing the required parameter 'chatroomId' when calling removeRoomAdmin(Async)"); + } + + // verify the required parameter 'oldAdmin' is set + if (oldAdmin == null) { + throw new ApiException("Missing the required parameter 'oldAdmin' when calling removeRoomAdmin(Async)"); + } + + return removeRoomAdminCall(chatroomId, oldAdmin, _callback); + + } + + /** + * 移除聊天室管理员 + * 将用户的角色从聊天室管理员降为普通聊天室成员。文档介绍:https://docs-im-beta.easemob.com/document/server-side/chatroom.html#%E6%B7%BB%E5%8A%A0%E8%81%8A%E5%A4%A9%E5%AE%A4%E7%AE%A1%E7%90%86%E5%91%98 + * @param chatroomId (required) + * @param oldAdmin (required) + * @return EMRemoveRoomAdminResult + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public EMRemoveRoomAdminResult removeRoomAdmin(String chatroomId, String oldAdmin) throws ApiException { + ApiResponse localVarResp = removeRoomAdminWithHttpInfo(chatroomId, oldAdmin); + return localVarResp.getData(); + } + + /** + * 移除聊天室管理员 + * 将用户的角色从聊天室管理员降为普通聊天室成员。文档介绍:https://docs-im-beta.easemob.com/document/server-side/chatroom.html#%E6%B7%BB%E5%8A%A0%E8%81%8A%E5%A4%A9%E5%AE%A4%E7%AE%A1%E7%90%86%E5%91%98 + * @param chatroomId (required) + * @param oldAdmin (required) + * @return ApiResponse<EMRemoveRoomAdminResult> + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public ApiResponse removeRoomAdminWithHttpInfo(String chatroomId, String oldAdmin) throws ApiException { + okhttp3.Call localVarCall = removeRoomAdminValidateBeforeCall(chatroomId, oldAdmin, null); + Type localVarReturnType = new TypeToken(){}.getType(); + return localVarApiClient.execute(localVarCall, localVarReturnType); + } + + /** + * 移除聊天室管理员 (asynchronously) + * 将用户的角色从聊天室管理员降为普通聊天室成员。文档介绍:https://docs-im-beta.easemob.com/document/server-side/chatroom.html#%E6%B7%BB%E5%8A%A0%E8%81%8A%E5%A4%A9%E5%AE%A4%E7%AE%A1%E7%90%86%E5%91%98 + * @param chatroomId (required) + * @param oldAdmin (required) + * @param _callback The callback to be executed when the API call finishes + * @return The request call + * @throws ApiException If fail to process the API call, e.g. serializing the request body object + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public okhttp3.Call removeRoomAdminAsync(String chatroomId, String oldAdmin, final ApiCallback _callback) throws ApiException { + + okhttp3.Call localVarCall = removeRoomAdminValidateBeforeCall(chatroomId, oldAdmin, _callback); + Type localVarReturnType = new TypeToken(){}.getType(); + localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); + return localVarCall; + } + /** + * Build call for removeRoomSuperAdmin + * @param superAdmin (required) + * @param _callback Callback for upload/download progress + * @return Call to execute + * @throws ApiException If fail to serialize the request body object + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public okhttp3.Call removeRoomSuperAdminCall(String superAdmin, final ApiCallback _callback) throws ApiException { + String basePath = null; + // Operation Servers + String[] localBasePaths = new String[] { }; + + // Determine Base Path to Use + if (localCustomBaseUrl != null){ + basePath = localCustomBaseUrl; + } else if ( localBasePaths.length > 0 ) { + basePath = localBasePaths[localHostIndex]; + } else { + basePath = null; + } + + Object localVarPostBody = null; + + // create path and map variables + String localVarPath = "/chatrooms/super_admin/{superAdmin}" + .replace("{" + "superAdmin" + "}", localVarApiClient.escapeString(superAdmin.toString())); + + List localVarQueryParams = new ArrayList(); + List localVarCollectionQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + Map localVarCookieParams = new HashMap(); + Map localVarFormParams = new HashMap(); + + final String[] localVarAccepts = { + "application/json" + }; + final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts); + if (localVarAccept != null) { + localVarHeaderParams.put("Accept", localVarAccept); + } + + final String[] localVarContentTypes = { + }; + final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); + if (localVarContentType != null) { + localVarHeaderParams.put("Content-Type", localVarContentType); + } + + String[] localVarAuthNames = new String[] { }; + return localVarApiClient.buildCall(basePath, localVarPath, "DELETE", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); + } + + @SuppressWarnings("rawtypes") + private okhttp3.Call removeRoomSuperAdminValidateBeforeCall(String superAdmin, final ApiCallback _callback) throws ApiException { + // verify the required parameter 'superAdmin' is set + if (superAdmin == null) { + throw new ApiException("Missing the required parameter 'superAdmin' when calling removeRoomSuperAdmin(Async)"); + } + + return removeRoomSuperAdminCall(superAdmin, _callback); + + } + + /** + * 撤销超级管理员 + * 撤销超级管理员权限,用户将不能再创建聊天室。文档介绍:https://docs-im-beta.easemob.com/document/server-side/chatroom.html#%E6%92%A4%E9%94%80%E8%B6%85%E7%BA%A7%E7%AE%A1%E7%90%86%E5%91%98 + * @param superAdmin (required) + * @return EMRemoveRoomSuperAdminResult + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public EMRemoveRoomSuperAdminResult removeRoomSuperAdmin(String superAdmin) throws ApiException { + ApiResponse localVarResp = removeRoomSuperAdminWithHttpInfo(superAdmin); + return localVarResp.getData(); + } + + /** + * 撤销超级管理员 + * 撤销超级管理员权限,用户将不能再创建聊天室。文档介绍:https://docs-im-beta.easemob.com/document/server-side/chatroom.html#%E6%92%A4%E9%94%80%E8%B6%85%E7%BA%A7%E7%AE%A1%E7%90%86%E5%91%98 + * @param superAdmin (required) + * @return ApiResponse<EMRemoveRoomSuperAdminResult> + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public ApiResponse removeRoomSuperAdminWithHttpInfo(String superAdmin) throws ApiException { + okhttp3.Call localVarCall = removeRoomSuperAdminValidateBeforeCall(superAdmin, null); + Type localVarReturnType = new TypeToken(){}.getType(); + return localVarApiClient.execute(localVarCall, localVarReturnType); + } + + /** + * 撤销超级管理员 (asynchronously) + * 撤销超级管理员权限,用户将不能再创建聊天室。文档介绍:https://docs-im-beta.easemob.com/document/server-side/chatroom.html#%E6%92%A4%E9%94%80%E8%B6%85%E7%BA%A7%E7%AE%A1%E7%90%86%E5%91%98 + * @param superAdmin (required) + * @param _callback The callback to be executed when the API call finishes + * @return The request call + * @throws ApiException If fail to process the API call, e.g. serializing the request body object + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public okhttp3.Call removeRoomSuperAdminAsync(String superAdmin, final ApiCallback _callback) throws ApiException { + + okhttp3.Call localVarCall = removeRoomSuperAdminValidateBeforeCall(superAdmin, _callback); + Type localVarReturnType = new TypeToken(){}.getType(); + localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); + return localVarCall; + } + /** + * Build call for removeUserFromRoom + * @param chatroomId (required) + * @param username (required) + * @param _callback Callback for upload/download progress + * @return Call to execute + * @throws ApiException If fail to serialize the request body object + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public okhttp3.Call removeUserFromRoomCall(String chatroomId, String username, final ApiCallback _callback) throws ApiException { + String basePath = null; + // Operation Servers + String[] localBasePaths = new String[] { }; + + // Determine Base Path to Use + if (localCustomBaseUrl != null){ + basePath = localCustomBaseUrl; + } else if ( localBasePaths.length > 0 ) { + basePath = localBasePaths[localHostIndex]; + } else { + basePath = null; + } + + Object localVarPostBody = null; + + // create path and map variables + String localVarPath = "/chatrooms/{chatroom_id}/users/{username}" + .replace("{" + "chatroom_id" + "}", localVarApiClient.escapeString(chatroomId.toString())) + .replace("{" + "username" + "}", localVarApiClient.escapeString(username.toString())); + + List localVarQueryParams = new ArrayList(); + List localVarCollectionQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + Map localVarCookieParams = new HashMap(); + Map localVarFormParams = new HashMap(); + + final String[] localVarAccepts = { + "application/json" + }; + final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts); + if (localVarAccept != null) { + localVarHeaderParams.put("Accept", localVarAccept); + } + + final String[] localVarContentTypes = { + }; + final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); + if (localVarContentType != null) { + localVarHeaderParams.put("Content-Type", localVarContentType); + } + + String[] localVarAuthNames = new String[] { }; + return localVarApiClient.buildCall(basePath, localVarPath, "DELETE", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); + } + + @SuppressWarnings("rawtypes") + private okhttp3.Call removeUserFromRoomValidateBeforeCall(String chatroomId, String username, final ApiCallback _callback) throws ApiException { + // verify the required parameter 'chatroomId' is set + if (chatroomId == null) { + throw new ApiException("Missing the required parameter 'chatroomId' when calling removeUserFromRoom(Async)"); + } + + // verify the required parameter 'username' is set + if (username == null) { + throw new ApiException("Missing the required parameter 'username' when calling removeUserFromRoom(Async)"); + } + + return removeUserFromRoomCall(chatroomId, username, _callback); + + } + + /** + * 移除单个聊天室成员 + * 从聊天室移除一个成员。如果被移除用户不在聊天室中或聊天室不存在,将返回错误。文档介绍:https://docs-im-beta.easemob.com/document/server-side/chatroom.html#%E7%A7%BB%E9%99%A4%E5%8D%95%E4%B8%AA%E8%81%8A%E5%A4%A9%E5%AE%A4%E6%88%90%E5%91%98 + * @param chatroomId (required) + * @param username (required) + * @return EMRemoveUserFromRoomResult + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public EMRemoveUserFromRoomResult removeUserFromRoom(String chatroomId, String username) throws ApiException { + ApiResponse localVarResp = removeUserFromRoomWithHttpInfo(chatroomId, username); + return localVarResp.getData(); + } + + /** + * 移除单个聊天室成员 + * 从聊天室移除一个成员。如果被移除用户不在聊天室中或聊天室不存在,将返回错误。文档介绍:https://docs-im-beta.easemob.com/document/server-side/chatroom.html#%E7%A7%BB%E9%99%A4%E5%8D%95%E4%B8%AA%E8%81%8A%E5%A4%A9%E5%AE%A4%E6%88%90%E5%91%98 + * @param chatroomId (required) + * @param username (required) + * @return ApiResponse<EMRemoveUserFromRoomResult> + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public ApiResponse removeUserFromRoomWithHttpInfo(String chatroomId, String username) throws ApiException { + okhttp3.Call localVarCall = removeUserFromRoomValidateBeforeCall(chatroomId, username, null); + Type localVarReturnType = new TypeToken(){}.getType(); + return localVarApiClient.execute(localVarCall, localVarReturnType); + } + + /** + * 移除单个聊天室成员 (asynchronously) + * 从聊天室移除一个成员。如果被移除用户不在聊天室中或聊天室不存在,将返回错误。文档介绍:https://docs-im-beta.easemob.com/document/server-side/chatroom.html#%E7%A7%BB%E9%99%A4%E5%8D%95%E4%B8%AA%E8%81%8A%E5%A4%A9%E5%AE%A4%E6%88%90%E5%91%98 + * @param chatroomId (required) + * @param username (required) + * @param _callback The callback to be executed when the API call finishes + * @return The request call + * @throws ApiException If fail to process the API call, e.g. serializing the request body object + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public okhttp3.Call removeUserFromRoomAsync(String chatroomId, String username, final ApiCallback _callback) throws ApiException { + + okhttp3.Call localVarCall = removeUserFromRoomValidateBeforeCall(chatroomId, username, _callback); + Type localVarReturnType = new TypeToken(){}.getType(); + localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); + return localVarCall; + } + /** + * Build call for removeUserFromRoomBlockList + * @param chatroomId (required) + * @param username (required) + * @param _callback Callback for upload/download progress + * @return Call to execute + * @throws ApiException If fail to serialize the request body object + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public okhttp3.Call removeUserFromRoomBlockListCall(String chatroomId, String username, final ApiCallback _callback) throws ApiException { + String basePath = null; + // Operation Servers + String[] localBasePaths = new String[] { }; + + // Determine Base Path to Use + if (localCustomBaseUrl != null){ + basePath = localCustomBaseUrl; + } else if ( localBasePaths.length > 0 ) { + basePath = localBasePaths[localHostIndex]; + } else { + basePath = null; + } + + Object localVarPostBody = null; + + // create path and map variables + String localVarPath = "/chatrooms/{chatroom_id}/blocks/users/{username}" + .replace("{" + "chatroom_id" + "}", localVarApiClient.escapeString(chatroomId.toString())) + .replace("{" + "username" + "}", localVarApiClient.escapeString(username.toString())); + + List localVarQueryParams = new ArrayList(); + List localVarCollectionQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + Map localVarCookieParams = new HashMap(); + Map localVarFormParams = new HashMap(); + + final String[] localVarAccepts = { + "application/json" + }; + final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts); + if (localVarAccept != null) { + localVarHeaderParams.put("Accept", localVarAccept); + } + + final String[] localVarContentTypes = { + }; + final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); + if (localVarContentType != null) { + localVarHeaderParams.put("Content-Type", localVarContentType); + } + + String[] localVarAuthNames = new String[] { }; + return localVarApiClient.buildCall(basePath, localVarPath, "DELETE", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); + } + + @SuppressWarnings("rawtypes") + private okhttp3.Call removeUserFromRoomBlockListValidateBeforeCall(String chatroomId, String username, final ApiCallback _callback) throws ApiException { + // verify the required parameter 'chatroomId' is set + if (chatroomId == null) { + throw new ApiException("Missing the required parameter 'chatroomId' when calling removeUserFromRoomBlockList(Async)"); + } + + // verify the required parameter 'username' is set + if (username == null) { + throw new ApiException("Missing the required parameter 'username' when calling removeUserFromRoomBlockList(Async)"); + } + + return removeUserFromRoomBlockListCall(chatroomId, username, _callback); + + } + + /** + * 从聊天室黑名单移出单个用户 + * 将指定用户移出聊天室黑名单。对于聊天室黑名单中的用户,如果需要将其再次加入聊天室,需要先将其从聊天室黑名单中移除。文档介绍:https://docs-im-beta.easemob.com/document/server-side/chatroom.html#%E4%BB%8E%E8%81%8A%E5%A4%A9%E5%AE%A4%E9%BB%91%E5%90%8D%E5%8D%95%E7%A7%BB%E5%87%BA%E5%8D%95%E4%B8%AA%E7%94%A8%E6%88%B7 + * @param chatroomId (required) + * @param username (required) + * @return EMRemoveUserFromRoomBlockListResult + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public EMRemoveUserFromRoomBlockListResult removeUserFromRoomBlockList(String chatroomId, String username) throws ApiException { + ApiResponse localVarResp = removeUserFromRoomBlockListWithHttpInfo(chatroomId, username); + return localVarResp.getData(); + } + + /** + * 从聊天室黑名单移出单个用户 + * 将指定用户移出聊天室黑名单。对于聊天室黑名单中的用户,如果需要将其再次加入聊天室,需要先将其从聊天室黑名单中移除。文档介绍:https://docs-im-beta.easemob.com/document/server-side/chatroom.html#%E4%BB%8E%E8%81%8A%E5%A4%A9%E5%AE%A4%E9%BB%91%E5%90%8D%E5%8D%95%E7%A7%BB%E5%87%BA%E5%8D%95%E4%B8%AA%E7%94%A8%E6%88%B7 + * @param chatroomId (required) + * @param username (required) + * @return ApiResponse<EMRemoveUserFromRoomBlockListResult> + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public ApiResponse removeUserFromRoomBlockListWithHttpInfo(String chatroomId, String username) throws ApiException { + okhttp3.Call localVarCall = removeUserFromRoomBlockListValidateBeforeCall(chatroomId, username, null); + Type localVarReturnType = new TypeToken(){}.getType(); + return localVarApiClient.execute(localVarCall, localVarReturnType); + } + + /** + * 从聊天室黑名单移出单个用户 (asynchronously) + * 将指定用户移出聊天室黑名单。对于聊天室黑名单中的用户,如果需要将其再次加入聊天室,需要先将其从聊天室黑名单中移除。文档介绍:https://docs-im-beta.easemob.com/document/server-side/chatroom.html#%E4%BB%8E%E8%81%8A%E5%A4%A9%E5%AE%A4%E9%BB%91%E5%90%8D%E5%8D%95%E7%A7%BB%E5%87%BA%E5%8D%95%E4%B8%AA%E7%94%A8%E6%88%B7 + * @param chatroomId (required) + * @param username (required) + * @param _callback The callback to be executed when the API call finishes + * @return The request call + * @throws ApiException If fail to process the API call, e.g. serializing the request body object + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public okhttp3.Call removeUserFromRoomBlockListAsync(String chatroomId, String username, final ApiCallback _callback) throws ApiException { + + okhttp3.Call localVarCall = removeUserFromRoomBlockListValidateBeforeCall(chatroomId, username, _callback); + Type localVarReturnType = new TypeToken(){}.getType(); + localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); + return localVarCall; + } + /** + * Build call for removeUserFromRoomWhiteList + * @param chatroomId (required) + * @param username (required) + * @param _callback Callback for upload/download progress + * @return Call to execute + * @throws ApiException If fail to serialize the request body object + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public okhttp3.Call removeUserFromRoomWhiteListCall(String chatroomId, String username, final ApiCallback _callback) throws ApiException { + String basePath = null; + // Operation Servers + String[] localBasePaths = new String[] { }; + + // Determine Base Path to Use + if (localCustomBaseUrl != null){ + basePath = localCustomBaseUrl; + } else if ( localBasePaths.length > 0 ) { + basePath = localBasePaths[localHostIndex]; + } else { + basePath = null; + } + + Object localVarPostBody = null; + + // create path and map variables + String localVarPath = "/chatrooms/{chatroom_id}/white/users/{username}" + .replace("{" + "chatroom_id" + "}", localVarApiClient.escapeString(chatroomId.toString())) + .replace("{" + "username" + "}", localVarApiClient.escapeString(username.toString())); + + List localVarQueryParams = new ArrayList(); + List localVarCollectionQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + Map localVarCookieParams = new HashMap(); + Map localVarFormParams = new HashMap(); + + final String[] localVarAccepts = { + "application/json" + }; + final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts); + if (localVarAccept != null) { + localVarHeaderParams.put("Accept", localVarAccept); + } + + final String[] localVarContentTypes = { + }; + final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); + if (localVarContentType != null) { + localVarHeaderParams.put("Content-Type", localVarContentType); + } + + String[] localVarAuthNames = new String[] { }; + return localVarApiClient.buildCall(basePath, localVarPath, "DELETE", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); + } + + @SuppressWarnings("rawtypes") + private okhttp3.Call removeUserFromRoomWhiteListValidateBeforeCall(String chatroomId, String username, final ApiCallback _callback) throws ApiException { + // verify the required parameter 'chatroomId' is set + if (chatroomId == null) { + throw new ApiException("Missing the required parameter 'chatroomId' when calling removeUserFromRoomWhiteList(Async)"); + } + + // verify the required parameter 'username' is set + if (username == null) { + throw new ApiException("Missing the required parameter 'username' when calling removeUserFromRoomWhiteList(Async)"); + } + + return removeUserFromRoomWhiteListCall(chatroomId, username, _callback); + + } + + /** + * 将用户移出聊天室白名单 + * 将指定用户从聊天室白名单移除。文档介绍:https://docs-im-beta.easemob.com/document/server-side/chatroom.html#%E5%B0%86%E7%94%A8%E6%88%B7%E7%A7%BB%E5%87%BA%E8%81%8A%E5%A4%A9%E5%AE%A4%E7%99%BD%E5%90%8D%E5%8D%95 + * @param chatroomId (required) + * @param username (required) + * @return EMRemoveUserFromRoomWhiteListResult + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public EMRemoveUserFromRoomWhiteListResult removeUserFromRoomWhiteList(String chatroomId, String username) throws ApiException { + ApiResponse localVarResp = removeUserFromRoomWhiteListWithHttpInfo(chatroomId, username); + return localVarResp.getData(); + } + + /** + * 将用户移出聊天室白名单 + * 将指定用户从聊天室白名单移除。文档介绍:https://docs-im-beta.easemob.com/document/server-side/chatroom.html#%E5%B0%86%E7%94%A8%E6%88%B7%E7%A7%BB%E5%87%BA%E8%81%8A%E5%A4%A9%E5%AE%A4%E7%99%BD%E5%90%8D%E5%8D%95 + * @param chatroomId (required) + * @param username (required) + * @return ApiResponse<EMRemoveUserFromRoomWhiteListResult> + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public ApiResponse removeUserFromRoomWhiteListWithHttpInfo(String chatroomId, String username) throws ApiException { + okhttp3.Call localVarCall = removeUserFromRoomWhiteListValidateBeforeCall(chatroomId, username, null); + Type localVarReturnType = new TypeToken(){}.getType(); + return localVarApiClient.execute(localVarCall, localVarReturnType); + } + + /** + * 将用户移出聊天室白名单 (asynchronously) + * 将指定用户从聊天室白名单移除。文档介绍:https://docs-im-beta.easemob.com/document/server-side/chatroom.html#%E5%B0%86%E7%94%A8%E6%88%B7%E7%A7%BB%E5%87%BA%E8%81%8A%E5%A4%A9%E5%AE%A4%E7%99%BD%E5%90%8D%E5%8D%95 + * @param chatroomId (required) + * @param username (required) + * @param _callback The callback to be executed when the API call finishes + * @return The request call + * @throws ApiException If fail to process the API call, e.g. serializing the request body object + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public okhttp3.Call removeUserFromRoomWhiteListAsync(String chatroomId, String username, final ApiCallback _callback) throws ApiException { + + okhttp3.Call localVarCall = removeUserFromRoomWhiteListValidateBeforeCall(chatroomId, username, _callback); + Type localVarReturnType = new TypeToken(){}.getType(); + localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); + return localVarCall; + } + /** + * Build call for setRoomCustomAttributes + * @param chatroomId (required) + * @param username (required) + * @param emSetRoomCustomAttributes (optional) + * @param _callback Callback for upload/download progress + * @return Call to execute + * @throws ApiException If fail to serialize the request body object + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public okhttp3.Call setRoomCustomAttributesCall(String chatroomId, String username, EMSetRoomCustomAttributes emSetRoomCustomAttributes, final ApiCallback _callback) throws ApiException { + String basePath = null; + // Operation Servers + String[] localBasePaths = new String[] { }; + + // Determine Base Path to Use + if (localCustomBaseUrl != null){ + basePath = localCustomBaseUrl; + } else if ( localBasePaths.length > 0 ) { + basePath = localBasePaths[localHostIndex]; + } else { + basePath = null; + } + + Object localVarPostBody = emSetRoomCustomAttributes; + + // create path and map variables + String localVarPath = "/metadata/chatroom/{chatroom_id}/user/{username}" + .replace("{" + "chatroom_id" + "}", localVarApiClient.escapeString(chatroomId.toString())) + .replace("{" + "username" + "}", localVarApiClient.escapeString(username.toString())); + + List localVarQueryParams = new ArrayList(); + List localVarCollectionQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + Map localVarCookieParams = new HashMap(); + Map localVarFormParams = new HashMap(); + + final String[] localVarAccepts = { + "application/json" + }; + final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts); + if (localVarAccept != null) { + localVarHeaderParams.put("Accept", localVarAccept); + } + + final String[] localVarContentTypes = { + "application/json" + }; + final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); + if (localVarContentType != null) { + localVarHeaderParams.put("Content-Type", localVarContentType); + } + + String[] localVarAuthNames = new String[] { }; + return localVarApiClient.buildCall(basePath, localVarPath, "PUT", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); + } + + @SuppressWarnings("rawtypes") + private okhttp3.Call setRoomCustomAttributesValidateBeforeCall(String chatroomId, String username, EMSetRoomCustomAttributes emSetRoomCustomAttributes, final ApiCallback _callback) throws ApiException { + // verify the required parameter 'chatroomId' is set + if (chatroomId == null) { + throw new ApiException("Missing the required parameter 'chatroomId' when calling setRoomCustomAttributes(Async)"); + } + + // verify the required parameter 'username' is set + if (username == null) { + throw new ApiException("Missing the required parameter 'username' when calling setRoomCustomAttributes(Async)"); + } + + return setRoomCustomAttributesCall(chatroomId, username, emSetRoomCustomAttributes, _callback); + + } + + /** + * 设置聊天室自定义属性 + * 指定用户设置特定聊天室的自定义属性。文档介绍:https://docs-im-beta.easemob.com/document/server-side/chatroom.html#%E8%AE%BE%E7%BD%AE%E8%81%8A%E5%A4%A9%E5%AE%A4%E8%87%AA%E5%AE%9A%E4%B9%89%E5%B1%9E%E6%80%A7 + * @param chatroomId (required) + * @param username (required) + * @param emSetRoomCustomAttributes (optional) + * @return EMSetRoomCustomAttributesResult + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public EMSetRoomCustomAttributesResult setRoomCustomAttributes(String chatroomId, String username, EMSetRoomCustomAttributes emSetRoomCustomAttributes) throws ApiException { + ApiResponse localVarResp = setRoomCustomAttributesWithHttpInfo(chatroomId, username, emSetRoomCustomAttributes); + return localVarResp.getData(); + } + + /** + * 设置聊天室自定义属性 + * 指定用户设置特定聊天室的自定义属性。文档介绍:https://docs-im-beta.easemob.com/document/server-side/chatroom.html#%E8%AE%BE%E7%BD%AE%E8%81%8A%E5%A4%A9%E5%AE%A4%E8%87%AA%E5%AE%9A%E4%B9%89%E5%B1%9E%E6%80%A7 + * @param chatroomId (required) + * @param username (required) + * @param emSetRoomCustomAttributes (optional) + * @return ApiResponse<EMSetRoomCustomAttributesResult> + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public ApiResponse setRoomCustomAttributesWithHttpInfo(String chatroomId, String username, EMSetRoomCustomAttributes emSetRoomCustomAttributes) throws ApiException { + okhttp3.Call localVarCall = setRoomCustomAttributesValidateBeforeCall(chatroomId, username, emSetRoomCustomAttributes, null); + Type localVarReturnType = new TypeToken(){}.getType(); + return localVarApiClient.execute(localVarCall, localVarReturnType); + } + + /** + * 设置聊天室自定义属性 (asynchronously) + * 指定用户设置特定聊天室的自定义属性。文档介绍:https://docs-im-beta.easemob.com/document/server-side/chatroom.html#%E8%AE%BE%E7%BD%AE%E8%81%8A%E5%A4%A9%E5%AE%A4%E8%87%AA%E5%AE%9A%E4%B9%89%E5%B1%9E%E6%80%A7 + * @param chatroomId (required) + * @param username (required) + * @param emSetRoomCustomAttributes (optional) + * @param _callback The callback to be executed when the API call finishes + * @return The request call + * @throws ApiException If fail to process the API call, e.g. serializing the request body object + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public okhttp3.Call setRoomCustomAttributesAsync(String chatroomId, String username, EMSetRoomCustomAttributes emSetRoomCustomAttributes, final ApiCallback _callback) throws ApiException { + + okhttp3.Call localVarCall = setRoomCustomAttributesValidateBeforeCall(chatroomId, username, emSetRoomCustomAttributes, _callback); + Type localVarReturnType = new TypeToken(){}.getType(); + localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); + return localVarCall; + } + /** + * Build call for unmuteAllRoomMember + * @param chatroomId (required) + * @param _callback Callback for upload/download progress + * @return Call to execute + * @throws ApiException If fail to serialize the request body object + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public okhttp3.Call unmuteAllRoomMemberCall(String chatroomId, final ApiCallback _callback) throws ApiException { + String basePath = null; + // Operation Servers + String[] localBasePaths = new String[] { }; + + // Determine Base Path to Use + if (localCustomBaseUrl != null){ + basePath = localCustomBaseUrl; + } else if ( localBasePaths.length > 0 ) { + basePath = localBasePaths[localHostIndex]; + } else { + basePath = null; + } + + Object localVarPostBody = null; + + // create path and map variables + String localVarPath = "/chatrooms/{chatroom_id}/ban" + .replace("{" + "chatroom_id" + "}", localVarApiClient.escapeString(chatroomId.toString())); + + List localVarQueryParams = new ArrayList(); + List localVarCollectionQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + Map localVarCookieParams = new HashMap(); + Map localVarFormParams = new HashMap(); + + final String[] localVarAccepts = { + "application/json" + }; + final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts); + if (localVarAccept != null) { + localVarHeaderParams.put("Accept", localVarAccept); + } + + final String[] localVarContentTypes = { + }; + final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); + if (localVarContentType != null) { + localVarHeaderParams.put("Content-Type", localVarContentType); + } + + String[] localVarAuthNames = new String[] { }; + return localVarApiClient.buildCall(basePath, localVarPath, "DELETE", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); + } + + @SuppressWarnings("rawtypes") + private okhttp3.Call unmuteAllRoomMemberValidateBeforeCall(String chatroomId, final ApiCallback _callback) throws ApiException { + // verify the required parameter 'chatroomId' is set + if (chatroomId == null) { + throw new ApiException("Missing the required parameter 'chatroomId' when calling unmuteAllRoomMember(Async)"); + } + + return unmuteAllRoomMemberCall(chatroomId, _callback); + + } + + /** + * 解除聊天室全员禁言 + * 一键取消对聊天室全体成员的禁言。解除禁言后,聊天室成员可以在聊天室中正常发送消息。文档介绍:https://docs-im-beta.easemob.com/document/server-side/chatroom.html#%E8%A7%A3%E9%99%A4%E8%81%8A%E5%A4%A9%E5%AE%A4%E5%85%A8%E5%91%98%E7%A6%81%E8%A8%80 + * @param chatroomId (required) + * @return EMUnmuteAllRoomMemberResult + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public EMUnmuteAllRoomMemberResult unmuteAllRoomMember(String chatroomId) throws ApiException { + ApiResponse localVarResp = unmuteAllRoomMemberWithHttpInfo(chatroomId); + return localVarResp.getData(); + } + + /** + * 解除聊天室全员禁言 + * 一键取消对聊天室全体成员的禁言。解除禁言后,聊天室成员可以在聊天室中正常发送消息。文档介绍:https://docs-im-beta.easemob.com/document/server-side/chatroom.html#%E8%A7%A3%E9%99%A4%E8%81%8A%E5%A4%A9%E5%AE%A4%E5%85%A8%E5%91%98%E7%A6%81%E8%A8%80 + * @param chatroomId (required) + * @return ApiResponse<EMUnmuteAllRoomMemberResult> + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public ApiResponse unmuteAllRoomMemberWithHttpInfo(String chatroomId) throws ApiException { + okhttp3.Call localVarCall = unmuteAllRoomMemberValidateBeforeCall(chatroomId, null); + Type localVarReturnType = new TypeToken(){}.getType(); + return localVarApiClient.execute(localVarCall, localVarReturnType); + } + + /** + * 解除聊天室全员禁言 (asynchronously) + * 一键取消对聊天室全体成员的禁言。解除禁言后,聊天室成员可以在聊天室中正常发送消息。文档介绍:https://docs-im-beta.easemob.com/document/server-side/chatroom.html#%E8%A7%A3%E9%99%A4%E8%81%8A%E5%A4%A9%E5%AE%A4%E5%85%A8%E5%91%98%E7%A6%81%E8%A8%80 + * @param chatroomId (required) + * @param _callback The callback to be executed when the API call finishes + * @return The request call + * @throws ApiException If fail to process the API call, e.g. serializing the request body object + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public okhttp3.Call unmuteAllRoomMemberAsync(String chatroomId, final ApiCallback _callback) throws ApiException { + + okhttp3.Call localVarCall = unmuteAllRoomMemberValidateBeforeCall(chatroomId, _callback); + Type localVarReturnType = new TypeToken(){}.getType(); + localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); + return localVarCall; + } + /** + * Build call for unmuteRoomMember + * @param chatroomId (required) + * @param username (required) + * @param _callback Callback for upload/download progress + * @return Call to execute + * @throws ApiException If fail to serialize the request body object + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public okhttp3.Call unmuteRoomMemberCall(String chatroomId, String username, final ApiCallback _callback) throws ApiException { + String basePath = null; + // Operation Servers + String[] localBasePaths = new String[] { }; + + // Determine Base Path to Use + if (localCustomBaseUrl != null){ + basePath = localCustomBaseUrl; + } else if ( localBasePaths.length > 0 ) { + basePath = localBasePaths[localHostIndex]; + } else { + basePath = null; + } + + Object localVarPostBody = null; + + // create path and map variables + String localVarPath = "/chatrooms/{chatroom_id}/mute/{username}" + .replace("{" + "chatroom_id" + "}", localVarApiClient.escapeString(chatroomId.toString())) + .replace("{" + "username" + "}", localVarApiClient.escapeString(username.toString())); + + List localVarQueryParams = new ArrayList(); + List localVarCollectionQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + Map localVarCookieParams = new HashMap(); + Map localVarFormParams = new HashMap(); + + final String[] localVarAccepts = { + "application/json" + }; + final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts); + if (localVarAccept != null) { + localVarHeaderParams.put("Accept", localVarAccept); + } + + final String[] localVarContentTypes = { + }; + final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); + if (localVarContentType != null) { + localVarHeaderParams.put("Content-Type", localVarContentType); + } + + String[] localVarAuthNames = new String[] { }; + return localVarApiClient.buildCall(basePath, localVarPath, "DELETE", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); + } + + @SuppressWarnings("rawtypes") + private okhttp3.Call unmuteRoomMemberValidateBeforeCall(String chatroomId, String username, final ApiCallback _callback) throws ApiException { + // verify the required parameter 'chatroomId' is set + if (chatroomId == null) { + throw new ApiException("Missing the required parameter 'chatroomId' when calling unmuteRoomMember(Async)"); + } + + // verify the required parameter 'username' is set + if (username == null) { + throw new ApiException("Missing the required parameter 'username' when calling unmuteRoomMember(Async)"); + } + + return unmuteRoomMemberCall(chatroomId, username, _callback); + + } + + /** + * 解除聊天室禁言成员 + * 解除对一个聊天室成员的禁言。解除禁言后,该成员可以正常在聊天室中发送消息。文档介绍:https://docs-im-beta.easemob.com/document/server-side/chatroom.html#%E8%A7%A3%E9%99%A4%E8%81%8A%E5%A4%A9%E5%AE%A4%E7%A6%81%E8%A8%80%E6%88%90%E5%91%98 + * @param chatroomId (required) + * @param username (required) + * @return EMUnmuteRoomMemberResult + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public EMUnmuteRoomMemberResult unmuteRoomMember(String chatroomId, String username) throws ApiException { + ApiResponse localVarResp = unmuteRoomMemberWithHttpInfo(chatroomId, username); + return localVarResp.getData(); + } + + /** + * 解除聊天室禁言成员 + * 解除对一个聊天室成员的禁言。解除禁言后,该成员可以正常在聊天室中发送消息。文档介绍:https://docs-im-beta.easemob.com/document/server-side/chatroom.html#%E8%A7%A3%E9%99%A4%E8%81%8A%E5%A4%A9%E5%AE%A4%E7%A6%81%E8%A8%80%E6%88%90%E5%91%98 + * @param chatroomId (required) + * @param username (required) + * @return ApiResponse<EMUnmuteRoomMemberResult> + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public ApiResponse unmuteRoomMemberWithHttpInfo(String chatroomId, String username) throws ApiException { + okhttp3.Call localVarCall = unmuteRoomMemberValidateBeforeCall(chatroomId, username, null); + Type localVarReturnType = new TypeToken(){}.getType(); + return localVarApiClient.execute(localVarCall, localVarReturnType); + } + + /** + * 解除聊天室禁言成员 (asynchronously) + * 解除对一个聊天室成员的禁言。解除禁言后,该成员可以正常在聊天室中发送消息。文档介绍:https://docs-im-beta.easemob.com/document/server-side/chatroom.html#%E8%A7%A3%E9%99%A4%E8%81%8A%E5%A4%A9%E5%AE%A4%E7%A6%81%E8%A8%80%E6%88%90%E5%91%98 + * @param chatroomId (required) + * @param username (required) + * @param _callback The callback to be executed when the API call finishes + * @return The request call + * @throws ApiException If fail to process the API call, e.g. serializing the request body object + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public okhttp3.Call unmuteRoomMemberAsync(String chatroomId, String username, final ApiCallback _callback) throws ApiException { + + okhttp3.Call localVarCall = unmuteRoomMemberValidateBeforeCall(chatroomId, username, _callback); + Type localVarReturnType = new TypeToken(){}.getType(); + localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); + return localVarCall; + } +} diff --git a/src/main/java/com/easemob/im/api/ThreadApi.java b/src/main/java/com/easemob/im/api/ThreadApi.java new file mode 100644 index 000000000..7c60a0106 --- /dev/null +++ b/src/main/java/com/easemob/im/api/ThreadApi.java @@ -0,0 +1,1364 @@ +/* + * EMService + * Easemob Rest API + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.easemob.im.api; + +import com.easemob.im.ApiCallback; +import com.easemob.im.ApiClient; +import com.easemob.im.ApiException; +import com.easemob.im.ApiResponse; +import com.easemob.im.Configuration; +import com.easemob.im.Pair; +import com.easemob.im.ProgressRequestBody; +import com.easemob.im.ProgressResponseBody; + +import com.google.gson.reflect.TypeToken; + +import java.io.IOException; + + +import com.easemob.im.api.model.EMAddMultipleUsersToThread; +import com.easemob.im.api.model.EMAddMultipleUsersToThreadResult; +import com.easemob.im.api.model.EMCreateThread; +import com.easemob.im.api.model.EMCreateThreadResult; +import com.easemob.im.api.model.EMDeleteThreadResult; +import com.easemob.im.api.model.EMGetThreadMemberListResult; +import com.easemob.im.api.model.EMGetThreadsUnderAppResult; +import com.easemob.im.api.model.EMGetUserJoinedThreadsResult; +import com.easemob.im.api.model.EMGetUserJoinedThreadsUnderGroupResult; +import com.easemob.im.api.model.EMModifyThread; +import com.easemob.im.api.model.EMModifyThreadResult; +import com.easemob.im.api.model.EMRemoveMultipleUsersFromThread; +import com.easemob.im.api.model.EMRemoveMultipleUsersFromThreadResult; + +import java.lang.reflect.Type; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +public class ThreadApi { + private ApiClient localVarApiClient; + private int localHostIndex; + private String localCustomBaseUrl; + + public ThreadApi() { + this(Configuration.getDefaultApiClient()); + } + + public ThreadApi(ApiClient apiClient) { + this.localVarApiClient = apiClient; + } + + public ApiClient getApiClient() { + return localVarApiClient; + } + + public void setApiClient(ApiClient apiClient) { + this.localVarApiClient = apiClient; + } + + public int getHostIndex() { + return localHostIndex; + } + + public void setHostIndex(int hostIndex) { + this.localHostIndex = hostIndex; + } + + public String getCustomBaseUrl() { + return localCustomBaseUrl; + } + + public void setCustomBaseUrl(String customBaseUrl) { + this.localCustomBaseUrl = customBaseUrl; + } + + /** + * Build call for addMultipleUsersToThread + * @param threadId (required) + * @param emAddMultipleUsersToThread (optional) + * @param _callback Callback for upload/download progress + * @return Call to execute + * @throws ApiException If fail to serialize the request body object + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public okhttp3.Call addMultipleUsersToThreadCall(String threadId, EMAddMultipleUsersToThread emAddMultipleUsersToThread, final ApiCallback _callback) throws ApiException { + String basePath = null; + // Operation Servers + String[] localBasePaths = new String[] { }; + + // Determine Base Path to Use + if (localCustomBaseUrl != null){ + basePath = localCustomBaseUrl; + } else if ( localBasePaths.length > 0 ) { + basePath = localBasePaths[localHostIndex]; + } else { + basePath = null; + } + + Object localVarPostBody = emAddMultipleUsersToThread; + + // create path and map variables + String localVarPath = "/thread/{thread_id}/users" + .replace("{" + "thread_id" + "}", localVarApiClient.escapeString(threadId.toString())); + + List localVarQueryParams = new ArrayList(); + List localVarCollectionQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + Map localVarCookieParams = new HashMap(); + Map localVarFormParams = new HashMap(); + + final String[] localVarAccepts = { + "application/json" + }; + final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts); + if (localVarAccept != null) { + localVarHeaderParams.put("Accept", localVarAccept); + } + + final String[] localVarContentTypes = { + "application/json" + }; + final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); + if (localVarContentType != null) { + localVarHeaderParams.put("Content-Type", localVarContentType); + } + + String[] localVarAuthNames = new String[] { }; + return localVarApiClient.buildCall(basePath, localVarPath, "POST", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); + } + + @SuppressWarnings("rawtypes") + private okhttp3.Call addMultipleUsersToThreadValidateBeforeCall(String threadId, EMAddMultipleUsersToThread emAddMultipleUsersToThread, final ApiCallback _callback) throws ApiException { + // verify the required parameter 'threadId' is set + if (threadId == null) { + throw new ApiException("Missing the required parameter 'threadId' when calling addMultipleUsersToThread(Async)"); + } + + return addMultipleUsersToThreadCall(threadId, emAddMultipleUsersToThread, _callback); + + } + + /** + * 用户批量加入子区 + * 用户批量加入指定的子区。文档介绍:https://docs-im-beta.easemob.com/document/server-side/group.html#%E7%94%A8%E6%88%B7%E6%89%B9%E9%87%8F%E5%8A%A0%E5%85%A5%E5%AD%90%E5%8C%BA + * @param threadId (required) + * @param emAddMultipleUsersToThread (optional) + * @return EMAddMultipleUsersToThreadResult + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public EMAddMultipleUsersToThreadResult addMultipleUsersToThread(String threadId, EMAddMultipleUsersToThread emAddMultipleUsersToThread) throws ApiException { + ApiResponse localVarResp = addMultipleUsersToThreadWithHttpInfo(threadId, emAddMultipleUsersToThread); + return localVarResp.getData(); + } + + /** + * 用户批量加入子区 + * 用户批量加入指定的子区。文档介绍:https://docs-im-beta.easemob.com/document/server-side/group.html#%E7%94%A8%E6%88%B7%E6%89%B9%E9%87%8F%E5%8A%A0%E5%85%A5%E5%AD%90%E5%8C%BA + * @param threadId (required) + * @param emAddMultipleUsersToThread (optional) + * @return ApiResponse<EMAddMultipleUsersToThreadResult> + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public ApiResponse addMultipleUsersToThreadWithHttpInfo(String threadId, EMAddMultipleUsersToThread emAddMultipleUsersToThread) throws ApiException { + okhttp3.Call localVarCall = addMultipleUsersToThreadValidateBeforeCall(threadId, emAddMultipleUsersToThread, null); + Type localVarReturnType = new TypeToken(){}.getType(); + return localVarApiClient.execute(localVarCall, localVarReturnType); + } + + /** + * 用户批量加入子区 (asynchronously) + * 用户批量加入指定的子区。文档介绍:https://docs-im-beta.easemob.com/document/server-side/group.html#%E7%94%A8%E6%88%B7%E6%89%B9%E9%87%8F%E5%8A%A0%E5%85%A5%E5%AD%90%E5%8C%BA + * @param threadId (required) + * @param emAddMultipleUsersToThread (optional) + * @param _callback The callback to be executed when the API call finishes + * @return The request call + * @throws ApiException If fail to process the API call, e.g. serializing the request body object + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public okhttp3.Call addMultipleUsersToThreadAsync(String threadId, EMAddMultipleUsersToThread emAddMultipleUsersToThread, final ApiCallback _callback) throws ApiException { + + okhttp3.Call localVarCall = addMultipleUsersToThreadValidateBeforeCall(threadId, emAddMultipleUsersToThread, _callback); + Type localVarReturnType = new TypeToken(){}.getType(); + localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); + return localVarCall; + } + /** + * Build call for createThread + * @param emCreateThread (optional) + * @param _callback Callback for upload/download progress + * @return Call to execute + * @throws ApiException If fail to serialize the request body object + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public okhttp3.Call createThreadCall(EMCreateThread emCreateThread, final ApiCallback _callback) throws ApiException { + String basePath = null; + // Operation Servers + String[] localBasePaths = new String[] { }; + + // Determine Base Path to Use + if (localCustomBaseUrl != null){ + basePath = localCustomBaseUrl; + } else if ( localBasePaths.length > 0 ) { + basePath = localBasePaths[localHostIndex]; + } else { + basePath = null; + } + + Object localVarPostBody = emCreateThread; + + // create path and map variables + String localVarPath = "/thread"; + + List localVarQueryParams = new ArrayList(); + List localVarCollectionQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + Map localVarCookieParams = new HashMap(); + Map localVarFormParams = new HashMap(); + + final String[] localVarAccepts = { + "application/json" + }; + final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts); + if (localVarAccept != null) { + localVarHeaderParams.put("Accept", localVarAccept); + } + + final String[] localVarContentTypes = { + "application/json" + }; + final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); + if (localVarContentType != null) { + localVarHeaderParams.put("Content-Type", localVarContentType); + } + + String[] localVarAuthNames = new String[] { }; + return localVarApiClient.buildCall(basePath, localVarPath, "POST", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); + } + + @SuppressWarnings("rawtypes") + private okhttp3.Call createThreadValidateBeforeCall(EMCreateThread emCreateThread, final ApiCallback _callback) throws ApiException { + return createThreadCall(emCreateThread, _callback); + + } + + /** + * 创建子区 + * 创建子区。文档介绍:https://docs-im-beta.easemob.com/document/server-side/group.html#%E5%88%9B%E5%BB%BA%E5%AD%90%E5%8C%BA + * @param emCreateThread (optional) + * @return EMCreateThreadResult + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public EMCreateThreadResult createThread(EMCreateThread emCreateThread) throws ApiException { + ApiResponse localVarResp = createThreadWithHttpInfo(emCreateThread); + return localVarResp.getData(); + } + + /** + * 创建子区 + * 创建子区。文档介绍:https://docs-im-beta.easemob.com/document/server-side/group.html#%E5%88%9B%E5%BB%BA%E5%AD%90%E5%8C%BA + * @param emCreateThread (optional) + * @return ApiResponse<EMCreateThreadResult> + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public ApiResponse createThreadWithHttpInfo(EMCreateThread emCreateThread) throws ApiException { + okhttp3.Call localVarCall = createThreadValidateBeforeCall(emCreateThread, null); + Type localVarReturnType = new TypeToken(){}.getType(); + return localVarApiClient.execute(localVarCall, localVarReturnType); + } + + /** + * 创建子区 (asynchronously) + * 创建子区。文档介绍:https://docs-im-beta.easemob.com/document/server-side/group.html#%E5%88%9B%E5%BB%BA%E5%AD%90%E5%8C%BA + * @param emCreateThread (optional) + * @param _callback The callback to be executed when the API call finishes + * @return The request call + * @throws ApiException If fail to process the API call, e.g. serializing the request body object + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public okhttp3.Call createThreadAsync(EMCreateThread emCreateThread, final ApiCallback _callback) throws ApiException { + + okhttp3.Call localVarCall = createThreadValidateBeforeCall(emCreateThread, _callback); + Type localVarReturnType = new TypeToken(){}.getType(); + localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); + return localVarCall; + } + /** + * Build call for deleteThread + * @param threadId (required) + * @param _callback Callback for upload/download progress + * @return Call to execute + * @throws ApiException If fail to serialize the request body object + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public okhttp3.Call deleteThreadCall(String threadId, final ApiCallback _callback) throws ApiException { + String basePath = null; + // Operation Servers + String[] localBasePaths = new String[] { }; + + // Determine Base Path to Use + if (localCustomBaseUrl != null){ + basePath = localCustomBaseUrl; + } else if ( localBasePaths.length > 0 ) { + basePath = localBasePaths[localHostIndex]; + } else { + basePath = null; + } + + Object localVarPostBody = null; + + // create path and map variables + String localVarPath = "/thread/{thread_id}" + .replace("{" + "thread_id" + "}", localVarApiClient.escapeString(threadId.toString())); + + List localVarQueryParams = new ArrayList(); + List localVarCollectionQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + Map localVarCookieParams = new HashMap(); + Map localVarFormParams = new HashMap(); + + final String[] localVarAccepts = { + "application/json" + }; + final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts); + if (localVarAccept != null) { + localVarHeaderParams.put("Accept", localVarAccept); + } + + final String[] localVarContentTypes = { + }; + final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); + if (localVarContentType != null) { + localVarHeaderParams.put("Content-Type", localVarContentType); + } + + String[] localVarAuthNames = new String[] { }; + return localVarApiClient.buildCall(basePath, localVarPath, "DELETE", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); + } + + @SuppressWarnings("rawtypes") + private okhttp3.Call deleteThreadValidateBeforeCall(String threadId, final ApiCallback _callback) throws ApiException { + // verify the required parameter 'threadId' is set + if (threadId == null) { + throw new ApiException("Missing the required parameter 'threadId' when calling deleteThread(Async)"); + } + + return deleteThreadCall(threadId, _callback); + + } + + /** + * 删除子区 + * 删除指定子区。文档介绍:https://docs-im-beta.easemob.com/document/server-side/group.html#%E5%88%A0%E9%99%A4%E5%AD%90%E5%8C%BA + * @param threadId (required) + * @return EMDeleteThreadResult + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public EMDeleteThreadResult deleteThread(String threadId) throws ApiException { + ApiResponse localVarResp = deleteThreadWithHttpInfo(threadId); + return localVarResp.getData(); + } + + /** + * 删除子区 + * 删除指定子区。文档介绍:https://docs-im-beta.easemob.com/document/server-side/group.html#%E5%88%A0%E9%99%A4%E5%AD%90%E5%8C%BA + * @param threadId (required) + * @return ApiResponse<EMDeleteThreadResult> + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public ApiResponse deleteThreadWithHttpInfo(String threadId) throws ApiException { + okhttp3.Call localVarCall = deleteThreadValidateBeforeCall(threadId, null); + Type localVarReturnType = new TypeToken(){}.getType(); + return localVarApiClient.execute(localVarCall, localVarReturnType); + } + + /** + * 删除子区 (asynchronously) + * 删除指定子区。文档介绍:https://docs-im-beta.easemob.com/document/server-side/group.html#%E5%88%A0%E9%99%A4%E5%AD%90%E5%8C%BA + * @param threadId (required) + * @param _callback The callback to be executed when the API call finishes + * @return The request call + * @throws ApiException If fail to process the API call, e.g. serializing the request body object + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public okhttp3.Call deleteThreadAsync(String threadId, final ApiCallback _callback) throws ApiException { + + okhttp3.Call localVarCall = deleteThreadValidateBeforeCall(threadId, _callback); + Type localVarReturnType = new TypeToken(){}.getType(); + localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); + return localVarCall; + } + /** + * Build call for getThreadMemberList + * @param threadId (required) + * @param limit 每次期望返回的子区成员数量,取值范围为 [1,50],默认值为 50 (optional) + * @param cursor 数据查询的起始位置 (optional) + * @param _callback Callback for upload/download progress + * @return Call to execute + * @throws ApiException If fail to serialize the request body object + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public okhttp3.Call getThreadMemberListCall(String threadId, Integer limit, String cursor, final ApiCallback _callback) throws ApiException { + String basePath = null; + // Operation Servers + String[] localBasePaths = new String[] { }; + + // Determine Base Path to Use + if (localCustomBaseUrl != null){ + basePath = localCustomBaseUrl; + } else if ( localBasePaths.length > 0 ) { + basePath = localBasePaths[localHostIndex]; + } else { + basePath = null; + } + + Object localVarPostBody = null; + + // create path and map variables + String localVarPath = "/thread/{thread_id}/users" + .replace("{" + "thread_id" + "}", localVarApiClient.escapeString(threadId.toString())); + + List localVarQueryParams = new ArrayList(); + List localVarCollectionQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + Map localVarCookieParams = new HashMap(); + Map localVarFormParams = new HashMap(); + + if (limit != null) { + localVarQueryParams.addAll(localVarApiClient.parameterToPair("limit", limit)); + } + + if (cursor != null) { + localVarQueryParams.addAll(localVarApiClient.parameterToPair("cursor", cursor)); + } + + final String[] localVarAccepts = { + "application/json" + }; + final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts); + if (localVarAccept != null) { + localVarHeaderParams.put("Accept", localVarAccept); + } + + final String[] localVarContentTypes = { + }; + final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); + if (localVarContentType != null) { + localVarHeaderParams.put("Content-Type", localVarContentType); + } + + String[] localVarAuthNames = new String[] { }; + return localVarApiClient.buildCall(basePath, localVarPath, "GET", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); + } + + @SuppressWarnings("rawtypes") + private okhttp3.Call getThreadMemberListValidateBeforeCall(String threadId, Integer limit, String cursor, final ApiCallback _callback) throws ApiException { + // verify the required parameter 'threadId' is set + if (threadId == null) { + throw new ApiException("Missing the required parameter 'threadId' when calling getThreadMemberList(Async)"); + } + + return getThreadMemberListCall(threadId, limit, cursor, _callback); + + } + + /** + * 获取子区成员列表(分页) + * 分页获取应用下的子区列表。文档介绍:https://docs-im-beta.easemob.com/document/server-side/group.html#%E8%8E%B7%E5%8F%96%E5%AD%90%E5%8C%BA%E6%88%90%E5%91%98%E5%88%97%E8%A1%A8-%E5%88%86%E9%A1%B5 + * @param threadId (required) + * @param limit 每次期望返回的子区成员数量,取值范围为 [1,50],默认值为 50 (optional) + * @param cursor 数据查询的起始位置 (optional) + * @return EMGetThreadMemberListResult + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public EMGetThreadMemberListResult getThreadMemberList(String threadId, Integer limit, String cursor) throws ApiException { + ApiResponse localVarResp = getThreadMemberListWithHttpInfo(threadId, limit, cursor); + return localVarResp.getData(); + } + + /** + * 获取子区成员列表(分页) + * 分页获取应用下的子区列表。文档介绍:https://docs-im-beta.easemob.com/document/server-side/group.html#%E8%8E%B7%E5%8F%96%E5%AD%90%E5%8C%BA%E6%88%90%E5%91%98%E5%88%97%E8%A1%A8-%E5%88%86%E9%A1%B5 + * @param threadId (required) + * @param limit 每次期望返回的子区成员数量,取值范围为 [1,50],默认值为 50 (optional) + * @param cursor 数据查询的起始位置 (optional) + * @return ApiResponse<EMGetThreadMemberListResult> + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public ApiResponse getThreadMemberListWithHttpInfo(String threadId, Integer limit, String cursor) throws ApiException { + okhttp3.Call localVarCall = getThreadMemberListValidateBeforeCall(threadId, limit, cursor, null); + Type localVarReturnType = new TypeToken(){}.getType(); + return localVarApiClient.execute(localVarCall, localVarReturnType); + } + + /** + * 获取子区成员列表(分页) (asynchronously) + * 分页获取应用下的子区列表。文档介绍:https://docs-im-beta.easemob.com/document/server-side/group.html#%E8%8E%B7%E5%8F%96%E5%AD%90%E5%8C%BA%E6%88%90%E5%91%98%E5%88%97%E8%A1%A8-%E5%88%86%E9%A1%B5 + * @param threadId (required) + * @param limit 每次期望返回的子区成员数量,取值范围为 [1,50],默认值为 50 (optional) + * @param cursor 数据查询的起始位置 (optional) + * @param _callback The callback to be executed when the API call finishes + * @return The request call + * @throws ApiException If fail to process the API call, e.g. serializing the request body object + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public okhttp3.Call getThreadMemberListAsync(String threadId, Integer limit, String cursor, final ApiCallback _callback) throws ApiException { + + okhttp3.Call localVarCall = getThreadMemberListValidateBeforeCall(threadId, limit, cursor, _callback); + Type localVarReturnType = new TypeToken(){}.getType(); + localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); + return localVarCall; + } + /** + * Build call for getThreadsUnderApp + * @param limit 每次期望返回的子区数量,取值范围为 [1,50],默认值为 50 (optional) + * @param cursor 数据查询的起始位置 (optional) + * @param sort 获取的子区的排序顺序: - asc:按子区创建时间的正序; - (默认)desc:按子区创建时间的倒序 (optional) + * @param _callback Callback for upload/download progress + * @return Call to execute + * @throws ApiException If fail to serialize the request body object + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public okhttp3.Call getThreadsUnderAppCall(Integer limit, String cursor, String sort, final ApiCallback _callback) throws ApiException { + String basePath = null; + // Operation Servers + String[] localBasePaths = new String[] { }; + + // Determine Base Path to Use + if (localCustomBaseUrl != null){ + basePath = localCustomBaseUrl; + } else if ( localBasePaths.length > 0 ) { + basePath = localBasePaths[localHostIndex]; + } else { + basePath = null; + } + + Object localVarPostBody = null; + + // create path and map variables + String localVarPath = "/thread"; + + List localVarQueryParams = new ArrayList(); + List localVarCollectionQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + Map localVarCookieParams = new HashMap(); + Map localVarFormParams = new HashMap(); + + if (limit != null) { + localVarQueryParams.addAll(localVarApiClient.parameterToPair("limit", limit)); + } + + if (cursor != null) { + localVarQueryParams.addAll(localVarApiClient.parameterToPair("cursor", cursor)); + } + + if (sort != null) { + localVarQueryParams.addAll(localVarApiClient.parameterToPair("sort", sort)); + } + + final String[] localVarAccepts = { + "application/json" + }; + final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts); + if (localVarAccept != null) { + localVarHeaderParams.put("Accept", localVarAccept); + } + + final String[] localVarContentTypes = { + }; + final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); + if (localVarContentType != null) { + localVarHeaderParams.put("Content-Type", localVarContentType); + } + + String[] localVarAuthNames = new String[] { }; + return localVarApiClient.buildCall(basePath, localVarPath, "GET", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); + } + + @SuppressWarnings("rawtypes") + private okhttp3.Call getThreadsUnderAppValidateBeforeCall(Integer limit, String cursor, String sort, final ApiCallback _callback) throws ApiException { + return getThreadsUnderAppCall(limit, cursor, sort, _callback); + + } + + /** + * 获取 app 中的子区 + * 分页获取应用下的子区列表。文档介绍:https://docs-im-beta.easemob.com/document/server-side/group.html#%E8%8E%B7%E5%8F%96-app-%E4%B8%AD%E7%9A%84%E5%AD%90%E5%8C%BA + * @param limit 每次期望返回的子区数量,取值范围为 [1,50],默认值为 50 (optional) + * @param cursor 数据查询的起始位置 (optional) + * @param sort 获取的子区的排序顺序: - asc:按子区创建时间的正序; - (默认)desc:按子区创建时间的倒序 (optional) + * @return EMGetThreadsUnderAppResult + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public EMGetThreadsUnderAppResult getThreadsUnderApp(Integer limit, String cursor, String sort) throws ApiException { + ApiResponse localVarResp = getThreadsUnderAppWithHttpInfo(limit, cursor, sort); + return localVarResp.getData(); + } + + /** + * 获取 app 中的子区 + * 分页获取应用下的子区列表。文档介绍:https://docs-im-beta.easemob.com/document/server-side/group.html#%E8%8E%B7%E5%8F%96-app-%E4%B8%AD%E7%9A%84%E5%AD%90%E5%8C%BA + * @param limit 每次期望返回的子区数量,取值范围为 [1,50],默认值为 50 (optional) + * @param cursor 数据查询的起始位置 (optional) + * @param sort 获取的子区的排序顺序: - asc:按子区创建时间的正序; - (默认)desc:按子区创建时间的倒序 (optional) + * @return ApiResponse<EMGetThreadsUnderAppResult> + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public ApiResponse getThreadsUnderAppWithHttpInfo(Integer limit, String cursor, String sort) throws ApiException { + okhttp3.Call localVarCall = getThreadsUnderAppValidateBeforeCall(limit, cursor, sort, null); + Type localVarReturnType = new TypeToken(){}.getType(); + return localVarApiClient.execute(localVarCall, localVarReturnType); + } + + /** + * 获取 app 中的子区 (asynchronously) + * 分页获取应用下的子区列表。文档介绍:https://docs-im-beta.easemob.com/document/server-side/group.html#%E8%8E%B7%E5%8F%96-app-%E4%B8%AD%E7%9A%84%E5%AD%90%E5%8C%BA + * @param limit 每次期望返回的子区数量,取值范围为 [1,50],默认值为 50 (optional) + * @param cursor 数据查询的起始位置 (optional) + * @param sort 获取的子区的排序顺序: - asc:按子区创建时间的正序; - (默认)desc:按子区创建时间的倒序 (optional) + * @param _callback The callback to be executed when the API call finishes + * @return The request call + * @throws ApiException If fail to process the API call, e.g. serializing the request body object + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public okhttp3.Call getThreadsUnderAppAsync(Integer limit, String cursor, String sort, final ApiCallback _callback) throws ApiException { + + okhttp3.Call localVarCall = getThreadsUnderAppValidateBeforeCall(limit, cursor, sort, _callback); + Type localVarReturnType = new TypeToken(){}.getType(); + localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); + return localVarCall; + } + /** + * Build call for getUserJoinedThreads + * @param username (required) + * @param limit 每次期望返回的子区数量,取值范围为 [1,50],默认值为 50 (optional) + * @param cursor 数据查询的起始位置 (optional) + * @param sort 获取的子区的排序顺序: - asc:按用户加入子区的时间的正序; - (默认)desc:按用户加入子区的时间的倒序 (optional) + * @param _callback Callback for upload/download progress + * @return Call to execute + * @throws ApiException If fail to serialize the request body object + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public okhttp3.Call getUserJoinedThreadsCall(String username, Integer limit, String cursor, String sort, final ApiCallback _callback) throws ApiException { + String basePath = null; + // Operation Servers + String[] localBasePaths = new String[] { }; + + // Determine Base Path to Use + if (localCustomBaseUrl != null){ + basePath = localCustomBaseUrl; + } else if ( localBasePaths.length > 0 ) { + basePath = localBasePaths[localHostIndex]; + } else { + basePath = null; + } + + Object localVarPostBody = null; + + // create path and map variables + String localVarPath = "/threads/user/{username}" + .replace("{" + "username" + "}", localVarApiClient.escapeString(username.toString())); + + List localVarQueryParams = new ArrayList(); + List localVarCollectionQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + Map localVarCookieParams = new HashMap(); + Map localVarFormParams = new HashMap(); + + if (limit != null) { + localVarQueryParams.addAll(localVarApiClient.parameterToPair("limit", limit)); + } + + if (cursor != null) { + localVarQueryParams.addAll(localVarApiClient.parameterToPair("cursor", cursor)); + } + + if (sort != null) { + localVarQueryParams.addAll(localVarApiClient.parameterToPair("sort", sort)); + } + + final String[] localVarAccepts = { + "application/json" + }; + final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts); + if (localVarAccept != null) { + localVarHeaderParams.put("Accept", localVarAccept); + } + + final String[] localVarContentTypes = { + }; + final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); + if (localVarContentType != null) { + localVarHeaderParams.put("Content-Type", localVarContentType); + } + + String[] localVarAuthNames = new String[] { }; + return localVarApiClient.buildCall(basePath, localVarPath, "GET", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); + } + + @SuppressWarnings("rawtypes") + private okhttp3.Call getUserJoinedThreadsValidateBeforeCall(String username, Integer limit, String cursor, String sort, final ApiCallback _callback) throws ApiException { + // verify the required parameter 'username' is set + if (username == null) { + throw new ApiException("Missing the required parameter 'username' when calling getUserJoinedThreads(Async)"); + } + + return getUserJoinedThreadsCall(username, limit, cursor, sort, _callback); + + } + + /** + * 获取单个用户加入的所有子区(分页获取) + * 根据用户 ID 获取该用户加入的所有子区。文档介绍:https://docs-im-beta.easemob.com/document/server-side/group.html#%E8%8E%B7%E5%8F%96%E5%8D%95%E4%B8%AA%E7%94%A8%E6%88%B7%E5%8A%A0%E5%85%A5%E7%9A%84%E6%89%80%E6%9C%89%E5%AD%90%E5%8C%BA-%E5%88%86%E9%A1%B5%E8%8E%B7%E5%8F%96 + * @param username (required) + * @param limit 每次期望返回的子区数量,取值范围为 [1,50],默认值为 50 (optional) + * @param cursor 数据查询的起始位置 (optional) + * @param sort 获取的子区的排序顺序: - asc:按用户加入子区的时间的正序; - (默认)desc:按用户加入子区的时间的倒序 (optional) + * @return EMGetUserJoinedThreadsResult + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public EMGetUserJoinedThreadsResult getUserJoinedThreads(String username, Integer limit, String cursor, String sort) throws ApiException { + ApiResponse localVarResp = getUserJoinedThreadsWithHttpInfo(username, limit, cursor, sort); + return localVarResp.getData(); + } + + /** + * 获取单个用户加入的所有子区(分页获取) + * 根据用户 ID 获取该用户加入的所有子区。文档介绍:https://docs-im-beta.easemob.com/document/server-side/group.html#%E8%8E%B7%E5%8F%96%E5%8D%95%E4%B8%AA%E7%94%A8%E6%88%B7%E5%8A%A0%E5%85%A5%E7%9A%84%E6%89%80%E6%9C%89%E5%AD%90%E5%8C%BA-%E5%88%86%E9%A1%B5%E8%8E%B7%E5%8F%96 + * @param username (required) + * @param limit 每次期望返回的子区数量,取值范围为 [1,50],默认值为 50 (optional) + * @param cursor 数据查询的起始位置 (optional) + * @param sort 获取的子区的排序顺序: - asc:按用户加入子区的时间的正序; - (默认)desc:按用户加入子区的时间的倒序 (optional) + * @return ApiResponse<EMGetUserJoinedThreadsResult> + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public ApiResponse getUserJoinedThreadsWithHttpInfo(String username, Integer limit, String cursor, String sort) throws ApiException { + okhttp3.Call localVarCall = getUserJoinedThreadsValidateBeforeCall(username, limit, cursor, sort, null); + Type localVarReturnType = new TypeToken(){}.getType(); + return localVarApiClient.execute(localVarCall, localVarReturnType); + } + + /** + * 获取单个用户加入的所有子区(分页获取) (asynchronously) + * 根据用户 ID 获取该用户加入的所有子区。文档介绍:https://docs-im-beta.easemob.com/document/server-side/group.html#%E8%8E%B7%E5%8F%96%E5%8D%95%E4%B8%AA%E7%94%A8%E6%88%B7%E5%8A%A0%E5%85%A5%E7%9A%84%E6%89%80%E6%9C%89%E5%AD%90%E5%8C%BA-%E5%88%86%E9%A1%B5%E8%8E%B7%E5%8F%96 + * @param username (required) + * @param limit 每次期望返回的子区数量,取值范围为 [1,50],默认值为 50 (optional) + * @param cursor 数据查询的起始位置 (optional) + * @param sort 获取的子区的排序顺序: - asc:按用户加入子区的时间的正序; - (默认)desc:按用户加入子区的时间的倒序 (optional) + * @param _callback The callback to be executed when the API call finishes + * @return The request call + * @throws ApiException If fail to process the API call, e.g. serializing the request body object + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public okhttp3.Call getUserJoinedThreadsAsync(String username, Integer limit, String cursor, String sort, final ApiCallback _callback) throws ApiException { + + okhttp3.Call localVarCall = getUserJoinedThreadsValidateBeforeCall(username, limit, cursor, sort, _callback); + Type localVarReturnType = new TypeToken(){}.getType(); + localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); + return localVarCall; + } + /** + * Build call for getUserJoinedThreadsUnderGroup + * @param groupId (required) + * @param username (required) + * @param limit 每次期望返回的子区数量,取值范围为 [1,50],默认值为 50 (optional) + * @param cursor 数据查询的起始位置 (optional) + * @param sort 获取的子区的排序顺序: - asc:按用户加入子区的时间的正序; - (默认)desc:按用户加入子区的时间的倒序 (optional) + * @param _callback Callback for upload/download progress + * @return Call to execute + * @throws ApiException If fail to serialize the request body object + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public okhttp3.Call getUserJoinedThreadsUnderGroupCall(String groupId, String username, Integer limit, String cursor, String sort, final ApiCallback _callback) throws ApiException { + String basePath = null; + // Operation Servers + String[] localBasePaths = new String[] { }; + + // Determine Base Path to Use + if (localCustomBaseUrl != null){ + basePath = localCustomBaseUrl; + } else if ( localBasePaths.length > 0 ) { + basePath = localBasePaths[localHostIndex]; + } else { + basePath = null; + } + + Object localVarPostBody = null; + + // create path and map variables + String localVarPath = "/threads/chatgroups/{group_id}/user/{username}" + .replace("{" + "group_id" + "}", localVarApiClient.escapeString(groupId.toString())) + .replace("{" + "username" + "}", localVarApiClient.escapeString(username.toString())); + + List localVarQueryParams = new ArrayList(); + List localVarCollectionQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + Map localVarCookieParams = new HashMap(); + Map localVarFormParams = new HashMap(); + + if (limit != null) { + localVarQueryParams.addAll(localVarApiClient.parameterToPair("limit", limit)); + } + + if (cursor != null) { + localVarQueryParams.addAll(localVarApiClient.parameterToPair("cursor", cursor)); + } + + if (sort != null) { + localVarQueryParams.addAll(localVarApiClient.parameterToPair("sort", sort)); + } + + final String[] localVarAccepts = { + "application/json" + }; + final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts); + if (localVarAccept != null) { + localVarHeaderParams.put("Accept", localVarAccept); + } + + final String[] localVarContentTypes = { + }; + final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); + if (localVarContentType != null) { + localVarHeaderParams.put("Content-Type", localVarContentType); + } + + String[] localVarAuthNames = new String[] { }; + return localVarApiClient.buildCall(basePath, localVarPath, "GET", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); + } + + @SuppressWarnings("rawtypes") + private okhttp3.Call getUserJoinedThreadsUnderGroupValidateBeforeCall(String groupId, String username, Integer limit, String cursor, String sort, final ApiCallback _callback) throws ApiException { + // verify the required parameter 'groupId' is set + if (groupId == null) { + throw new ApiException("Missing the required parameter 'groupId' when calling getUserJoinedThreadsUnderGroup(Async)"); + } + + // verify the required parameter 'username' is set + if (username == null) { + throw new ApiException("Missing the required parameter 'username' when calling getUserJoinedThreadsUnderGroup(Async)"); + } + + return getUserJoinedThreadsUnderGroupCall(groupId, username, limit, cursor, sort, _callback); + + } + + /** + * 获取单个用户在指定群组中加入的所有子区 (分页获取) + * 根据用户 ID 获取该用户在指定群组中加入的所有子区。文档介绍:https://docs-im-beta.easemob.com/document/server-side/group.html#%E8%8E%B7%E5%8F%96%E5%8D%95%E4%B8%AA%E7%94%A8%E6%88%B7%E5%9C%A8%E6%8C%87%E5%AE%9A%E7%BE%A4%E7%BB%84%E4%B8%AD%E5%8A%A0%E5%85%A5%E7%9A%84%E6%89%80%E6%9C%89%E5%AD%90%E5%8C%BA-%E5%88%86%E9%A1%B5%E8%8E%B7%E5%8F%96 + * @param groupId (required) + * @param username (required) + * @param limit 每次期望返回的子区数量,取值范围为 [1,50],默认值为 50 (optional) + * @param cursor 数据查询的起始位置 (optional) + * @param sort 获取的子区的排序顺序: - asc:按用户加入子区的时间的正序; - (默认)desc:按用户加入子区的时间的倒序 (optional) + * @return EMGetUserJoinedThreadsUnderGroupResult + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public EMGetUserJoinedThreadsUnderGroupResult getUserJoinedThreadsUnderGroup(String groupId, String username, Integer limit, String cursor, String sort) throws ApiException { + ApiResponse localVarResp = getUserJoinedThreadsUnderGroupWithHttpInfo(groupId, username, limit, cursor, sort); + return localVarResp.getData(); + } + + /** + * 获取单个用户在指定群组中加入的所有子区 (分页获取) + * 根据用户 ID 获取该用户在指定群组中加入的所有子区。文档介绍:https://docs-im-beta.easemob.com/document/server-side/group.html#%E8%8E%B7%E5%8F%96%E5%8D%95%E4%B8%AA%E7%94%A8%E6%88%B7%E5%9C%A8%E6%8C%87%E5%AE%9A%E7%BE%A4%E7%BB%84%E4%B8%AD%E5%8A%A0%E5%85%A5%E7%9A%84%E6%89%80%E6%9C%89%E5%AD%90%E5%8C%BA-%E5%88%86%E9%A1%B5%E8%8E%B7%E5%8F%96 + * @param groupId (required) + * @param username (required) + * @param limit 每次期望返回的子区数量,取值范围为 [1,50],默认值为 50 (optional) + * @param cursor 数据查询的起始位置 (optional) + * @param sort 获取的子区的排序顺序: - asc:按用户加入子区的时间的正序; - (默认)desc:按用户加入子区的时间的倒序 (optional) + * @return ApiResponse<EMGetUserJoinedThreadsUnderGroupResult> + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public ApiResponse getUserJoinedThreadsUnderGroupWithHttpInfo(String groupId, String username, Integer limit, String cursor, String sort) throws ApiException { + okhttp3.Call localVarCall = getUserJoinedThreadsUnderGroupValidateBeforeCall(groupId, username, limit, cursor, sort, null); + Type localVarReturnType = new TypeToken(){}.getType(); + return localVarApiClient.execute(localVarCall, localVarReturnType); + } + + /** + * 获取单个用户在指定群组中加入的所有子区 (分页获取) (asynchronously) + * 根据用户 ID 获取该用户在指定群组中加入的所有子区。文档介绍:https://docs-im-beta.easemob.com/document/server-side/group.html#%E8%8E%B7%E5%8F%96%E5%8D%95%E4%B8%AA%E7%94%A8%E6%88%B7%E5%9C%A8%E6%8C%87%E5%AE%9A%E7%BE%A4%E7%BB%84%E4%B8%AD%E5%8A%A0%E5%85%A5%E7%9A%84%E6%89%80%E6%9C%89%E5%AD%90%E5%8C%BA-%E5%88%86%E9%A1%B5%E8%8E%B7%E5%8F%96 + * @param groupId (required) + * @param username (required) + * @param limit 每次期望返回的子区数量,取值范围为 [1,50],默认值为 50 (optional) + * @param cursor 数据查询的起始位置 (optional) + * @param sort 获取的子区的排序顺序: - asc:按用户加入子区的时间的正序; - (默认)desc:按用户加入子区的时间的倒序 (optional) + * @param _callback The callback to be executed when the API call finishes + * @return The request call + * @throws ApiException If fail to process the API call, e.g. serializing the request body object + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public okhttp3.Call getUserJoinedThreadsUnderGroupAsync(String groupId, String username, Integer limit, String cursor, String sort, final ApiCallback _callback) throws ApiException { + + okhttp3.Call localVarCall = getUserJoinedThreadsUnderGroupValidateBeforeCall(groupId, username, limit, cursor, sort, _callback); + Type localVarReturnType = new TypeToken(){}.getType(); + localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); + return localVarCall; + } + /** + * Build call for modifyThread + * @param threadId (required) + * @param emModifyThread (optional) + * @param _callback Callback for upload/download progress + * @return Call to execute + * @throws ApiException If fail to serialize the request body object + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public okhttp3.Call modifyThreadCall(String threadId, EMModifyThread emModifyThread, final ApiCallback _callback) throws ApiException { + String basePath = null; + // Operation Servers + String[] localBasePaths = new String[] { }; + + // Determine Base Path to Use + if (localCustomBaseUrl != null){ + basePath = localCustomBaseUrl; + } else if ( localBasePaths.length > 0 ) { + basePath = localBasePaths[localHostIndex]; + } else { + basePath = null; + } + + Object localVarPostBody = emModifyThread; + + // create path and map variables + String localVarPath = "/thread/{thread_id}" + .replace("{" + "thread_id" + "}", localVarApiClient.escapeString(threadId.toString())); + + List localVarQueryParams = new ArrayList(); + List localVarCollectionQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + Map localVarCookieParams = new HashMap(); + Map localVarFormParams = new HashMap(); + + final String[] localVarAccepts = { + "application/json" + }; + final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts); + if (localVarAccept != null) { + localVarHeaderParams.put("Accept", localVarAccept); + } + + final String[] localVarContentTypes = { + "application/json" + }; + final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); + if (localVarContentType != null) { + localVarHeaderParams.put("Content-Type", localVarContentType); + } + + String[] localVarAuthNames = new String[] { }; + return localVarApiClient.buildCall(basePath, localVarPath, "PUT", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); + } + + @SuppressWarnings("rawtypes") + private okhttp3.Call modifyThreadValidateBeforeCall(String threadId, EMModifyThread emModifyThread, final ApiCallback _callback) throws ApiException { + // verify the required parameter 'threadId' is set + if (threadId == null) { + throw new ApiException("Missing the required parameter 'threadId' when calling modifyThread(Async)"); + } + + return modifyThreadCall(threadId, emModifyThread, _callback); + + } + + /** + * 修改子区 + * 分页获取应用下的子区列表。文档介绍:https://docs-im-beta.easemob.com/document/server-side/group.html#%E4%BF%AE%E6%94%B9%E5%AD%90%E5%8C%BA + * @param threadId (required) + * @param emModifyThread (optional) + * @return EMModifyThreadResult + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public EMModifyThreadResult modifyThread(String threadId, EMModifyThread emModifyThread) throws ApiException { + ApiResponse localVarResp = modifyThreadWithHttpInfo(threadId, emModifyThread); + return localVarResp.getData(); + } + + /** + * 修改子区 + * 分页获取应用下的子区列表。文档介绍:https://docs-im-beta.easemob.com/document/server-side/group.html#%E4%BF%AE%E6%94%B9%E5%AD%90%E5%8C%BA + * @param threadId (required) + * @param emModifyThread (optional) + * @return ApiResponse<EMModifyThreadResult> + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public ApiResponse modifyThreadWithHttpInfo(String threadId, EMModifyThread emModifyThread) throws ApiException { + okhttp3.Call localVarCall = modifyThreadValidateBeforeCall(threadId, emModifyThread, null); + Type localVarReturnType = new TypeToken(){}.getType(); + return localVarApiClient.execute(localVarCall, localVarReturnType); + } + + /** + * 修改子区 (asynchronously) + * 分页获取应用下的子区列表。文档介绍:https://docs-im-beta.easemob.com/document/server-side/group.html#%E4%BF%AE%E6%94%B9%E5%AD%90%E5%8C%BA + * @param threadId (required) + * @param emModifyThread (optional) + * @param _callback The callback to be executed when the API call finishes + * @return The request call + * @throws ApiException If fail to process the API call, e.g. serializing the request body object + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public okhttp3.Call modifyThreadAsync(String threadId, EMModifyThread emModifyThread, final ApiCallback _callback) throws ApiException { + + okhttp3.Call localVarCall = modifyThreadValidateBeforeCall(threadId, emModifyThread, _callback); + Type localVarReturnType = new TypeToken(){}.getType(); + localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); + return localVarCall; + } + /** + * Build call for removeMultipleUsersFromThread + * @param threadId (required) + * @param emRemoveMultipleUsersFromThread (optional) + * @param _callback Callback for upload/download progress + * @return Call to execute + * @throws ApiException If fail to serialize the request body object + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public okhttp3.Call removeMultipleUsersFromThreadCall(String threadId, EMRemoveMultipleUsersFromThread emRemoveMultipleUsersFromThread, final ApiCallback _callback) throws ApiException { + String basePath = null; + // Operation Servers + String[] localBasePaths = new String[] { }; + + // Determine Base Path to Use + if (localCustomBaseUrl != null){ + basePath = localCustomBaseUrl; + } else if ( localBasePaths.length > 0 ) { + basePath = localBasePaths[localHostIndex]; + } else { + basePath = null; + } + + Object localVarPostBody = emRemoveMultipleUsersFromThread; + + // create path and map variables + String localVarPath = "/thread/{thread_id}/users" + .replace("{" + "thread_id" + "}", localVarApiClient.escapeString(threadId.toString())); + + List localVarQueryParams = new ArrayList(); + List localVarCollectionQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + Map localVarCookieParams = new HashMap(); + Map localVarFormParams = new HashMap(); + + final String[] localVarAccepts = { + "application/json" + }; + final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts); + if (localVarAccept != null) { + localVarHeaderParams.put("Accept", localVarAccept); + } + + final String[] localVarContentTypes = { + "application/json" + }; + final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); + if (localVarContentType != null) { + localVarHeaderParams.put("Content-Type", localVarContentType); + } + + String[] localVarAuthNames = new String[] { }; + return localVarApiClient.buildCall(basePath, localVarPath, "DELETE", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); + } + + @SuppressWarnings("rawtypes") + private okhttp3.Call removeMultipleUsersFromThreadValidateBeforeCall(String threadId, EMRemoveMultipleUsersFromThread emRemoveMultipleUsersFromThread, final ApiCallback _callback) throws ApiException { + // verify the required parameter 'threadId' is set + if (threadId == null) { + throw new ApiException("Missing the required parameter 'threadId' when calling removeMultipleUsersFromThread(Async)"); + } + + return removeMultipleUsersFromThreadCall(threadId, emRemoveMultipleUsersFromThread, _callback); + + } + + /** + * 批量踢出子区成员 + * 批量踢出子区成员。文档介绍:https://docs-im-beta.easemob.com/document/server-side/group.html#%E6%89%B9%E9%87%8F%E8%B8%A2%E5%87%BA%E5%AD%90%E5%8C%BA%E6%88%90%E5%91%98 + * @param threadId (required) + * @param emRemoveMultipleUsersFromThread (optional) + * @return EMRemoveMultipleUsersFromThreadResult + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public EMRemoveMultipleUsersFromThreadResult removeMultipleUsersFromThread(String threadId, EMRemoveMultipleUsersFromThread emRemoveMultipleUsersFromThread) throws ApiException { + ApiResponse localVarResp = removeMultipleUsersFromThreadWithHttpInfo(threadId, emRemoveMultipleUsersFromThread); + return localVarResp.getData(); + } + + /** + * 批量踢出子区成员 + * 批量踢出子区成员。文档介绍:https://docs-im-beta.easemob.com/document/server-side/group.html#%E6%89%B9%E9%87%8F%E8%B8%A2%E5%87%BA%E5%AD%90%E5%8C%BA%E6%88%90%E5%91%98 + * @param threadId (required) + * @param emRemoveMultipleUsersFromThread (optional) + * @return ApiResponse<EMRemoveMultipleUsersFromThreadResult> + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public ApiResponse removeMultipleUsersFromThreadWithHttpInfo(String threadId, EMRemoveMultipleUsersFromThread emRemoveMultipleUsersFromThread) throws ApiException { + okhttp3.Call localVarCall = removeMultipleUsersFromThreadValidateBeforeCall(threadId, emRemoveMultipleUsersFromThread, null); + Type localVarReturnType = new TypeToken(){}.getType(); + return localVarApiClient.execute(localVarCall, localVarReturnType); + } + + /** + * 批量踢出子区成员 (asynchronously) + * 批量踢出子区成员。文档介绍:https://docs-im-beta.easemob.com/document/server-side/group.html#%E6%89%B9%E9%87%8F%E8%B8%A2%E5%87%BA%E5%AD%90%E5%8C%BA%E6%88%90%E5%91%98 + * @param threadId (required) + * @param emRemoveMultipleUsersFromThread (optional) + * @param _callback The callback to be executed when the API call finishes + * @return The request call + * @throws ApiException If fail to process the API call, e.g. serializing the request body object + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public okhttp3.Call removeMultipleUsersFromThreadAsync(String threadId, EMRemoveMultipleUsersFromThread emRemoveMultipleUsersFromThread, final ApiCallback _callback) throws ApiException { + + okhttp3.Call localVarCall = removeMultipleUsersFromThreadValidateBeforeCall(threadId, emRemoveMultipleUsersFromThread, _callback); + Type localVarReturnType = new TypeToken(){}.getType(); + localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); + return localVarCall; + } +} diff --git a/src/main/java/com/easemob/im/api/TokenApi.java b/src/main/java/com/easemob/im/api/TokenApi.java new file mode 100644 index 000000000..047d5ed7a --- /dev/null +++ b/src/main/java/com/easemob/im/api/TokenApi.java @@ -0,0 +1,202 @@ +/* + * EMService + * Easemob Rest API + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.easemob.im.api; + +import com.easemob.im.ApiCallback; +import com.easemob.im.ApiClient; +import com.easemob.im.ApiException; +import com.easemob.im.ApiResponse; +import com.easemob.im.Configuration; +import com.easemob.im.Pair; +import com.easemob.im.ProgressRequestBody; +import com.easemob.im.ProgressResponseBody; + +import com.google.gson.reflect.TypeToken; + +import java.io.IOException; + + +import com.easemob.im.api.model.EMCreateToken; +import com.easemob.im.api.model.EMGetToken; + +import java.lang.reflect.Type; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +public class TokenApi { + private ApiClient localVarApiClient; + private int localHostIndex; + private String localCustomBaseUrl; + + public TokenApi() { + this(Configuration.getDefaultApiClient()); + } + + public TokenApi(ApiClient apiClient) { + this.localVarApiClient = apiClient; + } + + public ApiClient getApiClient() { + return localVarApiClient; + } + + public void setApiClient(ApiClient apiClient) { + this.localVarApiClient = apiClient; + } + + public int getHostIndex() { + return localHostIndex; + } + + public void setHostIndex(int hostIndex) { + this.localHostIndex = hostIndex; + } + + public String getCustomBaseUrl() { + return localCustomBaseUrl; + } + + public void setCustomBaseUrl(String customBaseUrl) { + this.localCustomBaseUrl = customBaseUrl; + } + + /** + * Build call for getToken + * @param emCreateToken (optional) + * @param _callback Callback for upload/download progress + * @return Call to execute + * @throws ApiException If fail to serialize the request body object + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public okhttp3.Call getTokenCall(EMCreateToken emCreateToken, final ApiCallback _callback) throws ApiException { + String basePath = null; + // Operation Servers + String[] localBasePaths = new String[] { }; + + // Determine Base Path to Use + if (localCustomBaseUrl != null){ + basePath = localCustomBaseUrl; + } else if ( localBasePaths.length > 0 ) { + basePath = localBasePaths[localHostIndex]; + } else { + basePath = null; + } + + Object localVarPostBody = emCreateToken; + + // create path and map variables + String localVarPath = "/token"; + + List localVarQueryParams = new ArrayList(); + List localVarCollectionQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + Map localVarCookieParams = new HashMap(); + Map localVarFormParams = new HashMap(); + + final String[] localVarAccepts = { + "application/json" + }; + final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts); + if (localVarAccept != null) { + localVarHeaderParams.put("Accept", localVarAccept); + } + + final String[] localVarContentTypes = { + "application/json" + }; + final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); + if (localVarContentType != null) { + localVarHeaderParams.put("Content-Type", localVarContentType); + } + + String[] localVarAuthNames = new String[] { }; + return localVarApiClient.buildCall(basePath, localVarPath, "POST", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); + } + + @SuppressWarnings("rawtypes") + private okhttp3.Call getTokenValidateBeforeCall(EMCreateToken emCreateToken, final ApiCallback _callback) throws ApiException { + return getTokenCall(emCreateToken, _callback); + + } + + /** + * 获取 Token,可以获取管理员或者用户权限 Token + * 管理员权限 Token 可以用来调用环信 Rest API 接口,获取管理员 Token 文档介绍:https://docs-im-beta.easemob.com/document/server-side/easemob_app_token.html,获取用户 Token 文档介绍:https://docs-im-beta.easemob.com/document/server-side/easemob_user_token.html + * @param emCreateToken (optional) + * @return EMGetToken + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public EMGetToken getToken(EMCreateToken emCreateToken) throws ApiException { + ApiResponse localVarResp = getTokenWithHttpInfo(emCreateToken); + return localVarResp.getData(); + } + + /** + * 获取 Token,可以获取管理员或者用户权限 Token + * 管理员权限 Token 可以用来调用环信 Rest API 接口,获取管理员 Token 文档介绍:https://docs-im-beta.easemob.com/document/server-side/easemob_app_token.html,获取用户 Token 文档介绍:https://docs-im-beta.easemob.com/document/server-side/easemob_user_token.html + * @param emCreateToken (optional) + * @return ApiResponse<EMGetToken> + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public ApiResponse getTokenWithHttpInfo(EMCreateToken emCreateToken) throws ApiException { + okhttp3.Call localVarCall = getTokenValidateBeforeCall(emCreateToken, null); + Type localVarReturnType = new TypeToken(){}.getType(); + return localVarApiClient.execute(localVarCall, localVarReturnType); + } + + /** + * 获取 Token,可以获取管理员或者用户权限 Token (asynchronously) + * 管理员权限 Token 可以用来调用环信 Rest API 接口,获取管理员 Token 文档介绍:https://docs-im-beta.easemob.com/document/server-side/easemob_app_token.html,获取用户 Token 文档介绍:https://docs-im-beta.easemob.com/document/server-side/easemob_user_token.html + * @param emCreateToken (optional) + * @param _callback The callback to be executed when the API call finishes + * @return The request call + * @throws ApiException If fail to process the API call, e.g. serializing the request body object + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public okhttp3.Call getTokenAsync(EMCreateToken emCreateToken, final ApiCallback _callback) throws ApiException { + + okhttp3.Call localVarCall = getTokenValidateBeforeCall(emCreateToken, _callback); + Type localVarReturnType = new TypeToken(){}.getType(); + localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); + return localVarCall; + } +} diff --git a/src/main/java/com/easemob/im/api/UserApi.java b/src/main/java/com/easemob/im/api/UserApi.java new file mode 100644 index 000000000..a2f5e435a --- /dev/null +++ b/src/main/java/com/easemob/im/api/UserApi.java @@ -0,0 +1,2328 @@ +/* + * EMService + * Easemob Rest API + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.easemob.im.api; + +import com.easemob.im.ApiCallback; +import com.easemob.im.ApiClient; +import com.easemob.im.ApiException; +import com.easemob.im.ApiResponse; +import com.easemob.im.Configuration; +import com.easemob.im.Pair; +import com.easemob.im.ProgressRequestBody; +import com.easemob.im.ProgressResponseBody; + +import com.google.gson.reflect.TypeToken; + +import java.io.IOException; + + +import com.easemob.im.api.model.EMCreateUser; +import com.easemob.im.api.model.EMCreateUsersResult; +import com.easemob.im.api.model.EMDeleteUserResult; +import com.easemob.im.api.model.EMDeleteUsersResult; +import com.easemob.im.api.model.EMForceUserLogoutResult; +import com.easemob.im.api.model.EMGetAllGloballyMutedUsersResult; +import com.easemob.im.api.model.EMGetOfflineMessageStatusResult; +import com.easemob.im.api.model.EMGetUserGlobalMuteResult; +import com.easemob.im.api.model.EMGetUserOfflineMessageCountResult; +import com.easemob.im.api.model.EMGetUserOnlineLoginDeviceListResult; +import com.easemob.im.api.model.EMGetUserOnlineStateResult; +import com.easemob.im.api.model.EMGetUserResult; +import com.easemob.im.api.model.EMGetUsersOnlineState; +import com.easemob.im.api.model.EMGetUsersOnlineStateResult; +import com.easemob.im.api.model.EMGetUsersResult; +import com.easemob.im.api.model.EMModifyUserPassword; +import com.easemob.im.api.model.EMSetUserGlobalMute; +import com.easemob.im.api.model.EMSetUserGlobalMuteResult; +import com.easemob.im.api.model.EMUserDeactivateResult; + +import java.lang.reflect.Type; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +public class UserApi { + private ApiClient localVarApiClient; + private int localHostIndex; + private String localCustomBaseUrl; + + public UserApi() { + this(Configuration.getDefaultApiClient()); + } + + public UserApi(ApiClient apiClient) { + this.localVarApiClient = apiClient; + } + + public ApiClient getApiClient() { + return localVarApiClient; + } + + public void setApiClient(ApiClient apiClient) { + this.localVarApiClient = apiClient; + } + + public int getHostIndex() { + return localHostIndex; + } + + public void setHostIndex(int hostIndex) { + this.localHostIndex = hostIndex; + } + + public String getCustomBaseUrl() { + return localCustomBaseUrl; + } + + public void setCustomBaseUrl(String customBaseUrl) { + this.localCustomBaseUrl = customBaseUrl; + } + + /** + * Build call for createUsers + * @param emCreateUser (optional) + * @param _callback Callback for upload/download progress + * @return Call to execute + * @throws ApiException If fail to serialize the request body object + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public okhttp3.Call createUsersCall(List emCreateUser, final ApiCallback _callback) throws ApiException { + String basePath = null; + // Operation Servers + String[] localBasePaths = new String[] { }; + + // Determine Base Path to Use + if (localCustomBaseUrl != null){ + basePath = localCustomBaseUrl; + } else if ( localBasePaths.length > 0 ) { + basePath = localBasePaths[localHostIndex]; + } else { + basePath = null; + } + + Object localVarPostBody = emCreateUser; + + // create path and map variables + String localVarPath = "/users"; + + List localVarQueryParams = new ArrayList(); + List localVarCollectionQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + Map localVarCookieParams = new HashMap(); + Map localVarFormParams = new HashMap(); + + final String[] localVarAccepts = { + "application/json" + }; + final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts); + if (localVarAccept != null) { + localVarHeaderParams.put("Accept", localVarAccept); + } + + final String[] localVarContentTypes = { + "application/json" + }; + final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); + if (localVarContentType != null) { + localVarHeaderParams.put("Content-Type", localVarContentType); + } + + String[] localVarAuthNames = new String[] { }; + return localVarApiClient.buildCall(basePath, localVarPath, "POST", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); + } + + @SuppressWarnings("rawtypes") + private okhttp3.Call createUsersValidateBeforeCall(List emCreateUser, final ApiCallback _callback) throws ApiException { + return createUsersCall(emCreateUser, _callback); + + } + + /** + * 批量注册用户 + * 文档介绍:https://docs-im-beta.easemob.com/document/server-side/account_system.html#%E6%89%B9%E9%87%8F%E6%B3%A8%E5%86%8C%E7%94%A8%E6%88%B7 + * @param emCreateUser (optional) + * @return EMCreateUsersResult + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public EMCreateUsersResult createUsers(List emCreateUser) throws ApiException { + ApiResponse localVarResp = createUsersWithHttpInfo(emCreateUser); + return localVarResp.getData(); + } + + /** + * 批量注册用户 + * 文档介绍:https://docs-im-beta.easemob.com/document/server-side/account_system.html#%E6%89%B9%E9%87%8F%E6%B3%A8%E5%86%8C%E7%94%A8%E6%88%B7 + * @param emCreateUser (optional) + * @return ApiResponse<EMCreateUsersResult> + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public ApiResponse createUsersWithHttpInfo(List emCreateUser) throws ApiException { + okhttp3.Call localVarCall = createUsersValidateBeforeCall(emCreateUser, null); + Type localVarReturnType = new TypeToken(){}.getType(); + return localVarApiClient.execute(localVarCall, localVarReturnType); + } + + /** + * 批量注册用户 (asynchronously) + * 文档介绍:https://docs-im-beta.easemob.com/document/server-side/account_system.html#%E6%89%B9%E9%87%8F%E6%B3%A8%E5%86%8C%E7%94%A8%E6%88%B7 + * @param emCreateUser (optional) + * @param _callback The callback to be executed when the API call finishes + * @return The request call + * @throws ApiException If fail to process the API call, e.g. serializing the request body object + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public okhttp3.Call createUsersAsync(List emCreateUser, final ApiCallback _callback) throws ApiException { + + okhttp3.Call localVarCall = createUsersValidateBeforeCall(emCreateUser, _callback); + Type localVarReturnType = new TypeToken(){}.getType(); + localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); + return localVarCall; + } + /** + * Build call for deleteUser + * @param username 用户 ID (required) + * @param _callback Callback for upload/download progress + * @return Call to execute + * @throws ApiException If fail to serialize the request body object + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public okhttp3.Call deleteUserCall(String username, final ApiCallback _callback) throws ApiException { + String basePath = null; + // Operation Servers + String[] localBasePaths = new String[] { }; + + // Determine Base Path to Use + if (localCustomBaseUrl != null){ + basePath = localCustomBaseUrl; + } else if ( localBasePaths.length > 0 ) { + basePath = localBasePaths[localHostIndex]; + } else { + basePath = null; + } + + Object localVarPostBody = null; + + // create path and map variables + String localVarPath = "/users/{username}" + .replace("{" + "username" + "}", localVarApiClient.escapeString(username.toString())); + + List localVarQueryParams = new ArrayList(); + List localVarCollectionQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + Map localVarCookieParams = new HashMap(); + Map localVarFormParams = new HashMap(); + + final String[] localVarAccepts = { + "application/json" + }; + final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts); + if (localVarAccept != null) { + localVarHeaderParams.put("Accept", localVarAccept); + } + + final String[] localVarContentTypes = { + }; + final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); + if (localVarContentType != null) { + localVarHeaderParams.put("Content-Type", localVarContentType); + } + + String[] localVarAuthNames = new String[] { }; + return localVarApiClient.buildCall(basePath, localVarPath, "DELETE", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); + } + + @SuppressWarnings("rawtypes") + private okhttp3.Call deleteUserValidateBeforeCall(String username, final ApiCallback _callback) throws ApiException { + // verify the required parameter 'username' is set + if (username == null) { + throw new ApiException("Missing the required parameter 'username' when calling deleteUser(Async)"); + } + + return deleteUserCall(username, _callback); + + } + + /** + * 删除用户账号 + * 删除单个用户。如果该用户是群主或者聊天室所有者,系统会同时删除对应的群组和聊天室。文档介绍:https://docs-im-beta.easemob.com/document/server-side/account_system.html#%E5%88%A0%E9%99%A4%E5%8D%95%E4%B8%AA%E7%94%A8%E6%88%B7 + * @param username 用户 ID (required) + * @return EMDeleteUserResult + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public EMDeleteUserResult deleteUser(String username) throws ApiException { + ApiResponse localVarResp = deleteUserWithHttpInfo(username); + return localVarResp.getData(); + } + + /** + * 删除用户账号 + * 删除单个用户。如果该用户是群主或者聊天室所有者,系统会同时删除对应的群组和聊天室。文档介绍:https://docs-im-beta.easemob.com/document/server-side/account_system.html#%E5%88%A0%E9%99%A4%E5%8D%95%E4%B8%AA%E7%94%A8%E6%88%B7 + * @param username 用户 ID (required) + * @return ApiResponse<EMDeleteUserResult> + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public ApiResponse deleteUserWithHttpInfo(String username) throws ApiException { + okhttp3.Call localVarCall = deleteUserValidateBeforeCall(username, null); + Type localVarReturnType = new TypeToken(){}.getType(); + return localVarApiClient.execute(localVarCall, localVarReturnType); + } + + /** + * 删除用户账号 (asynchronously) + * 删除单个用户。如果该用户是群主或者聊天室所有者,系统会同时删除对应的群组和聊天室。文档介绍:https://docs-im-beta.easemob.com/document/server-side/account_system.html#%E5%88%A0%E9%99%A4%E5%8D%95%E4%B8%AA%E7%94%A8%E6%88%B7 + * @param username 用户 ID (required) + * @param _callback The callback to be executed when the API call finishes + * @return The request call + * @throws ApiException If fail to process the API call, e.g. serializing the request body object + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public okhttp3.Call deleteUserAsync(String username, final ApiCallback _callback) throws ApiException { + + okhttp3.Call localVarCall = deleteUserValidateBeforeCall(username, _callback); + Type localVarReturnType = new TypeToken(){}.getType(); + localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); + return localVarCall; + } + /** + * Build call for deleteUsers + * @param limit 要删除的用户的数量。取值范围为 [1,100],默认值为 10 (optional) + * @param cursor 开始删除用户的游标位置。第一次批量删除时若不设置 cursor,请求成功后会从最先创建的用户开始删除 limit 指定的用户数量。从响应 body 中获取 cursor,并在下一次请求的 URL 中传入该 cursor,直到响应 body 中不再有 cursor 字段,则表示已完全删除 app 中的所有用户 (optional) + * @param _callback Callback for upload/download progress + * @return Call to execute + * @throws ApiException If fail to serialize the request body object + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public okhttp3.Call deleteUsersCall(Integer limit, String cursor, final ApiCallback _callback) throws ApiException { + String basePath = null; + // Operation Servers + String[] localBasePaths = new String[] { }; + + // Determine Base Path to Use + if (localCustomBaseUrl != null){ + basePath = localCustomBaseUrl; + } else if ( localBasePaths.length > 0 ) { + basePath = localBasePaths[localHostIndex]; + } else { + basePath = null; + } + + Object localVarPostBody = null; + + // create path and map variables + String localVarPath = "/users"; + + List localVarQueryParams = new ArrayList(); + List localVarCollectionQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + Map localVarCookieParams = new HashMap(); + Map localVarFormParams = new HashMap(); + + if (limit != null) { + localVarQueryParams.addAll(localVarApiClient.parameterToPair("limit", limit)); + } + + if (cursor != null) { + localVarQueryParams.addAll(localVarApiClient.parameterToPair("cursor", cursor)); + } + + final String[] localVarAccepts = { + "application/json" + }; + final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts); + if (localVarAccept != null) { + localVarHeaderParams.put("Accept", localVarAccept); + } + + final String[] localVarContentTypes = { + }; + final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); + if (localVarContentType != null) { + localVarHeaderParams.put("Content-Type", localVarContentType); + } + + String[] localVarAuthNames = new String[] { }; + return localVarApiClient.buildCall(basePath, localVarPath, "DELETE", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); + } + + @SuppressWarnings("rawtypes") + private okhttp3.Call deleteUsersValidateBeforeCall(Integer limit, String cursor, final ApiCallback _callback) throws ApiException { + return deleteUsersCall(limit, cursor, _callback); + + } + + /** + * 批量删除用户 + * 删除某个 App 下指定数量的用户账号。建议一次删除的用户数量不要超过100。需要注意的是,这里只指定了要删除的用户数量,并未指定要删除的具体用户,你可以在响应中查看删除的用户。文档介绍:https://docs-im-beta.easemob.com/document/server-side/account_system.html#%E6%89%B9%E9%87%8F%E8%8E%B7%E5%8F%96%E7%94%A8%E6%88%B7%E8%AF%A6%E6%83%85 + * @param limit 要删除的用户的数量。取值范围为 [1,100],默认值为 10 (optional) + * @param cursor 开始删除用户的游标位置。第一次批量删除时若不设置 cursor,请求成功后会从最先创建的用户开始删除 limit 指定的用户数量。从响应 body 中获取 cursor,并在下一次请求的 URL 中传入该 cursor,直到响应 body 中不再有 cursor 字段,则表示已完全删除 app 中的所有用户 (optional) + * @return EMDeleteUsersResult + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public EMDeleteUsersResult deleteUsers(Integer limit, String cursor) throws ApiException { + ApiResponse localVarResp = deleteUsersWithHttpInfo(limit, cursor); + return localVarResp.getData(); + } + + /** + * 批量删除用户 + * 删除某个 App 下指定数量的用户账号。建议一次删除的用户数量不要超过100。需要注意的是,这里只指定了要删除的用户数量,并未指定要删除的具体用户,你可以在响应中查看删除的用户。文档介绍:https://docs-im-beta.easemob.com/document/server-side/account_system.html#%E6%89%B9%E9%87%8F%E8%8E%B7%E5%8F%96%E7%94%A8%E6%88%B7%E8%AF%A6%E6%83%85 + * @param limit 要删除的用户的数量。取值范围为 [1,100],默认值为 10 (optional) + * @param cursor 开始删除用户的游标位置。第一次批量删除时若不设置 cursor,请求成功后会从最先创建的用户开始删除 limit 指定的用户数量。从响应 body 中获取 cursor,并在下一次请求的 URL 中传入该 cursor,直到响应 body 中不再有 cursor 字段,则表示已完全删除 app 中的所有用户 (optional) + * @return ApiResponse<EMDeleteUsersResult> + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public ApiResponse deleteUsersWithHttpInfo(Integer limit, String cursor) throws ApiException { + okhttp3.Call localVarCall = deleteUsersValidateBeforeCall(limit, cursor, null); + Type localVarReturnType = new TypeToken(){}.getType(); + return localVarApiClient.execute(localVarCall, localVarReturnType); + } + + /** + * 批量删除用户 (asynchronously) + * 删除某个 App 下指定数量的用户账号。建议一次删除的用户数量不要超过100。需要注意的是,这里只指定了要删除的用户数量,并未指定要删除的具体用户,你可以在响应中查看删除的用户。文档介绍:https://docs-im-beta.easemob.com/document/server-side/account_system.html#%E6%89%B9%E9%87%8F%E8%8E%B7%E5%8F%96%E7%94%A8%E6%88%B7%E8%AF%A6%E6%83%85 + * @param limit 要删除的用户的数量。取值范围为 [1,100],默认值为 10 (optional) + * @param cursor 开始删除用户的游标位置。第一次批量删除时若不设置 cursor,请求成功后会从最先创建的用户开始删除 limit 指定的用户数量。从响应 body 中获取 cursor,并在下一次请求的 URL 中传入该 cursor,直到响应 body 中不再有 cursor 字段,则表示已完全删除 app 中的所有用户 (optional) + * @param _callback The callback to be executed when the API call finishes + * @return The request call + * @throws ApiException If fail to process the API call, e.g. serializing the request body object + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public okhttp3.Call deleteUsersAsync(Integer limit, String cursor, final ApiCallback _callback) throws ApiException { + + okhttp3.Call localVarCall = deleteUsersValidateBeforeCall(limit, cursor, _callback); + Type localVarReturnType = new TypeToken(){}.getType(); + localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); + return localVarCall; + } + /** + * Build call for forceUserLogout + * @param username (required) + * @param _callback Callback for upload/download progress + * @return Call to execute + * @throws ApiException If fail to serialize the request body object + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public okhttp3.Call forceUserLogoutCall(String username, final ApiCallback _callback) throws ApiException { + String basePath = null; + // Operation Servers + String[] localBasePaths = new String[] { }; + + // Determine Base Path to Use + if (localCustomBaseUrl != null){ + basePath = localCustomBaseUrl; + } else if ( localBasePaths.length > 0 ) { + basePath = localBasePaths[localHostIndex]; + } else { + basePath = null; + } + + Object localVarPostBody = null; + + // create path and map variables + String localVarPath = "/users/{username}/disconnect" + .replace("{" + "username" + "}", localVarApiClient.escapeString(username.toString())); + + List localVarQueryParams = new ArrayList(); + List localVarCollectionQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + Map localVarCookieParams = new HashMap(); + Map localVarFormParams = new HashMap(); + + final String[] localVarAccepts = { + "application/json" + }; + final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts); + if (localVarAccept != null) { + localVarHeaderParams.put("Accept", localVarAccept); + } + + final String[] localVarContentTypes = { + }; + final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); + if (localVarContentType != null) { + localVarHeaderParams.put("Content-Type", localVarContentType); + } + + String[] localVarAuthNames = new String[] { }; + return localVarApiClient.buildCall(basePath, localVarPath, "GET", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); + } + + @SuppressWarnings("rawtypes") + private okhttp3.Call forceUserLogoutValidateBeforeCall(String username, final ApiCallback _callback) throws ApiException { + // verify the required parameter 'username' is set + if (username == null) { + throw new ApiException("Missing the required parameter 'username' when calling forceUserLogout(Async)"); + } + + return forceUserLogoutCall(username, _callback); + + } + + /** + * 强制下线 + * 强制用户即将用户状态改为离线,用户需要重新登录才能正常使用。文档介绍:https://docs-im-beta.easemob.com/document/server-side/account_system.html#%E5%BC%BA%E5%88%B6%E4%B8%8B%E7%BA%BF + * @param username (required) + * @return EMForceUserLogoutResult + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public EMForceUserLogoutResult forceUserLogout(String username) throws ApiException { + ApiResponse localVarResp = forceUserLogoutWithHttpInfo(username); + return localVarResp.getData(); + } + + /** + * 强制下线 + * 强制用户即将用户状态改为离线,用户需要重新登录才能正常使用。文档介绍:https://docs-im-beta.easemob.com/document/server-side/account_system.html#%E5%BC%BA%E5%88%B6%E4%B8%8B%E7%BA%BF + * @param username (required) + * @return ApiResponse<EMForceUserLogoutResult> + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public ApiResponse forceUserLogoutWithHttpInfo(String username) throws ApiException { + okhttp3.Call localVarCall = forceUserLogoutValidateBeforeCall(username, null); + Type localVarReturnType = new TypeToken(){}.getType(); + return localVarApiClient.execute(localVarCall, localVarReturnType); + } + + /** + * 强制下线 (asynchronously) + * 强制用户即将用户状态改为离线,用户需要重新登录才能正常使用。文档介绍:https://docs-im-beta.easemob.com/document/server-side/account_system.html#%E5%BC%BA%E5%88%B6%E4%B8%8B%E7%BA%BF + * @param username (required) + * @param _callback The callback to be executed when the API call finishes + * @return The request call + * @throws ApiException If fail to process the API call, e.g. serializing the request body object + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public okhttp3.Call forceUserLogoutAsync(String username, final ApiCallback _callback) throws ApiException { + + okhttp3.Call localVarCall = forceUserLogoutValidateBeforeCall(username, _callback); + Type localVarReturnType = new TypeToken(){}.getType(); + localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); + return localVarCall; + } + /** + * Build call for getAllGloballyMutedUsers + * @param pageNum 请求查询的页码 (optional) + * @param pageSize 请求查询每页显示的禁言用户的数量。取值范围为 [1,50] (optional) + * @param _callback Callback for upload/download progress + * @return Call to execute + * @throws ApiException If fail to serialize the request body object + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public okhttp3.Call getAllGloballyMutedUsersCall(Integer pageNum, Integer pageSize, final ApiCallback _callback) throws ApiException { + String basePath = null; + // Operation Servers + String[] localBasePaths = new String[] { }; + + // Determine Base Path to Use + if (localCustomBaseUrl != null){ + basePath = localCustomBaseUrl; + } else if ( localBasePaths.length > 0 ) { + basePath = localBasePaths[localHostIndex]; + } else { + basePath = null; + } + + Object localVarPostBody = null; + + // create path and map variables + String localVarPath = "/mutes"; + + List localVarQueryParams = new ArrayList(); + List localVarCollectionQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + Map localVarCookieParams = new HashMap(); + Map localVarFormParams = new HashMap(); + + if (pageNum != null) { + localVarQueryParams.addAll(localVarApiClient.parameterToPair("pageNum", pageNum)); + } + + if (pageSize != null) { + localVarQueryParams.addAll(localVarApiClient.parameterToPair("pageSize", pageSize)); + } + + final String[] localVarAccepts = { + "application/json" + }; + final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts); + if (localVarAccept != null) { + localVarHeaderParams.put("Accept", localVarAccept); + } + + final String[] localVarContentTypes = { + }; + final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); + if (localVarContentType != null) { + localVarHeaderParams.put("Content-Type", localVarContentType); + } + + String[] localVarAuthNames = new String[] { }; + return localVarApiClient.buildCall(basePath, localVarPath, "GET", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); + } + + @SuppressWarnings("rawtypes") + private okhttp3.Call getAllGloballyMutedUsersValidateBeforeCall(Integer pageNum, Integer pageSize, final ApiCallback _callback) throws ApiException { + return getAllGloballyMutedUsersCall(pageNum, pageSize, _callback); + + } + + /** + * 查询 app 下的所有全局禁言的用户 + * 该方法查询 app 下所有全局禁言的用户及其禁言剩余时间。文档介绍:https://docs-im-beta.easemob.com/document/server-side/account_system.html#%E6%9F%A5%E8%AF%A2-app-%E4%B8%8B%E7%9A%84%E6%89%80%E6%9C%89%E5%85%A8%E5%B1%80%E7%A6%81%E8%A8%80%E7%9A%84%E7%94%A8%E6%88%B7 + * @param pageNum 请求查询的页码 (optional) + * @param pageSize 请求查询每页显示的禁言用户的数量。取值范围为 [1,50] (optional) + * @return EMGetAllGloballyMutedUsersResult + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public EMGetAllGloballyMutedUsersResult getAllGloballyMutedUsers(Integer pageNum, Integer pageSize) throws ApiException { + ApiResponse localVarResp = getAllGloballyMutedUsersWithHttpInfo(pageNum, pageSize); + return localVarResp.getData(); + } + + /** + * 查询 app 下的所有全局禁言的用户 + * 该方法查询 app 下所有全局禁言的用户及其禁言剩余时间。文档介绍:https://docs-im-beta.easemob.com/document/server-side/account_system.html#%E6%9F%A5%E8%AF%A2-app-%E4%B8%8B%E7%9A%84%E6%89%80%E6%9C%89%E5%85%A8%E5%B1%80%E7%A6%81%E8%A8%80%E7%9A%84%E7%94%A8%E6%88%B7 + * @param pageNum 请求查询的页码 (optional) + * @param pageSize 请求查询每页显示的禁言用户的数量。取值范围为 [1,50] (optional) + * @return ApiResponse<EMGetAllGloballyMutedUsersResult> + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public ApiResponse getAllGloballyMutedUsersWithHttpInfo(Integer pageNum, Integer pageSize) throws ApiException { + okhttp3.Call localVarCall = getAllGloballyMutedUsersValidateBeforeCall(pageNum, pageSize, null); + Type localVarReturnType = new TypeToken(){}.getType(); + return localVarApiClient.execute(localVarCall, localVarReturnType); + } + + /** + * 查询 app 下的所有全局禁言的用户 (asynchronously) + * 该方法查询 app 下所有全局禁言的用户及其禁言剩余时间。文档介绍:https://docs-im-beta.easemob.com/document/server-side/account_system.html#%E6%9F%A5%E8%AF%A2-app-%E4%B8%8B%E7%9A%84%E6%89%80%E6%9C%89%E5%85%A8%E5%B1%80%E7%A6%81%E8%A8%80%E7%9A%84%E7%94%A8%E6%88%B7 + * @param pageNum 请求查询的页码 (optional) + * @param pageSize 请求查询每页显示的禁言用户的数量。取值范围为 [1,50] (optional) + * @param _callback The callback to be executed when the API call finishes + * @return The request call + * @throws ApiException If fail to process the API call, e.g. serializing the request body object + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public okhttp3.Call getAllGloballyMutedUsersAsync(Integer pageNum, Integer pageSize, final ApiCallback _callback) throws ApiException { + + okhttp3.Call localVarCall = getAllGloballyMutedUsersValidateBeforeCall(pageNum, pageSize, _callback); + Type localVarReturnType = new TypeToken(){}.getType(); + localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); + return localVarCall; + } + /** + * Build call for getOfflineMessageStatus + * @param username (required) + * @param msgid 要查看状态的离线消息 ID (required) + * @param _callback Callback for upload/download progress + * @return Call to execute + * @throws ApiException If fail to serialize the request body object + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public okhttp3.Call getOfflineMessageStatusCall(String username, String msgid, final ApiCallback _callback) throws ApiException { + String basePath = null; + // Operation Servers + String[] localBasePaths = new String[] { }; + + // Determine Base Path to Use + if (localCustomBaseUrl != null){ + basePath = localCustomBaseUrl; + } else if ( localBasePaths.length > 0 ) { + basePath = localBasePaths[localHostIndex]; + } else { + basePath = null; + } + + Object localVarPostBody = null; + + // create path and map variables + String localVarPath = "/users/{username}/offline_msg_status/{msgid}" + .replace("{" + "username" + "}", localVarApiClient.escapeString(username.toString())) + .replace("{" + "msgid" + "}", localVarApiClient.escapeString(msgid.toString())); + + List localVarQueryParams = new ArrayList(); + List localVarCollectionQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + Map localVarCookieParams = new HashMap(); + Map localVarFormParams = new HashMap(); + + final String[] localVarAccepts = { + "application/json" + }; + final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts); + if (localVarAccept != null) { + localVarHeaderParams.put("Accept", localVarAccept); + } + + final String[] localVarContentTypes = { + }; + final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); + if (localVarContentType != null) { + localVarHeaderParams.put("Content-Type", localVarContentType); + } + + String[] localVarAuthNames = new String[] { }; + return localVarApiClient.buildCall(basePath, localVarPath, "GET", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); + } + + @SuppressWarnings("rawtypes") + private okhttp3.Call getOfflineMessageStatusValidateBeforeCall(String username, String msgid, final ApiCallback _callback) throws ApiException { + // verify the required parameter 'username' is set + if (username == null) { + throw new ApiException("Missing the required parameter 'username' when calling getOfflineMessageStatus(Async)"); + } + + // verify the required parameter 'msgid' is set + if (msgid == null) { + throw new ApiException("Missing the required parameter 'msgid' when calling getOfflineMessageStatus(Async)"); + } + + return getOfflineMessageStatusCall(username, msgid, _callback); + + } + + /** + * 获取指定离线消息的投递状态 + * 获取用户的指定离线消息的投递状态,即查看该消息是否已投递。文档介绍:https://docs-im-beta.easemob.com/document/server-side/account_system.html#%E8%8E%B7%E5%8F%96%E6%8C%87%E5%AE%9A%E7%A6%BB%E7%BA%BF%E6%B6%88%E6%81%AF%E7%9A%84%E6%8A%95%E9%80%92%E7%8A%B6%E6%80%81 + * @param username (required) + * @param msgid 要查看状态的离线消息 ID (required) + * @return EMGetOfflineMessageStatusResult + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public EMGetOfflineMessageStatusResult getOfflineMessageStatus(String username, String msgid) throws ApiException { + ApiResponse localVarResp = getOfflineMessageStatusWithHttpInfo(username, msgid); + return localVarResp.getData(); + } + + /** + * 获取指定离线消息的投递状态 + * 获取用户的指定离线消息的投递状态,即查看该消息是否已投递。文档介绍:https://docs-im-beta.easemob.com/document/server-side/account_system.html#%E8%8E%B7%E5%8F%96%E6%8C%87%E5%AE%9A%E7%A6%BB%E7%BA%BF%E6%B6%88%E6%81%AF%E7%9A%84%E6%8A%95%E9%80%92%E7%8A%B6%E6%80%81 + * @param username (required) + * @param msgid 要查看状态的离线消息 ID (required) + * @return ApiResponse<EMGetOfflineMessageStatusResult> + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public ApiResponse getOfflineMessageStatusWithHttpInfo(String username, String msgid) throws ApiException { + okhttp3.Call localVarCall = getOfflineMessageStatusValidateBeforeCall(username, msgid, null); + Type localVarReturnType = new TypeToken(){}.getType(); + return localVarApiClient.execute(localVarCall, localVarReturnType); + } + + /** + * 获取指定离线消息的投递状态 (asynchronously) + * 获取用户的指定离线消息的投递状态,即查看该消息是否已投递。文档介绍:https://docs-im-beta.easemob.com/document/server-side/account_system.html#%E8%8E%B7%E5%8F%96%E6%8C%87%E5%AE%9A%E7%A6%BB%E7%BA%BF%E6%B6%88%E6%81%AF%E7%9A%84%E6%8A%95%E9%80%92%E7%8A%B6%E6%80%81 + * @param username (required) + * @param msgid 要查看状态的离线消息 ID (required) + * @param _callback The callback to be executed when the API call finishes + * @return The request call + * @throws ApiException If fail to process the API call, e.g. serializing the request body object + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public okhttp3.Call getOfflineMessageStatusAsync(String username, String msgid, final ApiCallback _callback) throws ApiException { + + okhttp3.Call localVarCall = getOfflineMessageStatusValidateBeforeCall(username, msgid, _callback); + Type localVarReturnType = new TypeToken(){}.getType(); + localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); + return localVarCall; + } + /** + * Build call for getUser + * @param username 用户 ID (required) + * @param _callback Callback for upload/download progress + * @return Call to execute + * @throws ApiException If fail to serialize the request body object + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public okhttp3.Call getUserCall(String username, final ApiCallback _callback) throws ApiException { + String basePath = null; + // Operation Servers + String[] localBasePaths = new String[] { }; + + // Determine Base Path to Use + if (localCustomBaseUrl != null){ + basePath = localCustomBaseUrl; + } else if ( localBasePaths.length > 0 ) { + basePath = localBasePaths[localHostIndex]; + } else { + basePath = null; + } + + Object localVarPostBody = null; + + // create path and map variables + String localVarPath = "/users/{username}" + .replace("{" + "username" + "}", localVarApiClient.escapeString(username.toString())); + + List localVarQueryParams = new ArrayList(); + List localVarCollectionQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + Map localVarCookieParams = new HashMap(); + Map localVarFormParams = new HashMap(); + + final String[] localVarAccepts = { + "application/json" + }; + final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts); + if (localVarAccept != null) { + localVarHeaderParams.put("Accept", localVarAccept); + } + + final String[] localVarContentTypes = { + }; + final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); + if (localVarContentType != null) { + localVarHeaderParams.put("Content-Type", localVarContentType); + } + + String[] localVarAuthNames = new String[] { }; + return localVarApiClient.buildCall(basePath, localVarPath, "GET", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); + } + + @SuppressWarnings("rawtypes") + private okhttp3.Call getUserValidateBeforeCall(String username, final ApiCallback _callback) throws ApiException { + // verify the required parameter 'username' is set + if (username == null) { + throw new ApiException("Missing the required parameter 'username' when calling getUser(Async)"); + } + + return getUserCall(username, _callback); + + } + + /** + * 获取用户详情 + * 文档介绍:https://docs-im-beta.easemob.com/document/server-side/account_system.html#%E8%8E%B7%E5%8F%96%E5%8D%95%E4%B8%AA%E7%94%A8%E6%88%B7%E7%9A%84%E8%AF%A6%E6%83%85 + * @param username 用户 ID (required) + * @return EMGetUserResult + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public EMGetUserResult getUser(String username) throws ApiException { + ApiResponse localVarResp = getUserWithHttpInfo(username); + return localVarResp.getData(); + } + + /** + * 获取用户详情 + * 文档介绍:https://docs-im-beta.easemob.com/document/server-side/account_system.html#%E8%8E%B7%E5%8F%96%E5%8D%95%E4%B8%AA%E7%94%A8%E6%88%B7%E7%9A%84%E8%AF%A6%E6%83%85 + * @param username 用户 ID (required) + * @return ApiResponse<EMGetUserResult> + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public ApiResponse getUserWithHttpInfo(String username) throws ApiException { + okhttp3.Call localVarCall = getUserValidateBeforeCall(username, null); + Type localVarReturnType = new TypeToken(){}.getType(); + return localVarApiClient.execute(localVarCall, localVarReturnType); + } + + /** + * 获取用户详情 (asynchronously) + * 文档介绍:https://docs-im-beta.easemob.com/document/server-side/account_system.html#%E8%8E%B7%E5%8F%96%E5%8D%95%E4%B8%AA%E7%94%A8%E6%88%B7%E7%9A%84%E8%AF%A6%E6%83%85 + * @param username 用户 ID (required) + * @param _callback The callback to be executed when the API call finishes + * @return The request call + * @throws ApiException If fail to process the API call, e.g. serializing the request body object + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public okhttp3.Call getUserAsync(String username, final ApiCallback _callback) throws ApiException { + + okhttp3.Call localVarCall = getUserValidateBeforeCall(username, _callback); + Type localVarReturnType = new TypeToken(){}.getType(); + localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); + return localVarCall; + } + /** + * Build call for getUserGlobalMute + * @param username (required) + * @param _callback Callback for upload/download progress + * @return Call to execute + * @throws ApiException If fail to serialize the request body object + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public okhttp3.Call getUserGlobalMuteCall(String username, final ApiCallback _callback) throws ApiException { + String basePath = null; + // Operation Servers + String[] localBasePaths = new String[] { }; + + // Determine Base Path to Use + if (localCustomBaseUrl != null){ + basePath = localCustomBaseUrl; + } else if ( localBasePaths.length > 0 ) { + basePath = localBasePaths[localHostIndex]; + } else { + basePath = null; + } + + Object localVarPostBody = null; + + // create path and map variables + String localVarPath = "/mutes/{username}" + .replace("{" + "username" + "}", localVarApiClient.escapeString(username.toString())); + + List localVarQueryParams = new ArrayList(); + List localVarCollectionQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + Map localVarCookieParams = new HashMap(); + Map localVarFormParams = new HashMap(); + + final String[] localVarAccepts = { + "application/json" + }; + final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts); + if (localVarAccept != null) { + localVarHeaderParams.put("Accept", localVarAccept); + } + + final String[] localVarContentTypes = { + }; + final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); + if (localVarContentType != null) { + localVarHeaderParams.put("Content-Type", localVarContentType); + } + + String[] localVarAuthNames = new String[] { }; + return localVarApiClient.buildCall(basePath, localVarPath, "GET", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); + } + + @SuppressWarnings("rawtypes") + private okhttp3.Call getUserGlobalMuteValidateBeforeCall(String username, final ApiCallback _callback) throws ApiException { + // verify the required parameter 'username' is set + if (username == null) { + throw new ApiException("Missing the required parameter 'username' when calling getUserGlobalMute(Async)"); + } + + return getUserGlobalMuteCall(username, _callback); + + } + + /** + * 查询单个用户 ID 全局禁言 + * 查询单个用户的单聊、群聊和聊天室的全局禁言详情。文档介绍:https://docs-im-beta.easemob.com/document/server-side/account_system.html#%E6%9F%A5%E8%AF%A2%E5%8D%95%E4%B8%AA%E7%94%A8%E6%88%B7-id-%E5%85%A8%E5%B1%80%E7%A6%81%E8%A8%80 + * @param username (required) + * @return EMGetUserGlobalMuteResult + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public EMGetUserGlobalMuteResult getUserGlobalMute(String username) throws ApiException { + ApiResponse localVarResp = getUserGlobalMuteWithHttpInfo(username); + return localVarResp.getData(); + } + + /** + * 查询单个用户 ID 全局禁言 + * 查询单个用户的单聊、群聊和聊天室的全局禁言详情。文档介绍:https://docs-im-beta.easemob.com/document/server-side/account_system.html#%E6%9F%A5%E8%AF%A2%E5%8D%95%E4%B8%AA%E7%94%A8%E6%88%B7-id-%E5%85%A8%E5%B1%80%E7%A6%81%E8%A8%80 + * @param username (required) + * @return ApiResponse<EMGetUserGlobalMuteResult> + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public ApiResponse getUserGlobalMuteWithHttpInfo(String username) throws ApiException { + okhttp3.Call localVarCall = getUserGlobalMuteValidateBeforeCall(username, null); + Type localVarReturnType = new TypeToken(){}.getType(); + return localVarApiClient.execute(localVarCall, localVarReturnType); + } + + /** + * 查询单个用户 ID 全局禁言 (asynchronously) + * 查询单个用户的单聊、群聊和聊天室的全局禁言详情。文档介绍:https://docs-im-beta.easemob.com/document/server-side/account_system.html#%E6%9F%A5%E8%AF%A2%E5%8D%95%E4%B8%AA%E7%94%A8%E6%88%B7-id-%E5%85%A8%E5%B1%80%E7%A6%81%E8%A8%80 + * @param username (required) + * @param _callback The callback to be executed when the API call finishes + * @return The request call + * @throws ApiException If fail to process the API call, e.g. serializing the request body object + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public okhttp3.Call getUserGlobalMuteAsync(String username, final ApiCallback _callback) throws ApiException { + + okhttp3.Call localVarCall = getUserGlobalMuteValidateBeforeCall(username, _callback); + Type localVarReturnType = new TypeToken(){}.getType(); + localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); + return localVarCall; + } + /** + * Build call for getUserOfflineMessageCount + * @param username (required) + * @param _callback Callback for upload/download progress + * @return Call to execute + * @throws ApiException If fail to serialize the request body object + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public okhttp3.Call getUserOfflineMessageCountCall(String username, final ApiCallback _callback) throws ApiException { + String basePath = null; + // Operation Servers + String[] localBasePaths = new String[] { }; + + // Determine Base Path to Use + if (localCustomBaseUrl != null){ + basePath = localCustomBaseUrl; + } else if ( localBasePaths.length > 0 ) { + basePath = localBasePaths[localHostIndex]; + } else { + basePath = null; + } + + Object localVarPostBody = null; + + // create path and map variables + String localVarPath = "/users/{username}/offline_msg_count" + .replace("{" + "username" + "}", localVarApiClient.escapeString(username.toString())); + + List localVarQueryParams = new ArrayList(); + List localVarCollectionQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + Map localVarCookieParams = new HashMap(); + Map localVarFormParams = new HashMap(); + + final String[] localVarAccepts = { + "application/json" + }; + final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts); + if (localVarAccept != null) { + localVarHeaderParams.put("Accept", localVarAccept); + } + + final String[] localVarContentTypes = { + }; + final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); + if (localVarContentType != null) { + localVarHeaderParams.put("Content-Type", localVarContentType); + } + + String[] localVarAuthNames = new String[] { }; + return localVarApiClient.buildCall(basePath, localVarPath, "GET", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); + } + + @SuppressWarnings("rawtypes") + private okhttp3.Call getUserOfflineMessageCountValidateBeforeCall(String username, final ApiCallback _callback) throws ApiException { + // verify the required parameter 'username' is set + if (username == null) { + throw new ApiException("Missing the required parameter 'username' when calling getUserOfflineMessageCount(Async)"); + } + + return getUserOfflineMessageCountCall(username, _callback); + + } + + /** + * 获取用户离线消息数量 + * 文档介绍:https://docs-im-beta.easemob.com/document/server-side/account_system.html#%E8%8E%B7%E5%8F%96%E7%94%A8%E6%88%B7%E7%A6%BB%E7%BA%BF%E6%B6%88%E6%81%AF%E6%95%B0%E9%87%8F + * @param username (required) + * @return EMGetUserOfflineMessageCountResult + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public EMGetUserOfflineMessageCountResult getUserOfflineMessageCount(String username) throws ApiException { + ApiResponse localVarResp = getUserOfflineMessageCountWithHttpInfo(username); + return localVarResp.getData(); + } + + /** + * 获取用户离线消息数量 + * 文档介绍:https://docs-im-beta.easemob.com/document/server-side/account_system.html#%E8%8E%B7%E5%8F%96%E7%94%A8%E6%88%B7%E7%A6%BB%E7%BA%BF%E6%B6%88%E6%81%AF%E6%95%B0%E9%87%8F + * @param username (required) + * @return ApiResponse<EMGetUserOfflineMessageCountResult> + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public ApiResponse getUserOfflineMessageCountWithHttpInfo(String username) throws ApiException { + okhttp3.Call localVarCall = getUserOfflineMessageCountValidateBeforeCall(username, null); + Type localVarReturnType = new TypeToken(){}.getType(); + return localVarApiClient.execute(localVarCall, localVarReturnType); + } + + /** + * 获取用户离线消息数量 (asynchronously) + * 文档介绍:https://docs-im-beta.easemob.com/document/server-side/account_system.html#%E8%8E%B7%E5%8F%96%E7%94%A8%E6%88%B7%E7%A6%BB%E7%BA%BF%E6%B6%88%E6%81%AF%E6%95%B0%E9%87%8F + * @param username (required) + * @param _callback The callback to be executed when the API call finishes + * @return The request call + * @throws ApiException If fail to process the API call, e.g. serializing the request body object + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public okhttp3.Call getUserOfflineMessageCountAsync(String username, final ApiCallback _callback) throws ApiException { + + okhttp3.Call localVarCall = getUserOfflineMessageCountValidateBeforeCall(username, _callback); + Type localVarReturnType = new TypeToken(){}.getType(); + localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); + return localVarCall; + } + /** + * Build call for getUserOnlineLoginDeviceList + * @param username (required) + * @param _callback Callback for upload/download progress + * @return Call to execute + * @throws ApiException If fail to serialize the request body object + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public okhttp3.Call getUserOnlineLoginDeviceListCall(String username, final ApiCallback _callback) throws ApiException { + String basePath = null; + // Operation Servers + String[] localBasePaths = new String[] { }; + + // Determine Base Path to Use + if (localCustomBaseUrl != null){ + basePath = localCustomBaseUrl; + } else if ( localBasePaths.length > 0 ) { + basePath = localBasePaths[localHostIndex]; + } else { + basePath = null; + } + + Object localVarPostBody = null; + + // create path and map variables + String localVarPath = "/users/{username}/resources" + .replace("{" + "username" + "}", localVarApiClient.escapeString(username.toString())); + + List localVarQueryParams = new ArrayList(); + List localVarCollectionQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + Map localVarCookieParams = new HashMap(); + Map localVarFormParams = new HashMap(); + + final String[] localVarAccepts = { + "application/json" + }; + final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts); + if (localVarAccept != null) { + localVarHeaderParams.put("Accept", localVarAccept); + } + + final String[] localVarContentTypes = { + }; + final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); + if (localVarContentType != null) { + localVarHeaderParams.put("Content-Type", localVarContentType); + } + + String[] localVarAuthNames = new String[] { }; + return localVarApiClient.buildCall(basePath, localVarPath, "GET", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); + } + + @SuppressWarnings("rawtypes") + private okhttp3.Call getUserOnlineLoginDeviceListValidateBeforeCall(String username, final ApiCallback _callback) throws ApiException { + // verify the required parameter 'username' is set + if (username == null) { + throw new ApiException("Missing the required parameter 'username' when calling getUserOnlineLoginDeviceList(Async)"); + } + + return getUserOnlineLoginDeviceListCall(username, _callback); + + } + + /** + * 获取指定账号的在线登录设备列表 + * 多设备登录情况下,你可以调用该接口获取指定账号的在线登录设备列表。文档介绍:https://docs-im-beta.easemob.com/document/server-side/account_system.html#%E8%8E%B7%E5%8F%96%E6%8C%87%E5%AE%9A%E8%B4%A6%E5%8F%B7%E7%9A%84%E5%9C%A8%E7%BA%BF%E7%99%BB%E5%BD%95%E8%AE%BE%E5%A4%87%E5%88%97%E8%A1%A8 + * @param username (required) + * @return EMGetUserOnlineLoginDeviceListResult + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public EMGetUserOnlineLoginDeviceListResult getUserOnlineLoginDeviceList(String username) throws ApiException { + ApiResponse localVarResp = getUserOnlineLoginDeviceListWithHttpInfo(username); + return localVarResp.getData(); + } + + /** + * 获取指定账号的在线登录设备列表 + * 多设备登录情况下,你可以调用该接口获取指定账号的在线登录设备列表。文档介绍:https://docs-im-beta.easemob.com/document/server-side/account_system.html#%E8%8E%B7%E5%8F%96%E6%8C%87%E5%AE%9A%E8%B4%A6%E5%8F%B7%E7%9A%84%E5%9C%A8%E7%BA%BF%E7%99%BB%E5%BD%95%E8%AE%BE%E5%A4%87%E5%88%97%E8%A1%A8 + * @param username (required) + * @return ApiResponse<EMGetUserOnlineLoginDeviceListResult> + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public ApiResponse getUserOnlineLoginDeviceListWithHttpInfo(String username) throws ApiException { + okhttp3.Call localVarCall = getUserOnlineLoginDeviceListValidateBeforeCall(username, null); + Type localVarReturnType = new TypeToken(){}.getType(); + return localVarApiClient.execute(localVarCall, localVarReturnType); + } + + /** + * 获取指定账号的在线登录设备列表 (asynchronously) + * 多设备登录情况下,你可以调用该接口获取指定账号的在线登录设备列表。文档介绍:https://docs-im-beta.easemob.com/document/server-side/account_system.html#%E8%8E%B7%E5%8F%96%E6%8C%87%E5%AE%9A%E8%B4%A6%E5%8F%B7%E7%9A%84%E5%9C%A8%E7%BA%BF%E7%99%BB%E5%BD%95%E8%AE%BE%E5%A4%87%E5%88%97%E8%A1%A8 + * @param username (required) + * @param _callback The callback to be executed when the API call finishes + * @return The request call + * @throws ApiException If fail to process the API call, e.g. serializing the request body object + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public okhttp3.Call getUserOnlineLoginDeviceListAsync(String username, final ApiCallback _callback) throws ApiException { + + okhttp3.Call localVarCall = getUserOnlineLoginDeviceListValidateBeforeCall(username, _callback); + Type localVarReturnType = new TypeToken(){}.getType(); + localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); + return localVarCall; + } + /** + * Build call for getUserOnlineState + * @param username (required) + * @param _callback Callback for upload/download progress + * @return Call to execute + * @throws ApiException If fail to serialize the request body object + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public okhttp3.Call getUserOnlineStateCall(String username, final ApiCallback _callback) throws ApiException { + String basePath = null; + // Operation Servers + String[] localBasePaths = new String[] { }; + + // Determine Base Path to Use + if (localCustomBaseUrl != null){ + basePath = localCustomBaseUrl; + } else if ( localBasePaths.length > 0 ) { + basePath = localBasePaths[localHostIndex]; + } else { + basePath = null; + } + + Object localVarPostBody = null; + + // create path and map variables + String localVarPath = "/users/{username}/status" + .replace("{" + "username" + "}", localVarApiClient.escapeString(username.toString())); + + List localVarQueryParams = new ArrayList(); + List localVarCollectionQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + Map localVarCookieParams = new HashMap(); + Map localVarFormParams = new HashMap(); + + final String[] localVarAccepts = { + "application/json" + }; + final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts); + if (localVarAccept != null) { + localVarHeaderParams.put("Accept", localVarAccept); + } + + final String[] localVarContentTypes = { + }; + final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); + if (localVarContentType != null) { + localVarHeaderParams.put("Content-Type", localVarContentType); + } + + String[] localVarAuthNames = new String[] { }; + return localVarApiClient.buildCall(basePath, localVarPath, "GET", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); + } + + @SuppressWarnings("rawtypes") + private okhttp3.Call getUserOnlineStateValidateBeforeCall(String username, final ApiCallback _callback) throws ApiException { + // verify the required parameter 'username' is set + if (username == null) { + throw new ApiException("Missing the required parameter 'username' when calling getUserOnlineState(Async)"); + } + + return getUserOnlineStateCall(username, _callback); + + } + + /** + * 获取单个用户在线状态 + * 查看单个用户是在线还是离线状态。文档介绍:https://docs-im-beta.easemob.com/document/server-side/account_system.html#%E8%8E%B7%E5%8F%96%E5%8D%95%E4%B8%AA%E7%94%A8%E6%88%B7%E5%9C%A8%E7%BA%BF%E7%8A%B6%E6%80%81 + * @param username (required) + * @return EMGetUserOnlineStateResult + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public EMGetUserOnlineStateResult getUserOnlineState(String username) throws ApiException { + ApiResponse localVarResp = getUserOnlineStateWithHttpInfo(username); + return localVarResp.getData(); + } + + /** + * 获取单个用户在线状态 + * 查看单个用户是在线还是离线状态。文档介绍:https://docs-im-beta.easemob.com/document/server-side/account_system.html#%E8%8E%B7%E5%8F%96%E5%8D%95%E4%B8%AA%E7%94%A8%E6%88%B7%E5%9C%A8%E7%BA%BF%E7%8A%B6%E6%80%81 + * @param username (required) + * @return ApiResponse<EMGetUserOnlineStateResult> + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public ApiResponse getUserOnlineStateWithHttpInfo(String username) throws ApiException { + okhttp3.Call localVarCall = getUserOnlineStateValidateBeforeCall(username, null); + Type localVarReturnType = new TypeToken(){}.getType(); + return localVarApiClient.execute(localVarCall, localVarReturnType); + } + + /** + * 获取单个用户在线状态 (asynchronously) + * 查看单个用户是在线还是离线状态。文档介绍:https://docs-im-beta.easemob.com/document/server-side/account_system.html#%E8%8E%B7%E5%8F%96%E5%8D%95%E4%B8%AA%E7%94%A8%E6%88%B7%E5%9C%A8%E7%BA%BF%E7%8A%B6%E6%80%81 + * @param username (required) + * @param _callback The callback to be executed when the API call finishes + * @return The request call + * @throws ApiException If fail to process the API call, e.g. serializing the request body object + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public okhttp3.Call getUserOnlineStateAsync(String username, final ApiCallback _callback) throws ApiException { + + okhttp3.Call localVarCall = getUserOnlineStateValidateBeforeCall(username, _callback); + Type localVarReturnType = new TypeToken(){}.getType(); + localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); + return localVarCall; + } + /** + * Build call for getUsers + * @param limit 请求查询用户的数量。取值范围为 [1,100],默认值为 10。若实际用户数量超过 100,返回 100 个用户 (optional) + * @param cursor 开始获取数据的游标位置,用于分页显示用户列表。第一次发起批量查询用户请求时若不设置 cursor,请求成功后会获得第一页用户列表。从响应 body 中获取 cursor,并在下一次请求的 URL 中传入该 cursor,直到响应 body 中不再有 cursor 字段,则表示已查询到 app 中所有用户 (optional) + * @param _callback Callback for upload/download progress + * @return Call to execute + * @throws ApiException If fail to serialize the request body object + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public okhttp3.Call getUsersCall(Integer limit, String cursor, final ApiCallback _callback) throws ApiException { + String basePath = null; + // Operation Servers + String[] localBasePaths = new String[] { }; + + // Determine Base Path to Use + if (localCustomBaseUrl != null){ + basePath = localCustomBaseUrl; + } else if ( localBasePaths.length > 0 ) { + basePath = localBasePaths[localHostIndex]; + } else { + basePath = null; + } + + Object localVarPostBody = null; + + // create path and map variables + String localVarPath = "/users"; + + List localVarQueryParams = new ArrayList(); + List localVarCollectionQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + Map localVarCookieParams = new HashMap(); + Map localVarFormParams = new HashMap(); + + if (limit != null) { + localVarQueryParams.addAll(localVarApiClient.parameterToPair("limit", limit)); + } + + if (cursor != null) { + localVarQueryParams.addAll(localVarApiClient.parameterToPair("cursor", cursor)); + } + + final String[] localVarAccepts = { + "application/json" + }; + final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts); + if (localVarAccept != null) { + localVarHeaderParams.put("Accept", localVarAccept); + } + + final String[] localVarContentTypes = { + }; + final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); + if (localVarContentType != null) { + localVarHeaderParams.put("Content-Type", localVarContentType); + } + + String[] localVarAuthNames = new String[] { }; + return localVarApiClient.buildCall(basePath, localVarPath, "GET", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); + } + + @SuppressWarnings("rawtypes") + private okhttp3.Call getUsersValidateBeforeCall(Integer limit, String cursor, final ApiCallback _callback) throws ApiException { + return getUsersCall(limit, cursor, _callback); + + } + + /** + * 获取用户列表 + * 该接口查询多个用户的信息列表,按照用户创建时间顺序返回。文档介绍:https://docs-im-beta.easemob.com/document/server-side/account_system.html#%E6%89%B9%E9%87%8F%E8%8E%B7%E5%8F%96%E7%94%A8%E6%88%B7%E8%AF%A6%E6%83%85 + * @param limit 请求查询用户的数量。取值范围为 [1,100],默认值为 10。若实际用户数量超过 100,返回 100 个用户 (optional) + * @param cursor 开始获取数据的游标位置,用于分页显示用户列表。第一次发起批量查询用户请求时若不设置 cursor,请求成功后会获得第一页用户列表。从响应 body 中获取 cursor,并在下一次请求的 URL 中传入该 cursor,直到响应 body 中不再有 cursor 字段,则表示已查询到 app 中所有用户 (optional) + * @return EMGetUsersResult + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public EMGetUsersResult getUsers(Integer limit, String cursor) throws ApiException { + ApiResponse localVarResp = getUsersWithHttpInfo(limit, cursor); + return localVarResp.getData(); + } + + /** + * 获取用户列表 + * 该接口查询多个用户的信息列表,按照用户创建时间顺序返回。文档介绍:https://docs-im-beta.easemob.com/document/server-side/account_system.html#%E6%89%B9%E9%87%8F%E8%8E%B7%E5%8F%96%E7%94%A8%E6%88%B7%E8%AF%A6%E6%83%85 + * @param limit 请求查询用户的数量。取值范围为 [1,100],默认值为 10。若实际用户数量超过 100,返回 100 个用户 (optional) + * @param cursor 开始获取数据的游标位置,用于分页显示用户列表。第一次发起批量查询用户请求时若不设置 cursor,请求成功后会获得第一页用户列表。从响应 body 中获取 cursor,并在下一次请求的 URL 中传入该 cursor,直到响应 body 中不再有 cursor 字段,则表示已查询到 app 中所有用户 (optional) + * @return ApiResponse<EMGetUsersResult> + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public ApiResponse getUsersWithHttpInfo(Integer limit, String cursor) throws ApiException { + okhttp3.Call localVarCall = getUsersValidateBeforeCall(limit, cursor, null); + Type localVarReturnType = new TypeToken(){}.getType(); + return localVarApiClient.execute(localVarCall, localVarReturnType); + } + + /** + * 获取用户列表 (asynchronously) + * 该接口查询多个用户的信息列表,按照用户创建时间顺序返回。文档介绍:https://docs-im-beta.easemob.com/document/server-side/account_system.html#%E6%89%B9%E9%87%8F%E8%8E%B7%E5%8F%96%E7%94%A8%E6%88%B7%E8%AF%A6%E6%83%85 + * @param limit 请求查询用户的数量。取值范围为 [1,100],默认值为 10。若实际用户数量超过 100,返回 100 个用户 (optional) + * @param cursor 开始获取数据的游标位置,用于分页显示用户列表。第一次发起批量查询用户请求时若不设置 cursor,请求成功后会获得第一页用户列表。从响应 body 中获取 cursor,并在下一次请求的 URL 中传入该 cursor,直到响应 body 中不再有 cursor 字段,则表示已查询到 app 中所有用户 (optional) + * @param _callback The callback to be executed when the API call finishes + * @return The request call + * @throws ApiException If fail to process the API call, e.g. serializing the request body object + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public okhttp3.Call getUsersAsync(Integer limit, String cursor, final ApiCallback _callback) throws ApiException { + + okhttp3.Call localVarCall = getUsersValidateBeforeCall(limit, cursor, _callback); + Type localVarReturnType = new TypeToken(){}.getType(); + localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); + return localVarCall; + } + /** + * Build call for getUsersOnlineState + * @param emGetUsersOnlineState (optional) + * @param _callback Callback for upload/download progress + * @return Call to execute + * @throws ApiException If fail to serialize the request body object + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public okhttp3.Call getUsersOnlineStateCall(EMGetUsersOnlineState emGetUsersOnlineState, final ApiCallback _callback) throws ApiException { + String basePath = null; + // Operation Servers + String[] localBasePaths = new String[] { }; + + // Determine Base Path to Use + if (localCustomBaseUrl != null){ + basePath = localCustomBaseUrl; + } else if ( localBasePaths.length > 0 ) { + basePath = localBasePaths[localHostIndex]; + } else { + basePath = null; + } + + Object localVarPostBody = emGetUsersOnlineState; + + // create path and map variables + String localVarPath = "/users/batch/status"; + + List localVarQueryParams = new ArrayList(); + List localVarCollectionQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + Map localVarCookieParams = new HashMap(); + Map localVarFormParams = new HashMap(); + + final String[] localVarAccepts = { + "application/json" + }; + final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts); + if (localVarAccept != null) { + localVarHeaderParams.put("Accept", localVarAccept); + } + + final String[] localVarContentTypes = { + "application/json" + }; + final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); + if (localVarContentType != null) { + localVarHeaderParams.put("Content-Type", localVarContentType); + } + + String[] localVarAuthNames = new String[] { }; + return localVarApiClient.buildCall(basePath, localVarPath, "POST", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); + } + + @SuppressWarnings("rawtypes") + private okhttp3.Call getUsersOnlineStateValidateBeforeCall(EMGetUsersOnlineState emGetUsersOnlineState, final ApiCallback _callback) throws ApiException { + return getUsersOnlineStateCall(emGetUsersOnlineState, _callback); + + } + + /** + * 批量获取用户在线状态 + * 批量查看用户是在线还是离线状态,单次请求最多可查看 100 个用户的在线状态。文档介绍:https://docs-im-beta.easemob.com/document/server-side/account_system.html#%E6%89%B9%E9%87%8F%E8%8E%B7%E5%8F%96%E7%94%A8%E6%88%B7%E5%9C%A8%E7%BA%BF%E7%8A%B6%E6%80%81 + * @param emGetUsersOnlineState (optional) + * @return EMGetUsersOnlineStateResult + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public EMGetUsersOnlineStateResult getUsersOnlineState(EMGetUsersOnlineState emGetUsersOnlineState) throws ApiException { + ApiResponse localVarResp = getUsersOnlineStateWithHttpInfo(emGetUsersOnlineState); + return localVarResp.getData(); + } + + /** + * 批量获取用户在线状态 + * 批量查看用户是在线还是离线状态,单次请求最多可查看 100 个用户的在线状态。文档介绍:https://docs-im-beta.easemob.com/document/server-side/account_system.html#%E6%89%B9%E9%87%8F%E8%8E%B7%E5%8F%96%E7%94%A8%E6%88%B7%E5%9C%A8%E7%BA%BF%E7%8A%B6%E6%80%81 + * @param emGetUsersOnlineState (optional) + * @return ApiResponse<EMGetUsersOnlineStateResult> + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public ApiResponse getUsersOnlineStateWithHttpInfo(EMGetUsersOnlineState emGetUsersOnlineState) throws ApiException { + okhttp3.Call localVarCall = getUsersOnlineStateValidateBeforeCall(emGetUsersOnlineState, null); + Type localVarReturnType = new TypeToken(){}.getType(); + return localVarApiClient.execute(localVarCall, localVarReturnType); + } + + /** + * 批量获取用户在线状态 (asynchronously) + * 批量查看用户是在线还是离线状态,单次请求最多可查看 100 个用户的在线状态。文档介绍:https://docs-im-beta.easemob.com/document/server-side/account_system.html#%E6%89%B9%E9%87%8F%E8%8E%B7%E5%8F%96%E7%94%A8%E6%88%B7%E5%9C%A8%E7%BA%BF%E7%8A%B6%E6%80%81 + * @param emGetUsersOnlineState (optional) + * @param _callback The callback to be executed when the API call finishes + * @return The request call + * @throws ApiException If fail to process the API call, e.g. serializing the request body object + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public okhttp3.Call getUsersOnlineStateAsync(EMGetUsersOnlineState emGetUsersOnlineState, final ApiCallback _callback) throws ApiException { + + okhttp3.Call localVarCall = getUsersOnlineStateValidateBeforeCall(emGetUsersOnlineState, _callback); + Type localVarReturnType = new TypeToken(){}.getType(); + localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); + return localVarCall; + } + /** + * Build call for modifyUserPassword + * @param username 用户 ID (required) + * @param emModifyUserPassword (optional) + * @param _callback Callback for upload/download progress + * @return Call to execute + * @throws ApiException If fail to serialize the request body object + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public okhttp3.Call modifyUserPasswordCall(String username, EMModifyUserPassword emModifyUserPassword, final ApiCallback _callback) throws ApiException { + String basePath = null; + // Operation Servers + String[] localBasePaths = new String[] { }; + + // Determine Base Path to Use + if (localCustomBaseUrl != null){ + basePath = localCustomBaseUrl; + } else if ( localBasePaths.length > 0 ) { + basePath = localBasePaths[localHostIndex]; + } else { + basePath = null; + } + + Object localVarPostBody = emModifyUserPassword; + + // create path and map variables + String localVarPath = "/users/{username}/password" + .replace("{" + "username" + "}", localVarApiClient.escapeString(username.toString())); + + List localVarQueryParams = new ArrayList(); + List localVarCollectionQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + Map localVarCookieParams = new HashMap(); + Map localVarFormParams = new HashMap(); + + final String[] localVarAccepts = { + }; + final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts); + if (localVarAccept != null) { + localVarHeaderParams.put("Accept", localVarAccept); + } + + final String[] localVarContentTypes = { + "application/json" + }; + final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); + if (localVarContentType != null) { + localVarHeaderParams.put("Content-Type", localVarContentType); + } + + String[] localVarAuthNames = new String[] { }; + return localVarApiClient.buildCall(basePath, localVarPath, "PUT", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); + } + + @SuppressWarnings("rawtypes") + private okhttp3.Call modifyUserPasswordValidateBeforeCall(String username, EMModifyUserPassword emModifyUserPassword, final ApiCallback _callback) throws ApiException { + // verify the required parameter 'username' is set + if (username == null) { + throw new ApiException("Missing the required parameter 'username' when calling modifyUserPassword(Async)"); + } + + return modifyUserPasswordCall(username, emModifyUserPassword, _callback); + + } + + /** + * 修改用户密码 + * 通过服务端接口修改用户的登录密码,不需要提供原密码。文档介绍:https://docs-im-beta.easemob.com/document/server-side/account_system.html#%E4%BF%AE%E6%94%B9%E7%94%A8%E6%88%B7%E5%AF%86%E7%A0%81 + * @param username 用户 ID (required) + * @param emModifyUserPassword (optional) + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public void modifyUserPassword(String username, EMModifyUserPassword emModifyUserPassword) throws ApiException { + modifyUserPasswordWithHttpInfo(username, emModifyUserPassword); + } + + /** + * 修改用户密码 + * 通过服务端接口修改用户的登录密码,不需要提供原密码。文档介绍:https://docs-im-beta.easemob.com/document/server-side/account_system.html#%E4%BF%AE%E6%94%B9%E7%94%A8%E6%88%B7%E5%AF%86%E7%A0%81 + * @param username 用户 ID (required) + * @param emModifyUserPassword (optional) + * @return ApiResponse<Void> + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public ApiResponse modifyUserPasswordWithHttpInfo(String username, EMModifyUserPassword emModifyUserPassword) throws ApiException { + okhttp3.Call localVarCall = modifyUserPasswordValidateBeforeCall(username, emModifyUserPassword, null); + return localVarApiClient.execute(localVarCall); + } + + /** + * 修改用户密码 (asynchronously) + * 通过服务端接口修改用户的登录密码,不需要提供原密码。文档介绍:https://docs-im-beta.easemob.com/document/server-side/account_system.html#%E4%BF%AE%E6%94%B9%E7%94%A8%E6%88%B7%E5%AF%86%E7%A0%81 + * @param username 用户 ID (required) + * @param emModifyUserPassword (optional) + * @param _callback The callback to be executed when the API call finishes + * @return The request call + * @throws ApiException If fail to process the API call, e.g. serializing the request body object + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public okhttp3.Call modifyUserPasswordAsync(String username, EMModifyUserPassword emModifyUserPassword, final ApiCallback _callback) throws ApiException { + + okhttp3.Call localVarCall = modifyUserPasswordValidateBeforeCall(username, emModifyUserPassword, _callback); + localVarApiClient.executeAsync(localVarCall, _callback); + return localVarCall; + } + /** + * Build call for setUserGlobalMute + * @param emSetUserGlobalMute (optional) + * @param _callback Callback for upload/download progress + * @return Call to execute + * @throws ApiException If fail to serialize the request body object + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public okhttp3.Call setUserGlobalMuteCall(EMSetUserGlobalMute emSetUserGlobalMute, final ApiCallback _callback) throws ApiException { + String basePath = null; + // Operation Servers + String[] localBasePaths = new String[] { }; + + // Determine Base Path to Use + if (localCustomBaseUrl != null){ + basePath = localCustomBaseUrl; + } else if ( localBasePaths.length > 0 ) { + basePath = localBasePaths[localHostIndex]; + } else { + basePath = null; + } + + Object localVarPostBody = emSetUserGlobalMute; + + // create path and map variables + String localVarPath = "/mutes"; + + List localVarQueryParams = new ArrayList(); + List localVarCollectionQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + Map localVarCookieParams = new HashMap(); + Map localVarFormParams = new HashMap(); + + final String[] localVarAccepts = { + "application/json" + }; + final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts); + if (localVarAccept != null) { + localVarHeaderParams.put("Accept", localVarAccept); + } + + final String[] localVarContentTypes = { + "application/json" + }; + final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); + if (localVarContentType != null) { + localVarHeaderParams.put("Content-Type", localVarContentType); + } + + String[] localVarAuthNames = new String[] { }; + return localVarApiClient.buildCall(basePath, localVarPath, "POST", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); + } + + @SuppressWarnings("rawtypes") + private okhttp3.Call setUserGlobalMuteValidateBeforeCall(EMSetUserGlobalMute emSetUserGlobalMute, final ApiCallback _callback) throws ApiException { + return setUserGlobalMuteCall(emSetUserGlobalMute, _callback); + + } + + /** + * 设置用户全局禁言 + * 设置单个用户 ID 的单聊、群组或聊天室消息的全局禁言。设置成功后,该用户将无法在对应的单聊、群组或聊天室中发送消息。文档介绍:https://docs-im-beta.easemob.com/document/server-side/account_system.html#%E7%94%A8%E6%88%B7%E5%85%A8%E5%B1%80%E7%A6%81%E8%A8%80 + * @param emSetUserGlobalMute (optional) + * @return EMSetUserGlobalMuteResult + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public EMSetUserGlobalMuteResult setUserGlobalMute(EMSetUserGlobalMute emSetUserGlobalMute) throws ApiException { + ApiResponse localVarResp = setUserGlobalMuteWithHttpInfo(emSetUserGlobalMute); + return localVarResp.getData(); + } + + /** + * 设置用户全局禁言 + * 设置单个用户 ID 的单聊、群组或聊天室消息的全局禁言。设置成功后,该用户将无法在对应的单聊、群组或聊天室中发送消息。文档介绍:https://docs-im-beta.easemob.com/document/server-side/account_system.html#%E7%94%A8%E6%88%B7%E5%85%A8%E5%B1%80%E7%A6%81%E8%A8%80 + * @param emSetUserGlobalMute (optional) + * @return ApiResponse<EMSetUserGlobalMuteResult> + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public ApiResponse setUserGlobalMuteWithHttpInfo(EMSetUserGlobalMute emSetUserGlobalMute) throws ApiException { + okhttp3.Call localVarCall = setUserGlobalMuteValidateBeforeCall(emSetUserGlobalMute, null); + Type localVarReturnType = new TypeToken(){}.getType(); + return localVarApiClient.execute(localVarCall, localVarReturnType); + } + + /** + * 设置用户全局禁言 (asynchronously) + * 设置单个用户 ID 的单聊、群组或聊天室消息的全局禁言。设置成功后,该用户将无法在对应的单聊、群组或聊天室中发送消息。文档介绍:https://docs-im-beta.easemob.com/document/server-side/account_system.html#%E7%94%A8%E6%88%B7%E5%85%A8%E5%B1%80%E7%A6%81%E8%A8%80 + * @param emSetUserGlobalMute (optional) + * @param _callback The callback to be executed when the API call finishes + * @return The request call + * @throws ApiException If fail to process the API call, e.g. serializing the request body object + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public okhttp3.Call setUserGlobalMuteAsync(EMSetUserGlobalMute emSetUserGlobalMute, final ApiCallback _callback) throws ApiException { + + okhttp3.Call localVarCall = setUserGlobalMuteValidateBeforeCall(emSetUserGlobalMute, _callback); + Type localVarReturnType = new TypeToken(){}.getType(); + localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); + return localVarCall; + } + /** + * Build call for userActivate + * @param username (required) + * @param _callback Callback for upload/download progress + * @return Call to execute + * @throws ApiException If fail to serialize the request body object + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public okhttp3.Call userActivateCall(String username, final ApiCallback _callback) throws ApiException { + String basePath = null; + // Operation Servers + String[] localBasePaths = new String[] { }; + + // Determine Base Path to Use + if (localCustomBaseUrl != null){ + basePath = localCustomBaseUrl; + } else if ( localBasePaths.length > 0 ) { + basePath = localBasePaths[localHostIndex]; + } else { + basePath = null; + } + + Object localVarPostBody = null; + + // create path and map variables + String localVarPath = "/users/{username}/activate" + .replace("{" + "username" + "}", localVarApiClient.escapeString(username.toString())); + + List localVarQueryParams = new ArrayList(); + List localVarCollectionQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + Map localVarCookieParams = new HashMap(); + Map localVarFormParams = new HashMap(); + + final String[] localVarAccepts = { + }; + final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts); + if (localVarAccept != null) { + localVarHeaderParams.put("Accept", localVarAccept); + } + + final String[] localVarContentTypes = { + }; + final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); + if (localVarContentType != null) { + localVarHeaderParams.put("Content-Type", localVarContentType); + } + + String[] localVarAuthNames = new String[] { }; + return localVarApiClient.buildCall(basePath, localVarPath, "POST", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); + } + + @SuppressWarnings("rawtypes") + private okhttp3.Call userActivateValidateBeforeCall(String username, final ApiCallback _callback) throws ApiException { + // verify the required parameter 'username' is set + if (username == null) { + throw new ApiException("Missing the required parameter 'username' when calling userActivate(Async)"); + } + + return userActivateCall(username, _callback); + + } + + /** + * 账号解禁 + * 被解禁后用户才能恢复登录。文档介绍:https://docs-im-beta.easemob.com/document/server-side/account_system.html#%E8%B4%A6%E5%8F%B7%E8%A7%A3%E7%A6%81 + * @param username (required) + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public void userActivate(String username) throws ApiException { + userActivateWithHttpInfo(username); + } + + /** + * 账号解禁 + * 被解禁后用户才能恢复登录。文档介绍:https://docs-im-beta.easemob.com/document/server-side/account_system.html#%E8%B4%A6%E5%8F%B7%E8%A7%A3%E7%A6%81 + * @param username (required) + * @return ApiResponse<Void> + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public ApiResponse userActivateWithHttpInfo(String username) throws ApiException { + okhttp3.Call localVarCall = userActivateValidateBeforeCall(username, null); + return localVarApiClient.execute(localVarCall); + } + + /** + * 账号解禁 (asynchronously) + * 被解禁后用户才能恢复登录。文档介绍:https://docs-im-beta.easemob.com/document/server-side/account_system.html#%E8%B4%A6%E5%8F%B7%E8%A7%A3%E7%A6%81 + * @param username (required) + * @param _callback The callback to be executed when the API call finishes + * @return The request call + * @throws ApiException If fail to process the API call, e.g. serializing the request body object + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public okhttp3.Call userActivateAsync(String username, final ApiCallback _callback) throws ApiException { + + okhttp3.Call localVarCall = userActivateValidateBeforeCall(username, _callback); + localVarApiClient.executeAsync(localVarCall, _callback); + return localVarCall; + } + /** + * Build call for userDeactivate + * @param username (required) + * @param _callback Callback for upload/download progress + * @return Call to execute + * @throws ApiException If fail to serialize the request body object + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public okhttp3.Call userDeactivateCall(String username, final ApiCallback _callback) throws ApiException { + String basePath = null; + // Operation Servers + String[] localBasePaths = new String[] { }; + + // Determine Base Path to Use + if (localCustomBaseUrl != null){ + basePath = localCustomBaseUrl; + } else if ( localBasePaths.length > 0 ) { + basePath = localBasePaths[localHostIndex]; + } else { + basePath = null; + } + + Object localVarPostBody = null; + + // create path and map variables + String localVarPath = "/users/{username}/deactivate" + .replace("{" + "username" + "}", localVarApiClient.escapeString(username.toString())); + + List localVarQueryParams = new ArrayList(); + List localVarCollectionQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + Map localVarCookieParams = new HashMap(); + Map localVarFormParams = new HashMap(); + + final String[] localVarAccepts = { + "application/json" + }; + final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts); + if (localVarAccept != null) { + localVarHeaderParams.put("Accept", localVarAccept); + } + + final String[] localVarContentTypes = { + }; + final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); + if (localVarContentType != null) { + localVarHeaderParams.put("Content-Type", localVarContentType); + } + + String[] localVarAuthNames = new String[] { }; + return localVarApiClient.buildCall(basePath, localVarPath, "POST", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); + } + + @SuppressWarnings("rawtypes") + private okhttp3.Call userDeactivateValidateBeforeCall(String username, final ApiCallback _callback) throws ApiException { + // verify the required parameter 'username' is set + if (username == null) { + throw new ApiException("Missing the required parameter 'username' when calling userDeactivate(Async)"); + } + + return userDeactivateCall(username, _callback); + + } + + /** + * 账号封禁 + * 环信即时通讯 IM 提供了对用户的禁用以及解禁接口操作,用户若被禁用将立即下线并无法登录进入环信即时通讯 IM,直到被解禁后才能恢复登录。常用在对异常用户的即时处理场景使用。文档介绍:https://docs-im-beta.easemob.com/document/server-side/account_system.html#%E8%B4%A6%E5%8F%B7%E5%B0%81%E7%A6%81 + * @param username (required) + * @return EMUserDeactivateResult + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public EMUserDeactivateResult userDeactivate(String username) throws ApiException { + ApiResponse localVarResp = userDeactivateWithHttpInfo(username); + return localVarResp.getData(); + } + + /** + * 账号封禁 + * 环信即时通讯 IM 提供了对用户的禁用以及解禁接口操作,用户若被禁用将立即下线并无法登录进入环信即时通讯 IM,直到被解禁后才能恢复登录。常用在对异常用户的即时处理场景使用。文档介绍:https://docs-im-beta.easemob.com/document/server-side/account_system.html#%E8%B4%A6%E5%8F%B7%E5%B0%81%E7%A6%81 + * @param username (required) + * @return ApiResponse<EMUserDeactivateResult> + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public ApiResponse userDeactivateWithHttpInfo(String username) throws ApiException { + okhttp3.Call localVarCall = userDeactivateValidateBeforeCall(username, null); + Type localVarReturnType = new TypeToken(){}.getType(); + return localVarApiClient.execute(localVarCall, localVarReturnType); + } + + /** + * 账号封禁 (asynchronously) + * 环信即时通讯 IM 提供了对用户的禁用以及解禁接口操作,用户若被禁用将立即下线并无法登录进入环信即时通讯 IM,直到被解禁后才能恢复登录。常用在对异常用户的即时处理场景使用。文档介绍:https://docs-im-beta.easemob.com/document/server-side/account_system.html#%E8%B4%A6%E5%8F%B7%E5%B0%81%E7%A6%81 + * @param username (required) + * @param _callback The callback to be executed when the API call finishes + * @return The request call + * @throws ApiException If fail to process the API call, e.g. serializing the request body object + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK -
4xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
5xx 错误码:https://docs-im-beta.easemob.com/document/server-side/error.html -
+ */ + public okhttp3.Call userDeactivateAsync(String username, final ApiCallback _callback) throws ApiException { + + okhttp3.Call localVarCall = userDeactivateValidateBeforeCall(username, _callback); + Type localVarReturnType = new TypeToken(){}.getType(); + localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); + return localVarCall; + } +} diff --git a/src/main/java/com/easemob/im/api/model/AbstractOpenApiSchema.java b/src/main/java/com/easemob/im/api/model/AbstractOpenApiSchema.java new file mode 100644 index 000000000..8984c714d --- /dev/null +++ b/src/main/java/com/easemob/im/api/model/AbstractOpenApiSchema.java @@ -0,0 +1,148 @@ +/* + * EMService + * Easemob Rest API + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.easemob.im.api.model; + +import com.easemob.im.ApiException; +import java.util.Objects; +import java.lang.reflect.Type; +import java.util.Map; + +//import com.fasterxml.jackson.annotation.JsonValue; + +/** + * Abstract class for oneOf,anyOf schemas defined in OpenAPI spec + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-01-25T14:51:53.998371+08:00[Asia/Shanghai]") +public abstract class AbstractOpenApiSchema { + + // store the actual instance of the schema/object + private Object instance; + + // is nullable + private Boolean isNullable; + + // schema type (e.g. oneOf, anyOf) + private final String schemaType; + + public AbstractOpenApiSchema(String schemaType, Boolean isNullable) { + this.schemaType = schemaType; + this.isNullable = isNullable; + } + + /** + * Get the list of oneOf/anyOf composed schemas allowed to be stored in this object + * + * @return an instance of the actual schema/object + */ + public abstract Map> getSchemas(); + + /** + * Get the actual instance + * + * @return an instance of the actual schema/object + */ + //@JsonValue + public Object getActualInstance() {return instance;} + + /** + * Set the actual instance + * + * @param instance the actual instance of the schema/object + */ + public void setActualInstance(Object instance) {this.instance = instance;} + + /** + * Get the instant recursively when the schemas defined in oneOf/anyof happen to be oneOf/anyOf schema as well + * + * @return an instance of the actual schema/object + */ + public Object getActualInstanceRecursively() { + return getActualInstanceRecursively(this); + } + + private Object getActualInstanceRecursively(AbstractOpenApiSchema object) { + if (object.getActualInstance() == null) { + return null; + } else if (object.getActualInstance() instanceof AbstractOpenApiSchema) { + return getActualInstanceRecursively((AbstractOpenApiSchema)object.getActualInstance()); + } else { + return object.getActualInstance(); + } + } + + /** + * Get the schema type (e.g. anyOf, oneOf) + * + * @return the schema type + */ + public String getSchemaType() { + return schemaType; + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ").append(getClass()).append(" {\n"); + sb.append(" instance: ").append(toIndentedString(instance)).append("\n"); + sb.append(" isNullable: ").append(toIndentedString(isNullable)).append("\n"); + sb.append(" schemaType: ").append(toIndentedString(schemaType)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + AbstractOpenApiSchema a = (AbstractOpenApiSchema) o; + return Objects.equals(this.instance, a.instance) && + Objects.equals(this.isNullable, a.isNullable) && + Objects.equals(this.schemaType, a.schemaType); + } + + @Override + public int hashCode() { + return Objects.hash(instance, isNullable, schemaType); + } + + /** + * Is nullable + * + * @return true if it's nullable + */ + public Boolean isNullable() { + if (Boolean.TRUE.equals(isNullable)) { + return Boolean.TRUE; + } else { + return Boolean.FALSE; + } + } + + + +} diff --git a/src/main/java/com/easemob/im/api/model/EMAddContactResult.java b/src/main/java/com/easemob/im/api/model/EMAddContactResult.java new file mode 100644 index 000000000..67e6718b3 --- /dev/null +++ b/src/main/java/com/easemob/im/api/model/EMAddContactResult.java @@ -0,0 +1,230 @@ +/* + * EMService + * Easemob Rest API + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.easemob.im.api.model; + +import java.util.Objects; +import com.easemob.im.api.model.EMUserResource; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import com.easemob.im.JSON; + +/** + * EMAddContactResult + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-01-25T14:51:53.998371+08:00[Asia/Shanghai]") +public class EMAddContactResult { + public static final String SERIALIZED_NAME_ENTITIES = "entities"; + @SerializedName(SERIALIZED_NAME_ENTITIES) + private List entities; + + public EMAddContactResult() { + } + + public EMAddContactResult entities(List entities) { + + this.entities = entities; + return this; + } + + public EMAddContactResult addEntitiesItem(EMUserResource entitiesItem) { + if (this.entities == null) { + this.entities = new ArrayList<>(); + } + this.entities.add(entitiesItem); + return this; + } + + /** + * Get entities + * @return entities + **/ + @javax.annotation.Nullable + public List getEntities() { + return entities; + } + + + public void setEntities(List entities) { + this.entities = entities; + } + + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + EMAddContactResult addContactResult = (EMAddContactResult) o; + return Objects.equals(this.entities, addContactResult.entities); + } + + @Override + public int hashCode() { + return Objects.hash(entities); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class EMAddContactResult {\n"); + sb.append(" entities: ").append(toIndentedString(entities)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("entities"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to EMAddContactResult + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!EMAddContactResult.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format("The required field(s) %s in EMAddContactResult is not found in the empty JSON string", EMAddContactResult.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!EMAddContactResult.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `EMAddContactResult` properties. JSON: %s", entry.getKey(), jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + if (jsonObj.get("entities") != null && !jsonObj.get("entities").isJsonNull()) { + JsonArray jsonArrayentities = jsonObj.getAsJsonArray("entities"); + if (jsonArrayentities != null) { + // ensure the json data is an array + if (!jsonObj.get("entities").isJsonArray()) { + throw new IllegalArgumentException(String.format("Expected the field `entities` to be an array in the JSON string but got `%s`", jsonObj.get("entities").toString())); + } + + // validate the optional field `entities` (array) + for (int i = 0; i < jsonArrayentities.size(); i++) { + EMUserResource.validateJsonElement(jsonArrayentities.get(i)); + }; + } + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!EMAddContactResult.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'EMAddContactResult' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(EMAddContactResult.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, EMAddContactResult value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public EMAddContactResult read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + return thisAdapter.fromJsonTree(jsonElement); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of EMAddContactResult given an JSON string + * + * @param jsonString JSON string + * @return An instance of EMAddContactResult + * @throws IOException if the JSON string is invalid with respect to EMAddContactResult + */ + public static EMAddContactResult fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, EMAddContactResult.class); + } + + /** + * Convert an instance of EMAddContactResult to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/com/easemob/im/api/model/EMAddGroupAdmin.java b/src/main/java/com/easemob/im/api/model/EMAddGroupAdmin.java new file mode 100644 index 000000000..2556875f9 --- /dev/null +++ b/src/main/java/com/easemob/im/api/model/EMAddGroupAdmin.java @@ -0,0 +1,208 @@ +/* + * EMService + * Easemob Rest API + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.easemob.im.api.model; + +import java.util.Objects; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.Arrays; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import com.easemob.im.JSON; + +/** + * EMAddGroupAdmin + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-01-25T14:51:53.998371+08:00[Asia/Shanghai]") +public class EMAddGroupAdmin { + public static final String SERIALIZED_NAME_NEWADMIN = "newadmin"; + @SerializedName(SERIALIZED_NAME_NEWADMIN) + private String newadmin; + + public EMAddGroupAdmin() { + } + + public EMAddGroupAdmin newadmin(String newadmin) { + + this.newadmin = newadmin; + return this; + } + + /** + * 要添加的新管理员的用户 ID + * @return newadmin + **/ + @javax.annotation.Nullable + public String getNewadmin() { + return newadmin; + } + + + public void setNewadmin(String newadmin) { + this.newadmin = newadmin; + } + + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + EMAddGroupAdmin addGroupAdmin = (EMAddGroupAdmin) o; + return Objects.equals(this.newadmin, addGroupAdmin.newadmin); + } + + @Override + public int hashCode() { + return Objects.hash(newadmin); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class EMAddGroupAdmin {\n"); + sb.append(" newadmin: ").append(toIndentedString(newadmin)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("newadmin"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to EMAddGroupAdmin + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!EMAddGroupAdmin.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format("The required field(s) %s in EMAddGroupAdmin is not found in the empty JSON string", EMAddGroupAdmin.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!EMAddGroupAdmin.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `EMAddGroupAdmin` properties. JSON: %s", entry.getKey(), jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + if ((jsonObj.get("newadmin") != null && !jsonObj.get("newadmin").isJsonNull()) && !jsonObj.get("newadmin").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `newadmin` to be a primitive type in the JSON string but got `%s`", jsonObj.get("newadmin").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!EMAddGroupAdmin.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'EMAddGroupAdmin' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(EMAddGroupAdmin.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, EMAddGroupAdmin value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public EMAddGroupAdmin read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + return thisAdapter.fromJsonTree(jsonElement); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of EMAddGroupAdmin given an JSON string + * + * @param jsonString JSON string + * @return An instance of EMAddGroupAdmin + * @throws IOException if the JSON string is invalid with respect to EMAddGroupAdmin + */ + public static EMAddGroupAdmin fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, EMAddGroupAdmin.class); + } + + /** + * Convert an instance of EMAddGroupAdmin to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/com/easemob/im/api/model/EMAddGroupAdminResource.java b/src/main/java/com/easemob/im/api/model/EMAddGroupAdminResource.java new file mode 100644 index 000000000..cdf0c6693 --- /dev/null +++ b/src/main/java/com/easemob/im/api/model/EMAddGroupAdminResource.java @@ -0,0 +1,208 @@ +/* + * EMService + * Easemob Rest API + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.easemob.im.api.model; + +import java.util.Objects; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.Arrays; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import com.easemob.im.JSON; + +/** + * EMAddGroupAdminResource + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-01-25T14:51:53.998371+08:00[Asia/Shanghai]") +public class EMAddGroupAdminResource { + public static final String SERIALIZED_NAME_RESULT = "result"; + @SerializedName(SERIALIZED_NAME_RESULT) + private String result; + + public EMAddGroupAdminResource() { + } + + public EMAddGroupAdminResource result(String result) { + + this.result = result; + return this; + } + + /** + * Get result + * @return result + **/ + @javax.annotation.Nullable + public String getResult() { + return result; + } + + + public void setResult(String result) { + this.result = result; + } + + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + EMAddGroupAdminResource addGroupAdminResource = (EMAddGroupAdminResource) o; + return Objects.equals(this.result, addGroupAdminResource.result); + } + + @Override + public int hashCode() { + return Objects.hash(result); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class EMAddGroupAdminResource {\n"); + sb.append(" result: ").append(toIndentedString(result)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("result"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to EMAddGroupAdminResource + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!EMAddGroupAdminResource.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format("The required field(s) %s in EMAddGroupAdminResource is not found in the empty JSON string", EMAddGroupAdminResource.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!EMAddGroupAdminResource.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `EMAddGroupAdminResource` properties. JSON: %s", entry.getKey(), jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + if ((jsonObj.get("result") != null && !jsonObj.get("result").isJsonNull()) && !jsonObj.get("result").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `result` to be a primitive type in the JSON string but got `%s`", jsonObj.get("result").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!EMAddGroupAdminResource.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'EMAddGroupAdminResource' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(EMAddGroupAdminResource.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, EMAddGroupAdminResource value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public EMAddGroupAdminResource read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + return thisAdapter.fromJsonTree(jsonElement); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of EMAddGroupAdminResource given an JSON string + * + * @param jsonString JSON string + * @return An instance of EMAddGroupAdminResource + * @throws IOException if the JSON string is invalid with respect to EMAddGroupAdminResource + */ + public static EMAddGroupAdminResource fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, EMAddGroupAdminResource.class); + } + + /** + * Convert an instance of EMAddGroupAdminResource to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/com/easemob/im/api/model/EMAddGroupAdminResult.java b/src/main/java/com/easemob/im/api/model/EMAddGroupAdminResult.java new file mode 100644 index 000000000..c5624d8fe --- /dev/null +++ b/src/main/java/com/easemob/im/api/model/EMAddGroupAdminResult.java @@ -0,0 +1,210 @@ +/* + * EMService + * Easemob Rest API + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.easemob.im.api.model; + +import java.util.Objects; +import com.easemob.im.api.model.EMAddGroupAdminResource; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.Arrays; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import com.easemob.im.JSON; + +/** + * EMAddGroupAdminResult + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-01-25T14:51:53.998371+08:00[Asia/Shanghai]") +public class EMAddGroupAdminResult { + public static final String SERIALIZED_NAME_DATA = "data"; + @SerializedName(SERIALIZED_NAME_DATA) + private EMAddGroupAdminResource data; + + public EMAddGroupAdminResult() { + } + + public EMAddGroupAdminResult data(EMAddGroupAdminResource data) { + + this.data = data; + return this; + } + + /** + * Get data + * @return data + **/ + @javax.annotation.Nullable + public EMAddGroupAdminResource getData() { + return data; + } + + + public void setData(EMAddGroupAdminResource data) { + this.data = data; + } + + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + EMAddGroupAdminResult addGroupAdminResult = (EMAddGroupAdminResult) o; + return Objects.equals(this.data, addGroupAdminResult.data); + } + + @Override + public int hashCode() { + return Objects.hash(data); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class EMAddGroupAdminResult {\n"); + sb.append(" data: ").append(toIndentedString(data)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("data"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to EMAddGroupAdminResult + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!EMAddGroupAdminResult.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format("The required field(s) %s in EMAddGroupAdminResult is not found in the empty JSON string", EMAddGroupAdminResult.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!EMAddGroupAdminResult.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `EMAddGroupAdminResult` properties. JSON: %s", entry.getKey(), jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // validate the optional field `data` + if (jsonObj.get("data") != null && !jsonObj.get("data").isJsonNull()) { + EMAddGroupAdminResource.validateJsonElement(jsonObj.get("data")); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!EMAddGroupAdminResult.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'EMAddGroupAdminResult' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(EMAddGroupAdminResult.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, EMAddGroupAdminResult value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public EMAddGroupAdminResult read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + return thisAdapter.fromJsonTree(jsonElement); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of EMAddGroupAdminResult given an JSON string + * + * @param jsonString JSON string + * @return An instance of EMAddGroupAdminResult + * @throws IOException if the JSON string is invalid with respect to EMAddGroupAdminResult + */ + public static EMAddGroupAdminResult fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, EMAddGroupAdminResult.class); + } + + /** + * Convert an instance of EMAddGroupAdminResult to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/com/easemob/im/api/model/EMAddMultipleUserToGroup.java b/src/main/java/com/easemob/im/api/model/EMAddMultipleUserToGroup.java new file mode 100644 index 000000000..0745f46e3 --- /dev/null +++ b/src/main/java/com/easemob/im/api/model/EMAddMultipleUserToGroup.java @@ -0,0 +1,219 @@ +/* + * EMService + * Easemob Rest API + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.easemob.im.api.model; + +import java.util.Objects; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import com.easemob.im.JSON; + +/** + * EMAddMultipleUserToGroup + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-01-25T14:51:53.998371+08:00[Asia/Shanghai]") +public class EMAddMultipleUserToGroup { + public static final String SERIALIZED_NAME_USERNAMES = "usernames"; + @SerializedName(SERIALIZED_NAME_USERNAMES) + private List usernames; + + public EMAddMultipleUserToGroup() { + } + + public EMAddMultipleUserToGroup usernames(List usernames) { + + this.usernames = usernames; + return this; + } + + public EMAddMultipleUserToGroup addUsernamesItem(String usernamesItem) { + if (this.usernames == null) { + this.usernames = new ArrayList<>(); + } + this.usernames.add(usernamesItem); + return this; + } + + /** + * 要添加为群组成员的用户 ID 数组,每次最多可传 60 个用户 ID + * @return usernames + **/ + @javax.annotation.Nullable + public List getUsernames() { + return usernames; + } + + + public void setUsernames(List usernames) { + this.usernames = usernames; + } + + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + EMAddMultipleUserToGroup addMultipleUserToGroup = (EMAddMultipleUserToGroup) o; + return Objects.equals(this.usernames, addMultipleUserToGroup.usernames); + } + + @Override + public int hashCode() { + return Objects.hash(usernames); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class EMAddMultipleUserToGroup {\n"); + sb.append(" usernames: ").append(toIndentedString(usernames)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("usernames"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to EMAddMultipleUserToGroup + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!EMAddMultipleUserToGroup.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format("The required field(s) %s in EMAddMultipleUserToGroup is not found in the empty JSON string", EMAddMultipleUserToGroup.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!EMAddMultipleUserToGroup.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `EMAddMultipleUserToGroup` properties. JSON: %s", entry.getKey(), jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // ensure the optional json data is an array if present + if (jsonObj.get("usernames") != null && !jsonObj.get("usernames").isJsonNull() && !jsonObj.get("usernames").isJsonArray()) { + throw new IllegalArgumentException(String.format("Expected the field `usernames` to be an array in the JSON string but got `%s`", jsonObj.get("usernames").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!EMAddMultipleUserToGroup.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'EMAddMultipleUserToGroup' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(EMAddMultipleUserToGroup.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, EMAddMultipleUserToGroup value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public EMAddMultipleUserToGroup read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + return thisAdapter.fromJsonTree(jsonElement); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of EMAddMultipleUserToGroup given an JSON string + * + * @param jsonString JSON string + * @return An instance of EMAddMultipleUserToGroup + * @throws IOException if the JSON string is invalid with respect to EMAddMultipleUserToGroup + */ + public static EMAddMultipleUserToGroup fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, EMAddMultipleUserToGroup.class); + } + + /** + * Convert an instance of EMAddMultipleUserToGroup to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/com/easemob/im/api/model/EMAddMultipleUserToGroupBlockList.java b/src/main/java/com/easemob/im/api/model/EMAddMultipleUserToGroupBlockList.java new file mode 100644 index 000000000..c83362dc4 --- /dev/null +++ b/src/main/java/com/easemob/im/api/model/EMAddMultipleUserToGroupBlockList.java @@ -0,0 +1,219 @@ +/* + * EMService + * Easemob Rest API + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.easemob.im.api.model; + +import java.util.Objects; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import com.easemob.im.JSON; + +/** + * EMAddMultipleUserToGroupBlockList + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-01-25T14:51:53.998371+08:00[Asia/Shanghai]") +public class EMAddMultipleUserToGroupBlockList { + public static final String SERIALIZED_NAME_USERNAMES = "usernames"; + @SerializedName(SERIALIZED_NAME_USERNAMES) + private List usernames; + + public EMAddMultipleUserToGroupBlockList() { + } + + public EMAddMultipleUserToGroupBlockList usernames(List usernames) { + + this.usernames = usernames; + return this; + } + + public EMAddMultipleUserToGroupBlockList addUsernamesItem(String usernamesItem) { + if (this.usernames == null) { + this.usernames = new ArrayList<>(); + } + this.usernames.add(usernamesItem); + return this; + } + + /** + * 要添加至群组黑名单的用户 ID 数组,每次最多可传 60 个用户 ID + * @return usernames + **/ + @javax.annotation.Nullable + public List getUsernames() { + return usernames; + } + + + public void setUsernames(List usernames) { + this.usernames = usernames; + } + + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + EMAddMultipleUserToGroupBlockList addMultipleUserToGroupBlockList = (EMAddMultipleUserToGroupBlockList) o; + return Objects.equals(this.usernames, addMultipleUserToGroupBlockList.usernames); + } + + @Override + public int hashCode() { + return Objects.hash(usernames); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class EMAddMultipleUserToGroupBlockList {\n"); + sb.append(" usernames: ").append(toIndentedString(usernames)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("usernames"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to EMAddMultipleUserToGroupBlockList + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!EMAddMultipleUserToGroupBlockList.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format("The required field(s) %s in EMAddMultipleUserToGroupBlockList is not found in the empty JSON string", EMAddMultipleUserToGroupBlockList.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!EMAddMultipleUserToGroupBlockList.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `EMAddMultipleUserToGroupBlockList` properties. JSON: %s", entry.getKey(), jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // ensure the optional json data is an array if present + if (jsonObj.get("usernames") != null && !jsonObj.get("usernames").isJsonNull() && !jsonObj.get("usernames").isJsonArray()) { + throw new IllegalArgumentException(String.format("Expected the field `usernames` to be an array in the JSON string but got `%s`", jsonObj.get("usernames").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!EMAddMultipleUserToGroupBlockList.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'EMAddMultipleUserToGroupBlockList' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(EMAddMultipleUserToGroupBlockList.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, EMAddMultipleUserToGroupBlockList value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public EMAddMultipleUserToGroupBlockList read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + return thisAdapter.fromJsonTree(jsonElement); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of EMAddMultipleUserToGroupBlockList given an JSON string + * + * @param jsonString JSON string + * @return An instance of EMAddMultipleUserToGroupBlockList + * @throws IOException if the JSON string is invalid with respect to EMAddMultipleUserToGroupBlockList + */ + public static EMAddMultipleUserToGroupBlockList fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, EMAddMultipleUserToGroupBlockList.class); + } + + /** + * Convert an instance of EMAddMultipleUserToGroupBlockList to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/com/easemob/im/api/model/EMAddMultipleUserToGroupBlockListResult.java b/src/main/java/com/easemob/im/api/model/EMAddMultipleUserToGroupBlockListResult.java new file mode 100644 index 000000000..6d95bd1b9 --- /dev/null +++ b/src/main/java/com/easemob/im/api/model/EMAddMultipleUserToGroupBlockListResult.java @@ -0,0 +1,205 @@ +/* + * EMService + * Easemob Rest API + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.easemob.im.api.model; + +import java.util.Objects; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.Arrays; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import com.easemob.im.JSON; + +/** + * EMAddMultipleUserToGroupBlockListResult + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-01-25T14:51:53.998371+08:00[Asia/Shanghai]") +public class EMAddMultipleUserToGroupBlockListResult { + public static final String SERIALIZED_NAME_DATA = "data"; + @SerializedName(SERIALIZED_NAME_DATA) + private Object data; + + public EMAddMultipleUserToGroupBlockListResult() { + } + + public EMAddMultipleUserToGroupBlockListResult data(Object data) { + + this.data = data; + return this; + } + + /** + * Get data + * @return data + **/ + @javax.annotation.Nullable + public Object getData() { + return data; + } + + + public void setData(Object data) { + this.data = data; + } + + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + EMAddMultipleUserToGroupBlockListResult addMultipleUserToGroupBlockListResult = (EMAddMultipleUserToGroupBlockListResult) o; + return Objects.equals(this.data, addMultipleUserToGroupBlockListResult.data); + } + + @Override + public int hashCode() { + return Objects.hash(data); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class EMAddMultipleUserToGroupBlockListResult {\n"); + sb.append(" data: ").append(toIndentedString(data)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("data"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to EMAddMultipleUserToGroupBlockListResult + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!EMAddMultipleUserToGroupBlockListResult.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format("The required field(s) %s in EMAddMultipleUserToGroupBlockListResult is not found in the empty JSON string", EMAddMultipleUserToGroupBlockListResult.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!EMAddMultipleUserToGroupBlockListResult.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `EMAddMultipleUserToGroupBlockListResult` properties. JSON: %s", entry.getKey(), jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!EMAddMultipleUserToGroupBlockListResult.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'EMAddMultipleUserToGroupBlockListResult' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(EMAddMultipleUserToGroupBlockListResult.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, EMAddMultipleUserToGroupBlockListResult value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public EMAddMultipleUserToGroupBlockListResult read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + return thisAdapter.fromJsonTree(jsonElement); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of EMAddMultipleUserToGroupBlockListResult given an JSON string + * + * @param jsonString JSON string + * @return An instance of EMAddMultipleUserToGroupBlockListResult + * @throws IOException if the JSON string is invalid with respect to EMAddMultipleUserToGroupBlockListResult + */ + public static EMAddMultipleUserToGroupBlockListResult fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, EMAddMultipleUserToGroupBlockListResult.class); + } + + /** + * Convert an instance of EMAddMultipleUserToGroupBlockListResult to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/com/easemob/im/api/model/EMAddMultipleUserToGroupResource.java b/src/main/java/com/easemob/im/api/model/EMAddMultipleUserToGroupResource.java new file mode 100644 index 000000000..abe2b9d7e --- /dev/null +++ b/src/main/java/com/easemob/im/api/model/EMAddMultipleUserToGroupResource.java @@ -0,0 +1,219 @@ +/* + * EMService + * Easemob Rest API + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.easemob.im.api.model; + +import java.util.Objects; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import com.easemob.im.JSON; + +/** + * EMAddMultipleUserToGroupResource + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-01-25T14:51:53.998371+08:00[Asia/Shanghai]") +public class EMAddMultipleUserToGroupResource { + public static final String SERIALIZED_NAME_NEWMEMBERS = "newmembers"; + @SerializedName(SERIALIZED_NAME_NEWMEMBERS) + private List newmembers; + + public EMAddMultipleUserToGroupResource() { + } + + public EMAddMultipleUserToGroupResource newmembers(List newmembers) { + + this.newmembers = newmembers; + return this; + } + + public EMAddMultipleUserToGroupResource addNewmembersItem(String newmembersItem) { + if (this.newmembers == null) { + this.newmembers = new ArrayList<>(); + } + this.newmembers.add(newmembersItem); + return this; + } + + /** + * Get newmembers + * @return newmembers + **/ + @javax.annotation.Nullable + public List getNewmembers() { + return newmembers; + } + + + public void setNewmembers(List newmembers) { + this.newmembers = newmembers; + } + + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + EMAddMultipleUserToGroupResource addMultipleUserToGroupResource = (EMAddMultipleUserToGroupResource) o; + return Objects.equals(this.newmembers, addMultipleUserToGroupResource.newmembers); + } + + @Override + public int hashCode() { + return Objects.hash(newmembers); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class EMAddMultipleUserToGroupResource {\n"); + sb.append(" newmembers: ").append(toIndentedString(newmembers)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("newmembers"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to EMAddMultipleUserToGroupResource + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!EMAddMultipleUserToGroupResource.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format("The required field(s) %s in EMAddMultipleUserToGroupResource is not found in the empty JSON string", EMAddMultipleUserToGroupResource.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!EMAddMultipleUserToGroupResource.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `EMAddMultipleUserToGroupResource` properties. JSON: %s", entry.getKey(), jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // ensure the optional json data is an array if present + if (jsonObj.get("newmembers") != null && !jsonObj.get("newmembers").isJsonNull() && !jsonObj.get("newmembers").isJsonArray()) { + throw new IllegalArgumentException(String.format("Expected the field `newmembers` to be an array in the JSON string but got `%s`", jsonObj.get("newmembers").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!EMAddMultipleUserToGroupResource.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'EMAddMultipleUserToGroupResource' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(EMAddMultipleUserToGroupResource.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, EMAddMultipleUserToGroupResource value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public EMAddMultipleUserToGroupResource read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + return thisAdapter.fromJsonTree(jsonElement); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of EMAddMultipleUserToGroupResource given an JSON string + * + * @param jsonString JSON string + * @return An instance of EMAddMultipleUserToGroupResource + * @throws IOException if the JSON string is invalid with respect to EMAddMultipleUserToGroupResource + */ + public static EMAddMultipleUserToGroupResource fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, EMAddMultipleUserToGroupResource.class); + } + + /** + * Convert an instance of EMAddMultipleUserToGroupResource to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/com/easemob/im/api/model/EMAddMultipleUserToGroupResult.java b/src/main/java/com/easemob/im/api/model/EMAddMultipleUserToGroupResult.java new file mode 100644 index 000000000..a90dd8674 --- /dev/null +++ b/src/main/java/com/easemob/im/api/model/EMAddMultipleUserToGroupResult.java @@ -0,0 +1,210 @@ +/* + * EMService + * Easemob Rest API + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.easemob.im.api.model; + +import java.util.Objects; +import com.easemob.im.api.model.EMAddMultipleUserToGroupResource; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.Arrays; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import com.easemob.im.JSON; + +/** + * EMAddMultipleUserToGroupResult + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-01-25T14:51:53.998371+08:00[Asia/Shanghai]") +public class EMAddMultipleUserToGroupResult { + public static final String SERIALIZED_NAME_DATA = "data"; + @SerializedName(SERIALIZED_NAME_DATA) + private EMAddMultipleUserToGroupResource data; + + public EMAddMultipleUserToGroupResult() { + } + + public EMAddMultipleUserToGroupResult data(EMAddMultipleUserToGroupResource data) { + + this.data = data; + return this; + } + + /** + * Get data + * @return data + **/ + @javax.annotation.Nullable + public EMAddMultipleUserToGroupResource getData() { + return data; + } + + + public void setData(EMAddMultipleUserToGroupResource data) { + this.data = data; + } + + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + EMAddMultipleUserToGroupResult addMultipleUserToGroupResult = (EMAddMultipleUserToGroupResult) o; + return Objects.equals(this.data, addMultipleUserToGroupResult.data); + } + + @Override + public int hashCode() { + return Objects.hash(data); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class EMAddMultipleUserToGroupResult {\n"); + sb.append(" data: ").append(toIndentedString(data)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("data"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to EMAddMultipleUserToGroupResult + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!EMAddMultipleUserToGroupResult.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format("The required field(s) %s in EMAddMultipleUserToGroupResult is not found in the empty JSON string", EMAddMultipleUserToGroupResult.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!EMAddMultipleUserToGroupResult.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `EMAddMultipleUserToGroupResult` properties. JSON: %s", entry.getKey(), jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // validate the optional field `data` + if (jsonObj.get("data") != null && !jsonObj.get("data").isJsonNull()) { + EMAddMultipleUserToGroupResource.validateJsonElement(jsonObj.get("data")); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!EMAddMultipleUserToGroupResult.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'EMAddMultipleUserToGroupResult' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(EMAddMultipleUserToGroupResult.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, EMAddMultipleUserToGroupResult value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public EMAddMultipleUserToGroupResult read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + return thisAdapter.fromJsonTree(jsonElement); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of EMAddMultipleUserToGroupResult given an JSON string + * + * @param jsonString JSON string + * @return An instance of EMAddMultipleUserToGroupResult + * @throws IOException if the JSON string is invalid with respect to EMAddMultipleUserToGroupResult + */ + public static EMAddMultipleUserToGroupResult fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, EMAddMultipleUserToGroupResult.class); + } + + /** + * Convert an instance of EMAddMultipleUserToGroupResult to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/com/easemob/im/api/model/EMAddMultipleUserToGroupWhiteList.java b/src/main/java/com/easemob/im/api/model/EMAddMultipleUserToGroupWhiteList.java new file mode 100644 index 000000000..fd8d96e70 --- /dev/null +++ b/src/main/java/com/easemob/im/api/model/EMAddMultipleUserToGroupWhiteList.java @@ -0,0 +1,219 @@ +/* + * EMService + * Easemob Rest API + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.easemob.im.api.model; + +import java.util.Objects; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import com.easemob.im.JSON; + +/** + * EMAddMultipleUserToGroupWhiteList + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-01-25T14:51:53.998371+08:00[Asia/Shanghai]") +public class EMAddMultipleUserToGroupWhiteList { + public static final String SERIALIZED_NAME_USERNAMES = "usernames"; + @SerializedName(SERIALIZED_NAME_USERNAMES) + private List usernames; + + public EMAddMultipleUserToGroupWhiteList() { + } + + public EMAddMultipleUserToGroupWhiteList usernames(List usernames) { + + this.usernames = usernames; + return this; + } + + public EMAddMultipleUserToGroupWhiteList addUsernamesItem(String usernamesItem) { + if (this.usernames == null) { + this.usernames = new ArrayList<>(); + } + this.usernames.add(usernamesItem); + return this; + } + + /** + * 待添加至群组白名单中的用户 ID 数组,每次最多可传 60 个用户 ID + * @return usernames + **/ + @javax.annotation.Nullable + public List getUsernames() { + return usernames; + } + + + public void setUsernames(List usernames) { + this.usernames = usernames; + } + + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + EMAddMultipleUserToGroupWhiteList addMultipleUserToGroupWhiteList = (EMAddMultipleUserToGroupWhiteList) o; + return Objects.equals(this.usernames, addMultipleUserToGroupWhiteList.usernames); + } + + @Override + public int hashCode() { + return Objects.hash(usernames); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class EMAddMultipleUserToGroupWhiteList {\n"); + sb.append(" usernames: ").append(toIndentedString(usernames)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("usernames"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to EMAddMultipleUserToGroupWhiteList + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!EMAddMultipleUserToGroupWhiteList.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format("The required field(s) %s in EMAddMultipleUserToGroupWhiteList is not found in the empty JSON string", EMAddMultipleUserToGroupWhiteList.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!EMAddMultipleUserToGroupWhiteList.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `EMAddMultipleUserToGroupWhiteList` properties. JSON: %s", entry.getKey(), jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // ensure the optional json data is an array if present + if (jsonObj.get("usernames") != null && !jsonObj.get("usernames").isJsonNull() && !jsonObj.get("usernames").isJsonArray()) { + throw new IllegalArgumentException(String.format("Expected the field `usernames` to be an array in the JSON string but got `%s`", jsonObj.get("usernames").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!EMAddMultipleUserToGroupWhiteList.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'EMAddMultipleUserToGroupWhiteList' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(EMAddMultipleUserToGroupWhiteList.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, EMAddMultipleUserToGroupWhiteList value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public EMAddMultipleUserToGroupWhiteList read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + return thisAdapter.fromJsonTree(jsonElement); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of EMAddMultipleUserToGroupWhiteList given an JSON string + * + * @param jsonString JSON string + * @return An instance of EMAddMultipleUserToGroupWhiteList + * @throws IOException if the JSON string is invalid with respect to EMAddMultipleUserToGroupWhiteList + */ + public static EMAddMultipleUserToGroupWhiteList fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, EMAddMultipleUserToGroupWhiteList.class); + } + + /** + * Convert an instance of EMAddMultipleUserToGroupWhiteList to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/com/easemob/im/api/model/EMAddMultipleUserToGroupWhiteListResult.java b/src/main/java/com/easemob/im/api/model/EMAddMultipleUserToGroupWhiteListResult.java new file mode 100644 index 000000000..f6c40a840 --- /dev/null +++ b/src/main/java/com/easemob/im/api/model/EMAddMultipleUserToGroupWhiteListResult.java @@ -0,0 +1,205 @@ +/* + * EMService + * Easemob Rest API + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.easemob.im.api.model; + +import java.util.Objects; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.Arrays; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import com.easemob.im.JSON; + +/** + * EMAddMultipleUserToGroupWhiteListResult + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-01-25T14:51:53.998371+08:00[Asia/Shanghai]") +public class EMAddMultipleUserToGroupWhiteListResult { + public static final String SERIALIZED_NAME_DATA = "data"; + @SerializedName(SERIALIZED_NAME_DATA) + private Object data; + + public EMAddMultipleUserToGroupWhiteListResult() { + } + + public EMAddMultipleUserToGroupWhiteListResult data(Object data) { + + this.data = data; + return this; + } + + /** + * Get data + * @return data + **/ + @javax.annotation.Nullable + public Object getData() { + return data; + } + + + public void setData(Object data) { + this.data = data; + } + + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + EMAddMultipleUserToGroupWhiteListResult addMultipleUserToGroupWhiteListResult = (EMAddMultipleUserToGroupWhiteListResult) o; + return Objects.equals(this.data, addMultipleUserToGroupWhiteListResult.data); + } + + @Override + public int hashCode() { + return Objects.hash(data); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class EMAddMultipleUserToGroupWhiteListResult {\n"); + sb.append(" data: ").append(toIndentedString(data)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("data"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to EMAddMultipleUserToGroupWhiteListResult + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!EMAddMultipleUserToGroupWhiteListResult.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format("The required field(s) %s in EMAddMultipleUserToGroupWhiteListResult is not found in the empty JSON string", EMAddMultipleUserToGroupWhiteListResult.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!EMAddMultipleUserToGroupWhiteListResult.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `EMAddMultipleUserToGroupWhiteListResult` properties. JSON: %s", entry.getKey(), jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!EMAddMultipleUserToGroupWhiteListResult.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'EMAddMultipleUserToGroupWhiteListResult' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(EMAddMultipleUserToGroupWhiteListResult.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, EMAddMultipleUserToGroupWhiteListResult value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public EMAddMultipleUserToGroupWhiteListResult read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + return thisAdapter.fromJsonTree(jsonElement); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of EMAddMultipleUserToGroupWhiteListResult given an JSON string + * + * @param jsonString JSON string + * @return An instance of EMAddMultipleUserToGroupWhiteListResult + * @throws IOException if the JSON string is invalid with respect to EMAddMultipleUserToGroupWhiteListResult + */ + public static EMAddMultipleUserToGroupWhiteListResult fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, EMAddMultipleUserToGroupWhiteListResult.class); + } + + /** + * Convert an instance of EMAddMultipleUserToGroupWhiteListResult to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/com/easemob/im/api/model/EMAddMultipleUserToRoom.java b/src/main/java/com/easemob/im/api/model/EMAddMultipleUserToRoom.java new file mode 100644 index 000000000..a7a3b126f --- /dev/null +++ b/src/main/java/com/easemob/im/api/model/EMAddMultipleUserToRoom.java @@ -0,0 +1,219 @@ +/* + * EMService + * Easemob Rest API + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.easemob.im.api.model; + +import java.util.Objects; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import com.easemob.im.JSON; + +/** + * EMAddMultipleUserToRoom + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-01-25T14:51:53.998371+08:00[Asia/Shanghai]") +public class EMAddMultipleUserToRoom { + public static final String SERIALIZED_NAME_USERNAMES = "usernames"; + @SerializedName(SERIALIZED_NAME_USERNAMES) + private List usernames; + + public EMAddMultipleUserToRoom() { + } + + public EMAddMultipleUserToRoom usernames(List usernames) { + + this.usernames = usernames; + return this; + } + + public EMAddMultipleUserToRoom addUsernamesItem(String usernamesItem) { + if (this.usernames == null) { + this.usernames = new ArrayList<>(); + } + this.usernames.add(usernamesItem); + return this; + } + + /** + * 添加的用户 ID 数组,每次最多可传 60 个用户 ID + * @return usernames + **/ + @javax.annotation.Nullable + public List getUsernames() { + return usernames; + } + + + public void setUsernames(List usernames) { + this.usernames = usernames; + } + + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + EMAddMultipleUserToRoom addMultipleUserToRoom = (EMAddMultipleUserToRoom) o; + return Objects.equals(this.usernames, addMultipleUserToRoom.usernames); + } + + @Override + public int hashCode() { + return Objects.hash(usernames); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class EMAddMultipleUserToRoom {\n"); + sb.append(" usernames: ").append(toIndentedString(usernames)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("usernames"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to EMAddMultipleUserToRoom + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!EMAddMultipleUserToRoom.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format("The required field(s) %s in EMAddMultipleUserToRoom is not found in the empty JSON string", EMAddMultipleUserToRoom.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!EMAddMultipleUserToRoom.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `EMAddMultipleUserToRoom` properties. JSON: %s", entry.getKey(), jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // ensure the optional json data is an array if present + if (jsonObj.get("usernames") != null && !jsonObj.get("usernames").isJsonNull() && !jsonObj.get("usernames").isJsonArray()) { + throw new IllegalArgumentException(String.format("Expected the field `usernames` to be an array in the JSON string but got `%s`", jsonObj.get("usernames").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!EMAddMultipleUserToRoom.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'EMAddMultipleUserToRoom' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(EMAddMultipleUserToRoom.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, EMAddMultipleUserToRoom value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public EMAddMultipleUserToRoom read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + return thisAdapter.fromJsonTree(jsonElement); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of EMAddMultipleUserToRoom given an JSON string + * + * @param jsonString JSON string + * @return An instance of EMAddMultipleUserToRoom + * @throws IOException if the JSON string is invalid with respect to EMAddMultipleUserToRoom + */ + public static EMAddMultipleUserToRoom fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, EMAddMultipleUserToRoom.class); + } + + /** + * Convert an instance of EMAddMultipleUserToRoom to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/com/easemob/im/api/model/EMAddMultipleUserToRoomBlockList.java b/src/main/java/com/easemob/im/api/model/EMAddMultipleUserToRoomBlockList.java new file mode 100644 index 000000000..ce295986c --- /dev/null +++ b/src/main/java/com/easemob/im/api/model/EMAddMultipleUserToRoomBlockList.java @@ -0,0 +1,219 @@ +/* + * EMService + * Easemob Rest API + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.easemob.im.api.model; + +import java.util.Objects; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import com.easemob.im.JSON; + +/** + * EMAddMultipleUserToRoomBlockList + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-01-25T14:51:53.998371+08:00[Asia/Shanghai]") +public class EMAddMultipleUserToRoomBlockList { + public static final String SERIALIZED_NAME_USERNAMES = "usernames"; + @SerializedName(SERIALIZED_NAME_USERNAMES) + private List usernames; + + public EMAddMultipleUserToRoomBlockList() { + } + + public EMAddMultipleUserToRoomBlockList usernames(List usernames) { + + this.usernames = usernames; + return this; + } + + public EMAddMultipleUserToRoomBlockList addUsernamesItem(String usernamesItem) { + if (this.usernames == null) { + this.usernames = new ArrayList<>(); + } + this.usernames.add(usernamesItem); + return this; + } + + /** + * 待添加到聊天室黑名单的用户 ID,最多可添加 60 个 + * @return usernames + **/ + @javax.annotation.Nullable + public List getUsernames() { + return usernames; + } + + + public void setUsernames(List usernames) { + this.usernames = usernames; + } + + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + EMAddMultipleUserToRoomBlockList addMultipleUserToRoomBlockList = (EMAddMultipleUserToRoomBlockList) o; + return Objects.equals(this.usernames, addMultipleUserToRoomBlockList.usernames); + } + + @Override + public int hashCode() { + return Objects.hash(usernames); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class EMAddMultipleUserToRoomBlockList {\n"); + sb.append(" usernames: ").append(toIndentedString(usernames)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("usernames"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to EMAddMultipleUserToRoomBlockList + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!EMAddMultipleUserToRoomBlockList.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format("The required field(s) %s in EMAddMultipleUserToRoomBlockList is not found in the empty JSON string", EMAddMultipleUserToRoomBlockList.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!EMAddMultipleUserToRoomBlockList.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `EMAddMultipleUserToRoomBlockList` properties. JSON: %s", entry.getKey(), jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // ensure the optional json data is an array if present + if (jsonObj.get("usernames") != null && !jsonObj.get("usernames").isJsonNull() && !jsonObj.get("usernames").isJsonArray()) { + throw new IllegalArgumentException(String.format("Expected the field `usernames` to be an array in the JSON string but got `%s`", jsonObj.get("usernames").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!EMAddMultipleUserToRoomBlockList.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'EMAddMultipleUserToRoomBlockList' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(EMAddMultipleUserToRoomBlockList.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, EMAddMultipleUserToRoomBlockList value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public EMAddMultipleUserToRoomBlockList read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + return thisAdapter.fromJsonTree(jsonElement); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of EMAddMultipleUserToRoomBlockList given an JSON string + * + * @param jsonString JSON string + * @return An instance of EMAddMultipleUserToRoomBlockList + * @throws IOException if the JSON string is invalid with respect to EMAddMultipleUserToRoomBlockList + */ + public static EMAddMultipleUserToRoomBlockList fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, EMAddMultipleUserToRoomBlockList.class); + } + + /** + * Convert an instance of EMAddMultipleUserToRoomBlockList to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/com/easemob/im/api/model/EMAddMultipleUserToRoomBlockListResult.java b/src/main/java/com/easemob/im/api/model/EMAddMultipleUserToRoomBlockListResult.java new file mode 100644 index 000000000..f7917bec6 --- /dev/null +++ b/src/main/java/com/easemob/im/api/model/EMAddMultipleUserToRoomBlockListResult.java @@ -0,0 +1,205 @@ +/* + * EMService + * Easemob Rest API + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.easemob.im.api.model; + +import java.util.Objects; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.Arrays; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import com.easemob.im.JSON; + +/** + * EMAddMultipleUserToRoomBlockListResult + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-01-25T14:51:53.998371+08:00[Asia/Shanghai]") +public class EMAddMultipleUserToRoomBlockListResult { + public static final String SERIALIZED_NAME_DATA = "data"; + @SerializedName(SERIALIZED_NAME_DATA) + private Object data; + + public EMAddMultipleUserToRoomBlockListResult() { + } + + public EMAddMultipleUserToRoomBlockListResult data(Object data) { + + this.data = data; + return this; + } + + /** + * Get data + * @return data + **/ + @javax.annotation.Nullable + public Object getData() { + return data; + } + + + public void setData(Object data) { + this.data = data; + } + + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + EMAddMultipleUserToRoomBlockListResult addMultipleUserToRoomBlockListResult = (EMAddMultipleUserToRoomBlockListResult) o; + return Objects.equals(this.data, addMultipleUserToRoomBlockListResult.data); + } + + @Override + public int hashCode() { + return Objects.hash(data); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class EMAddMultipleUserToRoomBlockListResult {\n"); + sb.append(" data: ").append(toIndentedString(data)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("data"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to EMAddMultipleUserToRoomBlockListResult + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!EMAddMultipleUserToRoomBlockListResult.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format("The required field(s) %s in EMAddMultipleUserToRoomBlockListResult is not found in the empty JSON string", EMAddMultipleUserToRoomBlockListResult.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!EMAddMultipleUserToRoomBlockListResult.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `EMAddMultipleUserToRoomBlockListResult` properties. JSON: %s", entry.getKey(), jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!EMAddMultipleUserToRoomBlockListResult.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'EMAddMultipleUserToRoomBlockListResult' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(EMAddMultipleUserToRoomBlockListResult.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, EMAddMultipleUserToRoomBlockListResult value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public EMAddMultipleUserToRoomBlockListResult read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + return thisAdapter.fromJsonTree(jsonElement); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of EMAddMultipleUserToRoomBlockListResult given an JSON string + * + * @param jsonString JSON string + * @return An instance of EMAddMultipleUserToRoomBlockListResult + * @throws IOException if the JSON string is invalid with respect to EMAddMultipleUserToRoomBlockListResult + */ + public static EMAddMultipleUserToRoomBlockListResult fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, EMAddMultipleUserToRoomBlockListResult.class); + } + + /** + * Convert an instance of EMAddMultipleUserToRoomBlockListResult to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/com/easemob/im/api/model/EMAddMultipleUserToRoomWhiteList.java b/src/main/java/com/easemob/im/api/model/EMAddMultipleUserToRoomWhiteList.java new file mode 100644 index 000000000..236f16c66 --- /dev/null +++ b/src/main/java/com/easemob/im/api/model/EMAddMultipleUserToRoomWhiteList.java @@ -0,0 +1,219 @@ +/* + * EMService + * Easemob Rest API + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.easemob.im.api.model; + +import java.util.Objects; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import com.easemob.im.JSON; + +/** + * EMAddMultipleUserToRoomWhiteList + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-01-25T14:51:53.998371+08:00[Asia/Shanghai]") +public class EMAddMultipleUserToRoomWhiteList { + public static final String SERIALIZED_NAME_USERNAMES = "usernames"; + @SerializedName(SERIALIZED_NAME_USERNAMES) + private List usernames; + + public EMAddMultipleUserToRoomWhiteList() { + } + + public EMAddMultipleUserToRoomWhiteList usernames(List usernames) { + + this.usernames = usernames; + return this; + } + + public EMAddMultipleUserToRoomWhiteList addUsernamesItem(String usernamesItem) { + if (this.usernames == null) { + this.usernames = new ArrayList<>(); + } + this.usernames.add(usernamesItem); + return this; + } + + /** + * 待添加至聊天室白名单中的用户 ID,每次最多可传 60 个 + * @return usernames + **/ + @javax.annotation.Nullable + public List getUsernames() { + return usernames; + } + + + public void setUsernames(List usernames) { + this.usernames = usernames; + } + + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + EMAddMultipleUserToRoomWhiteList addMultipleUserToRoomWhiteList = (EMAddMultipleUserToRoomWhiteList) o; + return Objects.equals(this.usernames, addMultipleUserToRoomWhiteList.usernames); + } + + @Override + public int hashCode() { + return Objects.hash(usernames); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class EMAddMultipleUserToRoomWhiteList {\n"); + sb.append(" usernames: ").append(toIndentedString(usernames)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("usernames"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to EMAddMultipleUserToRoomWhiteList + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!EMAddMultipleUserToRoomWhiteList.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format("The required field(s) %s in EMAddMultipleUserToRoomWhiteList is not found in the empty JSON string", EMAddMultipleUserToRoomWhiteList.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!EMAddMultipleUserToRoomWhiteList.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `EMAddMultipleUserToRoomWhiteList` properties. JSON: %s", entry.getKey(), jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // ensure the optional json data is an array if present + if (jsonObj.get("usernames") != null && !jsonObj.get("usernames").isJsonNull() && !jsonObj.get("usernames").isJsonArray()) { + throw new IllegalArgumentException(String.format("Expected the field `usernames` to be an array in the JSON string but got `%s`", jsonObj.get("usernames").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!EMAddMultipleUserToRoomWhiteList.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'EMAddMultipleUserToRoomWhiteList' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(EMAddMultipleUserToRoomWhiteList.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, EMAddMultipleUserToRoomWhiteList value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public EMAddMultipleUserToRoomWhiteList read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + return thisAdapter.fromJsonTree(jsonElement); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of EMAddMultipleUserToRoomWhiteList given an JSON string + * + * @param jsonString JSON string + * @return An instance of EMAddMultipleUserToRoomWhiteList + * @throws IOException if the JSON string is invalid with respect to EMAddMultipleUserToRoomWhiteList + */ + public static EMAddMultipleUserToRoomWhiteList fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, EMAddMultipleUserToRoomWhiteList.class); + } + + /** + * Convert an instance of EMAddMultipleUserToRoomWhiteList to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/com/easemob/im/api/model/EMAddMultipleUserToRoomWhiteListResult.java b/src/main/java/com/easemob/im/api/model/EMAddMultipleUserToRoomWhiteListResult.java new file mode 100644 index 000000000..cbf8d7fce --- /dev/null +++ b/src/main/java/com/easemob/im/api/model/EMAddMultipleUserToRoomWhiteListResult.java @@ -0,0 +1,205 @@ +/* + * EMService + * Easemob Rest API + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.easemob.im.api.model; + +import java.util.Objects; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.Arrays; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import com.easemob.im.JSON; + +/** + * EMAddMultipleUserToRoomWhiteListResult + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-01-25T14:51:53.998371+08:00[Asia/Shanghai]") +public class EMAddMultipleUserToRoomWhiteListResult { + public static final String SERIALIZED_NAME_DATA = "data"; + @SerializedName(SERIALIZED_NAME_DATA) + private Object data; + + public EMAddMultipleUserToRoomWhiteListResult() { + } + + public EMAddMultipleUserToRoomWhiteListResult data(Object data) { + + this.data = data; + return this; + } + + /** + * Get data + * @return data + **/ + @javax.annotation.Nullable + public Object getData() { + return data; + } + + + public void setData(Object data) { + this.data = data; + } + + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + EMAddMultipleUserToRoomWhiteListResult addMultipleUserToRoomWhiteListResult = (EMAddMultipleUserToRoomWhiteListResult) o; + return Objects.equals(this.data, addMultipleUserToRoomWhiteListResult.data); + } + + @Override + public int hashCode() { + return Objects.hash(data); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class EMAddMultipleUserToRoomWhiteListResult {\n"); + sb.append(" data: ").append(toIndentedString(data)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("data"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to EMAddMultipleUserToRoomWhiteListResult + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!EMAddMultipleUserToRoomWhiteListResult.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format("The required field(s) %s in EMAddMultipleUserToRoomWhiteListResult is not found in the empty JSON string", EMAddMultipleUserToRoomWhiteListResult.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!EMAddMultipleUserToRoomWhiteListResult.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `EMAddMultipleUserToRoomWhiteListResult` properties. JSON: %s", entry.getKey(), jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!EMAddMultipleUserToRoomWhiteListResult.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'EMAddMultipleUserToRoomWhiteListResult' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(EMAddMultipleUserToRoomWhiteListResult.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, EMAddMultipleUserToRoomWhiteListResult value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public EMAddMultipleUserToRoomWhiteListResult read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + return thisAdapter.fromJsonTree(jsonElement); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of EMAddMultipleUserToRoomWhiteListResult given an JSON string + * + * @param jsonString JSON string + * @return An instance of EMAddMultipleUserToRoomWhiteListResult + * @throws IOException if the JSON string is invalid with respect to EMAddMultipleUserToRoomWhiteListResult + */ + public static EMAddMultipleUserToRoomWhiteListResult fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, EMAddMultipleUserToRoomWhiteListResult.class); + } + + /** + * Convert an instance of EMAddMultipleUserToRoomWhiteListResult to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/com/easemob/im/api/model/EMAddMultipleUsersToThread.java b/src/main/java/com/easemob/im/api/model/EMAddMultipleUsersToThread.java new file mode 100644 index 000000000..723772460 --- /dev/null +++ b/src/main/java/com/easemob/im/api/model/EMAddMultipleUsersToThread.java @@ -0,0 +1,219 @@ +/* + * EMService + * Easemob Rest API + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.easemob.im.api.model; + +import java.util.Objects; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import com.easemob.im.JSON; + +/** + * EMAddMultipleUsersToThread + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-01-25T14:51:53.998371+08:00[Asia/Shanghai]") +public class EMAddMultipleUsersToThread { + public static final String SERIALIZED_NAME_USERNAMES = "usernames"; + @SerializedName(SERIALIZED_NAME_USERNAMES) + private List usernames; + + public EMAddMultipleUsersToThread() { + } + + public EMAddMultipleUsersToThread usernames(List usernames) { + + this.usernames = usernames; + return this; + } + + public EMAddMultipleUsersToThread addUsernamesItem(String usernamesItem) { + if (this.usernames == null) { + this.usernames = new ArrayList<>(); + } + this.usernames.add(usernamesItem); + return this; + } + + /** + * 批量加入子区的用户 ID 列表。每次最多支持 10 个用户加入子区 + * @return usernames + **/ + @javax.annotation.Nullable + public List getUsernames() { + return usernames; + } + + + public void setUsernames(List usernames) { + this.usernames = usernames; + } + + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + EMAddMultipleUsersToThread addMultipleUsersToThread = (EMAddMultipleUsersToThread) o; + return Objects.equals(this.usernames, addMultipleUsersToThread.usernames); + } + + @Override + public int hashCode() { + return Objects.hash(usernames); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class EMAddMultipleUsersToThread {\n"); + sb.append(" usernames: ").append(toIndentedString(usernames)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("usernames"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to EMAddMultipleUsersToThread + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!EMAddMultipleUsersToThread.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format("The required field(s) %s in EMAddMultipleUsersToThread is not found in the empty JSON string", EMAddMultipleUsersToThread.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!EMAddMultipleUsersToThread.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `EMAddMultipleUsersToThread` properties. JSON: %s", entry.getKey(), jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // ensure the optional json data is an array if present + if (jsonObj.get("usernames") != null && !jsonObj.get("usernames").isJsonNull() && !jsonObj.get("usernames").isJsonArray()) { + throw new IllegalArgumentException(String.format("Expected the field `usernames` to be an array in the JSON string but got `%s`", jsonObj.get("usernames").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!EMAddMultipleUsersToThread.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'EMAddMultipleUsersToThread' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(EMAddMultipleUsersToThread.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, EMAddMultipleUsersToThread value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public EMAddMultipleUsersToThread read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + return thisAdapter.fromJsonTree(jsonElement); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of EMAddMultipleUsersToThread given an JSON string + * + * @param jsonString JSON string + * @return An instance of EMAddMultipleUsersToThread + * @throws IOException if the JSON string is invalid with respect to EMAddMultipleUsersToThread + */ + public static EMAddMultipleUsersToThread fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, EMAddMultipleUsersToThread.class); + } + + /** + * Convert an instance of EMAddMultipleUsersToThread to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/com/easemob/im/api/model/EMAddMultipleUsersToThreadResource.java b/src/main/java/com/easemob/im/api/model/EMAddMultipleUsersToThreadResource.java new file mode 100644 index 000000000..063a7b779 --- /dev/null +++ b/src/main/java/com/easemob/im/api/model/EMAddMultipleUsersToThreadResource.java @@ -0,0 +1,208 @@ +/* + * EMService + * Easemob Rest API + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.easemob.im.api.model; + +import java.util.Objects; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.Arrays; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import com.easemob.im.JSON; + +/** + * EMAddMultipleUsersToThreadResource + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-01-25T14:51:53.998371+08:00[Asia/Shanghai]") +public class EMAddMultipleUsersToThreadResource { + public static final String SERIALIZED_NAME_STATUS = "status"; + @SerializedName(SERIALIZED_NAME_STATUS) + private String status; + + public EMAddMultipleUsersToThreadResource() { + } + + public EMAddMultipleUsersToThreadResource status(String status) { + + this.status = status; + return this; + } + + /** + * Get status + * @return status + **/ + @javax.annotation.Nullable + public String getStatus() { + return status; + } + + + public void setStatus(String status) { + this.status = status; + } + + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + EMAddMultipleUsersToThreadResource addMultipleUsersToThreadResource = (EMAddMultipleUsersToThreadResource) o; + return Objects.equals(this.status, addMultipleUsersToThreadResource.status); + } + + @Override + public int hashCode() { + return Objects.hash(status); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class EMAddMultipleUsersToThreadResource {\n"); + sb.append(" status: ").append(toIndentedString(status)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("status"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to EMAddMultipleUsersToThreadResource + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!EMAddMultipleUsersToThreadResource.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format("The required field(s) %s in EMAddMultipleUsersToThreadResource is not found in the empty JSON string", EMAddMultipleUsersToThreadResource.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!EMAddMultipleUsersToThreadResource.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `EMAddMultipleUsersToThreadResource` properties. JSON: %s", entry.getKey(), jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + if ((jsonObj.get("status") != null && !jsonObj.get("status").isJsonNull()) && !jsonObj.get("status").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `status` to be a primitive type in the JSON string but got `%s`", jsonObj.get("status").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!EMAddMultipleUsersToThreadResource.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'EMAddMultipleUsersToThreadResource' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(EMAddMultipleUsersToThreadResource.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, EMAddMultipleUsersToThreadResource value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public EMAddMultipleUsersToThreadResource read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + return thisAdapter.fromJsonTree(jsonElement); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of EMAddMultipleUsersToThreadResource given an JSON string + * + * @param jsonString JSON string + * @return An instance of EMAddMultipleUsersToThreadResource + * @throws IOException if the JSON string is invalid with respect to EMAddMultipleUsersToThreadResource + */ + public static EMAddMultipleUsersToThreadResource fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, EMAddMultipleUsersToThreadResource.class); + } + + /** + * Convert an instance of EMAddMultipleUsersToThreadResource to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/com/easemob/im/api/model/EMAddMultipleUsersToThreadResult.java b/src/main/java/com/easemob/im/api/model/EMAddMultipleUsersToThreadResult.java new file mode 100644 index 000000000..8abccf64e --- /dev/null +++ b/src/main/java/com/easemob/im/api/model/EMAddMultipleUsersToThreadResult.java @@ -0,0 +1,210 @@ +/* + * EMService + * Easemob Rest API + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.easemob.im.api.model; + +import java.util.Objects; +import com.easemob.im.api.model.EMAddMultipleUsersToThreadResource; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.Arrays; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import com.easemob.im.JSON; + +/** + * EMAddMultipleUsersToThreadResult + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-01-25T14:51:53.998371+08:00[Asia/Shanghai]") +public class EMAddMultipleUsersToThreadResult { + public static final String SERIALIZED_NAME_DATA = "data"; + @SerializedName(SERIALIZED_NAME_DATA) + private EMAddMultipleUsersToThreadResource data; + + public EMAddMultipleUsersToThreadResult() { + } + + public EMAddMultipleUsersToThreadResult data(EMAddMultipleUsersToThreadResource data) { + + this.data = data; + return this; + } + + /** + * Get data + * @return data + **/ + @javax.annotation.Nullable + public EMAddMultipleUsersToThreadResource getData() { + return data; + } + + + public void setData(EMAddMultipleUsersToThreadResource data) { + this.data = data; + } + + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + EMAddMultipleUsersToThreadResult addMultipleUsersToThreadResult = (EMAddMultipleUsersToThreadResult) o; + return Objects.equals(this.data, addMultipleUsersToThreadResult.data); + } + + @Override + public int hashCode() { + return Objects.hash(data); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class EMAddMultipleUsersToThreadResult {\n"); + sb.append(" data: ").append(toIndentedString(data)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("data"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to EMAddMultipleUsersToThreadResult + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!EMAddMultipleUsersToThreadResult.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format("The required field(s) %s in EMAddMultipleUsersToThreadResult is not found in the empty JSON string", EMAddMultipleUsersToThreadResult.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!EMAddMultipleUsersToThreadResult.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `EMAddMultipleUsersToThreadResult` properties. JSON: %s", entry.getKey(), jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // validate the optional field `data` + if (jsonObj.get("data") != null && !jsonObj.get("data").isJsonNull()) { + EMAddMultipleUsersToThreadResource.validateJsonElement(jsonObj.get("data")); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!EMAddMultipleUsersToThreadResult.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'EMAddMultipleUsersToThreadResult' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(EMAddMultipleUsersToThreadResult.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, EMAddMultipleUsersToThreadResult value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public EMAddMultipleUsersToThreadResult read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + return thisAdapter.fromJsonTree(jsonElement); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of EMAddMultipleUsersToThreadResult given an JSON string + * + * @param jsonString JSON string + * @return An instance of EMAddMultipleUsersToThreadResult + * @throws IOException if the JSON string is invalid with respect to EMAddMultipleUsersToThreadResult + */ + public static EMAddMultipleUsersToThreadResult fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, EMAddMultipleUsersToThreadResult.class); + } + + /** + * Convert an instance of EMAddMultipleUsersToThreadResult to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/com/easemob/im/api/model/EMAddRoomAdmin.java b/src/main/java/com/easemob/im/api/model/EMAddRoomAdmin.java new file mode 100644 index 000000000..8a846dfd6 --- /dev/null +++ b/src/main/java/com/easemob/im/api/model/EMAddRoomAdmin.java @@ -0,0 +1,208 @@ +/* + * EMService + * Easemob Rest API + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.easemob.im.api.model; + +import java.util.Objects; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.Arrays; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import com.easemob.im.JSON; + +/** + * EMAddRoomAdmin + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-01-25T14:51:53.998371+08:00[Asia/Shanghai]") +public class EMAddRoomAdmin { + public static final String SERIALIZED_NAME_NEWADMIN = "newadmin"; + @SerializedName(SERIALIZED_NAME_NEWADMIN) + private String newadmin; + + public EMAddRoomAdmin() { + } + + public EMAddRoomAdmin newadmin(String newadmin) { + + this.newadmin = newadmin; + return this; + } + + /** + * 要添加为聊天室管理员的成员用户 ID + * @return newadmin + **/ + @javax.annotation.Nullable + public String getNewadmin() { + return newadmin; + } + + + public void setNewadmin(String newadmin) { + this.newadmin = newadmin; + } + + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + EMAddRoomAdmin addRoomAdmin = (EMAddRoomAdmin) o; + return Objects.equals(this.newadmin, addRoomAdmin.newadmin); + } + + @Override + public int hashCode() { + return Objects.hash(newadmin); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class EMAddRoomAdmin {\n"); + sb.append(" newadmin: ").append(toIndentedString(newadmin)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("newadmin"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to EMAddRoomAdmin + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!EMAddRoomAdmin.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format("The required field(s) %s in EMAddRoomAdmin is not found in the empty JSON string", EMAddRoomAdmin.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!EMAddRoomAdmin.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `EMAddRoomAdmin` properties. JSON: %s", entry.getKey(), jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + if ((jsonObj.get("newadmin") != null && !jsonObj.get("newadmin").isJsonNull()) && !jsonObj.get("newadmin").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `newadmin` to be a primitive type in the JSON string but got `%s`", jsonObj.get("newadmin").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!EMAddRoomAdmin.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'EMAddRoomAdmin' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(EMAddRoomAdmin.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, EMAddRoomAdmin value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public EMAddRoomAdmin read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + return thisAdapter.fromJsonTree(jsonElement); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of EMAddRoomAdmin given an JSON string + * + * @param jsonString JSON string + * @return An instance of EMAddRoomAdmin + * @throws IOException if the JSON string is invalid with respect to EMAddRoomAdmin + */ + public static EMAddRoomAdmin fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, EMAddRoomAdmin.class); + } + + /** + * Convert an instance of EMAddRoomAdmin to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/com/easemob/im/api/model/EMAddRoomAdminResource.java b/src/main/java/com/easemob/im/api/model/EMAddRoomAdminResource.java new file mode 100644 index 000000000..df1092fd2 --- /dev/null +++ b/src/main/java/com/easemob/im/api/model/EMAddRoomAdminResource.java @@ -0,0 +1,208 @@ +/* + * EMService + * Easemob Rest API + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.easemob.im.api.model; + +import java.util.Objects; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.Arrays; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import com.easemob.im.JSON; + +/** + * EMAddRoomAdminResource + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-01-25T14:51:53.998371+08:00[Asia/Shanghai]") +public class EMAddRoomAdminResource { + public static final String SERIALIZED_NAME_RESULT = "result"; + @SerializedName(SERIALIZED_NAME_RESULT) + private String result; + + public EMAddRoomAdminResource() { + } + + public EMAddRoomAdminResource result(String result) { + + this.result = result; + return this; + } + + /** + * Get result + * @return result + **/ + @javax.annotation.Nullable + public String getResult() { + return result; + } + + + public void setResult(String result) { + this.result = result; + } + + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + EMAddRoomAdminResource addRoomAdminResource = (EMAddRoomAdminResource) o; + return Objects.equals(this.result, addRoomAdminResource.result); + } + + @Override + public int hashCode() { + return Objects.hash(result); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class EMAddRoomAdminResource {\n"); + sb.append(" result: ").append(toIndentedString(result)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("result"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to EMAddRoomAdminResource + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!EMAddRoomAdminResource.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format("The required field(s) %s in EMAddRoomAdminResource is not found in the empty JSON string", EMAddRoomAdminResource.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!EMAddRoomAdminResource.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `EMAddRoomAdminResource` properties. JSON: %s", entry.getKey(), jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + if ((jsonObj.get("result") != null && !jsonObj.get("result").isJsonNull()) && !jsonObj.get("result").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `result` to be a primitive type in the JSON string but got `%s`", jsonObj.get("result").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!EMAddRoomAdminResource.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'EMAddRoomAdminResource' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(EMAddRoomAdminResource.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, EMAddRoomAdminResource value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public EMAddRoomAdminResource read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + return thisAdapter.fromJsonTree(jsonElement); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of EMAddRoomAdminResource given an JSON string + * + * @param jsonString JSON string + * @return An instance of EMAddRoomAdminResource + * @throws IOException if the JSON string is invalid with respect to EMAddRoomAdminResource + */ + public static EMAddRoomAdminResource fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, EMAddRoomAdminResource.class); + } + + /** + * Convert an instance of EMAddRoomAdminResource to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/com/easemob/im/api/model/EMAddRoomAdminResult.java b/src/main/java/com/easemob/im/api/model/EMAddRoomAdminResult.java new file mode 100644 index 000000000..1cddaf66e --- /dev/null +++ b/src/main/java/com/easemob/im/api/model/EMAddRoomAdminResult.java @@ -0,0 +1,210 @@ +/* + * EMService + * Easemob Rest API + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.easemob.im.api.model; + +import java.util.Objects; +import com.easemob.im.api.model.EMAddRoomAdminResource; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.Arrays; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import com.easemob.im.JSON; + +/** + * EMAddRoomAdminResult + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-01-25T14:51:53.998371+08:00[Asia/Shanghai]") +public class EMAddRoomAdminResult { + public static final String SERIALIZED_NAME_DATA = "data"; + @SerializedName(SERIALIZED_NAME_DATA) + private EMAddRoomAdminResource data; + + public EMAddRoomAdminResult() { + } + + public EMAddRoomAdminResult data(EMAddRoomAdminResource data) { + + this.data = data; + return this; + } + + /** + * Get data + * @return data + **/ + @javax.annotation.Nullable + public EMAddRoomAdminResource getData() { + return data; + } + + + public void setData(EMAddRoomAdminResource data) { + this.data = data; + } + + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + EMAddRoomAdminResult addRoomAdminResult = (EMAddRoomAdminResult) o; + return Objects.equals(this.data, addRoomAdminResult.data); + } + + @Override + public int hashCode() { + return Objects.hash(data); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class EMAddRoomAdminResult {\n"); + sb.append(" data: ").append(toIndentedString(data)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("data"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to EMAddRoomAdminResult + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!EMAddRoomAdminResult.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format("The required field(s) %s in EMAddRoomAdminResult is not found in the empty JSON string", EMAddRoomAdminResult.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!EMAddRoomAdminResult.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `EMAddRoomAdminResult` properties. JSON: %s", entry.getKey(), jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // validate the optional field `data` + if (jsonObj.get("data") != null && !jsonObj.get("data").isJsonNull()) { + EMAddRoomAdminResource.validateJsonElement(jsonObj.get("data")); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!EMAddRoomAdminResult.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'EMAddRoomAdminResult' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(EMAddRoomAdminResult.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, EMAddRoomAdminResult value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public EMAddRoomAdminResult read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + return thisAdapter.fromJsonTree(jsonElement); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of EMAddRoomAdminResult given an JSON string + * + * @param jsonString JSON string + * @return An instance of EMAddRoomAdminResult + * @throws IOException if the JSON string is invalid with respect to EMAddRoomAdminResult + */ + public static EMAddRoomAdminResult fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, EMAddRoomAdminResult.class); + } + + /** + * Convert an instance of EMAddRoomAdminResult to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/com/easemob/im/api/model/EMAddRoomSuperAdmin.java b/src/main/java/com/easemob/im/api/model/EMAddRoomSuperAdmin.java new file mode 100644 index 000000000..ccb969a7c --- /dev/null +++ b/src/main/java/com/easemob/im/api/model/EMAddRoomSuperAdmin.java @@ -0,0 +1,208 @@ +/* + * EMService + * Easemob Rest API + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.easemob.im.api.model; + +import java.util.Objects; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.Arrays; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import com.easemob.im.JSON; + +/** + * EMAddRoomSuperAdmin + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-01-25T14:51:53.998371+08:00[Asia/Shanghai]") +public class EMAddRoomSuperAdmin { + public static final String SERIALIZED_NAME_SUPERADMIN = "superadmin"; + @SerializedName(SERIALIZED_NAME_SUPERADMIN) + private String superadmin; + + public EMAddRoomSuperAdmin() { + } + + public EMAddRoomSuperAdmin superadmin(String superadmin) { + + this.superadmin = superadmin; + return this; + } + + /** + * 添加的超级管理员的用户 ID,每次只能添加一个 + * @return superadmin + **/ + @javax.annotation.Nullable + public String getSuperadmin() { + return superadmin; + } + + + public void setSuperadmin(String superadmin) { + this.superadmin = superadmin; + } + + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + EMAddRoomSuperAdmin addRoomSuperAdmin = (EMAddRoomSuperAdmin) o; + return Objects.equals(this.superadmin, addRoomSuperAdmin.superadmin); + } + + @Override + public int hashCode() { + return Objects.hash(superadmin); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class EMAddRoomSuperAdmin {\n"); + sb.append(" superadmin: ").append(toIndentedString(superadmin)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("superadmin"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to EMAddRoomSuperAdmin + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!EMAddRoomSuperAdmin.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format("The required field(s) %s in EMAddRoomSuperAdmin is not found in the empty JSON string", EMAddRoomSuperAdmin.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!EMAddRoomSuperAdmin.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `EMAddRoomSuperAdmin` properties. JSON: %s", entry.getKey(), jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + if ((jsonObj.get("superadmin") != null && !jsonObj.get("superadmin").isJsonNull()) && !jsonObj.get("superadmin").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `superadmin` to be a primitive type in the JSON string but got `%s`", jsonObj.get("superadmin").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!EMAddRoomSuperAdmin.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'EMAddRoomSuperAdmin' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(EMAddRoomSuperAdmin.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, EMAddRoomSuperAdmin value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public EMAddRoomSuperAdmin read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + return thisAdapter.fromJsonTree(jsonElement); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of EMAddRoomSuperAdmin given an JSON string + * + * @param jsonString JSON string + * @return An instance of EMAddRoomSuperAdmin + * @throws IOException if the JSON string is invalid with respect to EMAddRoomSuperAdmin + */ + public static EMAddRoomSuperAdmin fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, EMAddRoomSuperAdmin.class); + } + + /** + * Convert an instance of EMAddRoomSuperAdmin to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/com/easemob/im/api/model/EMAddRoomSuperAdminResource.java b/src/main/java/com/easemob/im/api/model/EMAddRoomSuperAdminResource.java new file mode 100644 index 000000000..a458e0aab --- /dev/null +++ b/src/main/java/com/easemob/im/api/model/EMAddRoomSuperAdminResource.java @@ -0,0 +1,208 @@ +/* + * EMService + * Easemob Rest API + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.easemob.im.api.model; + +import java.util.Objects; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.Arrays; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import com.easemob.im.JSON; + +/** + * EMAddRoomSuperAdminResource + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-01-25T14:51:53.998371+08:00[Asia/Shanghai]") +public class EMAddRoomSuperAdminResource { + public static final String SERIALIZED_NAME_RESULT = "result"; + @SerializedName(SERIALIZED_NAME_RESULT) + private String result; + + public EMAddRoomSuperAdminResource() { + } + + public EMAddRoomSuperAdminResource result(String result) { + + this.result = result; + return this; + } + + /** + * Get result + * @return result + **/ + @javax.annotation.Nullable + public String getResult() { + return result; + } + + + public void setResult(String result) { + this.result = result; + } + + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + EMAddRoomSuperAdminResource addRoomSuperAdminResource = (EMAddRoomSuperAdminResource) o; + return Objects.equals(this.result, addRoomSuperAdminResource.result); + } + + @Override + public int hashCode() { + return Objects.hash(result); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class EMAddRoomSuperAdminResource {\n"); + sb.append(" result: ").append(toIndentedString(result)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("result"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to EMAddRoomSuperAdminResource + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!EMAddRoomSuperAdminResource.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format("The required field(s) %s in EMAddRoomSuperAdminResource is not found in the empty JSON string", EMAddRoomSuperAdminResource.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!EMAddRoomSuperAdminResource.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `EMAddRoomSuperAdminResource` properties. JSON: %s", entry.getKey(), jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + if ((jsonObj.get("result") != null && !jsonObj.get("result").isJsonNull()) && !jsonObj.get("result").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `result` to be a primitive type in the JSON string but got `%s`", jsonObj.get("result").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!EMAddRoomSuperAdminResource.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'EMAddRoomSuperAdminResource' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(EMAddRoomSuperAdminResource.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, EMAddRoomSuperAdminResource value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public EMAddRoomSuperAdminResource read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + return thisAdapter.fromJsonTree(jsonElement); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of EMAddRoomSuperAdminResource given an JSON string + * + * @param jsonString JSON string + * @return An instance of EMAddRoomSuperAdminResource + * @throws IOException if the JSON string is invalid with respect to EMAddRoomSuperAdminResource + */ + public static EMAddRoomSuperAdminResource fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, EMAddRoomSuperAdminResource.class); + } + + /** + * Convert an instance of EMAddRoomSuperAdminResource to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/com/easemob/im/api/model/EMAddRoomSuperAdminResult.java b/src/main/java/com/easemob/im/api/model/EMAddRoomSuperAdminResult.java new file mode 100644 index 000000000..6a0332be5 --- /dev/null +++ b/src/main/java/com/easemob/im/api/model/EMAddRoomSuperAdminResult.java @@ -0,0 +1,210 @@ +/* + * EMService + * Easemob Rest API + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.easemob.im.api.model; + +import java.util.Objects; +import com.easemob.im.api.model.EMAddRoomSuperAdminResource; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.Arrays; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import com.easemob.im.JSON; + +/** + * EMAddRoomSuperAdminResult + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-01-25T14:51:53.998371+08:00[Asia/Shanghai]") +public class EMAddRoomSuperAdminResult { + public static final String SERIALIZED_NAME_DATA = "data"; + @SerializedName(SERIALIZED_NAME_DATA) + private EMAddRoomSuperAdminResource data; + + public EMAddRoomSuperAdminResult() { + } + + public EMAddRoomSuperAdminResult data(EMAddRoomSuperAdminResource data) { + + this.data = data; + return this; + } + + /** + * Get data + * @return data + **/ + @javax.annotation.Nullable + public EMAddRoomSuperAdminResource getData() { + return data; + } + + + public void setData(EMAddRoomSuperAdminResource data) { + this.data = data; + } + + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + EMAddRoomSuperAdminResult addRoomSuperAdminResult = (EMAddRoomSuperAdminResult) o; + return Objects.equals(this.data, addRoomSuperAdminResult.data); + } + + @Override + public int hashCode() { + return Objects.hash(data); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class EMAddRoomSuperAdminResult {\n"); + sb.append(" data: ").append(toIndentedString(data)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("data"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to EMAddRoomSuperAdminResult + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!EMAddRoomSuperAdminResult.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format("The required field(s) %s in EMAddRoomSuperAdminResult is not found in the empty JSON string", EMAddRoomSuperAdminResult.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!EMAddRoomSuperAdminResult.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `EMAddRoomSuperAdminResult` properties. JSON: %s", entry.getKey(), jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // validate the optional field `data` + if (jsonObj.get("data") != null && !jsonObj.get("data").isJsonNull()) { + EMAddRoomSuperAdminResource.validateJsonElement(jsonObj.get("data")); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!EMAddRoomSuperAdminResult.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'EMAddRoomSuperAdminResult' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(EMAddRoomSuperAdminResult.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, EMAddRoomSuperAdminResult value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public EMAddRoomSuperAdminResult read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + return thisAdapter.fromJsonTree(jsonElement); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of EMAddRoomSuperAdminResult given an JSON string + * + * @param jsonString JSON string + * @return An instance of EMAddRoomSuperAdminResult + * @throws IOException if the JSON string is invalid with respect to EMAddRoomSuperAdminResult + */ + public static EMAddRoomSuperAdminResult fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, EMAddRoomSuperAdminResult.class); + } + + /** + * Convert an instance of EMAddRoomSuperAdminResult to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/com/easemob/im/api/model/EMAddUserToBlockList.java b/src/main/java/com/easemob/im/api/model/EMAddUserToBlockList.java new file mode 100644 index 000000000..ee15fc589 --- /dev/null +++ b/src/main/java/com/easemob/im/api/model/EMAddUserToBlockList.java @@ -0,0 +1,219 @@ +/* + * EMService + * Easemob Rest API + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.easemob.im.api.model; + +import java.util.Objects; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import com.easemob.im.JSON; + +/** + * EMAddUserToBlockList + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-01-25T14:51:53.998371+08:00[Asia/Shanghai]") +public class EMAddUserToBlockList { + public static final String SERIALIZED_NAME_USERNAMES = "usernames"; + @SerializedName(SERIALIZED_NAME_USERNAMES) + private List usernames; + + public EMAddUserToBlockList() { + } + + public EMAddUserToBlockList usernames(List usernames) { + + this.usernames = usernames; + return this; + } + + public EMAddUserToBlockList addUsernamesItem(String usernamesItem) { + if (this.usernames == null) { + this.usernames = new ArrayList<>(); + } + this.usernames.add(usernamesItem); + return this; + } + + /** + * 要加入黑名单的用户 ID + * @return usernames + **/ + @javax.annotation.Nullable + public List getUsernames() { + return usernames; + } + + + public void setUsernames(List usernames) { + this.usernames = usernames; + } + + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + EMAddUserToBlockList addUserToBlockList = (EMAddUserToBlockList) o; + return Objects.equals(this.usernames, addUserToBlockList.usernames); + } + + @Override + public int hashCode() { + return Objects.hash(usernames); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class EMAddUserToBlockList {\n"); + sb.append(" usernames: ").append(toIndentedString(usernames)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("usernames"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to EMAddUserToBlockList + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!EMAddUserToBlockList.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format("The required field(s) %s in EMAddUserToBlockList is not found in the empty JSON string", EMAddUserToBlockList.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!EMAddUserToBlockList.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `EMAddUserToBlockList` properties. JSON: %s", entry.getKey(), jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // ensure the optional json data is an array if present + if (jsonObj.get("usernames") != null && !jsonObj.get("usernames").isJsonNull() && !jsonObj.get("usernames").isJsonArray()) { + throw new IllegalArgumentException(String.format("Expected the field `usernames` to be an array in the JSON string but got `%s`", jsonObj.get("usernames").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!EMAddUserToBlockList.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'EMAddUserToBlockList' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(EMAddUserToBlockList.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, EMAddUserToBlockList value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public EMAddUserToBlockList read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + return thisAdapter.fromJsonTree(jsonElement); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of EMAddUserToBlockList given an JSON string + * + * @param jsonString JSON string + * @return An instance of EMAddUserToBlockList + * @throws IOException if the JSON string is invalid with respect to EMAddUserToBlockList + */ + public static EMAddUserToBlockList fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, EMAddUserToBlockList.class); + } + + /** + * Convert an instance of EMAddUserToBlockList to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/com/easemob/im/api/model/EMAddUserToBlockListResult.java b/src/main/java/com/easemob/im/api/model/EMAddUserToBlockListResult.java new file mode 100644 index 000000000..8b97c87aa --- /dev/null +++ b/src/main/java/com/easemob/im/api/model/EMAddUserToBlockListResult.java @@ -0,0 +1,219 @@ +/* + * EMService + * Easemob Rest API + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.easemob.im.api.model; + +import java.util.Objects; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import com.easemob.im.JSON; + +/** + * EMAddUserToBlockListResult + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-01-25T14:51:53.998371+08:00[Asia/Shanghai]") +public class EMAddUserToBlockListResult { + public static final String SERIALIZED_NAME_DATA = "data"; + @SerializedName(SERIALIZED_NAME_DATA) + private List data; + + public EMAddUserToBlockListResult() { + } + + public EMAddUserToBlockListResult data(List data) { + + this.data = data; + return this; + } + + public EMAddUserToBlockListResult addDataItem(String dataItem) { + if (this.data == null) { + this.data = new ArrayList<>(); + } + this.data.add(dataItem); + return this; + } + + /** + * Get data + * @return data + **/ + @javax.annotation.Nullable + public List getData() { + return data; + } + + + public void setData(List data) { + this.data = data; + } + + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + EMAddUserToBlockListResult addUserToBlockListResult = (EMAddUserToBlockListResult) o; + return Objects.equals(this.data, addUserToBlockListResult.data); + } + + @Override + public int hashCode() { + return Objects.hash(data); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class EMAddUserToBlockListResult {\n"); + sb.append(" data: ").append(toIndentedString(data)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("data"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to EMAddUserToBlockListResult + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!EMAddUserToBlockListResult.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format("The required field(s) %s in EMAddUserToBlockListResult is not found in the empty JSON string", EMAddUserToBlockListResult.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!EMAddUserToBlockListResult.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `EMAddUserToBlockListResult` properties. JSON: %s", entry.getKey(), jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // ensure the optional json data is an array if present + if (jsonObj.get("data") != null && !jsonObj.get("data").isJsonNull() && !jsonObj.get("data").isJsonArray()) { + throw new IllegalArgumentException(String.format("Expected the field `data` to be an array in the JSON string but got `%s`", jsonObj.get("data").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!EMAddUserToBlockListResult.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'EMAddUserToBlockListResult' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(EMAddUserToBlockListResult.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, EMAddUserToBlockListResult value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public EMAddUserToBlockListResult read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + return thisAdapter.fromJsonTree(jsonElement); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of EMAddUserToBlockListResult given an JSON string + * + * @param jsonString JSON string + * @return An instance of EMAddUserToBlockListResult + * @throws IOException if the JSON string is invalid with respect to EMAddUserToBlockListResult + */ + public static EMAddUserToBlockListResult fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, EMAddUserToBlockListResult.class); + } + + /** + * Convert an instance of EMAddUserToBlockListResult to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/com/easemob/im/api/model/EMAddUserToGroupBlockListResource.java b/src/main/java/com/easemob/im/api/model/EMAddUserToGroupBlockListResource.java new file mode 100644 index 000000000..97e2c846d --- /dev/null +++ b/src/main/java/com/easemob/im/api/model/EMAddUserToGroupBlockListResource.java @@ -0,0 +1,205 @@ +/* + * EMService + * Easemob Rest API + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.easemob.im.api.model; + +import java.util.Objects; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.Arrays; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import com.easemob.im.JSON; + +/** + * EMAddUserToGroupBlockListResource + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-01-25T14:51:53.998371+08:00[Asia/Shanghai]") +public class EMAddUserToGroupBlockListResource { + public static final String SERIALIZED_NAME_RESULT = "result"; + @SerializedName(SERIALIZED_NAME_RESULT) + private Boolean result; + + public EMAddUserToGroupBlockListResource() { + } + + public EMAddUserToGroupBlockListResource result(Boolean result) { + + this.result = result; + return this; + } + + /** + * Get result + * @return result + **/ + @javax.annotation.Nullable + public Boolean getResult() { + return result; + } + + + public void setResult(Boolean result) { + this.result = result; + } + + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + EMAddUserToGroupBlockListResource addUserToGroupBlockListResource = (EMAddUserToGroupBlockListResource) o; + return Objects.equals(this.result, addUserToGroupBlockListResource.result); + } + + @Override + public int hashCode() { + return Objects.hash(result); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class EMAddUserToGroupBlockListResource {\n"); + sb.append(" result: ").append(toIndentedString(result)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("result"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to EMAddUserToGroupBlockListResource + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!EMAddUserToGroupBlockListResource.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format("The required field(s) %s in EMAddUserToGroupBlockListResource is not found in the empty JSON string", EMAddUserToGroupBlockListResource.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!EMAddUserToGroupBlockListResource.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `EMAddUserToGroupBlockListResource` properties. JSON: %s", entry.getKey(), jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!EMAddUserToGroupBlockListResource.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'EMAddUserToGroupBlockListResource' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(EMAddUserToGroupBlockListResource.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, EMAddUserToGroupBlockListResource value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public EMAddUserToGroupBlockListResource read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + return thisAdapter.fromJsonTree(jsonElement); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of EMAddUserToGroupBlockListResource given an JSON string + * + * @param jsonString JSON string + * @return An instance of EMAddUserToGroupBlockListResource + * @throws IOException if the JSON string is invalid with respect to EMAddUserToGroupBlockListResource + */ + public static EMAddUserToGroupBlockListResource fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, EMAddUserToGroupBlockListResource.class); + } + + /** + * Convert an instance of EMAddUserToGroupBlockListResource to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/com/easemob/im/api/model/EMAddUserToGroupBlockListResult.java b/src/main/java/com/easemob/im/api/model/EMAddUserToGroupBlockListResult.java new file mode 100644 index 000000000..36e070b68 --- /dev/null +++ b/src/main/java/com/easemob/im/api/model/EMAddUserToGroupBlockListResult.java @@ -0,0 +1,210 @@ +/* + * EMService + * Easemob Rest API + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.easemob.im.api.model; + +import java.util.Objects; +import com.easemob.im.api.model.EMAddUserToGroupBlockListResource; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.Arrays; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import com.easemob.im.JSON; + +/** + * EMAddUserToGroupBlockListResult + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-01-25T14:51:53.998371+08:00[Asia/Shanghai]") +public class EMAddUserToGroupBlockListResult { + public static final String SERIALIZED_NAME_DATA = "data"; + @SerializedName(SERIALIZED_NAME_DATA) + private EMAddUserToGroupBlockListResource data; + + public EMAddUserToGroupBlockListResult() { + } + + public EMAddUserToGroupBlockListResult data(EMAddUserToGroupBlockListResource data) { + + this.data = data; + return this; + } + + /** + * Get data + * @return data + **/ + @javax.annotation.Nullable + public EMAddUserToGroupBlockListResource getData() { + return data; + } + + + public void setData(EMAddUserToGroupBlockListResource data) { + this.data = data; + } + + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + EMAddUserToGroupBlockListResult addUserToGroupBlockListResult = (EMAddUserToGroupBlockListResult) o; + return Objects.equals(this.data, addUserToGroupBlockListResult.data); + } + + @Override + public int hashCode() { + return Objects.hash(data); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class EMAddUserToGroupBlockListResult {\n"); + sb.append(" data: ").append(toIndentedString(data)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("data"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to EMAddUserToGroupBlockListResult + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!EMAddUserToGroupBlockListResult.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format("The required field(s) %s in EMAddUserToGroupBlockListResult is not found in the empty JSON string", EMAddUserToGroupBlockListResult.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!EMAddUserToGroupBlockListResult.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `EMAddUserToGroupBlockListResult` properties. JSON: %s", entry.getKey(), jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // validate the optional field `data` + if (jsonObj.get("data") != null && !jsonObj.get("data").isJsonNull()) { + EMAddUserToGroupBlockListResource.validateJsonElement(jsonObj.get("data")); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!EMAddUserToGroupBlockListResult.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'EMAddUserToGroupBlockListResult' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(EMAddUserToGroupBlockListResult.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, EMAddUserToGroupBlockListResult value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public EMAddUserToGroupBlockListResult read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + return thisAdapter.fromJsonTree(jsonElement); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of EMAddUserToGroupBlockListResult given an JSON string + * + * @param jsonString JSON string + * @return An instance of EMAddUserToGroupBlockListResult + * @throws IOException if the JSON string is invalid with respect to EMAddUserToGroupBlockListResult + */ + public static EMAddUserToGroupBlockListResult fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, EMAddUserToGroupBlockListResult.class); + } + + /** + * Convert an instance of EMAddUserToGroupBlockListResult to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/com/easemob/im/api/model/EMAddUserToGroupResource.java b/src/main/java/com/easemob/im/api/model/EMAddUserToGroupResource.java new file mode 100644 index 000000000..46a15e148 --- /dev/null +++ b/src/main/java/com/easemob/im/api/model/EMAddUserToGroupResource.java @@ -0,0 +1,205 @@ +/* + * EMService + * Easemob Rest API + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.easemob.im.api.model; + +import java.util.Objects; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.Arrays; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import com.easemob.im.JSON; + +/** + * EMAddUserToGroupResource + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-01-25T14:51:53.998371+08:00[Asia/Shanghai]") +public class EMAddUserToGroupResource { + public static final String SERIALIZED_NAME_RESULT = "result"; + @SerializedName(SERIALIZED_NAME_RESULT) + private Boolean result; + + public EMAddUserToGroupResource() { + } + + public EMAddUserToGroupResource result(Boolean result) { + + this.result = result; + return this; + } + + /** + * Get result + * @return result + **/ + @javax.annotation.Nullable + public Boolean getResult() { + return result; + } + + + public void setResult(Boolean result) { + this.result = result; + } + + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + EMAddUserToGroupResource addUserToGroupResource = (EMAddUserToGroupResource) o; + return Objects.equals(this.result, addUserToGroupResource.result); + } + + @Override + public int hashCode() { + return Objects.hash(result); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class EMAddUserToGroupResource {\n"); + sb.append(" result: ").append(toIndentedString(result)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("result"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to EMAddUserToGroupResource + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!EMAddUserToGroupResource.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format("The required field(s) %s in EMAddUserToGroupResource is not found in the empty JSON string", EMAddUserToGroupResource.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!EMAddUserToGroupResource.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `EMAddUserToGroupResource` properties. JSON: %s", entry.getKey(), jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!EMAddUserToGroupResource.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'EMAddUserToGroupResource' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(EMAddUserToGroupResource.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, EMAddUserToGroupResource value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public EMAddUserToGroupResource read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + return thisAdapter.fromJsonTree(jsonElement); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of EMAddUserToGroupResource given an JSON string + * + * @param jsonString JSON string + * @return An instance of EMAddUserToGroupResource + * @throws IOException if the JSON string is invalid with respect to EMAddUserToGroupResource + */ + public static EMAddUserToGroupResource fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, EMAddUserToGroupResource.class); + } + + /** + * Convert an instance of EMAddUserToGroupResource to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/com/easemob/im/api/model/EMAddUserToGroupResult.java b/src/main/java/com/easemob/im/api/model/EMAddUserToGroupResult.java new file mode 100644 index 000000000..715be5022 --- /dev/null +++ b/src/main/java/com/easemob/im/api/model/EMAddUserToGroupResult.java @@ -0,0 +1,210 @@ +/* + * EMService + * Easemob Rest API + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.easemob.im.api.model; + +import java.util.Objects; +import com.easemob.im.api.model.EMAddUserToGroupResource; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.Arrays; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import com.easemob.im.JSON; + +/** + * EMAddUserToGroupResult + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-01-25T14:51:53.998371+08:00[Asia/Shanghai]") +public class EMAddUserToGroupResult { + public static final String SERIALIZED_NAME_DATA = "data"; + @SerializedName(SERIALIZED_NAME_DATA) + private EMAddUserToGroupResource data; + + public EMAddUserToGroupResult() { + } + + public EMAddUserToGroupResult data(EMAddUserToGroupResource data) { + + this.data = data; + return this; + } + + /** + * Get data + * @return data + **/ + @javax.annotation.Nullable + public EMAddUserToGroupResource getData() { + return data; + } + + + public void setData(EMAddUserToGroupResource data) { + this.data = data; + } + + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + EMAddUserToGroupResult addUserToGroupResult = (EMAddUserToGroupResult) o; + return Objects.equals(this.data, addUserToGroupResult.data); + } + + @Override + public int hashCode() { + return Objects.hash(data); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class EMAddUserToGroupResult {\n"); + sb.append(" data: ").append(toIndentedString(data)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("data"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to EMAddUserToGroupResult + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!EMAddUserToGroupResult.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format("The required field(s) %s in EMAddUserToGroupResult is not found in the empty JSON string", EMAddUserToGroupResult.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!EMAddUserToGroupResult.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `EMAddUserToGroupResult` properties. JSON: %s", entry.getKey(), jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // validate the optional field `data` + if (jsonObj.get("data") != null && !jsonObj.get("data").isJsonNull()) { + EMAddUserToGroupResource.validateJsonElement(jsonObj.get("data")); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!EMAddUserToGroupResult.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'EMAddUserToGroupResult' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(EMAddUserToGroupResult.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, EMAddUserToGroupResult value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public EMAddUserToGroupResult read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + return thisAdapter.fromJsonTree(jsonElement); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of EMAddUserToGroupResult given an JSON string + * + * @param jsonString JSON string + * @return An instance of EMAddUserToGroupResult + * @throws IOException if the JSON string is invalid with respect to EMAddUserToGroupResult + */ + public static EMAddUserToGroupResult fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, EMAddUserToGroupResult.class); + } + + /** + * Convert an instance of EMAddUserToGroupResult to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/com/easemob/im/api/model/EMAddUserToGroupWhiteListResource.java b/src/main/java/com/easemob/im/api/model/EMAddUserToGroupWhiteListResource.java new file mode 100644 index 000000000..e9c9ec99e --- /dev/null +++ b/src/main/java/com/easemob/im/api/model/EMAddUserToGroupWhiteListResource.java @@ -0,0 +1,205 @@ +/* + * EMService + * Easemob Rest API + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.easemob.im.api.model; + +import java.util.Objects; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.Arrays; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import com.easemob.im.JSON; + +/** + * EMAddUserToGroupWhiteListResource + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-01-25T14:51:53.998371+08:00[Asia/Shanghai]") +public class EMAddUserToGroupWhiteListResource { + public static final String SERIALIZED_NAME_RESULT = "result"; + @SerializedName(SERIALIZED_NAME_RESULT) + private Boolean result; + + public EMAddUserToGroupWhiteListResource() { + } + + public EMAddUserToGroupWhiteListResource result(Boolean result) { + + this.result = result; + return this; + } + + /** + * Get result + * @return result + **/ + @javax.annotation.Nullable + public Boolean getResult() { + return result; + } + + + public void setResult(Boolean result) { + this.result = result; + } + + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + EMAddUserToGroupWhiteListResource addUserToGroupWhiteListResource = (EMAddUserToGroupWhiteListResource) o; + return Objects.equals(this.result, addUserToGroupWhiteListResource.result); + } + + @Override + public int hashCode() { + return Objects.hash(result); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class EMAddUserToGroupWhiteListResource {\n"); + sb.append(" result: ").append(toIndentedString(result)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("result"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to EMAddUserToGroupWhiteListResource + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!EMAddUserToGroupWhiteListResource.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format("The required field(s) %s in EMAddUserToGroupWhiteListResource is not found in the empty JSON string", EMAddUserToGroupWhiteListResource.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!EMAddUserToGroupWhiteListResource.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `EMAddUserToGroupWhiteListResource` properties. JSON: %s", entry.getKey(), jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!EMAddUserToGroupWhiteListResource.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'EMAddUserToGroupWhiteListResource' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(EMAddUserToGroupWhiteListResource.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, EMAddUserToGroupWhiteListResource value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public EMAddUserToGroupWhiteListResource read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + return thisAdapter.fromJsonTree(jsonElement); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of EMAddUserToGroupWhiteListResource given an JSON string + * + * @param jsonString JSON string + * @return An instance of EMAddUserToGroupWhiteListResource + * @throws IOException if the JSON string is invalid with respect to EMAddUserToGroupWhiteListResource + */ + public static EMAddUserToGroupWhiteListResource fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, EMAddUserToGroupWhiteListResource.class); + } + + /** + * Convert an instance of EMAddUserToGroupWhiteListResource to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/com/easemob/im/api/model/EMAddUserToGroupWhiteListResult.java b/src/main/java/com/easemob/im/api/model/EMAddUserToGroupWhiteListResult.java new file mode 100644 index 000000000..87693927b --- /dev/null +++ b/src/main/java/com/easemob/im/api/model/EMAddUserToGroupWhiteListResult.java @@ -0,0 +1,210 @@ +/* + * EMService + * Easemob Rest API + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.easemob.im.api.model; + +import java.util.Objects; +import com.easemob.im.api.model.EMAddUserToGroupWhiteListResource; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.Arrays; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import com.easemob.im.JSON; + +/** + * EMAddUserToGroupWhiteListResult + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-01-25T14:51:53.998371+08:00[Asia/Shanghai]") +public class EMAddUserToGroupWhiteListResult { + public static final String SERIALIZED_NAME_DATA = "data"; + @SerializedName(SERIALIZED_NAME_DATA) + private EMAddUserToGroupWhiteListResource data; + + public EMAddUserToGroupWhiteListResult() { + } + + public EMAddUserToGroupWhiteListResult data(EMAddUserToGroupWhiteListResource data) { + + this.data = data; + return this; + } + + /** + * Get data + * @return data + **/ + @javax.annotation.Nullable + public EMAddUserToGroupWhiteListResource getData() { + return data; + } + + + public void setData(EMAddUserToGroupWhiteListResource data) { + this.data = data; + } + + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + EMAddUserToGroupWhiteListResult addUserToGroupWhiteListResult = (EMAddUserToGroupWhiteListResult) o; + return Objects.equals(this.data, addUserToGroupWhiteListResult.data); + } + + @Override + public int hashCode() { + return Objects.hash(data); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class EMAddUserToGroupWhiteListResult {\n"); + sb.append(" data: ").append(toIndentedString(data)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("data"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to EMAddUserToGroupWhiteListResult + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!EMAddUserToGroupWhiteListResult.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format("The required field(s) %s in EMAddUserToGroupWhiteListResult is not found in the empty JSON string", EMAddUserToGroupWhiteListResult.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!EMAddUserToGroupWhiteListResult.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `EMAddUserToGroupWhiteListResult` properties. JSON: %s", entry.getKey(), jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // validate the optional field `data` + if (jsonObj.get("data") != null && !jsonObj.get("data").isJsonNull()) { + EMAddUserToGroupWhiteListResource.validateJsonElement(jsonObj.get("data")); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!EMAddUserToGroupWhiteListResult.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'EMAddUserToGroupWhiteListResult' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(EMAddUserToGroupWhiteListResult.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, EMAddUserToGroupWhiteListResult value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public EMAddUserToGroupWhiteListResult read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + return thisAdapter.fromJsonTree(jsonElement); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of EMAddUserToGroupWhiteListResult given an JSON string + * + * @param jsonString JSON string + * @return An instance of EMAddUserToGroupWhiteListResult + * @throws IOException if the JSON string is invalid with respect to EMAddUserToGroupWhiteListResult + */ + public static EMAddUserToGroupWhiteListResult fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, EMAddUserToGroupWhiteListResult.class); + } + + /** + * Convert an instance of EMAddUserToGroupWhiteListResult to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/com/easemob/im/api/model/EMAddUserToRoomBlockListResource.java b/src/main/java/com/easemob/im/api/model/EMAddUserToRoomBlockListResource.java new file mode 100644 index 000000000..ce4c95431 --- /dev/null +++ b/src/main/java/com/easemob/im/api/model/EMAddUserToRoomBlockListResource.java @@ -0,0 +1,205 @@ +/* + * EMService + * Easemob Rest API + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.easemob.im.api.model; + +import java.util.Objects; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.Arrays; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import com.easemob.im.JSON; + +/** + * EMAddUserToRoomBlockListResource + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-01-25T14:51:53.998371+08:00[Asia/Shanghai]") +public class EMAddUserToRoomBlockListResource { + public static final String SERIALIZED_NAME_RESULT = "result"; + @SerializedName(SERIALIZED_NAME_RESULT) + private Boolean result; + + public EMAddUserToRoomBlockListResource() { + } + + public EMAddUserToRoomBlockListResource result(Boolean result) { + + this.result = result; + return this; + } + + /** + * Get result + * @return result + **/ + @javax.annotation.Nullable + public Boolean getResult() { + return result; + } + + + public void setResult(Boolean result) { + this.result = result; + } + + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + EMAddUserToRoomBlockListResource addUserToRoomBlockListResource = (EMAddUserToRoomBlockListResource) o; + return Objects.equals(this.result, addUserToRoomBlockListResource.result); + } + + @Override + public int hashCode() { + return Objects.hash(result); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class EMAddUserToRoomBlockListResource {\n"); + sb.append(" result: ").append(toIndentedString(result)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("result"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to EMAddUserToRoomBlockListResource + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!EMAddUserToRoomBlockListResource.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format("The required field(s) %s in EMAddUserToRoomBlockListResource is not found in the empty JSON string", EMAddUserToRoomBlockListResource.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!EMAddUserToRoomBlockListResource.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `EMAddUserToRoomBlockListResource` properties. JSON: %s", entry.getKey(), jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!EMAddUserToRoomBlockListResource.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'EMAddUserToRoomBlockListResource' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(EMAddUserToRoomBlockListResource.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, EMAddUserToRoomBlockListResource value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public EMAddUserToRoomBlockListResource read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + return thisAdapter.fromJsonTree(jsonElement); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of EMAddUserToRoomBlockListResource given an JSON string + * + * @param jsonString JSON string + * @return An instance of EMAddUserToRoomBlockListResource + * @throws IOException if the JSON string is invalid with respect to EMAddUserToRoomBlockListResource + */ + public static EMAddUserToRoomBlockListResource fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, EMAddUserToRoomBlockListResource.class); + } + + /** + * Convert an instance of EMAddUserToRoomBlockListResource to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/com/easemob/im/api/model/EMAddUserToRoomBlockListResult.java b/src/main/java/com/easemob/im/api/model/EMAddUserToRoomBlockListResult.java new file mode 100644 index 000000000..f758937ce --- /dev/null +++ b/src/main/java/com/easemob/im/api/model/EMAddUserToRoomBlockListResult.java @@ -0,0 +1,210 @@ +/* + * EMService + * Easemob Rest API + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.easemob.im.api.model; + +import java.util.Objects; +import com.easemob.im.api.model.EMAddUserToRoomBlockListResource; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.Arrays; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import com.easemob.im.JSON; + +/** + * EMAddUserToRoomBlockListResult + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-01-25T14:51:53.998371+08:00[Asia/Shanghai]") +public class EMAddUserToRoomBlockListResult { + public static final String SERIALIZED_NAME_DATA = "data"; + @SerializedName(SERIALIZED_NAME_DATA) + private EMAddUserToRoomBlockListResource data; + + public EMAddUserToRoomBlockListResult() { + } + + public EMAddUserToRoomBlockListResult data(EMAddUserToRoomBlockListResource data) { + + this.data = data; + return this; + } + + /** + * Get data + * @return data + **/ + @javax.annotation.Nullable + public EMAddUserToRoomBlockListResource getData() { + return data; + } + + + public void setData(EMAddUserToRoomBlockListResource data) { + this.data = data; + } + + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + EMAddUserToRoomBlockListResult addUserToRoomBlockListResult = (EMAddUserToRoomBlockListResult) o; + return Objects.equals(this.data, addUserToRoomBlockListResult.data); + } + + @Override + public int hashCode() { + return Objects.hash(data); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class EMAddUserToRoomBlockListResult {\n"); + sb.append(" data: ").append(toIndentedString(data)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("data"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to EMAddUserToRoomBlockListResult + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!EMAddUserToRoomBlockListResult.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format("The required field(s) %s in EMAddUserToRoomBlockListResult is not found in the empty JSON string", EMAddUserToRoomBlockListResult.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!EMAddUserToRoomBlockListResult.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `EMAddUserToRoomBlockListResult` properties. JSON: %s", entry.getKey(), jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // validate the optional field `data` + if (jsonObj.get("data") != null && !jsonObj.get("data").isJsonNull()) { + EMAddUserToRoomBlockListResource.validateJsonElement(jsonObj.get("data")); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!EMAddUserToRoomBlockListResult.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'EMAddUserToRoomBlockListResult' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(EMAddUserToRoomBlockListResult.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, EMAddUserToRoomBlockListResult value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public EMAddUserToRoomBlockListResult read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + return thisAdapter.fromJsonTree(jsonElement); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of EMAddUserToRoomBlockListResult given an JSON string + * + * @param jsonString JSON string + * @return An instance of EMAddUserToRoomBlockListResult + * @throws IOException if the JSON string is invalid with respect to EMAddUserToRoomBlockListResult + */ + public static EMAddUserToRoomBlockListResult fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, EMAddUserToRoomBlockListResult.class); + } + + /** + * Convert an instance of EMAddUserToRoomBlockListResult to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/com/easemob/im/api/model/EMAddUserToRoomResource.java b/src/main/java/com/easemob/im/api/model/EMAddUserToRoomResource.java new file mode 100644 index 000000000..9ca9f78d8 --- /dev/null +++ b/src/main/java/com/easemob/im/api/model/EMAddUserToRoomResource.java @@ -0,0 +1,205 @@ +/* + * EMService + * Easemob Rest API + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.easemob.im.api.model; + +import java.util.Objects; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.Arrays; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import com.easemob.im.JSON; + +/** + * EMAddUserToRoomResource + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-01-25T14:51:53.998371+08:00[Asia/Shanghai]") +public class EMAddUserToRoomResource { + public static final String SERIALIZED_NAME_RESULT = "result"; + @SerializedName(SERIALIZED_NAME_RESULT) + private Boolean result; + + public EMAddUserToRoomResource() { + } + + public EMAddUserToRoomResource result(Boolean result) { + + this.result = result; + return this; + } + + /** + * Get result + * @return result + **/ + @javax.annotation.Nullable + public Boolean getResult() { + return result; + } + + + public void setResult(Boolean result) { + this.result = result; + } + + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + EMAddUserToRoomResource addUserToRoomResource = (EMAddUserToRoomResource) o; + return Objects.equals(this.result, addUserToRoomResource.result); + } + + @Override + public int hashCode() { + return Objects.hash(result); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class EMAddUserToRoomResource {\n"); + sb.append(" result: ").append(toIndentedString(result)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("result"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to EMAddUserToRoomResource + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!EMAddUserToRoomResource.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format("The required field(s) %s in EMAddUserToRoomResource is not found in the empty JSON string", EMAddUserToRoomResource.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!EMAddUserToRoomResource.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `EMAddUserToRoomResource` properties. JSON: %s", entry.getKey(), jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!EMAddUserToRoomResource.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'EMAddUserToRoomResource' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(EMAddUserToRoomResource.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, EMAddUserToRoomResource value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public EMAddUserToRoomResource read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + return thisAdapter.fromJsonTree(jsonElement); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of EMAddUserToRoomResource given an JSON string + * + * @param jsonString JSON string + * @return An instance of EMAddUserToRoomResource + * @throws IOException if the JSON string is invalid with respect to EMAddUserToRoomResource + */ + public static EMAddUserToRoomResource fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, EMAddUserToRoomResource.class); + } + + /** + * Convert an instance of EMAddUserToRoomResource to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/com/easemob/im/api/model/EMAddUserToRoomResult.java b/src/main/java/com/easemob/im/api/model/EMAddUserToRoomResult.java new file mode 100644 index 000000000..e9f826814 --- /dev/null +++ b/src/main/java/com/easemob/im/api/model/EMAddUserToRoomResult.java @@ -0,0 +1,210 @@ +/* + * EMService + * Easemob Rest API + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.easemob.im.api.model; + +import java.util.Objects; +import com.easemob.im.api.model.EMAddUserToRoomResource; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.Arrays; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import com.easemob.im.JSON; + +/** + * EMAddUserToRoomResult + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-01-25T14:51:53.998371+08:00[Asia/Shanghai]") +public class EMAddUserToRoomResult { + public static final String SERIALIZED_NAME_DATA = "data"; + @SerializedName(SERIALIZED_NAME_DATA) + private EMAddUserToRoomResource data; + + public EMAddUserToRoomResult() { + } + + public EMAddUserToRoomResult data(EMAddUserToRoomResource data) { + + this.data = data; + return this; + } + + /** + * Get data + * @return data + **/ + @javax.annotation.Nullable + public EMAddUserToRoomResource getData() { + return data; + } + + + public void setData(EMAddUserToRoomResource data) { + this.data = data; + } + + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + EMAddUserToRoomResult addUserToRoomResult = (EMAddUserToRoomResult) o; + return Objects.equals(this.data, addUserToRoomResult.data); + } + + @Override + public int hashCode() { + return Objects.hash(data); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class EMAddUserToRoomResult {\n"); + sb.append(" data: ").append(toIndentedString(data)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("data"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to EMAddUserToRoomResult + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!EMAddUserToRoomResult.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format("The required field(s) %s in EMAddUserToRoomResult is not found in the empty JSON string", EMAddUserToRoomResult.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!EMAddUserToRoomResult.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `EMAddUserToRoomResult` properties. JSON: %s", entry.getKey(), jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // validate the optional field `data` + if (jsonObj.get("data") != null && !jsonObj.get("data").isJsonNull()) { + EMAddUserToRoomResource.validateJsonElement(jsonObj.get("data")); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!EMAddUserToRoomResult.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'EMAddUserToRoomResult' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(EMAddUserToRoomResult.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, EMAddUserToRoomResult value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public EMAddUserToRoomResult read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + return thisAdapter.fromJsonTree(jsonElement); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of EMAddUserToRoomResult given an JSON string + * + * @param jsonString JSON string + * @return An instance of EMAddUserToRoomResult + * @throws IOException if the JSON string is invalid with respect to EMAddUserToRoomResult + */ + public static EMAddUserToRoomResult fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, EMAddUserToRoomResult.class); + } + + /** + * Convert an instance of EMAddUserToRoomResult to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/com/easemob/im/api/model/EMAddUserToRoomWhiteListResource.java b/src/main/java/com/easemob/im/api/model/EMAddUserToRoomWhiteListResource.java new file mode 100644 index 000000000..41522b10d --- /dev/null +++ b/src/main/java/com/easemob/im/api/model/EMAddUserToRoomWhiteListResource.java @@ -0,0 +1,205 @@ +/* + * EMService + * Easemob Rest API + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.easemob.im.api.model; + +import java.util.Objects; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.Arrays; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import com.easemob.im.JSON; + +/** + * EMAddUserToRoomWhiteListResource + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-01-25T14:51:53.998371+08:00[Asia/Shanghai]") +public class EMAddUserToRoomWhiteListResource { + public static final String SERIALIZED_NAME_RESULT = "result"; + @SerializedName(SERIALIZED_NAME_RESULT) + private Boolean result; + + public EMAddUserToRoomWhiteListResource() { + } + + public EMAddUserToRoomWhiteListResource result(Boolean result) { + + this.result = result; + return this; + } + + /** + * Get result + * @return result + **/ + @javax.annotation.Nullable + public Boolean getResult() { + return result; + } + + + public void setResult(Boolean result) { + this.result = result; + } + + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + EMAddUserToRoomWhiteListResource addUserToRoomWhiteListResource = (EMAddUserToRoomWhiteListResource) o; + return Objects.equals(this.result, addUserToRoomWhiteListResource.result); + } + + @Override + public int hashCode() { + return Objects.hash(result); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class EMAddUserToRoomWhiteListResource {\n"); + sb.append(" result: ").append(toIndentedString(result)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("result"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to EMAddUserToRoomWhiteListResource + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!EMAddUserToRoomWhiteListResource.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format("The required field(s) %s in EMAddUserToRoomWhiteListResource is not found in the empty JSON string", EMAddUserToRoomWhiteListResource.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!EMAddUserToRoomWhiteListResource.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `EMAddUserToRoomWhiteListResource` properties. JSON: %s", entry.getKey(), jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!EMAddUserToRoomWhiteListResource.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'EMAddUserToRoomWhiteListResource' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(EMAddUserToRoomWhiteListResource.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, EMAddUserToRoomWhiteListResource value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public EMAddUserToRoomWhiteListResource read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + return thisAdapter.fromJsonTree(jsonElement); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of EMAddUserToRoomWhiteListResource given an JSON string + * + * @param jsonString JSON string + * @return An instance of EMAddUserToRoomWhiteListResource + * @throws IOException if the JSON string is invalid with respect to EMAddUserToRoomWhiteListResource + */ + public static EMAddUserToRoomWhiteListResource fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, EMAddUserToRoomWhiteListResource.class); + } + + /** + * Convert an instance of EMAddUserToRoomWhiteListResource to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/com/easemob/im/api/model/EMAddUserToRoomWhiteListResult.java b/src/main/java/com/easemob/im/api/model/EMAddUserToRoomWhiteListResult.java new file mode 100644 index 000000000..4b5571a59 --- /dev/null +++ b/src/main/java/com/easemob/im/api/model/EMAddUserToRoomWhiteListResult.java @@ -0,0 +1,210 @@ +/* + * EMService + * Easemob Rest API + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.easemob.im.api.model; + +import java.util.Objects; +import com.easemob.im.api.model.EMAddUserToRoomWhiteListResource; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.Arrays; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import com.easemob.im.JSON; + +/** + * EMAddUserToRoomWhiteListResult + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-01-25T14:51:53.998371+08:00[Asia/Shanghai]") +public class EMAddUserToRoomWhiteListResult { + public static final String SERIALIZED_NAME_DATA = "data"; + @SerializedName(SERIALIZED_NAME_DATA) + private EMAddUserToRoomWhiteListResource data; + + public EMAddUserToRoomWhiteListResult() { + } + + public EMAddUserToRoomWhiteListResult data(EMAddUserToRoomWhiteListResource data) { + + this.data = data; + return this; + } + + /** + * Get data + * @return data + **/ + @javax.annotation.Nullable + public EMAddUserToRoomWhiteListResource getData() { + return data; + } + + + public void setData(EMAddUserToRoomWhiteListResource data) { + this.data = data; + } + + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + EMAddUserToRoomWhiteListResult addUserToRoomWhiteListResult = (EMAddUserToRoomWhiteListResult) o; + return Objects.equals(this.data, addUserToRoomWhiteListResult.data); + } + + @Override + public int hashCode() { + return Objects.hash(data); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class EMAddUserToRoomWhiteListResult {\n"); + sb.append(" data: ").append(toIndentedString(data)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("data"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to EMAddUserToRoomWhiteListResult + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!EMAddUserToRoomWhiteListResult.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format("The required field(s) %s in EMAddUserToRoomWhiteListResult is not found in the empty JSON string", EMAddUserToRoomWhiteListResult.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!EMAddUserToRoomWhiteListResult.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `EMAddUserToRoomWhiteListResult` properties. JSON: %s", entry.getKey(), jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // validate the optional field `data` + if (jsonObj.get("data") != null && !jsonObj.get("data").isJsonNull()) { + EMAddUserToRoomWhiteListResource.validateJsonElement(jsonObj.get("data")); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!EMAddUserToRoomWhiteListResult.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'EMAddUserToRoomWhiteListResult' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(EMAddUserToRoomWhiteListResult.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, EMAddUserToRoomWhiteListResult value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public EMAddUserToRoomWhiteListResult read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + return thisAdapter.fromJsonTree(jsonElement); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of EMAddUserToRoomWhiteListResult given an JSON string + * + * @param jsonString JSON string + * @return An instance of EMAddUserToRoomWhiteListResult + * @throws IOException if the JSON string is invalid with respect to EMAddUserToRoomWhiteListResult + */ + public static EMAddUserToRoomWhiteListResult fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, EMAddUserToRoomWhiteListResult.class); + } + + /** + * Convert an instance of EMAddUserToRoomWhiteListResult to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/com/easemob/im/api/model/EMAllGloballyMutedUsersResource.java b/src/main/java/com/easemob/im/api/model/EMAllGloballyMutedUsersResource.java new file mode 100644 index 000000000..076fda305 --- /dev/null +++ b/src/main/java/com/easemob/im/api/model/EMAllGloballyMutedUsersResource.java @@ -0,0 +1,219 @@ +/* + * EMService + * Easemob Rest API + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.easemob.im.api.model; + +import java.util.Objects; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import com.easemob.im.JSON; + +/** + * EMAllGloballyMutedUsersResource + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-01-25T14:51:53.998371+08:00[Asia/Shanghai]") +public class EMAllGloballyMutedUsersResource { + public static final String SERIALIZED_NAME_DATA = "data"; + @SerializedName(SERIALIZED_NAME_DATA) + private List data; + + public EMAllGloballyMutedUsersResource() { + } + + public EMAllGloballyMutedUsersResource data(List data) { + + this.data = data; + return this; + } + + public EMAllGloballyMutedUsersResource addDataItem(Object dataItem) { + if (this.data == null) { + this.data = new ArrayList<>(); + } + this.data.add(dataItem); + return this; + } + + /** + * Get data + * @return data + **/ + @javax.annotation.Nullable + public List getData() { + return data; + } + + + public void setData(List data) { + this.data = data; + } + + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + EMAllGloballyMutedUsersResource allGloballyMutedUsersResource = (EMAllGloballyMutedUsersResource) o; + return Objects.equals(this.data, allGloballyMutedUsersResource.data); + } + + @Override + public int hashCode() { + return Objects.hash(data); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class EMAllGloballyMutedUsersResource {\n"); + sb.append(" data: ").append(toIndentedString(data)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("data"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to EMAllGloballyMutedUsersResource + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!EMAllGloballyMutedUsersResource.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format("The required field(s) %s in EMAllGloballyMutedUsersResource is not found in the empty JSON string", EMAllGloballyMutedUsersResource.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!EMAllGloballyMutedUsersResource.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `EMAllGloballyMutedUsersResource` properties. JSON: %s", entry.getKey(), jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // ensure the optional json data is an array if present + if (jsonObj.get("data") != null && !jsonObj.get("data").isJsonNull() && !jsonObj.get("data").isJsonArray()) { + throw new IllegalArgumentException(String.format("Expected the field `data` to be an array in the JSON string but got `%s`", jsonObj.get("data").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!EMAllGloballyMutedUsersResource.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'EMAllGloballyMutedUsersResource' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(EMAllGloballyMutedUsersResource.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, EMAllGloballyMutedUsersResource value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public EMAllGloballyMutedUsersResource read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + return thisAdapter.fromJsonTree(jsonElement); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of EMAllGloballyMutedUsersResource given an JSON string + * + * @param jsonString JSON string + * @return An instance of EMAllGloballyMutedUsersResource + * @throws IOException if the JSON string is invalid with respect to EMAllGloballyMutedUsersResource + */ + public static EMAllGloballyMutedUsersResource fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, EMAllGloballyMutedUsersResource.class); + } + + /** + * Convert an instance of EMAllGloballyMutedUsersResource to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/com/easemob/im/api/model/EMCheckUserJoinedGroupResult.java b/src/main/java/com/easemob/im/api/model/EMCheckUserJoinedGroupResult.java new file mode 100644 index 000000000..a69ed4eae --- /dev/null +++ b/src/main/java/com/easemob/im/api/model/EMCheckUserJoinedGroupResult.java @@ -0,0 +1,205 @@ +/* + * EMService + * Easemob Rest API + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.easemob.im.api.model; + +import java.util.Objects; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.Arrays; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import com.easemob.im.JSON; + +/** + * EMCheckUserJoinedGroupResult + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-01-25T14:51:53.998371+08:00[Asia/Shanghai]") +public class EMCheckUserJoinedGroupResult { + public static final String SERIALIZED_NAME_DATA = "data"; + @SerializedName(SERIALIZED_NAME_DATA) + private Boolean data; + + public EMCheckUserJoinedGroupResult() { + } + + public EMCheckUserJoinedGroupResult data(Boolean data) { + + this.data = data; + return this; + } + + /** + * Get data + * @return data + **/ + @javax.annotation.Nullable + public Boolean getData() { + return data; + } + + + public void setData(Boolean data) { + this.data = data; + } + + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + EMCheckUserJoinedGroupResult checkUserJoinedGroupResult = (EMCheckUserJoinedGroupResult) o; + return Objects.equals(this.data, checkUserJoinedGroupResult.data); + } + + @Override + public int hashCode() { + return Objects.hash(data); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class EMCheckUserJoinedGroupResult {\n"); + sb.append(" data: ").append(toIndentedString(data)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("data"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to EMCheckUserJoinedGroupResult + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!EMCheckUserJoinedGroupResult.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format("The required field(s) %s in EMCheckUserJoinedGroupResult is not found in the empty JSON string", EMCheckUserJoinedGroupResult.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!EMCheckUserJoinedGroupResult.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `EMCheckUserJoinedGroupResult` properties. JSON: %s", entry.getKey(), jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!EMCheckUserJoinedGroupResult.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'EMCheckUserJoinedGroupResult' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(EMCheckUserJoinedGroupResult.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, EMCheckUserJoinedGroupResult value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public EMCheckUserJoinedGroupResult read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + return thisAdapter.fromJsonTree(jsonElement); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of EMCheckUserJoinedGroupResult given an JSON string + * + * @param jsonString JSON string + * @return An instance of EMCheckUserJoinedGroupResult + * @throws IOException if the JSON string is invalid with respect to EMCheckUserJoinedGroupResult + */ + public static EMCheckUserJoinedGroupResult fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, EMCheckUserJoinedGroupResult.class); + } + + /** + * Convert an instance of EMCheckUserJoinedGroupResult to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/com/easemob/im/api/model/EMContactRemarkResource.java b/src/main/java/com/easemob/im/api/model/EMContactRemarkResource.java new file mode 100644 index 000000000..4773b955e --- /dev/null +++ b/src/main/java/com/easemob/im/api/model/EMContactRemarkResource.java @@ -0,0 +1,239 @@ +/* + * EMService + * Easemob Rest API + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.easemob.im.api.model; + +import java.util.Objects; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.Arrays; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import com.easemob.im.JSON; + +/** + * EMContactRemarkResource + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-01-25T14:51:53.998371+08:00[Asia/Shanghai]") +public class EMContactRemarkResource { + public static final String SERIALIZED_NAME_REMARK = "remark"; + @SerializedName(SERIALIZED_NAME_REMARK) + private String remark; + + public static final String SERIALIZED_NAME_USERNAME = "username"; + @SerializedName(SERIALIZED_NAME_USERNAME) + private String username; + + public EMContactRemarkResource() { + } + + public EMContactRemarkResource remark(String remark) { + + this.remark = remark; + return this; + } + + /** + * 好友备注内容 + * @return remark + **/ + @javax.annotation.Nullable + public String getRemark() { + return remark; + } + + + public void setRemark(String remark) { + this.remark = remark; + } + + + public EMContactRemarkResource username(String username) { + + this.username = username; + return this; + } + + /** + * 好友 ID + * @return username + **/ + @javax.annotation.Nullable + public String getUsername() { + return username; + } + + + public void setUsername(String username) { + this.username = username; + } + + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + EMContactRemarkResource contactRemarkResource = (EMContactRemarkResource) o; + return Objects.equals(this.remark, contactRemarkResource.remark) && + Objects.equals(this.username, contactRemarkResource.username); + } + + @Override + public int hashCode() { + return Objects.hash(remark, username); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class EMContactRemarkResource {\n"); + sb.append(" remark: ").append(toIndentedString(remark)).append("\n"); + sb.append(" username: ").append(toIndentedString(username)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("remark"); + openapiFields.add("username"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to EMContactRemarkResource + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!EMContactRemarkResource.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format("The required field(s) %s in EMContactRemarkResource is not found in the empty JSON string", EMContactRemarkResource.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!EMContactRemarkResource.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `EMContactRemarkResource` properties. JSON: %s", entry.getKey(), jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + if ((jsonObj.get("remark") != null && !jsonObj.get("remark").isJsonNull()) && !jsonObj.get("remark").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `remark` to be a primitive type in the JSON string but got `%s`", jsonObj.get("remark").toString())); + } + if ((jsonObj.get("username") != null && !jsonObj.get("username").isJsonNull()) && !jsonObj.get("username").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `username` to be a primitive type in the JSON string but got `%s`", jsonObj.get("username").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!EMContactRemarkResource.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'EMContactRemarkResource' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(EMContactRemarkResource.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, EMContactRemarkResource value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public EMContactRemarkResource read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + return thisAdapter.fromJsonTree(jsonElement); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of EMContactRemarkResource given an JSON string + * + * @param jsonString JSON string + * @return An instance of EMContactRemarkResource + * @throws IOException if the JSON string is invalid with respect to EMContactRemarkResource + */ + public static EMContactRemarkResource fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, EMContactRemarkResource.class); + } + + /** + * Convert an instance of EMContactRemarkResource to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/com/easemob/im/api/model/EMCreateGroup.java b/src/main/java/com/easemob/im/api/model/EMCreateGroup.java new file mode 100644 index 000000000..71640eea4 --- /dev/null +++ b/src/main/java/com/easemob/im/api/model/EMCreateGroup.java @@ -0,0 +1,523 @@ +/* + * EMService + * Easemob Rest API + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.easemob.im.api.model; + +import java.util.Objects; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import com.easemob.im.JSON; + +/** + * EMCreateGroup + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-01-25T14:51:53.998371+08:00[Asia/Shanghai]") +public class EMCreateGroup { + public static final String SERIALIZED_NAME_GROUPNAME = "groupname"; + @SerializedName(SERIALIZED_NAME_GROUPNAME) + private String groupname; + + public static final String SERIALIZED_NAME_DESCRIPTION = "description"; + @SerializedName(SERIALIZED_NAME_DESCRIPTION) + private String description; + + public static final String SERIALIZED_NAME_PUBLIC = "public"; + @SerializedName(SERIALIZED_NAME_PUBLIC) + private Boolean _public; + + public static final String SERIALIZED_NAME_SCALE = "scale"; + @SerializedName(SERIALIZED_NAME_SCALE) + private String scale; + + public static final String SERIALIZED_NAME_MAXUSERS = "maxusers"; + @SerializedName(SERIALIZED_NAME_MAXUSERS) + private Integer maxusers; + + public static final String SERIALIZED_NAME_ALLOWINVITES = "allowinvites"; + @SerializedName(SERIALIZED_NAME_ALLOWINVITES) + private Boolean allowinvites; + + public static final String SERIALIZED_NAME_MEMBERSONLY = "membersonly"; + @SerializedName(SERIALIZED_NAME_MEMBERSONLY) + private Boolean membersonly; + + public static final String SERIALIZED_NAME_INVITE_NEED_CONFIRM = "invite_need_confirm"; + @SerializedName(SERIALIZED_NAME_INVITE_NEED_CONFIRM) + private Boolean inviteNeedConfirm; + + public static final String SERIALIZED_NAME_OWNER = "owner"; + @SerializedName(SERIALIZED_NAME_OWNER) + private String owner; + + public static final String SERIALIZED_NAME_MEMBERS = "members"; + @SerializedName(SERIALIZED_NAME_MEMBERS) + private List members; + + public static final String SERIALIZED_NAME_CUSTOM = "custom"; + @SerializedName(SERIALIZED_NAME_CUSTOM) + private String custom; + + public EMCreateGroup() { + } + + public EMCreateGroup groupname(String groupname) { + + this.groupname = groupname; + return this; + } + + /** + * 群组名称,最大长度为 128 字符 + * @return groupname + **/ + @javax.annotation.Nullable + public String getGroupname() { + return groupname; + } + + + public void setGroupname(String groupname) { + this.groupname = groupname; + } + + + public EMCreateGroup description(String description) { + + this.description = description; + return this; + } + + /** + * 群组描述,最大长度为 512 字符 + * @return description + **/ + @javax.annotation.Nullable + public String getDescription() { + return description; + } + + + public void setDescription(String description) { + this.description = description; + } + + + public EMCreateGroup _public(Boolean _public) { + + this._public = _public; + return this; + } + + /** + * 是否是公开群。公开群可以被搜索到,用户可以申请加入公开群;私有群无法被搜索到,因此需要群主或群管理员添加,用户才可以加入。 - true:公开群; - false:私有群 + * @return _public + **/ + @javax.annotation.Nonnull + public Boolean getPublic() { + return _public; + } + + + public void setPublic(Boolean _public) { + this._public = _public; + } + + + public EMCreateGroup scale(String scale) { + + this.scale = scale; + return this; + } + + /** + * 群组规模,取决于群成员总数 maxusers 参数。 - (默认)normal:普通群,即群成员总数不超过 3000。 - large:大型群,群成员总数超过 3000 注意: - 创建大型群时,该参数必传; - 大型群不支持离线推送。仅旗舰版支持创建大型群,如需该功能,请联系环信商务 + * @return scale + **/ + @javax.annotation.Nullable + public String getScale() { + return scale; + } + + + public void setScale(String scale) { + this.scale = scale; + } + + + public EMCreateGroup maxusers(Integer maxusers) { + + this.maxusers = maxusers; + return this; + } + + /** + * 群组最大成员数(包括群主)。对于普通群,该参数的默认值为 200,大型群为 1000。不同套餐支持的人数上限不同,详见 产品价格 + * @return maxusers + **/ + @javax.annotation.Nullable + public Integer getMaxusers() { + return maxusers; + } + + + public void setMaxusers(Integer maxusers) { + this.maxusers = maxusers; + } + + + public EMCreateGroup allowinvites(Boolean allowinvites) { + + this.allowinvites = allowinvites; + return this; + } + + /** + * 是否允许群成员邀请用户加入群组: - true:群成员可拉人入群; - (默认)false:只有群主或者管理员才可以拉人入群。 注:该参数仅对私有群有效,因为公开群不允许群成员邀请其他用户入群 + * @return allowinvites + **/ + @javax.annotation.Nullable + public Boolean getAllowinvites() { + return allowinvites; + } + + + public void setAllowinvites(Boolean allowinvites) { + this.allowinvites = allowinvites; + } + + + public EMCreateGroup membersonly(Boolean membersonly) { + + this.membersonly = membersonly; + return this; + } + + /** + * 群组最大成员数(包括群主)。对于普通群,该参数的默认值为 200,大型群为 1000。不同套餐支持的人数上限不同,详见 产品价格 + * @return membersonly + **/ + @javax.annotation.Nullable + public Boolean getMembersonly() { + return membersonly; + } + + + public void setMembersonly(Boolean membersonly) { + this.membersonly = membersonly; + } + + + public EMCreateGroup inviteNeedConfirm(Boolean inviteNeedConfirm) { + + this.inviteNeedConfirm = inviteNeedConfirm; + return this; + } + + /** + * 邀请用户入群时是否需要被邀用户同意。 - (默认)true:是; - false:否 + * @return inviteNeedConfirm + **/ + @javax.annotation.Nullable + public Boolean getInviteNeedConfirm() { + return inviteNeedConfirm; + } + + + public void setInviteNeedConfirm(Boolean inviteNeedConfirm) { + this.inviteNeedConfirm = inviteNeedConfirm; + } + + + public EMCreateGroup owner(String owner) { + + this.owner = owner; + return this; + } + + /** + * 群主的用户 ID + * @return owner + **/ + @javax.annotation.Nonnull + public String getOwner() { + return owner; + } + + + public void setOwner(String owner) { + this.owner = owner; + } + + + public EMCreateGroup members(List members) { + + this.members = members; + return this; + } + + public EMCreateGroup addMembersItem(String membersItem) { + if (this.members == null) { + this.members = new ArrayList<>(); + } + this.members.add(membersItem); + return this; + } + + /** + * 群成员的用户 ID 数组,不包含群主的用户 ID。该数组可包含的元素数量不超过 maxusers 的值 + * @return members + **/ + @javax.annotation.Nullable + public List getMembers() { + return members; + } + + + public void setMembers(List members) { + this.members = members; + } + + + public EMCreateGroup custom(String custom) { + + this.custom = custom; + return this; + } + + /** + * 群组扩展信息,例如可以给群组添加业务相关的标记,不要超过 1,024 字符 + * @return custom + **/ + @javax.annotation.Nullable + public String getCustom() { + return custom; + } + + + public void setCustom(String custom) { + this.custom = custom; + } + + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + EMCreateGroup createGroup = (EMCreateGroup) o; + return Objects.equals(this.groupname, createGroup.groupname) && + Objects.equals(this.description, createGroup.description) && + Objects.equals(this._public, createGroup._public) && + Objects.equals(this.scale, createGroup.scale) && + Objects.equals(this.maxusers, createGroup.maxusers) && + Objects.equals(this.allowinvites, createGroup.allowinvites) && + Objects.equals(this.membersonly, createGroup.membersonly) && + Objects.equals(this.inviteNeedConfirm, createGroup.inviteNeedConfirm) && + Objects.equals(this.owner, createGroup.owner) && + Objects.equals(this.members, createGroup.members) && + Objects.equals(this.custom, createGroup.custom); + } + + @Override + public int hashCode() { + return Objects.hash(groupname, description, _public, scale, maxusers, allowinvites, membersonly, inviteNeedConfirm, owner, members, custom); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class EMCreateGroup {\n"); + sb.append(" groupname: ").append(toIndentedString(groupname)).append("\n"); + sb.append(" description: ").append(toIndentedString(description)).append("\n"); + sb.append(" _public: ").append(toIndentedString(_public)).append("\n"); + sb.append(" scale: ").append(toIndentedString(scale)).append("\n"); + sb.append(" maxusers: ").append(toIndentedString(maxusers)).append("\n"); + sb.append(" allowinvites: ").append(toIndentedString(allowinvites)).append("\n"); + sb.append(" membersonly: ").append(toIndentedString(membersonly)).append("\n"); + sb.append(" inviteNeedConfirm: ").append(toIndentedString(inviteNeedConfirm)).append("\n"); + sb.append(" owner: ").append(toIndentedString(owner)).append("\n"); + sb.append(" members: ").append(toIndentedString(members)).append("\n"); + sb.append(" custom: ").append(toIndentedString(custom)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("groupname"); + openapiFields.add("description"); + openapiFields.add("public"); + openapiFields.add("scale"); + openapiFields.add("maxusers"); + openapiFields.add("allowinvites"); + openapiFields.add("membersonly"); + openapiFields.add("invite_need_confirm"); + openapiFields.add("owner"); + openapiFields.add("members"); + openapiFields.add("custom"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + openapiRequiredFields.add("public"); + openapiRequiredFields.add("owner"); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to EMCreateGroup + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!EMCreateGroup.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format("The required field(s) %s in EMCreateGroup is not found in the empty JSON string", EMCreateGroup.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!EMCreateGroup.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `EMCreateGroup` properties. JSON: %s", entry.getKey(), jsonElement.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : EMCreateGroup.openapiRequiredFields) { + if (jsonElement.getAsJsonObject().get(requiredField) == null) { + throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + if ((jsonObj.get("groupname") != null && !jsonObj.get("groupname").isJsonNull()) && !jsonObj.get("groupname").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `groupname` to be a primitive type in the JSON string but got `%s`", jsonObj.get("groupname").toString())); + } + if ((jsonObj.get("description") != null && !jsonObj.get("description").isJsonNull()) && !jsonObj.get("description").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `description` to be a primitive type in the JSON string but got `%s`", jsonObj.get("description").toString())); + } + if ((jsonObj.get("scale") != null && !jsonObj.get("scale").isJsonNull()) && !jsonObj.get("scale").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `scale` to be a primitive type in the JSON string but got `%s`", jsonObj.get("scale").toString())); + } + if (!jsonObj.get("owner").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `owner` to be a primitive type in the JSON string but got `%s`", jsonObj.get("owner").toString())); + } + // ensure the optional json data is an array if present + if (jsonObj.get("members") != null && !jsonObj.get("members").isJsonNull() && !jsonObj.get("members").isJsonArray()) { + throw new IllegalArgumentException(String.format("Expected the field `members` to be an array in the JSON string but got `%s`", jsonObj.get("members").toString())); + } + if ((jsonObj.get("custom") != null && !jsonObj.get("custom").isJsonNull()) && !jsonObj.get("custom").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `custom` to be a primitive type in the JSON string but got `%s`", jsonObj.get("custom").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!EMCreateGroup.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'EMCreateGroup' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(EMCreateGroup.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, EMCreateGroup value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public EMCreateGroup read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + return thisAdapter.fromJsonTree(jsonElement); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of EMCreateGroup given an JSON string + * + * @param jsonString JSON string + * @return An instance of EMCreateGroup + * @throws IOException if the JSON string is invalid with respect to EMCreateGroup + */ + public static EMCreateGroup fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, EMCreateGroup.class); + } + + /** + * Convert an instance of EMCreateGroup to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/com/easemob/im/api/model/EMCreateGroupResource.java b/src/main/java/com/easemob/im/api/model/EMCreateGroupResource.java new file mode 100644 index 000000000..f1b6a5bc2 --- /dev/null +++ b/src/main/java/com/easemob/im/api/model/EMCreateGroupResource.java @@ -0,0 +1,208 @@ +/* + * EMService + * Easemob Rest API + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.easemob.im.api.model; + +import java.util.Objects; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.Arrays; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import com.easemob.im.JSON; + +/** + * EMCreateGroupResource + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-01-25T14:51:53.998371+08:00[Asia/Shanghai]") +public class EMCreateGroupResource { + public static final String SERIALIZED_NAME_GROUPID = "groupid"; + @SerializedName(SERIALIZED_NAME_GROUPID) + private String groupid; + + public EMCreateGroupResource() { + } + + public EMCreateGroupResource groupid(String groupid) { + + this.groupid = groupid; + return this; + } + + /** + * Get groupid + * @return groupid + **/ + @javax.annotation.Nullable + public String getGroupid() { + return groupid; + } + + + public void setGroupid(String groupid) { + this.groupid = groupid; + } + + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + EMCreateGroupResource createGroupResource = (EMCreateGroupResource) o; + return Objects.equals(this.groupid, createGroupResource.groupid); + } + + @Override + public int hashCode() { + return Objects.hash(groupid); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class EMCreateGroupResource {\n"); + sb.append(" groupid: ").append(toIndentedString(groupid)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("groupid"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to EMCreateGroupResource + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!EMCreateGroupResource.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format("The required field(s) %s in EMCreateGroupResource is not found in the empty JSON string", EMCreateGroupResource.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!EMCreateGroupResource.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `EMCreateGroupResource` properties. JSON: %s", entry.getKey(), jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + if ((jsonObj.get("groupid") != null && !jsonObj.get("groupid").isJsonNull()) && !jsonObj.get("groupid").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `groupid` to be a primitive type in the JSON string but got `%s`", jsonObj.get("groupid").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!EMCreateGroupResource.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'EMCreateGroupResource' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(EMCreateGroupResource.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, EMCreateGroupResource value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public EMCreateGroupResource read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + return thisAdapter.fromJsonTree(jsonElement); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of EMCreateGroupResource given an JSON string + * + * @param jsonString JSON string + * @return An instance of EMCreateGroupResource + * @throws IOException if the JSON string is invalid with respect to EMCreateGroupResource + */ + public static EMCreateGroupResource fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, EMCreateGroupResource.class); + } + + /** + * Convert an instance of EMCreateGroupResource to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/com/easemob/im/api/model/EMCreateGroupResult.java b/src/main/java/com/easemob/im/api/model/EMCreateGroupResult.java new file mode 100644 index 000000000..c0cfcd658 --- /dev/null +++ b/src/main/java/com/easemob/im/api/model/EMCreateGroupResult.java @@ -0,0 +1,210 @@ +/* + * EMService + * Easemob Rest API + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.easemob.im.api.model; + +import java.util.Objects; +import com.easemob.im.api.model.EMCreateGroupResource; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.Arrays; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import com.easemob.im.JSON; + +/** + * EMCreateGroupResult + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-01-25T14:51:53.998371+08:00[Asia/Shanghai]") +public class EMCreateGroupResult { + public static final String SERIALIZED_NAME_DATA = "data"; + @SerializedName(SERIALIZED_NAME_DATA) + private EMCreateGroupResource data; + + public EMCreateGroupResult() { + } + + public EMCreateGroupResult data(EMCreateGroupResource data) { + + this.data = data; + return this; + } + + /** + * Get data + * @return data + **/ + @javax.annotation.Nullable + public EMCreateGroupResource getData() { + return data; + } + + + public void setData(EMCreateGroupResource data) { + this.data = data; + } + + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + EMCreateGroupResult createGroupResult = (EMCreateGroupResult) o; + return Objects.equals(this.data, createGroupResult.data); + } + + @Override + public int hashCode() { + return Objects.hash(data); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class EMCreateGroupResult {\n"); + sb.append(" data: ").append(toIndentedString(data)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("data"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to EMCreateGroupResult + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!EMCreateGroupResult.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format("The required field(s) %s in EMCreateGroupResult is not found in the empty JSON string", EMCreateGroupResult.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!EMCreateGroupResult.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `EMCreateGroupResult` properties. JSON: %s", entry.getKey(), jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // validate the optional field `data` + if (jsonObj.get("data") != null && !jsonObj.get("data").isJsonNull()) { + EMCreateGroupResource.validateJsonElement(jsonObj.get("data")); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!EMCreateGroupResult.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'EMCreateGroupResult' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(EMCreateGroupResult.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, EMCreateGroupResult value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public EMCreateGroupResult read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + return thisAdapter.fromJsonTree(jsonElement); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of EMCreateGroupResult given an JSON string + * + * @param jsonString JSON string + * @return An instance of EMCreateGroupResult + * @throws IOException if the JSON string is invalid with respect to EMCreateGroupResult + */ + public static EMCreateGroupResult fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, EMCreateGroupResult.class); + } + + /** + * Convert an instance of EMCreateGroupResult to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/com/easemob/im/api/model/EMCreateMessage.java b/src/main/java/com/easemob/im/api/model/EMCreateMessage.java new file mode 100644 index 000000000..4f0df4a63 --- /dev/null +++ b/src/main/java/com/easemob/im/api/model/EMCreateMessage.java @@ -0,0 +1,442 @@ +/* + * EMService + * Easemob Rest API + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.easemob.im.api.model; + +import java.util.Objects; +import com.easemob.im.api.model.EMMessageContent; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import com.easemob.im.JSON; + +/** + * EMCreateMessage + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-01-25T14:51:53.998371+08:00[Asia/Shanghai]") +public class EMCreateMessage { + public static final String SERIALIZED_NAME_FROM = "from"; + @SerializedName(SERIALIZED_NAME_FROM) + private String from; + + public static final String SERIALIZED_NAME_TO = "to"; + @SerializedName(SERIALIZED_NAME_TO) + private List to = new ArrayList<>(); + + public static final String SERIALIZED_NAME_TYPE = "type"; + @SerializedName(SERIALIZED_NAME_TYPE) + private String type; + + public static final String SERIALIZED_NAME_BODY = "body"; + @SerializedName(SERIALIZED_NAME_BODY) + private EMMessageContent body; + + public static final String SERIALIZED_NAME_SYNC_DEVICE = "sync_device"; + @SerializedName(SERIALIZED_NAME_SYNC_DEVICE) + private Boolean syncDevice; + + public static final String SERIALIZED_NAME_ROUTETYPE = "routetype"; + @SerializedName(SERIALIZED_NAME_ROUTETYPE) + private String routetype; + + public static final String SERIALIZED_NAME_EXT = "ext"; + @SerializedName(SERIALIZED_NAME_EXT) + private Object ext; + + public static final String SERIALIZED_NAME_CHATROOM_MSG_LEVEL = "chatroom_msg_level"; + @SerializedName(SERIALIZED_NAME_CHATROOM_MSG_LEVEL) + private String chatroomMsgLevel; + + public EMCreateMessage() { + } + + public EMCreateMessage from(String from) { + + this.from = from; + return this; + } + + /** + * 消息发送方的用户 ID。若不传入该字段,服务器默认设置为管理员,即 “admin”;若传入字段但值为空字符串 (“”),请求失败 + * @return from + **/ + @javax.annotation.Nullable + public String getFrom() { + return from; + } + + + public void setFrom(String from) { + this.from = from; + } + + + public EMCreateMessage to(List to) { + + this.to = to; + return this; + } + + public EMCreateMessage addToItem(String toItem) { + if (this.to == null) { + this.to = new ArrayList<>(); + } + this.to.add(toItem); + return this; + } + + /** + * 发送单聊消息 - 消息接收方的用户 ID 数组。每次最多可向 600 个用户发送消息 发送群聊消息 - 消息接收方群组 ID 数组。每次最多可向 3 个群组发送消息 发送聊天室消息 - 消息接收方聊天室 ID 数组。每次最多可向 10 个聊天室发送消息 + * @return to + **/ + @javax.annotation.Nonnull + public List getTo() { + return to; + } + + + public void setTo(List to) { + this.to = to; + } + + + public EMCreateMessage type(String type) { + + this.type = type; + return this; + } + + /** + * 消息类型: - txt:文本消息; - img:图片消息; - audio:语音消息; - video:视频消息; - file:文件消息; - loc:位置消息; - cmd:透传消息; - custom:自定义消息。 + * @return type + **/ + @javax.annotation.Nonnull + public String getType() { + return type; + } + + + public void setType(String type) { + this.type = type; + } + + + public EMCreateMessage body(EMMessageContent body) { + + this.body = body; + return this; + } + + /** + * Get body + * @return body + **/ + @javax.annotation.Nonnull + public EMMessageContent getBody() { + return body; + } + + + public void setBody(EMMessageContent body) { + this.body = body; + } + + + public EMCreateMessage syncDevice(Boolean syncDevice) { + + this.syncDevice = syncDevice; + return this; + } + + /** + * 消息发送成功后,是否将消息同步到发送方 - true:是; - (默认)false:否 + * @return syncDevice + **/ + @javax.annotation.Nullable + public Boolean getSyncDevice() { + return syncDevice; + } + + + public void setSyncDevice(Boolean syncDevice) { + this.syncDevice = syncDevice; + } + + + public EMCreateMessage routetype(String routetype) { + + this.routetype = routetype; + return this; + } + + /** + * 若传入该参数,其值为 ROUTE_ONLINE,表示接收方只有在线时才能收到消息,若接收方离线则无法收到消息。若不传入该参数,无论接收方在线还是离线都能收到消息 + * @return routetype + **/ + @javax.annotation.Nullable + public String getRoutetype() { + return routetype; + } + + + public void setRoutetype(String routetype) { + this.routetype = routetype; + } + + + public EMCreateMessage ext(Object ext) { + + this.ext = ext; + return this; + } + + /** + * 消息支持扩展字段,可添加自定义信息。不能对该参数传入 null。同时,推送通知也支持自定义扩展字段,详见 APNs 自定义显示:https://docs-im-beta.easemob.com/document/ios/push.html#_4-%E8%AE%BE%E7%BD%AE%E7%A6%BB%E7%BA%BF%E6%8E%A8%E9%80%81 和 Android 推送字段说明:https://docs-im-beta.easemob.com/document/android/push.html#_5-%E8%A7%A3%E6%9E%90%E6%94%B6%E5%88%B0%E7%9A%84%E6%8E%A8%E9%80%81%E5%AD%97%E6%AE%B5 + * @return ext + **/ + @javax.annotation.Nullable + public Object getExt() { + return ext; + } + + + public void setExt(Object ext) { + this.ext = ext; + } + + + public EMCreateMessage chatroomMsgLevel(String chatroomMsgLevel) { + + this.chatroomMsgLevel = chatroomMsgLevel; + return this; + } + + /** + * 聊天室消息优先级,仅对发送聊天室消息有效: - high:高; - (默认)normal:普通; - low:低 + * @return chatroomMsgLevel + **/ + @javax.annotation.Nullable + public String getChatroomMsgLevel() { + return chatroomMsgLevel; + } + + + public void setChatroomMsgLevel(String chatroomMsgLevel) { + this.chatroomMsgLevel = chatroomMsgLevel; + } + + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + EMCreateMessage createMessage = (EMCreateMessage) o; + return Objects.equals(this.from, createMessage.from) && + Objects.equals(this.to, createMessage.to) && + Objects.equals(this.type, createMessage.type) && + Objects.equals(this.body, createMessage.body) && + Objects.equals(this.syncDevice, createMessage.syncDevice) && + Objects.equals(this.routetype, createMessage.routetype) && + Objects.equals(this.ext, createMessage.ext) && + Objects.equals(this.chatroomMsgLevel, createMessage.chatroomMsgLevel); + } + + @Override + public int hashCode() { + return Objects.hash(from, to, type, body, syncDevice, routetype, ext, chatroomMsgLevel); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class EMCreateMessage {\n"); + sb.append(" from: ").append(toIndentedString(from)).append("\n"); + sb.append(" to: ").append(toIndentedString(to)).append("\n"); + sb.append(" type: ").append(toIndentedString(type)).append("\n"); + sb.append(" body: ").append(toIndentedString(body)).append("\n"); + sb.append(" syncDevice: ").append(toIndentedString(syncDevice)).append("\n"); + sb.append(" routetype: ").append(toIndentedString(routetype)).append("\n"); + sb.append(" ext: ").append(toIndentedString(ext)).append("\n"); + sb.append(" chatroomMsgLevel: ").append(toIndentedString(chatroomMsgLevel)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("from"); + openapiFields.add("to"); + openapiFields.add("type"); + openapiFields.add("body"); + openapiFields.add("sync_device"); + openapiFields.add("routetype"); + openapiFields.add("ext"); + openapiFields.add("chatroom_msg_level"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + openapiRequiredFields.add("to"); + openapiRequiredFields.add("type"); + openapiRequiredFields.add("body"); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to EMCreateMessage + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!EMCreateMessage.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format("The required field(s) %s in EMCreateMessage is not found in the empty JSON string", EMCreateMessage.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!EMCreateMessage.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `EMCreateMessage` properties. JSON: %s", entry.getKey(), jsonElement.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : EMCreateMessage.openapiRequiredFields) { + if (jsonElement.getAsJsonObject().get(requiredField) == null) { + throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + if ((jsonObj.get("from") != null && !jsonObj.get("from").isJsonNull()) && !jsonObj.get("from").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `from` to be a primitive type in the JSON string but got `%s`", jsonObj.get("from").toString())); + } + // ensure the required json array is present + if (jsonObj.get("to") == null) { + throw new IllegalArgumentException("Expected the field `linkedContent` to be an array in the JSON string but got `null`"); + } else if (!jsonObj.get("to").isJsonArray()) { + throw new IllegalArgumentException(String.format("Expected the field `to` to be an array in the JSON string but got `%s`", jsonObj.get("to").toString())); + } + if (!jsonObj.get("type").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `type` to be a primitive type in the JSON string but got `%s`", jsonObj.get("type").toString())); + } + // validate the required field `body` + EMMessageContent.validateJsonElement(jsonObj.get("body")); + if ((jsonObj.get("routetype") != null && !jsonObj.get("routetype").isJsonNull()) && !jsonObj.get("routetype").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `routetype` to be a primitive type in the JSON string but got `%s`", jsonObj.get("routetype").toString())); + } + if ((jsonObj.get("chatroom_msg_level") != null && !jsonObj.get("chatroom_msg_level").isJsonNull()) && !jsonObj.get("chatroom_msg_level").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `chatroom_msg_level` to be a primitive type in the JSON string but got `%s`", jsonObj.get("chatroom_msg_level").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!EMCreateMessage.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'EMCreateMessage' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(EMCreateMessage.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, EMCreateMessage value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public EMCreateMessage read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + return thisAdapter.fromJsonTree(jsonElement); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of EMCreateMessage given an JSON string + * + * @param jsonString JSON string + * @return An instance of EMCreateMessage + * @throws IOException if the JSON string is invalid with respect to EMCreateMessage + */ + public static EMCreateMessage fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, EMCreateMessage.class); + } + + /** + * Convert an instance of EMCreateMessage to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/com/easemob/im/api/model/EMCreateRoom.java b/src/main/java/com/easemob/im/api/model/EMCreateRoom.java new file mode 100644 index 000000000..dc5d43a42 --- /dev/null +++ b/src/main/java/com/easemob/im/api/model/EMCreateRoom.java @@ -0,0 +1,381 @@ +/* + * EMService + * Easemob Rest API + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.easemob.im.api.model; + +import java.util.Objects; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import com.easemob.im.JSON; + +/** + * EMCreateRoom + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-01-25T14:51:53.998371+08:00[Asia/Shanghai]") +public class EMCreateRoom { + public static final String SERIALIZED_NAME_NAME = "name"; + @SerializedName(SERIALIZED_NAME_NAME) + private String name; + + public static final String SERIALIZED_NAME_DESCRIPTION = "description"; + @SerializedName(SERIALIZED_NAME_DESCRIPTION) + private String description; + + public static final String SERIALIZED_NAME_MAXUSERS = "maxusers"; + @SerializedName(SERIALIZED_NAME_MAXUSERS) + private Integer maxusers; + + public static final String SERIALIZED_NAME_OWNER = "owner"; + @SerializedName(SERIALIZED_NAME_OWNER) + private String owner; + + public static final String SERIALIZED_NAME_MEMBERS = "members"; + @SerializedName(SERIALIZED_NAME_MEMBERS) + private List members; + + public static final String SERIALIZED_NAME_CUSTOM = "custom"; + @SerializedName(SERIALIZED_NAME_CUSTOM) + private String custom; + + public EMCreateRoom() { + } + + public EMCreateRoom name(String name) { + + this.name = name; + return this; + } + + /** + * 聊天室名称,最大长度为 128 个字符 + * @return name + **/ + @javax.annotation.Nonnull + public String getName() { + return name; + } + + + public void setName(String name) { + this.name = name; + } + + + public EMCreateRoom description(String description) { + + this.description = description; + return this; + } + + /** + * 聊天室描述,最大长度为 512 个字符 + * @return description + **/ + @javax.annotation.Nonnull + public String getDescription() { + return description; + } + + + public void setDescription(String description) { + this.description = description; + } + + + public EMCreateRoom maxusers(Integer maxusers) { + + this.maxusers = maxusers; + return this; + } + + /** + * 聊天室最大成员数(包括聊天室所有者)。取值范围为 [1,10,000],默认值为 1000。如需调整请联系商务 + * @return maxusers + **/ + @javax.annotation.Nullable + public Integer getMaxusers() { + return maxusers; + } + + + public void setMaxusers(Integer maxusers) { + this.maxusers = maxusers; + } + + + public EMCreateRoom owner(String owner) { + + this.owner = owner; + return this; + } + + /** + * 聊天室所有者 + * @return owner + **/ + @javax.annotation.Nonnull + public String getOwner() { + return owner; + } + + + public void setOwner(String owner) { + this.owner = owner; + } + + + public EMCreateRoom members(List members) { + + this.members = members; + return this; + } + + public EMCreateRoom addMembersItem(String membersItem) { + if (this.members == null) { + this.members = new ArrayList<>(); + } + this.members.add(membersItem); + return this; + } + + /** + * 聊天室普通成员和管理员的用户 ID 数组,不包含聊天室所有者的用户 ID。该数组可包含的元素数量不超过 maxusers 的值。若传该参数,确保至少设置一个数组元素 + * @return members + **/ + @javax.annotation.Nullable + public List getMembers() { + return members; + } + + + public void setMembers(List members) { + this.members = members; + } + + + public EMCreateRoom custom(String custom) { + + this.custom = custom; + return this; + } + + /** + * 聊天室扩展信息,例如可以给聊天室添加业务相关的标记,不要超过 1,024 个字符 + * @return custom + **/ + @javax.annotation.Nullable + public String getCustom() { + return custom; + } + + + public void setCustom(String custom) { + this.custom = custom; + } + + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + EMCreateRoom createRoom = (EMCreateRoom) o; + return Objects.equals(this.name, createRoom.name) && + Objects.equals(this.description, createRoom.description) && + Objects.equals(this.maxusers, createRoom.maxusers) && + Objects.equals(this.owner, createRoom.owner) && + Objects.equals(this.members, createRoom.members) && + Objects.equals(this.custom, createRoom.custom); + } + + @Override + public int hashCode() { + return Objects.hash(name, description, maxusers, owner, members, custom); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class EMCreateRoom {\n"); + sb.append(" name: ").append(toIndentedString(name)).append("\n"); + sb.append(" description: ").append(toIndentedString(description)).append("\n"); + sb.append(" maxusers: ").append(toIndentedString(maxusers)).append("\n"); + sb.append(" owner: ").append(toIndentedString(owner)).append("\n"); + sb.append(" members: ").append(toIndentedString(members)).append("\n"); + sb.append(" custom: ").append(toIndentedString(custom)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("name"); + openapiFields.add("description"); + openapiFields.add("maxusers"); + openapiFields.add("owner"); + openapiFields.add("members"); + openapiFields.add("custom"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + openapiRequiredFields.add("name"); + openapiRequiredFields.add("description"); + openapiRequiredFields.add("owner"); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to EMCreateRoom + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!EMCreateRoom.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format("The required field(s) %s in EMCreateRoom is not found in the empty JSON string", EMCreateRoom.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!EMCreateRoom.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `EMCreateRoom` properties. JSON: %s", entry.getKey(), jsonElement.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : EMCreateRoom.openapiRequiredFields) { + if (jsonElement.getAsJsonObject().get(requiredField) == null) { + throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + if (!jsonObj.get("name").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("name").toString())); + } + if (!jsonObj.get("description").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `description` to be a primitive type in the JSON string but got `%s`", jsonObj.get("description").toString())); + } + if (!jsonObj.get("owner").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `owner` to be a primitive type in the JSON string but got `%s`", jsonObj.get("owner").toString())); + } + // ensure the optional json data is an array if present + if (jsonObj.get("members") != null && !jsonObj.get("members").isJsonNull() && !jsonObj.get("members").isJsonArray()) { + throw new IllegalArgumentException(String.format("Expected the field `members` to be an array in the JSON string but got `%s`", jsonObj.get("members").toString())); + } + if ((jsonObj.get("custom") != null && !jsonObj.get("custom").isJsonNull()) && !jsonObj.get("custom").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `custom` to be a primitive type in the JSON string but got `%s`", jsonObj.get("custom").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!EMCreateRoom.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'EMCreateRoom' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(EMCreateRoom.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, EMCreateRoom value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public EMCreateRoom read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + return thisAdapter.fromJsonTree(jsonElement); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of EMCreateRoom given an JSON string + * + * @param jsonString JSON string + * @return An instance of EMCreateRoom + * @throws IOException if the JSON string is invalid with respect to EMCreateRoom + */ + public static EMCreateRoom fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, EMCreateRoom.class); + } + + /** + * Convert an instance of EMCreateRoom to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/com/easemob/im/api/model/EMCreateRoomResource.java b/src/main/java/com/easemob/im/api/model/EMCreateRoomResource.java new file mode 100644 index 000000000..69a73b9c5 --- /dev/null +++ b/src/main/java/com/easemob/im/api/model/EMCreateRoomResource.java @@ -0,0 +1,208 @@ +/* + * EMService + * Easemob Rest API + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.easemob.im.api.model; + +import java.util.Objects; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.Arrays; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import com.easemob.im.JSON; + +/** + * EMCreateRoomResource + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-01-25T14:51:53.998371+08:00[Asia/Shanghai]") +public class EMCreateRoomResource { + public static final String SERIALIZED_NAME_ID = "id"; + @SerializedName(SERIALIZED_NAME_ID) + private String id; + + public EMCreateRoomResource() { + } + + public EMCreateRoomResource id(String id) { + + this.id = id; + return this; + } + + /** + * Get id + * @return id + **/ + @javax.annotation.Nullable + public String getId() { + return id; + } + + + public void setId(String id) { + this.id = id; + } + + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + EMCreateRoomResource createRoomResource = (EMCreateRoomResource) o; + return Objects.equals(this.id, createRoomResource.id); + } + + @Override + public int hashCode() { + return Objects.hash(id); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class EMCreateRoomResource {\n"); + sb.append(" id: ").append(toIndentedString(id)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("id"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to EMCreateRoomResource + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!EMCreateRoomResource.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format("The required field(s) %s in EMCreateRoomResource is not found in the empty JSON string", EMCreateRoomResource.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!EMCreateRoomResource.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `EMCreateRoomResource` properties. JSON: %s", entry.getKey(), jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + if ((jsonObj.get("id") != null && !jsonObj.get("id").isJsonNull()) && !jsonObj.get("id").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `id` to be a primitive type in the JSON string but got `%s`", jsonObj.get("id").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!EMCreateRoomResource.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'EMCreateRoomResource' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(EMCreateRoomResource.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, EMCreateRoomResource value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public EMCreateRoomResource read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + return thisAdapter.fromJsonTree(jsonElement); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of EMCreateRoomResource given an JSON string + * + * @param jsonString JSON string + * @return An instance of EMCreateRoomResource + * @throws IOException if the JSON string is invalid with respect to EMCreateRoomResource + */ + public static EMCreateRoomResource fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, EMCreateRoomResource.class); + } + + /** + * Convert an instance of EMCreateRoomResource to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/com/easemob/im/api/model/EMCreateRoomResult.java b/src/main/java/com/easemob/im/api/model/EMCreateRoomResult.java new file mode 100644 index 000000000..2bdd20aaa --- /dev/null +++ b/src/main/java/com/easemob/im/api/model/EMCreateRoomResult.java @@ -0,0 +1,210 @@ +/* + * EMService + * Easemob Rest API + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.easemob.im.api.model; + +import java.util.Objects; +import com.easemob.im.api.model.EMCreateRoomResource; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.Arrays; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import com.easemob.im.JSON; + +/** + * EMCreateRoomResult + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-01-25T14:51:53.998371+08:00[Asia/Shanghai]") +public class EMCreateRoomResult { + public static final String SERIALIZED_NAME_DATA = "data"; + @SerializedName(SERIALIZED_NAME_DATA) + private EMCreateRoomResource data; + + public EMCreateRoomResult() { + } + + public EMCreateRoomResult data(EMCreateRoomResource data) { + + this.data = data; + return this; + } + + /** + * Get data + * @return data + **/ + @javax.annotation.Nullable + public EMCreateRoomResource getData() { + return data; + } + + + public void setData(EMCreateRoomResource data) { + this.data = data; + } + + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + EMCreateRoomResult createRoomResult = (EMCreateRoomResult) o; + return Objects.equals(this.data, createRoomResult.data); + } + + @Override + public int hashCode() { + return Objects.hash(data); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class EMCreateRoomResult {\n"); + sb.append(" data: ").append(toIndentedString(data)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("data"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to EMCreateRoomResult + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!EMCreateRoomResult.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format("The required field(s) %s in EMCreateRoomResult is not found in the empty JSON string", EMCreateRoomResult.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!EMCreateRoomResult.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `EMCreateRoomResult` properties. JSON: %s", entry.getKey(), jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // validate the optional field `data` + if (jsonObj.get("data") != null && !jsonObj.get("data").isJsonNull()) { + EMCreateRoomResource.validateJsonElement(jsonObj.get("data")); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!EMCreateRoomResult.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'EMCreateRoomResult' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(EMCreateRoomResult.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, EMCreateRoomResult value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public EMCreateRoomResult read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + return thisAdapter.fromJsonTree(jsonElement); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of EMCreateRoomResult given an JSON string + * + * @param jsonString JSON string + * @return An instance of EMCreateRoomResult + * @throws IOException if the JSON string is invalid with respect to EMCreateRoomResult + */ + public static EMCreateRoomResult fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, EMCreateRoomResult.class); + } + + /** + * Convert an instance of EMCreateRoomResult to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/com/easemob/im/api/model/EMCreateThread.java b/src/main/java/com/easemob/im/api/model/EMCreateThread.java new file mode 100644 index 000000000..5d4dd3a80 --- /dev/null +++ b/src/main/java/com/easemob/im/api/model/EMCreateThread.java @@ -0,0 +1,301 @@ +/* + * EMService + * Easemob Rest API + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.easemob.im.api.model; + +import java.util.Objects; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.Arrays; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import com.easemob.im.JSON; + +/** + * EMCreateThread + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-01-25T14:51:53.998371+08:00[Asia/Shanghai]") +public class EMCreateThread { + public static final String SERIALIZED_NAME_GROUP_ID = "group_id"; + @SerializedName(SERIALIZED_NAME_GROUP_ID) + private String groupId; + + public static final String SERIALIZED_NAME_NAME = "name"; + @SerializedName(SERIALIZED_NAME_NAME) + private String name; + + public static final String SERIALIZED_NAME_MSG_ID = "msg_id"; + @SerializedName(SERIALIZED_NAME_MSG_ID) + private String msgId; + + public static final String SERIALIZED_NAME_OWNER = "owner"; + @SerializedName(SERIALIZED_NAME_OWNER) + private String owner; + + public EMCreateThread() { + } + + public EMCreateThread groupId(String groupId) { + + this.groupId = groupId; + return this; + } + + /** + * 子区所在的群组 ID + * @return groupId + **/ + @javax.annotation.Nullable + public String getGroupId() { + return groupId; + } + + + public void setGroupId(String groupId) { + this.groupId = groupId; + } + + + public EMCreateThread name(String name) { + + this.name = name; + return this; + } + + /** + * 子区名称,不能超过 64 个字符 + * @return name + **/ + @javax.annotation.Nullable + public String getName() { + return name; + } + + + public void setName(String name) { + this.name = name; + } + + + public EMCreateThread msgId(String msgId) { + + this.msgId = msgId; + return this; + } + + /** + * 子区的父消息 ID + * @return msgId + **/ + @javax.annotation.Nullable + public String getMsgId() { + return msgId; + } + + + public void setMsgId(String msgId) { + this.msgId = msgId; + } + + + public EMCreateThread owner(String owner) { + + this.owner = owner; + return this; + } + + /** + * 子区的所有者,即创建子区的群成员 + * @return owner + **/ + @javax.annotation.Nullable + public String getOwner() { + return owner; + } + + + public void setOwner(String owner) { + this.owner = owner; + } + + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + EMCreateThread createThread = (EMCreateThread) o; + return Objects.equals(this.groupId, createThread.groupId) && + Objects.equals(this.name, createThread.name) && + Objects.equals(this.msgId, createThread.msgId) && + Objects.equals(this.owner, createThread.owner); + } + + @Override + public int hashCode() { + return Objects.hash(groupId, name, msgId, owner); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class EMCreateThread {\n"); + sb.append(" groupId: ").append(toIndentedString(groupId)).append("\n"); + sb.append(" name: ").append(toIndentedString(name)).append("\n"); + sb.append(" msgId: ").append(toIndentedString(msgId)).append("\n"); + sb.append(" owner: ").append(toIndentedString(owner)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("group_id"); + openapiFields.add("name"); + openapiFields.add("msg_id"); + openapiFields.add("owner"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to EMCreateThread + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!EMCreateThread.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format("The required field(s) %s in EMCreateThread is not found in the empty JSON string", EMCreateThread.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!EMCreateThread.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `EMCreateThread` properties. JSON: %s", entry.getKey(), jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + if ((jsonObj.get("group_id") != null && !jsonObj.get("group_id").isJsonNull()) && !jsonObj.get("group_id").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `group_id` to be a primitive type in the JSON string but got `%s`", jsonObj.get("group_id").toString())); + } + if ((jsonObj.get("name") != null && !jsonObj.get("name").isJsonNull()) && !jsonObj.get("name").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("name").toString())); + } + if ((jsonObj.get("msg_id") != null && !jsonObj.get("msg_id").isJsonNull()) && !jsonObj.get("msg_id").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `msg_id` to be a primitive type in the JSON string but got `%s`", jsonObj.get("msg_id").toString())); + } + if ((jsonObj.get("owner") != null && !jsonObj.get("owner").isJsonNull()) && !jsonObj.get("owner").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `owner` to be a primitive type in the JSON string but got `%s`", jsonObj.get("owner").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!EMCreateThread.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'EMCreateThread' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(EMCreateThread.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, EMCreateThread value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public EMCreateThread read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + return thisAdapter.fromJsonTree(jsonElement); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of EMCreateThread given an JSON string + * + * @param jsonString JSON string + * @return An instance of EMCreateThread + * @throws IOException if the JSON string is invalid with respect to EMCreateThread + */ + public static EMCreateThread fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, EMCreateThread.class); + } + + /** + * Convert an instance of EMCreateThread to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/com/easemob/im/api/model/EMCreateThreadResource.java b/src/main/java/com/easemob/im/api/model/EMCreateThreadResource.java new file mode 100644 index 000000000..262ccc448 --- /dev/null +++ b/src/main/java/com/easemob/im/api/model/EMCreateThreadResource.java @@ -0,0 +1,208 @@ +/* + * EMService + * Easemob Rest API + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.easemob.im.api.model; + +import java.util.Objects; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.Arrays; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import com.easemob.im.JSON; + +/** + * EMCreateThreadResource + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-01-25T14:51:53.998371+08:00[Asia/Shanghai]") +public class EMCreateThreadResource { + public static final String SERIALIZED_NAME_THREAD_ID = "thread_id"; + @SerializedName(SERIALIZED_NAME_THREAD_ID) + private String threadId; + + public EMCreateThreadResource() { + } + + public EMCreateThreadResource threadId(String threadId) { + + this.threadId = threadId; + return this; + } + + /** + * Get threadId + * @return threadId + **/ + @javax.annotation.Nullable + public String getThreadId() { + return threadId; + } + + + public void setThreadId(String threadId) { + this.threadId = threadId; + } + + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + EMCreateThreadResource createThreadResource = (EMCreateThreadResource) o; + return Objects.equals(this.threadId, createThreadResource.threadId); + } + + @Override + public int hashCode() { + return Objects.hash(threadId); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class EMCreateThreadResource {\n"); + sb.append(" threadId: ").append(toIndentedString(threadId)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("thread_id"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to EMCreateThreadResource + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!EMCreateThreadResource.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format("The required field(s) %s in EMCreateThreadResource is not found in the empty JSON string", EMCreateThreadResource.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!EMCreateThreadResource.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `EMCreateThreadResource` properties. JSON: %s", entry.getKey(), jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + if ((jsonObj.get("thread_id") != null && !jsonObj.get("thread_id").isJsonNull()) && !jsonObj.get("thread_id").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `thread_id` to be a primitive type in the JSON string but got `%s`", jsonObj.get("thread_id").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!EMCreateThreadResource.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'EMCreateThreadResource' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(EMCreateThreadResource.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, EMCreateThreadResource value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public EMCreateThreadResource read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + return thisAdapter.fromJsonTree(jsonElement); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of EMCreateThreadResource given an JSON string + * + * @param jsonString JSON string + * @return An instance of EMCreateThreadResource + * @throws IOException if the JSON string is invalid with respect to EMCreateThreadResource + */ + public static EMCreateThreadResource fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, EMCreateThreadResource.class); + } + + /** + * Convert an instance of EMCreateThreadResource to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/com/easemob/im/api/model/EMCreateThreadResult.java b/src/main/java/com/easemob/im/api/model/EMCreateThreadResult.java new file mode 100644 index 000000000..ed8803840 --- /dev/null +++ b/src/main/java/com/easemob/im/api/model/EMCreateThreadResult.java @@ -0,0 +1,210 @@ +/* + * EMService + * Easemob Rest API + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.easemob.im.api.model; + +import java.util.Objects; +import com.easemob.im.api.model.EMCreateThreadResource; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.Arrays; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import com.easemob.im.JSON; + +/** + * EMCreateThreadResult + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-01-25T14:51:53.998371+08:00[Asia/Shanghai]") +public class EMCreateThreadResult { + public static final String SERIALIZED_NAME_DATA = "data"; + @SerializedName(SERIALIZED_NAME_DATA) + private EMCreateThreadResource data; + + public EMCreateThreadResult() { + } + + public EMCreateThreadResult data(EMCreateThreadResource data) { + + this.data = data; + return this; + } + + /** + * Get data + * @return data + **/ + @javax.annotation.Nullable + public EMCreateThreadResource getData() { + return data; + } + + + public void setData(EMCreateThreadResource data) { + this.data = data; + } + + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + EMCreateThreadResult createThreadResult = (EMCreateThreadResult) o; + return Objects.equals(this.data, createThreadResult.data); + } + + @Override + public int hashCode() { + return Objects.hash(data); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class EMCreateThreadResult {\n"); + sb.append(" data: ").append(toIndentedString(data)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("data"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to EMCreateThreadResult + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!EMCreateThreadResult.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format("The required field(s) %s in EMCreateThreadResult is not found in the empty JSON string", EMCreateThreadResult.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!EMCreateThreadResult.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `EMCreateThreadResult` properties. JSON: %s", entry.getKey(), jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // validate the optional field `data` + if (jsonObj.get("data") != null && !jsonObj.get("data").isJsonNull()) { + EMCreateThreadResource.validateJsonElement(jsonObj.get("data")); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!EMCreateThreadResult.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'EMCreateThreadResult' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(EMCreateThreadResult.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, EMCreateThreadResult value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public EMCreateThreadResult read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + return thisAdapter.fromJsonTree(jsonElement); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of EMCreateThreadResult given an JSON string + * + * @param jsonString JSON string + * @return An instance of EMCreateThreadResult + * @throws IOException if the JSON string is invalid with respect to EMCreateThreadResult + */ + public static EMCreateThreadResult fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, EMCreateThreadResult.class); + } + + /** + * Convert an instance of EMCreateThreadResult to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/com/easemob/im/api/model/EMCreateToken.java b/src/main/java/com/easemob/im/api/model/EMCreateToken.java new file mode 100644 index 000000000..66b4f6984 --- /dev/null +++ b/src/main/java/com/easemob/im/api/model/EMCreateToken.java @@ -0,0 +1,388 @@ +/* + * EMService + * Easemob Rest API + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.easemob.im.api.model; + +import java.util.Objects; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.Arrays; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import com.easemob.im.JSON; + +/** + * EMCreateToken + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-01-25T14:51:53.998371+08:00[Asia/Shanghai]") +public class EMCreateToken { + public static final String SERIALIZED_NAME_GRANT_TYPE = "grant_type"; + @SerializedName(SERIALIZED_NAME_GRANT_TYPE) + private String grantType; + + public static final String SERIALIZED_NAME_CLIENT_ID = "client_id"; + @SerializedName(SERIALIZED_NAME_CLIENT_ID) + private String clientId; + + public static final String SERIALIZED_NAME_CLIENT_SECRET = "client_secret"; + @SerializedName(SERIALIZED_NAME_CLIENT_SECRET) + private String clientSecret; + + public static final String SERIALIZED_NAME_USERNAME = "username"; + @SerializedName(SERIALIZED_NAME_USERNAME) + private String username; + + public static final String SERIALIZED_NAME_PASSWORD = "password"; + @SerializedName(SERIALIZED_NAME_PASSWORD) + private String password; + + public static final String SERIALIZED_NAME_AUTO_CREATE_USER = "autoCreateUser"; + @SerializedName(SERIALIZED_NAME_AUTO_CREATE_USER) + private Boolean autoCreateUser; + + public static final String SERIALIZED_NAME_TTL = "ttl"; + @SerializedName(SERIALIZED_NAME_TTL) + private Integer ttl; + + public EMCreateToken() { + } + + public EMCreateToken grantType(String grantType) { + + this.grantType = grantType; + return this; + } + + /** + * 授权方式。 - client_credentials:获取 App Token 使用 - password:通过用户 ID 和密码获取用户 Token 使用 - inherit:通过用户 ID 获取用户 Token 使用 + * @return grantType + **/ + @javax.annotation.Nullable + public String getGrantType() { + return grantType; + } + + + public void setGrantType(String grantType) { + this.grantType = grantType; + } + + + public EMCreateToken clientId(String clientId) { + + this.clientId = clientId; + return this; + } + + /** + * App 的 client_id,用于生成 App Token 调用 REST API。详见 环信即时通讯云控制台的应用详情页面 + * @return clientId + **/ + @javax.annotation.Nullable + public String getClientId() { + return clientId; + } + + + public void setClientId(String clientId) { + this.clientId = clientId; + } + + + public EMCreateToken clientSecret(String clientSecret) { + + this.clientSecret = clientSecret; + return this; + } + + /** + * App 的 client_secret,用于生成 App Token 调用 REST API。详见 环信即时通讯云控制台的应用详情页面 + * @return clientSecret + **/ + @javax.annotation.Nullable + public String getClientSecret() { + return clientSecret; + } + + + public void setClientSecret(String clientSecret) { + this.clientSecret = clientSecret; + } + + + public EMCreateToken username(String username) { + + this.username = username; + return this; + } + + /** + * 用户 ID,通过用户 ID 和密码 或 通过用户 ID获取用户 Token 使用 + * @return username + **/ + @javax.annotation.Nullable + public String getUsername() { + return username; + } + + + public void setUsername(String username) { + this.username = username; + } + + + public EMCreateToken password(String password) { + + this.password = password; + return this; + } + + /** + * 用户的登录密码,通过用户 ID 和密码获取用户 Token 使用 + * @return password + **/ + @javax.annotation.Nullable + public String getPassword() { + return password; + } + + + public void setPassword(String password) { + this.password = password; + } + + + public EMCreateToken autoCreateUser(Boolean autoCreateUser) { + + this.autoCreateUser = autoCreateUser; + return this; + } + + /** + * 当用户不存在时,是否自动创建用户。自动创建用户时,需保证授权方式(grant_type)必须为 inherit,通过用户 ID获取用户 Token 使用 + * @return autoCreateUser + **/ + @javax.annotation.Nullable + public Boolean getAutoCreateUser() { + return autoCreateUser; + } + + + public void setAutoCreateUser(Boolean autoCreateUser) { + this.autoCreateUser = autoCreateUser; + } + + + public EMCreateToken ttl(Integer ttl) { + + this.ttl = ttl; + return this; + } + + /** + * token 有效期,单位为秒 + * @return ttl + **/ + @javax.annotation.Nullable + public Integer getTtl() { + return ttl; + } + + + public void setTtl(Integer ttl) { + this.ttl = ttl; + } + + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + EMCreateToken createToken = (EMCreateToken) o; + return Objects.equals(this.grantType, createToken.grantType) && + Objects.equals(this.clientId, createToken.clientId) && + Objects.equals(this.clientSecret, createToken.clientSecret) && + Objects.equals(this.username, createToken.username) && + Objects.equals(this.password, createToken.password) && + Objects.equals(this.autoCreateUser, createToken.autoCreateUser) && + Objects.equals(this.ttl, createToken.ttl); + } + + @Override + public int hashCode() { + return Objects.hash(grantType, clientId, clientSecret, username, password, autoCreateUser, ttl); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class EMCreateToken {\n"); + sb.append(" grantType: ").append(toIndentedString(grantType)).append("\n"); + sb.append(" clientId: ").append(toIndentedString(clientId)).append("\n"); + sb.append(" clientSecret: ").append(toIndentedString(clientSecret)).append("\n"); + sb.append(" username: ").append(toIndentedString(username)).append("\n"); + sb.append(" password: ").append(toIndentedString(password)).append("\n"); + sb.append(" autoCreateUser: ").append(toIndentedString(autoCreateUser)).append("\n"); + sb.append(" ttl: ").append(toIndentedString(ttl)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("grant_type"); + openapiFields.add("client_id"); + openapiFields.add("client_secret"); + openapiFields.add("username"); + openapiFields.add("password"); + openapiFields.add("autoCreateUser"); + openapiFields.add("ttl"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to EMCreateToken + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!EMCreateToken.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format("The required field(s) %s in EMCreateToken is not found in the empty JSON string", EMCreateToken.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!EMCreateToken.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `EMCreateToken` properties. JSON: %s", entry.getKey(), jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + if ((jsonObj.get("grant_type") != null && !jsonObj.get("grant_type").isJsonNull()) && !jsonObj.get("grant_type").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `grant_type` to be a primitive type in the JSON string but got `%s`", jsonObj.get("grant_type").toString())); + } + if ((jsonObj.get("client_id") != null && !jsonObj.get("client_id").isJsonNull()) && !jsonObj.get("client_id").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `client_id` to be a primitive type in the JSON string but got `%s`", jsonObj.get("client_id").toString())); + } + if ((jsonObj.get("client_secret") != null && !jsonObj.get("client_secret").isJsonNull()) && !jsonObj.get("client_secret").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `client_secret` to be a primitive type in the JSON string but got `%s`", jsonObj.get("client_secret").toString())); + } + if ((jsonObj.get("username") != null && !jsonObj.get("username").isJsonNull()) && !jsonObj.get("username").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `username` to be a primitive type in the JSON string but got `%s`", jsonObj.get("username").toString())); + } + if ((jsonObj.get("password") != null && !jsonObj.get("password").isJsonNull()) && !jsonObj.get("password").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `password` to be a primitive type in the JSON string but got `%s`", jsonObj.get("password").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!EMCreateToken.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'EMCreateToken' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(EMCreateToken.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, EMCreateToken value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public EMCreateToken read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + return thisAdapter.fromJsonTree(jsonElement); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of EMCreateToken given an JSON string + * + * @param jsonString JSON string + * @return An instance of EMCreateToken + * @throws IOException if the JSON string is invalid with respect to EMCreateToken + */ + public static EMCreateToken fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, EMCreateToken.class); + } + + /** + * Convert an instance of EMCreateToken to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/com/easemob/im/api/model/EMCreateUser.java b/src/main/java/com/easemob/im/api/model/EMCreateUser.java new file mode 100644 index 000000000..1326b31f4 --- /dev/null +++ b/src/main/java/com/easemob/im/api/model/EMCreateUser.java @@ -0,0 +1,239 @@ +/* + * EMService + * Easemob Rest API + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.easemob.im.api.model; + +import java.util.Objects; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.Arrays; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import com.easemob.im.JSON; + +/** + * EMCreateUser + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-01-25T14:51:53.998371+08:00[Asia/Shanghai]") +public class EMCreateUser { + public static final String SERIALIZED_NAME_USERNAME = "username"; + @SerializedName(SERIALIZED_NAME_USERNAME) + private String username; + + public static final String SERIALIZED_NAME_PASSWORD = "password"; + @SerializedName(SERIALIZED_NAME_PASSWORD) + private String password; + + public EMCreateUser() { + } + + public EMCreateUser username(String username) { + + this.username = username; + return this; + } + + /** + * 用户 ID,长度不可超过 64 字节 + * @return username + **/ + @javax.annotation.Nullable + public String getUsername() { + return username; + } + + + public void setUsername(String username) { + this.username = username; + } + + + public EMCreateUser password(String password) { + + this.password = password; + return this; + } + + /** + * 用户的登录密码,长度不可超过 64 个字符 + * @return password + **/ + @javax.annotation.Nullable + public String getPassword() { + return password; + } + + + public void setPassword(String password) { + this.password = password; + } + + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + EMCreateUser createUser = (EMCreateUser) o; + return Objects.equals(this.username, createUser.username) && + Objects.equals(this.password, createUser.password); + } + + @Override + public int hashCode() { + return Objects.hash(username, password); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class EMCreateUser {\n"); + sb.append(" username: ").append(toIndentedString(username)).append("\n"); + sb.append(" password: ").append(toIndentedString(password)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("username"); + openapiFields.add("password"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to EMCreateUser + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!EMCreateUser.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format("The required field(s) %s in EMCreateUser is not found in the empty JSON string", EMCreateUser.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!EMCreateUser.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `EMCreateUser` properties. JSON: %s", entry.getKey(), jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + if ((jsonObj.get("username") != null && !jsonObj.get("username").isJsonNull()) && !jsonObj.get("username").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `username` to be a primitive type in the JSON string but got `%s`", jsonObj.get("username").toString())); + } + if ((jsonObj.get("password") != null && !jsonObj.get("password").isJsonNull()) && !jsonObj.get("password").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `password` to be a primitive type in the JSON string but got `%s`", jsonObj.get("password").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!EMCreateUser.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'EMCreateUser' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(EMCreateUser.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, EMCreateUser value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public EMCreateUser read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + return thisAdapter.fromJsonTree(jsonElement); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of EMCreateUser given an JSON string + * + * @param jsonString JSON string + * @return An instance of EMCreateUser + * @throws IOException if the JSON string is invalid with respect to EMCreateUser + */ + public static EMCreateUser fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, EMCreateUser.class); + } + + /** + * Convert an instance of EMCreateUser to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/com/easemob/im/api/model/EMCreateUserFailResource.java b/src/main/java/com/easemob/im/api/model/EMCreateUserFailResource.java new file mode 100644 index 000000000..bfedf2181 --- /dev/null +++ b/src/main/java/com/easemob/im/api/model/EMCreateUserFailResource.java @@ -0,0 +1,239 @@ +/* + * EMService + * Easemob Rest API + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.easemob.im.api.model; + +import java.util.Objects; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.Arrays; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import com.easemob.im.JSON; + +/** + * EMCreateUserFailResource + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-01-25T14:51:53.998371+08:00[Asia/Shanghai]") +public class EMCreateUserFailResource { + public static final String SERIALIZED_NAME_USERNAME = "username"; + @SerializedName(SERIALIZED_NAME_USERNAME) + private String username; + + public static final String SERIALIZED_NAME_REGISTER_USER_FAIL_REASON = "registerUserFailReason"; + @SerializedName(SERIALIZED_NAME_REGISTER_USER_FAIL_REASON) + private String registerUserFailReason; + + public EMCreateUserFailResource() { + } + + public EMCreateUserFailResource username(String username) { + + this.username = username; + return this; + } + + /** + * Get username + * @return username + **/ + @javax.annotation.Nullable + public String getUsername() { + return username; + } + + + public void setUsername(String username) { + this.username = username; + } + + + public EMCreateUserFailResource registerUserFailReason(String registerUserFailReason) { + + this.registerUserFailReason = registerUserFailReason; + return this; + } + + /** + * Get registerUserFailReason + * @return registerUserFailReason + **/ + @javax.annotation.Nullable + public String getRegisterUserFailReason() { + return registerUserFailReason; + } + + + public void setRegisterUserFailReason(String registerUserFailReason) { + this.registerUserFailReason = registerUserFailReason; + } + + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + EMCreateUserFailResource createUserFailResource = (EMCreateUserFailResource) o; + return Objects.equals(this.username, createUserFailResource.username) && + Objects.equals(this.registerUserFailReason, createUserFailResource.registerUserFailReason); + } + + @Override + public int hashCode() { + return Objects.hash(username, registerUserFailReason); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class EMCreateUserFailResource {\n"); + sb.append(" username: ").append(toIndentedString(username)).append("\n"); + sb.append(" registerUserFailReason: ").append(toIndentedString(registerUserFailReason)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("username"); + openapiFields.add("registerUserFailReason"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to EMCreateUserFailResource + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!EMCreateUserFailResource.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format("The required field(s) %s in EMCreateUserFailResource is not found in the empty JSON string", EMCreateUserFailResource.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!EMCreateUserFailResource.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `EMCreateUserFailResource` properties. JSON: %s", entry.getKey(), jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + if ((jsonObj.get("username") != null && !jsonObj.get("username").isJsonNull()) && !jsonObj.get("username").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `username` to be a primitive type in the JSON string but got `%s`", jsonObj.get("username").toString())); + } + if ((jsonObj.get("registerUserFailReason") != null && !jsonObj.get("registerUserFailReason").isJsonNull()) && !jsonObj.get("registerUserFailReason").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `registerUserFailReason` to be a primitive type in the JSON string but got `%s`", jsonObj.get("registerUserFailReason").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!EMCreateUserFailResource.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'EMCreateUserFailResource' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(EMCreateUserFailResource.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, EMCreateUserFailResource value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public EMCreateUserFailResource read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + return thisAdapter.fromJsonTree(jsonElement); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of EMCreateUserFailResource given an JSON string + * + * @param jsonString JSON string + * @return An instance of EMCreateUserFailResource + * @throws IOException if the JSON string is invalid with respect to EMCreateUserFailResource + */ + public static EMCreateUserFailResource fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, EMCreateUserFailResource.class); + } + + /** + * Convert an instance of EMCreateUserFailResource to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/com/easemob/im/api/model/EMCreateUserResource.java b/src/main/java/com/easemob/im/api/model/EMCreateUserResource.java new file mode 100644 index 000000000..3c3bdcbd4 --- /dev/null +++ b/src/main/java/com/easemob/im/api/model/EMCreateUserResource.java @@ -0,0 +1,296 @@ +/* + * EMService + * Easemob Rest API + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.easemob.im.api.model; + +import java.util.Objects; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.math.BigDecimal; +import java.util.Arrays; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import com.easemob.im.JSON; + +/** + * EMCreateUserResource + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-01-25T14:51:53.998371+08:00[Asia/Shanghai]") +public class EMCreateUserResource { + public static final String SERIALIZED_NAME_UUID = "uuid"; + @SerializedName(SERIALIZED_NAME_UUID) + private String uuid; + + public static final String SERIALIZED_NAME_CREATED = "created"; + @SerializedName(SERIALIZED_NAME_CREATED) + private BigDecimal created; + + public static final String SERIALIZED_NAME_USERNAME = "username"; + @SerializedName(SERIALIZED_NAME_USERNAME) + private String username; + + public static final String SERIALIZED_NAME_ACTIVATED = "activated"; + @SerializedName(SERIALIZED_NAME_ACTIVATED) + private Boolean activated; + + public EMCreateUserResource() { + } + + public EMCreateUserResource uuid(String uuid) { + + this.uuid = uuid; + return this; + } + + /** + * Get uuid + * @return uuid + **/ + @javax.annotation.Nullable + public String getUuid() { + return uuid; + } + + + public void setUuid(String uuid) { + this.uuid = uuid; + } + + + public EMCreateUserResource created(BigDecimal created) { + + this.created = created; + return this; + } + + /** + * Get created + * @return created + **/ + @javax.annotation.Nullable + public BigDecimal getCreated() { + return created; + } + + + public void setCreated(BigDecimal created) { + this.created = created; + } + + + public EMCreateUserResource username(String username) { + + this.username = username; + return this; + } + + /** + * Get username + * @return username + **/ + @javax.annotation.Nullable + public String getUsername() { + return username; + } + + + public void setUsername(String username) { + this.username = username; + } + + + public EMCreateUserResource activated(Boolean activated) { + + this.activated = activated; + return this; + } + + /** + * Get activated + * @return activated + **/ + @javax.annotation.Nullable + public Boolean getActivated() { + return activated; + } + + + public void setActivated(Boolean activated) { + this.activated = activated; + } + + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + EMCreateUserResource createUserResource = (EMCreateUserResource) o; + return Objects.equals(this.uuid, createUserResource.uuid) && + Objects.equals(this.created, createUserResource.created) && + Objects.equals(this.username, createUserResource.username) && + Objects.equals(this.activated, createUserResource.activated); + } + + @Override + public int hashCode() { + return Objects.hash(uuid, created, username, activated); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class EMCreateUserResource {\n"); + sb.append(" uuid: ").append(toIndentedString(uuid)).append("\n"); + sb.append(" created: ").append(toIndentedString(created)).append("\n"); + sb.append(" username: ").append(toIndentedString(username)).append("\n"); + sb.append(" activated: ").append(toIndentedString(activated)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("uuid"); + openapiFields.add("created"); + openapiFields.add("username"); + openapiFields.add("activated"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to EMCreateUserResource + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!EMCreateUserResource.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format("The required field(s) %s in EMCreateUserResource is not found in the empty JSON string", EMCreateUserResource.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!EMCreateUserResource.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `EMCreateUserResource` properties. JSON: %s", entry.getKey(), jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + if ((jsonObj.get("uuid") != null && !jsonObj.get("uuid").isJsonNull()) && !jsonObj.get("uuid").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `uuid` to be a primitive type in the JSON string but got `%s`", jsonObj.get("uuid").toString())); + } + if ((jsonObj.get("username") != null && !jsonObj.get("username").isJsonNull()) && !jsonObj.get("username").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `username` to be a primitive type in the JSON string but got `%s`", jsonObj.get("username").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!EMCreateUserResource.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'EMCreateUserResource' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(EMCreateUserResource.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, EMCreateUserResource value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public EMCreateUserResource read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + return thisAdapter.fromJsonTree(jsonElement); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of EMCreateUserResource given an JSON string + * + * @param jsonString JSON string + * @return An instance of EMCreateUserResource + * @throws IOException if the JSON string is invalid with respect to EMCreateUserResource + */ + public static EMCreateUserResource fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, EMCreateUserResource.class); + } + + /** + * Convert an instance of EMCreateUserResource to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/com/easemob/im/api/model/EMCreateUsersResult.java b/src/main/java/com/easemob/im/api/model/EMCreateUsersResult.java new file mode 100644 index 000000000..5aea9cf1c --- /dev/null +++ b/src/main/java/com/easemob/im/api/model/EMCreateUsersResult.java @@ -0,0 +1,281 @@ +/* + * EMService + * Easemob Rest API + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.easemob.im.api.model; + +import java.util.Objects; +import com.easemob.im.api.model.EMCreateUserFailResource; +import com.easemob.im.api.model.EMCreateUserResource; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import com.easemob.im.JSON; + +/** + * EMCreateUsersResult + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-01-25T14:51:53.998371+08:00[Asia/Shanghai]") +public class EMCreateUsersResult { + public static final String SERIALIZED_NAME_ENTITIES = "entities"; + @SerializedName(SERIALIZED_NAME_ENTITIES) + private List entities; + + public static final String SERIALIZED_NAME_DATA = "data"; + @SerializedName(SERIALIZED_NAME_DATA) + private List data; + + public EMCreateUsersResult() { + } + + public EMCreateUsersResult entities(List entities) { + + this.entities = entities; + return this; + } + + public EMCreateUsersResult addEntitiesItem(EMCreateUserResource entitiesItem) { + if (this.entities == null) { + this.entities = new ArrayList<>(); + } + this.entities.add(entitiesItem); + return this; + } + + /** + * Get entities + * @return entities + **/ + @javax.annotation.Nullable + public List getEntities() { + return entities; + } + + + public void setEntities(List entities) { + this.entities = entities; + } + + + public EMCreateUsersResult data(List data) { + + this.data = data; + return this; + } + + public EMCreateUsersResult addDataItem(EMCreateUserFailResource dataItem) { + if (this.data == null) { + this.data = new ArrayList<>(); + } + this.data.add(dataItem); + return this; + } + + /** + * Get data + * @return data + **/ + @javax.annotation.Nullable + public List getData() { + return data; + } + + + public void setData(List data) { + this.data = data; + } + + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + EMCreateUsersResult createUsersResult = (EMCreateUsersResult) o; + return Objects.equals(this.entities, createUsersResult.entities) && + Objects.equals(this.data, createUsersResult.data); + } + + @Override + public int hashCode() { + return Objects.hash(entities, data); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class EMCreateUsersResult {\n"); + sb.append(" entities: ").append(toIndentedString(entities)).append("\n"); + sb.append(" data: ").append(toIndentedString(data)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("entities"); + openapiFields.add("data"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to EMCreateUsersResult + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!EMCreateUsersResult.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format("The required field(s) %s in EMCreateUsersResult is not found in the empty JSON string", EMCreateUsersResult.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!EMCreateUsersResult.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `EMCreateUsersResult` properties. JSON: %s", entry.getKey(), jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + if (jsonObj.get("entities") != null && !jsonObj.get("entities").isJsonNull()) { + JsonArray jsonArrayentities = jsonObj.getAsJsonArray("entities"); + if (jsonArrayentities != null) { + // ensure the json data is an array + if (!jsonObj.get("entities").isJsonArray()) { + throw new IllegalArgumentException(String.format("Expected the field `entities` to be an array in the JSON string but got `%s`", jsonObj.get("entities").toString())); + } + + // validate the optional field `entities` (array) + for (int i = 0; i < jsonArrayentities.size(); i++) { + EMCreateUserResource.validateJsonElement(jsonArrayentities.get(i)); + }; + } + } + if (jsonObj.get("data") != null && !jsonObj.get("data").isJsonNull()) { + JsonArray jsonArraydata = jsonObj.getAsJsonArray("data"); + if (jsonArraydata != null) { + // ensure the json data is an array + if (!jsonObj.get("data").isJsonArray()) { + throw new IllegalArgumentException(String.format("Expected the field `data` to be an array in the JSON string but got `%s`", jsonObj.get("data").toString())); + } + + // validate the optional field `data` (array) + for (int i = 0; i < jsonArraydata.size(); i++) { + EMCreateUserFailResource.validateJsonElement(jsonArraydata.get(i)); + }; + } + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!EMCreateUsersResult.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'EMCreateUsersResult' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(EMCreateUsersResult.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, EMCreateUsersResult value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public EMCreateUsersResult read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + return thisAdapter.fromJsonTree(jsonElement); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of EMCreateUsersResult given an JSON string + * + * @param jsonString JSON string + * @return An instance of EMCreateUsersResult + * @throws IOException if the JSON string is invalid with respect to EMCreateUsersResult + */ + public static EMCreateUsersResult fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, EMCreateUsersResult.class); + } + + /** + * Convert an instance of EMCreateUsersResult to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/com/easemob/im/api/model/EMCustomGroupMemberAttribute.java b/src/main/java/com/easemob/im/api/model/EMCustomGroupMemberAttribute.java new file mode 100644 index 000000000..e7fc370a0 --- /dev/null +++ b/src/main/java/com/easemob/im/api/model/EMCustomGroupMemberAttribute.java @@ -0,0 +1,213 @@ +/* + * EMService + * Easemob Rest API + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.easemob.im.api.model; + +import java.util.Objects; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.Arrays; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import com.easemob.im.JSON; + +/** + * EMCustomGroupMemberAttribute + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-01-25T14:51:53.998371+08:00[Asia/Shanghai]") +public class EMCustomGroupMemberAttribute { + public static final String SERIALIZED_NAME_META_DATA = "metaData"; + @SerializedName(SERIALIZED_NAME_META_DATA) + private Object metaData; + + public EMCustomGroupMemberAttribute() { + } + + public EMCustomGroupMemberAttribute metaData(Object metaData) { + + this.metaData = metaData; + return this; + } + + /** + * 要设置的群成员自定义属性,为 key-value 键值对。对于单个键值对: - key 表示属性名称,不能超过 16 字节。 - value 表示属性值,不能超过 512 个字节。若 value 设置为空字符串即删除该自定义属性。 单个群成员的自定义属性总长度不能超过 4 KB + * @return metaData + **/ + @javax.annotation.Nonnull + public Object getMetaData() { + return metaData; + } + + + public void setMetaData(Object metaData) { + this.metaData = metaData; + } + + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + EMCustomGroupMemberAttribute customGroupMemberAttribute = (EMCustomGroupMemberAttribute) o; + return Objects.equals(this.metaData, customGroupMemberAttribute.metaData); + } + + @Override + public int hashCode() { + return Objects.hash(metaData); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class EMCustomGroupMemberAttribute {\n"); + sb.append(" metaData: ").append(toIndentedString(metaData)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("metaData"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + openapiRequiredFields.add("metaData"); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to EMCustomGroupMemberAttribute + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!EMCustomGroupMemberAttribute.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format("The required field(s) %s in EMCustomGroupMemberAttribute is not found in the empty JSON string", EMCustomGroupMemberAttribute.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!EMCustomGroupMemberAttribute.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `EMCustomGroupMemberAttribute` properties. JSON: %s", entry.getKey(), jsonElement.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : EMCustomGroupMemberAttribute.openapiRequiredFields) { + if (jsonElement.getAsJsonObject().get(requiredField) == null) { + throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!EMCustomGroupMemberAttribute.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'EMCustomGroupMemberAttribute' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(EMCustomGroupMemberAttribute.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, EMCustomGroupMemberAttribute value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public EMCustomGroupMemberAttribute read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + return thisAdapter.fromJsonTree(jsonElement); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of EMCustomGroupMemberAttribute given an JSON string + * + * @param jsonString JSON string + * @return An instance of EMCustomGroupMemberAttribute + * @throws IOException if the JSON string is invalid with respect to EMCustomGroupMemberAttribute + */ + public static EMCustomGroupMemberAttribute fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, EMCustomGroupMemberAttribute.class); + } + + /** + * Convert an instance of EMCustomGroupMemberAttribute to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/com/easemob/im/api/model/EMCustomGroupMemberAttributeResult.java b/src/main/java/com/easemob/im/api/model/EMCustomGroupMemberAttributeResult.java new file mode 100644 index 000000000..f0f7c97f1 --- /dev/null +++ b/src/main/java/com/easemob/im/api/model/EMCustomGroupMemberAttributeResult.java @@ -0,0 +1,205 @@ +/* + * EMService + * Easemob Rest API + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.easemob.im.api.model; + +import java.util.Objects; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.Arrays; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import com.easemob.im.JSON; + +/** + * EMCustomGroupMemberAttributeResult + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-01-25T14:51:53.998371+08:00[Asia/Shanghai]") +public class EMCustomGroupMemberAttributeResult { + public static final String SERIALIZED_NAME_DATA = "data"; + @SerializedName(SERIALIZED_NAME_DATA) + private Object data; + + public EMCustomGroupMemberAttributeResult() { + } + + public EMCustomGroupMemberAttributeResult data(Object data) { + + this.data = data; + return this; + } + + /** + * Get data + * @return data + **/ + @javax.annotation.Nullable + public Object getData() { + return data; + } + + + public void setData(Object data) { + this.data = data; + } + + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + EMCustomGroupMemberAttributeResult customGroupMemberAttributeResult = (EMCustomGroupMemberAttributeResult) o; + return Objects.equals(this.data, customGroupMemberAttributeResult.data); + } + + @Override + public int hashCode() { + return Objects.hash(data); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class EMCustomGroupMemberAttributeResult {\n"); + sb.append(" data: ").append(toIndentedString(data)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("data"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to EMCustomGroupMemberAttributeResult + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!EMCustomGroupMemberAttributeResult.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format("The required field(s) %s in EMCustomGroupMemberAttributeResult is not found in the empty JSON string", EMCustomGroupMemberAttributeResult.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!EMCustomGroupMemberAttributeResult.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `EMCustomGroupMemberAttributeResult` properties. JSON: %s", entry.getKey(), jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!EMCustomGroupMemberAttributeResult.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'EMCustomGroupMemberAttributeResult' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(EMCustomGroupMemberAttributeResult.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, EMCustomGroupMemberAttributeResult value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public EMCustomGroupMemberAttributeResult read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + return thisAdapter.fromJsonTree(jsonElement); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of EMCustomGroupMemberAttributeResult given an JSON string + * + * @param jsonString JSON string + * @return An instance of EMCustomGroupMemberAttributeResult + * @throws IOException if the JSON string is invalid with respect to EMCustomGroupMemberAttributeResult + */ + public static EMCustomGroupMemberAttributeResult fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, EMCustomGroupMemberAttributeResult.class); + } + + /** + * Convert an instance of EMCustomGroupMemberAttributeResult to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/com/easemob/im/api/model/EMDeleteGroupResource.java b/src/main/java/com/easemob/im/api/model/EMDeleteGroupResource.java new file mode 100644 index 000000000..6240faaaa --- /dev/null +++ b/src/main/java/com/easemob/im/api/model/EMDeleteGroupResource.java @@ -0,0 +1,236 @@ +/* + * EMService + * Easemob Rest API + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.easemob.im.api.model; + +import java.util.Objects; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.Arrays; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import com.easemob.im.JSON; + +/** + * EMDeleteGroupResource + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-01-25T14:51:53.998371+08:00[Asia/Shanghai]") +public class EMDeleteGroupResource { + public static final String SERIALIZED_NAME_SUCCESS = "success"; + @SerializedName(SERIALIZED_NAME_SUCCESS) + private Boolean success; + + public static final String SERIALIZED_NAME_GROUPID = "groupid"; + @SerializedName(SERIALIZED_NAME_GROUPID) + private String groupid; + + public EMDeleteGroupResource() { + } + + public EMDeleteGroupResource success(Boolean success) { + + this.success = success; + return this; + } + + /** + * Get success + * @return success + **/ + @javax.annotation.Nullable + public Boolean getSuccess() { + return success; + } + + + public void setSuccess(Boolean success) { + this.success = success; + } + + + public EMDeleteGroupResource groupid(String groupid) { + + this.groupid = groupid; + return this; + } + + /** + * Get groupid + * @return groupid + **/ + @javax.annotation.Nullable + public String getGroupid() { + return groupid; + } + + + public void setGroupid(String groupid) { + this.groupid = groupid; + } + + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + EMDeleteGroupResource deleteGroupResource = (EMDeleteGroupResource) o; + return Objects.equals(this.success, deleteGroupResource.success) && + Objects.equals(this.groupid, deleteGroupResource.groupid); + } + + @Override + public int hashCode() { + return Objects.hash(success, groupid); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class EMDeleteGroupResource {\n"); + sb.append(" success: ").append(toIndentedString(success)).append("\n"); + sb.append(" groupid: ").append(toIndentedString(groupid)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("success"); + openapiFields.add("groupid"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to EMDeleteGroupResource + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!EMDeleteGroupResource.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format("The required field(s) %s in EMDeleteGroupResource is not found in the empty JSON string", EMDeleteGroupResource.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!EMDeleteGroupResource.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `EMDeleteGroupResource` properties. JSON: %s", entry.getKey(), jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + if ((jsonObj.get("groupid") != null && !jsonObj.get("groupid").isJsonNull()) && !jsonObj.get("groupid").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `groupid` to be a primitive type in the JSON string but got `%s`", jsonObj.get("groupid").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!EMDeleteGroupResource.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'EMDeleteGroupResource' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(EMDeleteGroupResource.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, EMDeleteGroupResource value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public EMDeleteGroupResource read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + return thisAdapter.fromJsonTree(jsonElement); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of EMDeleteGroupResource given an JSON string + * + * @param jsonString JSON string + * @return An instance of EMDeleteGroupResource + * @throws IOException if the JSON string is invalid with respect to EMDeleteGroupResource + */ + public static EMDeleteGroupResource fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, EMDeleteGroupResource.class); + } + + /** + * Convert an instance of EMDeleteGroupResource to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/com/easemob/im/api/model/EMDeleteGroupResult.java b/src/main/java/com/easemob/im/api/model/EMDeleteGroupResult.java new file mode 100644 index 000000000..db0f73294 --- /dev/null +++ b/src/main/java/com/easemob/im/api/model/EMDeleteGroupResult.java @@ -0,0 +1,210 @@ +/* + * EMService + * Easemob Rest API + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.easemob.im.api.model; + +import java.util.Objects; +import com.easemob.im.api.model.EMDeleteGroupResource; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.Arrays; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import com.easemob.im.JSON; + +/** + * EMDeleteGroupResult + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-01-25T14:51:53.998371+08:00[Asia/Shanghai]") +public class EMDeleteGroupResult { + public static final String SERIALIZED_NAME_DATA = "data"; + @SerializedName(SERIALIZED_NAME_DATA) + private EMDeleteGroupResource data; + + public EMDeleteGroupResult() { + } + + public EMDeleteGroupResult data(EMDeleteGroupResource data) { + + this.data = data; + return this; + } + + /** + * Get data + * @return data + **/ + @javax.annotation.Nullable + public EMDeleteGroupResource getData() { + return data; + } + + + public void setData(EMDeleteGroupResource data) { + this.data = data; + } + + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + EMDeleteGroupResult deleteGroupResult = (EMDeleteGroupResult) o; + return Objects.equals(this.data, deleteGroupResult.data); + } + + @Override + public int hashCode() { + return Objects.hash(data); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class EMDeleteGroupResult {\n"); + sb.append(" data: ").append(toIndentedString(data)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("data"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to EMDeleteGroupResult + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!EMDeleteGroupResult.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format("The required field(s) %s in EMDeleteGroupResult is not found in the empty JSON string", EMDeleteGroupResult.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!EMDeleteGroupResult.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `EMDeleteGroupResult` properties. JSON: %s", entry.getKey(), jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // validate the optional field `data` + if (jsonObj.get("data") != null && !jsonObj.get("data").isJsonNull()) { + EMDeleteGroupResource.validateJsonElement(jsonObj.get("data")); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!EMDeleteGroupResult.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'EMDeleteGroupResult' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(EMDeleteGroupResult.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, EMDeleteGroupResult value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public EMDeleteGroupResult read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + return thisAdapter.fromJsonTree(jsonElement); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of EMDeleteGroupResult given an JSON string + * + * @param jsonString JSON string + * @return An instance of EMDeleteGroupResult + * @throws IOException if the JSON string is invalid with respect to EMDeleteGroupResult + */ + public static EMDeleteGroupResult fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, EMDeleteGroupResult.class); + } + + /** + * Convert an instance of EMDeleteGroupResult to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/com/easemob/im/api/model/EMDeleteGroupShareFileResource.java b/src/main/java/com/easemob/im/api/model/EMDeleteGroupShareFileResource.java new file mode 100644 index 000000000..445341630 --- /dev/null +++ b/src/main/java/com/easemob/im/api/model/EMDeleteGroupShareFileResource.java @@ -0,0 +1,267 @@ +/* + * EMService + * Easemob Rest API + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.easemob.im.api.model; + +import java.util.Objects; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.Arrays; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import com.easemob.im.JSON; + +/** + * EMDeleteGroupShareFileResource + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-01-25T14:51:53.998371+08:00[Asia/Shanghai]") +public class EMDeleteGroupShareFileResource { + public static final String SERIALIZED_NAME_GROUP_ID = "group_id"; + @SerializedName(SERIALIZED_NAME_GROUP_ID) + private String groupId; + + public static final String SERIALIZED_NAME_FILE_ID = "file_id"; + @SerializedName(SERIALIZED_NAME_FILE_ID) + private String fileId; + + public static final String SERIALIZED_NAME_RESULT = "result"; + @SerializedName(SERIALIZED_NAME_RESULT) + private Boolean result; + + public EMDeleteGroupShareFileResource() { + } + + public EMDeleteGroupShareFileResource groupId(String groupId) { + + this.groupId = groupId; + return this; + } + + /** + * Get groupId + * @return groupId + **/ + @javax.annotation.Nullable + public String getGroupId() { + return groupId; + } + + + public void setGroupId(String groupId) { + this.groupId = groupId; + } + + + public EMDeleteGroupShareFileResource fileId(String fileId) { + + this.fileId = fileId; + return this; + } + + /** + * Get fileId + * @return fileId + **/ + @javax.annotation.Nullable + public String getFileId() { + return fileId; + } + + + public void setFileId(String fileId) { + this.fileId = fileId; + } + + + public EMDeleteGroupShareFileResource result(Boolean result) { + + this.result = result; + return this; + } + + /** + * Get result + * @return result + **/ + @javax.annotation.Nullable + public Boolean getResult() { + return result; + } + + + public void setResult(Boolean result) { + this.result = result; + } + + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + EMDeleteGroupShareFileResource deleteGroupShareFileResource = (EMDeleteGroupShareFileResource) o; + return Objects.equals(this.groupId, deleteGroupShareFileResource.groupId) && + Objects.equals(this.fileId, deleteGroupShareFileResource.fileId) && + Objects.equals(this.result, deleteGroupShareFileResource.result); + } + + @Override + public int hashCode() { + return Objects.hash(groupId, fileId, result); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class EMDeleteGroupShareFileResource {\n"); + sb.append(" groupId: ").append(toIndentedString(groupId)).append("\n"); + sb.append(" fileId: ").append(toIndentedString(fileId)).append("\n"); + sb.append(" result: ").append(toIndentedString(result)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("group_id"); + openapiFields.add("file_id"); + openapiFields.add("result"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to EMDeleteGroupShareFileResource + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!EMDeleteGroupShareFileResource.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format("The required field(s) %s in EMDeleteGroupShareFileResource is not found in the empty JSON string", EMDeleteGroupShareFileResource.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!EMDeleteGroupShareFileResource.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `EMDeleteGroupShareFileResource` properties. JSON: %s", entry.getKey(), jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + if ((jsonObj.get("group_id") != null && !jsonObj.get("group_id").isJsonNull()) && !jsonObj.get("group_id").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `group_id` to be a primitive type in the JSON string but got `%s`", jsonObj.get("group_id").toString())); + } + if ((jsonObj.get("file_id") != null && !jsonObj.get("file_id").isJsonNull()) && !jsonObj.get("file_id").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `file_id` to be a primitive type in the JSON string but got `%s`", jsonObj.get("file_id").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!EMDeleteGroupShareFileResource.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'EMDeleteGroupShareFileResource' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(EMDeleteGroupShareFileResource.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, EMDeleteGroupShareFileResource value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public EMDeleteGroupShareFileResource read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + return thisAdapter.fromJsonTree(jsonElement); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of EMDeleteGroupShareFileResource given an JSON string + * + * @param jsonString JSON string + * @return An instance of EMDeleteGroupShareFileResource + * @throws IOException if the JSON string is invalid with respect to EMDeleteGroupShareFileResource + */ + public static EMDeleteGroupShareFileResource fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, EMDeleteGroupShareFileResource.class); + } + + /** + * Convert an instance of EMDeleteGroupShareFileResource to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/com/easemob/im/api/model/EMDeleteGroupShareFileResult.java b/src/main/java/com/easemob/im/api/model/EMDeleteGroupShareFileResult.java new file mode 100644 index 000000000..7b9b04e60 --- /dev/null +++ b/src/main/java/com/easemob/im/api/model/EMDeleteGroupShareFileResult.java @@ -0,0 +1,210 @@ +/* + * EMService + * Easemob Rest API + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.easemob.im.api.model; + +import java.util.Objects; +import com.easemob.im.api.model.EMDeleteGroupShareFileResource; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.Arrays; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import com.easemob.im.JSON; + +/** + * EMDeleteGroupShareFileResult + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-01-25T14:51:53.998371+08:00[Asia/Shanghai]") +public class EMDeleteGroupShareFileResult { + public static final String SERIALIZED_NAME_DATA = "data"; + @SerializedName(SERIALIZED_NAME_DATA) + private EMDeleteGroupShareFileResource data; + + public EMDeleteGroupShareFileResult() { + } + + public EMDeleteGroupShareFileResult data(EMDeleteGroupShareFileResource data) { + + this.data = data; + return this; + } + + /** + * Get data + * @return data + **/ + @javax.annotation.Nullable + public EMDeleteGroupShareFileResource getData() { + return data; + } + + + public void setData(EMDeleteGroupShareFileResource data) { + this.data = data; + } + + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + EMDeleteGroupShareFileResult deleteGroupShareFileResult = (EMDeleteGroupShareFileResult) o; + return Objects.equals(this.data, deleteGroupShareFileResult.data); + } + + @Override + public int hashCode() { + return Objects.hash(data); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class EMDeleteGroupShareFileResult {\n"); + sb.append(" data: ").append(toIndentedString(data)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("data"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to EMDeleteGroupShareFileResult + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!EMDeleteGroupShareFileResult.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format("The required field(s) %s in EMDeleteGroupShareFileResult is not found in the empty JSON string", EMDeleteGroupShareFileResult.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!EMDeleteGroupShareFileResult.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `EMDeleteGroupShareFileResult` properties. JSON: %s", entry.getKey(), jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // validate the optional field `data` + if (jsonObj.get("data") != null && !jsonObj.get("data").isJsonNull()) { + EMDeleteGroupShareFileResource.validateJsonElement(jsonObj.get("data")); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!EMDeleteGroupShareFileResult.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'EMDeleteGroupShareFileResult' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(EMDeleteGroupShareFileResult.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, EMDeleteGroupShareFileResult value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public EMDeleteGroupShareFileResult read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + return thisAdapter.fromJsonTree(jsonElement); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of EMDeleteGroupShareFileResult given an JSON string + * + * @param jsonString JSON string + * @return An instance of EMDeleteGroupShareFileResult + * @throws IOException if the JSON string is invalid with respect to EMDeleteGroupShareFileResult + */ + public static EMDeleteGroupShareFileResult fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, EMDeleteGroupShareFileResult.class); + } + + /** + * Convert an instance of EMDeleteGroupShareFileResult to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/com/easemob/im/api/model/EMDeleteRoomCustomAttributes.java b/src/main/java/com/easemob/im/api/model/EMDeleteRoomCustomAttributes.java new file mode 100644 index 000000000..97b1e2769 --- /dev/null +++ b/src/main/java/com/easemob/im/api/model/EMDeleteRoomCustomAttributes.java @@ -0,0 +1,219 @@ +/* + * EMService + * Easemob Rest API + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.easemob.im.api.model; + +import java.util.Objects; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import com.easemob.im.JSON; + +/** + * EMDeleteRoomCustomAttributes + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-01-25T14:51:53.998371+08:00[Asia/Shanghai]") +public class EMDeleteRoomCustomAttributes { + public static final String SERIALIZED_NAME_KEYS = "keys"; + @SerializedName(SERIALIZED_NAME_KEYS) + private List keys; + + public EMDeleteRoomCustomAttributes() { + } + + public EMDeleteRoomCustomAttributes keys(List keys) { + + this.keys = keys; + return this; + } + + public EMDeleteRoomCustomAttributes addKeysItem(String keysItem) { + if (this.keys == null) { + this.keys = new ArrayList<>(); + } + this.keys.add(keysItem); + return this; + } + + /** + * 聊天室自定义属性名称列表。每次最多可传 10 个自定义属性名称 + * @return keys + **/ + @javax.annotation.Nullable + public List getKeys() { + return keys; + } + + + public void setKeys(List keys) { + this.keys = keys; + } + + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + EMDeleteRoomCustomAttributes deleteRoomCustomAttributes = (EMDeleteRoomCustomAttributes) o; + return Objects.equals(this.keys, deleteRoomCustomAttributes.keys); + } + + @Override + public int hashCode() { + return Objects.hash(keys); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class EMDeleteRoomCustomAttributes {\n"); + sb.append(" keys: ").append(toIndentedString(keys)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("keys"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to EMDeleteRoomCustomAttributes + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!EMDeleteRoomCustomAttributes.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format("The required field(s) %s in EMDeleteRoomCustomAttributes is not found in the empty JSON string", EMDeleteRoomCustomAttributes.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!EMDeleteRoomCustomAttributes.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `EMDeleteRoomCustomAttributes` properties. JSON: %s", entry.getKey(), jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // ensure the optional json data is an array if present + if (jsonObj.get("keys") != null && !jsonObj.get("keys").isJsonNull() && !jsonObj.get("keys").isJsonArray()) { + throw new IllegalArgumentException(String.format("Expected the field `keys` to be an array in the JSON string but got `%s`", jsonObj.get("keys").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!EMDeleteRoomCustomAttributes.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'EMDeleteRoomCustomAttributes' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(EMDeleteRoomCustomAttributes.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, EMDeleteRoomCustomAttributes value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public EMDeleteRoomCustomAttributes read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + return thisAdapter.fromJsonTree(jsonElement); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of EMDeleteRoomCustomAttributes given an JSON string + * + * @param jsonString JSON string + * @return An instance of EMDeleteRoomCustomAttributes + * @throws IOException if the JSON string is invalid with respect to EMDeleteRoomCustomAttributes + */ + public static EMDeleteRoomCustomAttributes fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, EMDeleteRoomCustomAttributes.class); + } + + /** + * Convert an instance of EMDeleteRoomCustomAttributes to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/com/easemob/im/api/model/EMDeleteRoomCustomAttributesResource.java b/src/main/java/com/easemob/im/api/model/EMDeleteRoomCustomAttributesResource.java new file mode 100644 index 000000000..88aaf6951 --- /dev/null +++ b/src/main/java/com/easemob/im/api/model/EMDeleteRoomCustomAttributesResource.java @@ -0,0 +1,247 @@ +/* + * EMService + * Easemob Rest API + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.easemob.im.api.model; + +import java.util.Objects; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import com.easemob.im.JSON; + +/** + * EMDeleteRoomCustomAttributesResource + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-01-25T14:51:53.998371+08:00[Asia/Shanghai]") +public class EMDeleteRoomCustomAttributesResource { + public static final String SERIALIZED_NAME_SUCCESS_KEYS = "successKeys"; + @SerializedName(SERIALIZED_NAME_SUCCESS_KEYS) + private List successKeys; + + public static final String SERIALIZED_NAME_ERROR_KEYS = "errorKeys"; + @SerializedName(SERIALIZED_NAME_ERROR_KEYS) + private Object errorKeys; + + public EMDeleteRoomCustomAttributesResource() { + } + + public EMDeleteRoomCustomAttributesResource successKeys(List successKeys) { + + this.successKeys = successKeys; + return this; + } + + public EMDeleteRoomCustomAttributesResource addSuccessKeysItem(String successKeysItem) { + if (this.successKeys == null) { + this.successKeys = new ArrayList<>(); + } + this.successKeys.add(successKeysItem); + return this; + } + + /** + * Get successKeys + * @return successKeys + **/ + @javax.annotation.Nullable + public List getSuccessKeys() { + return successKeys; + } + + + public void setSuccessKeys(List successKeys) { + this.successKeys = successKeys; + } + + + public EMDeleteRoomCustomAttributesResource errorKeys(Object errorKeys) { + + this.errorKeys = errorKeys; + return this; + } + + /** + * Get errorKeys + * @return errorKeys + **/ + @javax.annotation.Nullable + public Object getErrorKeys() { + return errorKeys; + } + + + public void setErrorKeys(Object errorKeys) { + this.errorKeys = errorKeys; + } + + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + EMDeleteRoomCustomAttributesResource deleteRoomCustomAttributesResource = (EMDeleteRoomCustomAttributesResource) o; + return Objects.equals(this.successKeys, deleteRoomCustomAttributesResource.successKeys) && + Objects.equals(this.errorKeys, deleteRoomCustomAttributesResource.errorKeys); + } + + @Override + public int hashCode() { + return Objects.hash(successKeys, errorKeys); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class EMDeleteRoomCustomAttributesResource {\n"); + sb.append(" successKeys: ").append(toIndentedString(successKeys)).append("\n"); + sb.append(" errorKeys: ").append(toIndentedString(errorKeys)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("successKeys"); + openapiFields.add("errorKeys"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to EMDeleteRoomCustomAttributesResource + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!EMDeleteRoomCustomAttributesResource.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format("The required field(s) %s in EMDeleteRoomCustomAttributesResource is not found in the empty JSON string", EMDeleteRoomCustomAttributesResource.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!EMDeleteRoomCustomAttributesResource.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `EMDeleteRoomCustomAttributesResource` properties. JSON: %s", entry.getKey(), jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // ensure the optional json data is an array if present + if (jsonObj.get("successKeys") != null && !jsonObj.get("successKeys").isJsonNull() && !jsonObj.get("successKeys").isJsonArray()) { + throw new IllegalArgumentException(String.format("Expected the field `successKeys` to be an array in the JSON string but got `%s`", jsonObj.get("successKeys").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!EMDeleteRoomCustomAttributesResource.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'EMDeleteRoomCustomAttributesResource' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(EMDeleteRoomCustomAttributesResource.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, EMDeleteRoomCustomAttributesResource value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public EMDeleteRoomCustomAttributesResource read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + return thisAdapter.fromJsonTree(jsonElement); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of EMDeleteRoomCustomAttributesResource given an JSON string + * + * @param jsonString JSON string + * @return An instance of EMDeleteRoomCustomAttributesResource + * @throws IOException if the JSON string is invalid with respect to EMDeleteRoomCustomAttributesResource + */ + public static EMDeleteRoomCustomAttributesResource fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, EMDeleteRoomCustomAttributesResource.class); + } + + /** + * Convert an instance of EMDeleteRoomCustomAttributesResource to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/com/easemob/im/api/model/EMDeleteRoomCustomAttributesResult.java b/src/main/java/com/easemob/im/api/model/EMDeleteRoomCustomAttributesResult.java new file mode 100644 index 000000000..e6bfaf315 --- /dev/null +++ b/src/main/java/com/easemob/im/api/model/EMDeleteRoomCustomAttributesResult.java @@ -0,0 +1,210 @@ +/* + * EMService + * Easemob Rest API + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.easemob.im.api.model; + +import java.util.Objects; +import com.easemob.im.api.model.EMDeleteRoomCustomAttributesResource; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.Arrays; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import com.easemob.im.JSON; + +/** + * EMDeleteRoomCustomAttributesResult + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-01-25T14:51:53.998371+08:00[Asia/Shanghai]") +public class EMDeleteRoomCustomAttributesResult { + public static final String SERIALIZED_NAME_DATA = "data"; + @SerializedName(SERIALIZED_NAME_DATA) + private EMDeleteRoomCustomAttributesResource data; + + public EMDeleteRoomCustomAttributesResult() { + } + + public EMDeleteRoomCustomAttributesResult data(EMDeleteRoomCustomAttributesResource data) { + + this.data = data; + return this; + } + + /** + * Get data + * @return data + **/ + @javax.annotation.Nullable + public EMDeleteRoomCustomAttributesResource getData() { + return data; + } + + + public void setData(EMDeleteRoomCustomAttributesResource data) { + this.data = data; + } + + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + EMDeleteRoomCustomAttributesResult deleteRoomCustomAttributesResult = (EMDeleteRoomCustomAttributesResult) o; + return Objects.equals(this.data, deleteRoomCustomAttributesResult.data); + } + + @Override + public int hashCode() { + return Objects.hash(data); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class EMDeleteRoomCustomAttributesResult {\n"); + sb.append(" data: ").append(toIndentedString(data)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("data"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to EMDeleteRoomCustomAttributesResult + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!EMDeleteRoomCustomAttributesResult.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format("The required field(s) %s in EMDeleteRoomCustomAttributesResult is not found in the empty JSON string", EMDeleteRoomCustomAttributesResult.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!EMDeleteRoomCustomAttributesResult.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `EMDeleteRoomCustomAttributesResult` properties. JSON: %s", entry.getKey(), jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // validate the optional field `data` + if (jsonObj.get("data") != null && !jsonObj.get("data").isJsonNull()) { + EMDeleteRoomCustomAttributesResource.validateJsonElement(jsonObj.get("data")); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!EMDeleteRoomCustomAttributesResult.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'EMDeleteRoomCustomAttributesResult' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(EMDeleteRoomCustomAttributesResult.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, EMDeleteRoomCustomAttributesResult value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public EMDeleteRoomCustomAttributesResult read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + return thisAdapter.fromJsonTree(jsonElement); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of EMDeleteRoomCustomAttributesResult given an JSON string + * + * @param jsonString JSON string + * @return An instance of EMDeleteRoomCustomAttributesResult + * @throws IOException if the JSON string is invalid with respect to EMDeleteRoomCustomAttributesResult + */ + public static EMDeleteRoomCustomAttributesResult fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, EMDeleteRoomCustomAttributesResult.class); + } + + /** + * Convert an instance of EMDeleteRoomCustomAttributesResult to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/com/easemob/im/api/model/EMDeleteRoomResource.java b/src/main/java/com/easemob/im/api/model/EMDeleteRoomResource.java new file mode 100644 index 000000000..1267a06e9 --- /dev/null +++ b/src/main/java/com/easemob/im/api/model/EMDeleteRoomResource.java @@ -0,0 +1,205 @@ +/* + * EMService + * Easemob Rest API + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.easemob.im.api.model; + +import java.util.Objects; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.Arrays; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import com.easemob.im.JSON; + +/** + * EMDeleteRoomResource + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-01-25T14:51:53.998371+08:00[Asia/Shanghai]") +public class EMDeleteRoomResource { + public static final String SERIALIZED_NAME_SUCCESS = "success"; + @SerializedName(SERIALIZED_NAME_SUCCESS) + private Boolean success; + + public EMDeleteRoomResource() { + } + + public EMDeleteRoomResource success(Boolean success) { + + this.success = success; + return this; + } + + /** + * Get success + * @return success + **/ + @javax.annotation.Nullable + public Boolean getSuccess() { + return success; + } + + + public void setSuccess(Boolean success) { + this.success = success; + } + + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + EMDeleteRoomResource deleteRoomResource = (EMDeleteRoomResource) o; + return Objects.equals(this.success, deleteRoomResource.success); + } + + @Override + public int hashCode() { + return Objects.hash(success); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class EMDeleteRoomResource {\n"); + sb.append(" success: ").append(toIndentedString(success)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("success"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to EMDeleteRoomResource + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!EMDeleteRoomResource.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format("The required field(s) %s in EMDeleteRoomResource is not found in the empty JSON string", EMDeleteRoomResource.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!EMDeleteRoomResource.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `EMDeleteRoomResource` properties. JSON: %s", entry.getKey(), jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!EMDeleteRoomResource.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'EMDeleteRoomResource' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(EMDeleteRoomResource.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, EMDeleteRoomResource value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public EMDeleteRoomResource read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + return thisAdapter.fromJsonTree(jsonElement); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of EMDeleteRoomResource given an JSON string + * + * @param jsonString JSON string + * @return An instance of EMDeleteRoomResource + * @throws IOException if the JSON string is invalid with respect to EMDeleteRoomResource + */ + public static EMDeleteRoomResource fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, EMDeleteRoomResource.class); + } + + /** + * Convert an instance of EMDeleteRoomResource to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/com/easemob/im/api/model/EMDeleteRoomResult.java b/src/main/java/com/easemob/im/api/model/EMDeleteRoomResult.java new file mode 100644 index 000000000..22e6d2e41 --- /dev/null +++ b/src/main/java/com/easemob/im/api/model/EMDeleteRoomResult.java @@ -0,0 +1,210 @@ +/* + * EMService + * Easemob Rest API + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.easemob.im.api.model; + +import java.util.Objects; +import com.easemob.im.api.model.EMDeleteRoomResource; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.Arrays; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import com.easemob.im.JSON; + +/** + * EMDeleteRoomResult + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-01-25T14:51:53.998371+08:00[Asia/Shanghai]") +public class EMDeleteRoomResult { + public static final String SERIALIZED_NAME_DATA = "data"; + @SerializedName(SERIALIZED_NAME_DATA) + private EMDeleteRoomResource data; + + public EMDeleteRoomResult() { + } + + public EMDeleteRoomResult data(EMDeleteRoomResource data) { + + this.data = data; + return this; + } + + /** + * Get data + * @return data + **/ + @javax.annotation.Nullable + public EMDeleteRoomResource getData() { + return data; + } + + + public void setData(EMDeleteRoomResource data) { + this.data = data; + } + + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + EMDeleteRoomResult deleteRoomResult = (EMDeleteRoomResult) o; + return Objects.equals(this.data, deleteRoomResult.data); + } + + @Override + public int hashCode() { + return Objects.hash(data); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class EMDeleteRoomResult {\n"); + sb.append(" data: ").append(toIndentedString(data)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("data"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to EMDeleteRoomResult + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!EMDeleteRoomResult.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format("The required field(s) %s in EMDeleteRoomResult is not found in the empty JSON string", EMDeleteRoomResult.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!EMDeleteRoomResult.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `EMDeleteRoomResult` properties. JSON: %s", entry.getKey(), jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // validate the optional field `data` + if (jsonObj.get("data") != null && !jsonObj.get("data").isJsonNull()) { + EMDeleteRoomResource.validateJsonElement(jsonObj.get("data")); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!EMDeleteRoomResult.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'EMDeleteRoomResult' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(EMDeleteRoomResult.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, EMDeleteRoomResult value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public EMDeleteRoomResult read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + return thisAdapter.fromJsonTree(jsonElement); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of EMDeleteRoomResult given an JSON string + * + * @param jsonString JSON string + * @return An instance of EMDeleteRoomResult + * @throws IOException if the JSON string is invalid with respect to EMDeleteRoomResult + */ + public static EMDeleteRoomResult fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, EMDeleteRoomResult.class); + } + + /** + * Convert an instance of EMDeleteRoomResult to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/com/easemob/im/api/model/EMDeleteThreadResource.java b/src/main/java/com/easemob/im/api/model/EMDeleteThreadResource.java new file mode 100644 index 000000000..36d1264c5 --- /dev/null +++ b/src/main/java/com/easemob/im/api/model/EMDeleteThreadResource.java @@ -0,0 +1,208 @@ +/* + * EMService + * Easemob Rest API + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.easemob.im.api.model; + +import java.util.Objects; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.Arrays; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import com.easemob.im.JSON; + +/** + * EMDeleteThreadResource + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-01-25T14:51:53.998371+08:00[Asia/Shanghai]") +public class EMDeleteThreadResource { + public static final String SERIALIZED_NAME_STATUS = "status"; + @SerializedName(SERIALIZED_NAME_STATUS) + private String status; + + public EMDeleteThreadResource() { + } + + public EMDeleteThreadResource status(String status) { + + this.status = status; + return this; + } + + /** + * Get status + * @return status + **/ + @javax.annotation.Nullable + public String getStatus() { + return status; + } + + + public void setStatus(String status) { + this.status = status; + } + + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + EMDeleteThreadResource deleteThreadResource = (EMDeleteThreadResource) o; + return Objects.equals(this.status, deleteThreadResource.status); + } + + @Override + public int hashCode() { + return Objects.hash(status); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class EMDeleteThreadResource {\n"); + sb.append(" status: ").append(toIndentedString(status)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("status"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to EMDeleteThreadResource + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!EMDeleteThreadResource.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format("The required field(s) %s in EMDeleteThreadResource is not found in the empty JSON string", EMDeleteThreadResource.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!EMDeleteThreadResource.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `EMDeleteThreadResource` properties. JSON: %s", entry.getKey(), jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + if ((jsonObj.get("status") != null && !jsonObj.get("status").isJsonNull()) && !jsonObj.get("status").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `status` to be a primitive type in the JSON string but got `%s`", jsonObj.get("status").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!EMDeleteThreadResource.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'EMDeleteThreadResource' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(EMDeleteThreadResource.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, EMDeleteThreadResource value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public EMDeleteThreadResource read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + return thisAdapter.fromJsonTree(jsonElement); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of EMDeleteThreadResource given an JSON string + * + * @param jsonString JSON string + * @return An instance of EMDeleteThreadResource + * @throws IOException if the JSON string is invalid with respect to EMDeleteThreadResource + */ + public static EMDeleteThreadResource fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, EMDeleteThreadResource.class); + } + + /** + * Convert an instance of EMDeleteThreadResource to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/com/easemob/im/api/model/EMDeleteThreadResult.java b/src/main/java/com/easemob/im/api/model/EMDeleteThreadResult.java new file mode 100644 index 000000000..93886f8a1 --- /dev/null +++ b/src/main/java/com/easemob/im/api/model/EMDeleteThreadResult.java @@ -0,0 +1,210 @@ +/* + * EMService + * Easemob Rest API + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.easemob.im.api.model; + +import java.util.Objects; +import com.easemob.im.api.model.EMDeleteThreadResource; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.Arrays; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import com.easemob.im.JSON; + +/** + * EMDeleteThreadResult + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-01-25T14:51:53.998371+08:00[Asia/Shanghai]") +public class EMDeleteThreadResult { + public static final String SERIALIZED_NAME_DATA = "data"; + @SerializedName(SERIALIZED_NAME_DATA) + private EMDeleteThreadResource data; + + public EMDeleteThreadResult() { + } + + public EMDeleteThreadResult data(EMDeleteThreadResource data) { + + this.data = data; + return this; + } + + /** + * Get data + * @return data + **/ + @javax.annotation.Nullable + public EMDeleteThreadResource getData() { + return data; + } + + + public void setData(EMDeleteThreadResource data) { + this.data = data; + } + + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + EMDeleteThreadResult deleteThreadResult = (EMDeleteThreadResult) o; + return Objects.equals(this.data, deleteThreadResult.data); + } + + @Override + public int hashCode() { + return Objects.hash(data); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class EMDeleteThreadResult {\n"); + sb.append(" data: ").append(toIndentedString(data)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("data"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to EMDeleteThreadResult + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!EMDeleteThreadResult.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format("The required field(s) %s in EMDeleteThreadResult is not found in the empty JSON string", EMDeleteThreadResult.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!EMDeleteThreadResult.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `EMDeleteThreadResult` properties. JSON: %s", entry.getKey(), jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // validate the optional field `data` + if (jsonObj.get("data") != null && !jsonObj.get("data").isJsonNull()) { + EMDeleteThreadResource.validateJsonElement(jsonObj.get("data")); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!EMDeleteThreadResult.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'EMDeleteThreadResult' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(EMDeleteThreadResult.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, EMDeleteThreadResult value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public EMDeleteThreadResult read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + return thisAdapter.fromJsonTree(jsonElement); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of EMDeleteThreadResult given an JSON string + * + * @param jsonString JSON string + * @return An instance of EMDeleteThreadResult + * @throws IOException if the JSON string is invalid with respect to EMDeleteThreadResult + */ + public static EMDeleteThreadResult fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, EMDeleteThreadResult.class); + } + + /** + * Convert an instance of EMDeleteThreadResult to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/com/easemob/im/api/model/EMDeleteUserMetadataResult.java b/src/main/java/com/easemob/im/api/model/EMDeleteUserMetadataResult.java new file mode 100644 index 000000000..bd3f78d63 --- /dev/null +++ b/src/main/java/com/easemob/im/api/model/EMDeleteUserMetadataResult.java @@ -0,0 +1,205 @@ +/* + * EMService + * Easemob Rest API + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.easemob.im.api.model; + +import java.util.Objects; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.Arrays; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import com.easemob.im.JSON; + +/** + * EMDeleteUserMetadataResult + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-01-25T14:51:53.998371+08:00[Asia/Shanghai]") +public class EMDeleteUserMetadataResult { + public static final String SERIALIZED_NAME_DATA = "data"; + @SerializedName(SERIALIZED_NAME_DATA) + private Boolean data; + + public EMDeleteUserMetadataResult() { + } + + public EMDeleteUserMetadataResult data(Boolean data) { + + this.data = data; + return this; + } + + /** + * Get data + * @return data + **/ + @javax.annotation.Nullable + public Boolean getData() { + return data; + } + + + public void setData(Boolean data) { + this.data = data; + } + + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + EMDeleteUserMetadataResult deleteUserMetadataResult = (EMDeleteUserMetadataResult) o; + return Objects.equals(this.data, deleteUserMetadataResult.data); + } + + @Override + public int hashCode() { + return Objects.hash(data); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class EMDeleteUserMetadataResult {\n"); + sb.append(" data: ").append(toIndentedString(data)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("data"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to EMDeleteUserMetadataResult + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!EMDeleteUserMetadataResult.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format("The required field(s) %s in EMDeleteUserMetadataResult is not found in the empty JSON string", EMDeleteUserMetadataResult.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!EMDeleteUserMetadataResult.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `EMDeleteUserMetadataResult` properties. JSON: %s", entry.getKey(), jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!EMDeleteUserMetadataResult.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'EMDeleteUserMetadataResult' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(EMDeleteUserMetadataResult.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, EMDeleteUserMetadataResult value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public EMDeleteUserMetadataResult read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + return thisAdapter.fromJsonTree(jsonElement); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of EMDeleteUserMetadataResult given an JSON string + * + * @param jsonString JSON string + * @return An instance of EMDeleteUserMetadataResult + * @throws IOException if the JSON string is invalid with respect to EMDeleteUserMetadataResult + */ + public static EMDeleteUserMetadataResult fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, EMDeleteUserMetadataResult.class); + } + + /** + * Convert an instance of EMDeleteUserMetadataResult to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/com/easemob/im/api/model/EMDeleteUserResult.java b/src/main/java/com/easemob/im/api/model/EMDeleteUserResult.java new file mode 100644 index 000000000..a8f3a14a4 --- /dev/null +++ b/src/main/java/com/easemob/im/api/model/EMDeleteUserResult.java @@ -0,0 +1,230 @@ +/* + * EMService + * Easemob Rest API + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.easemob.im.api.model; + +import java.util.Objects; +import com.easemob.im.api.model.EMUserResource; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import com.easemob.im.JSON; + +/** + * EMDeleteUserResult + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-01-25T14:51:53.998371+08:00[Asia/Shanghai]") +public class EMDeleteUserResult { + public static final String SERIALIZED_NAME_ENTITIES = "entities"; + @SerializedName(SERIALIZED_NAME_ENTITIES) + private List entities; + + public EMDeleteUserResult() { + } + + public EMDeleteUserResult entities(List entities) { + + this.entities = entities; + return this; + } + + public EMDeleteUserResult addEntitiesItem(EMUserResource entitiesItem) { + if (this.entities == null) { + this.entities = new ArrayList<>(); + } + this.entities.add(entitiesItem); + return this; + } + + /** + * Get entities + * @return entities + **/ + @javax.annotation.Nullable + public List getEntities() { + return entities; + } + + + public void setEntities(List entities) { + this.entities = entities; + } + + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + EMDeleteUserResult deleteUserResult = (EMDeleteUserResult) o; + return Objects.equals(this.entities, deleteUserResult.entities); + } + + @Override + public int hashCode() { + return Objects.hash(entities); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class EMDeleteUserResult {\n"); + sb.append(" entities: ").append(toIndentedString(entities)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("entities"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to EMDeleteUserResult + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!EMDeleteUserResult.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format("The required field(s) %s in EMDeleteUserResult is not found in the empty JSON string", EMDeleteUserResult.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!EMDeleteUserResult.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `EMDeleteUserResult` properties. JSON: %s", entry.getKey(), jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + if (jsonObj.get("entities") != null && !jsonObj.get("entities").isJsonNull()) { + JsonArray jsonArrayentities = jsonObj.getAsJsonArray("entities"); + if (jsonArrayentities != null) { + // ensure the json data is an array + if (!jsonObj.get("entities").isJsonArray()) { + throw new IllegalArgumentException(String.format("Expected the field `entities` to be an array in the JSON string but got `%s`", jsonObj.get("entities").toString())); + } + + // validate the optional field `entities` (array) + for (int i = 0; i < jsonArrayentities.size(); i++) { + EMUserResource.validateJsonElement(jsonArrayentities.get(i)); + }; + } + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!EMDeleteUserResult.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'EMDeleteUserResult' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(EMDeleteUserResult.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, EMDeleteUserResult value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public EMDeleteUserResult read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + return thisAdapter.fromJsonTree(jsonElement); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of EMDeleteUserResult given an JSON string + * + * @param jsonString JSON string + * @return An instance of EMDeleteUserResult + * @throws IOException if the JSON string is invalid with respect to EMDeleteUserResult + */ + public static EMDeleteUserResult fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, EMDeleteUserResult.class); + } + + /** + * Convert an instance of EMDeleteUserResult to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/com/easemob/im/api/model/EMDeleteUsersResult.java b/src/main/java/com/easemob/im/api/model/EMDeleteUsersResult.java new file mode 100644 index 000000000..5e6c2d5fa --- /dev/null +++ b/src/main/java/com/easemob/im/api/model/EMDeleteUsersResult.java @@ -0,0 +1,261 @@ +/* + * EMService + * Easemob Rest API + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.easemob.im.api.model; + +import java.util.Objects; +import com.easemob.im.api.model.EMUserResource; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import com.easemob.im.JSON; + +/** + * EMDeleteUsersResult + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-01-25T14:51:53.998371+08:00[Asia/Shanghai]") +public class EMDeleteUsersResult { + public static final String SERIALIZED_NAME_ENTITIES = "entities"; + @SerializedName(SERIALIZED_NAME_ENTITIES) + private List entities; + + public static final String SERIALIZED_NAME_CURSOR = "cursor"; + @SerializedName(SERIALIZED_NAME_CURSOR) + private String cursor; + + public EMDeleteUsersResult() { + } + + public EMDeleteUsersResult entities(List entities) { + + this.entities = entities; + return this; + } + + public EMDeleteUsersResult addEntitiesItem(EMUserResource entitiesItem) { + if (this.entities == null) { + this.entities = new ArrayList<>(); + } + this.entities.add(entitiesItem); + return this; + } + + /** + * Get entities + * @return entities + **/ + @javax.annotation.Nullable + public List getEntities() { + return entities; + } + + + public void setEntities(List entities) { + this.entities = entities; + } + + + public EMDeleteUsersResult cursor(String cursor) { + + this.cursor = cursor; + return this; + } + + /** + * Get cursor + * @return cursor + **/ + @javax.annotation.Nullable + public String getCursor() { + return cursor; + } + + + public void setCursor(String cursor) { + this.cursor = cursor; + } + + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + EMDeleteUsersResult deleteUsersResult = (EMDeleteUsersResult) o; + return Objects.equals(this.entities, deleteUsersResult.entities) && + Objects.equals(this.cursor, deleteUsersResult.cursor); + } + + @Override + public int hashCode() { + return Objects.hash(entities, cursor); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class EMDeleteUsersResult {\n"); + sb.append(" entities: ").append(toIndentedString(entities)).append("\n"); + sb.append(" cursor: ").append(toIndentedString(cursor)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("entities"); + openapiFields.add("cursor"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to EMDeleteUsersResult + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!EMDeleteUsersResult.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format("The required field(s) %s in EMDeleteUsersResult is not found in the empty JSON string", EMDeleteUsersResult.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!EMDeleteUsersResult.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `EMDeleteUsersResult` properties. JSON: %s", entry.getKey(), jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + if (jsonObj.get("entities") != null && !jsonObj.get("entities").isJsonNull()) { + JsonArray jsonArrayentities = jsonObj.getAsJsonArray("entities"); + if (jsonArrayentities != null) { + // ensure the json data is an array + if (!jsonObj.get("entities").isJsonArray()) { + throw new IllegalArgumentException(String.format("Expected the field `entities` to be an array in the JSON string but got `%s`", jsonObj.get("entities").toString())); + } + + // validate the optional field `entities` (array) + for (int i = 0; i < jsonArrayentities.size(); i++) { + EMUserResource.validateJsonElement(jsonArrayentities.get(i)); + }; + } + } + if ((jsonObj.get("cursor") != null && !jsonObj.get("cursor").isJsonNull()) && !jsonObj.get("cursor").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `cursor` to be a primitive type in the JSON string but got `%s`", jsonObj.get("cursor").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!EMDeleteUsersResult.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'EMDeleteUsersResult' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(EMDeleteUsersResult.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, EMDeleteUsersResult value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public EMDeleteUsersResult read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + return thisAdapter.fromJsonTree(jsonElement); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of EMDeleteUsersResult given an JSON string + * + * @param jsonString JSON string + * @return An instance of EMDeleteUsersResult + * @throws IOException if the JSON string is invalid with respect to EMDeleteUsersResult + */ + public static EMDeleteUsersResult fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, EMDeleteUsersResult.class); + } + + /** + * Convert an instance of EMDeleteUsersResult to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/com/easemob/im/api/model/EMDeviceResource.java b/src/main/java/com/easemob/im/api/model/EMDeviceResource.java new file mode 100644 index 000000000..f81f1d290 --- /dev/null +++ b/src/main/java/com/easemob/im/api/model/EMDeviceResource.java @@ -0,0 +1,270 @@ +/* + * EMService + * Easemob Rest API + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.easemob.im.api.model; + +import java.util.Objects; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.Arrays; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import com.easemob.im.JSON; + +/** + * EMDeviceResource + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-01-25T14:51:53.998371+08:00[Asia/Shanghai]") +public class EMDeviceResource { + public static final String SERIALIZED_NAME_RES = "res"; + @SerializedName(SERIALIZED_NAME_RES) + private String res; + + public static final String SERIALIZED_NAME_DEVICE_UUID = "device_uuid"; + @SerializedName(SERIALIZED_NAME_DEVICE_UUID) + private String deviceUuid; + + public static final String SERIALIZED_NAME_DEVICE_NAME = "device_name"; + @SerializedName(SERIALIZED_NAME_DEVICE_NAME) + private String deviceName; + + public EMDeviceResource() { + } + + public EMDeviceResource res(String res) { + + this.res = res; + return this; + } + + /** + * 已登录设备的资源 ID,即服务器分配给每个设备资源的唯一标识符 + * @return res + **/ + @javax.annotation.Nullable + public String getRes() { + return res; + } + + + public void setRes(String res) { + this.res = res; + } + + + public EMDeviceResource deviceUuid(String deviceUuid) { + + this.deviceUuid = deviceUuid; + return this; + } + + /** + * 已登录设备的 UUID + * @return deviceUuid + **/ + @javax.annotation.Nullable + public String getDeviceUuid() { + return deviceUuid; + } + + + public void setDeviceUuid(String deviceUuid) { + this.deviceUuid = deviceUuid; + } + + + public EMDeviceResource deviceName(String deviceName) { + + this.deviceName = deviceName; + return this; + } + + /** + * 已登录设备的名称 + * @return deviceName + **/ + @javax.annotation.Nullable + public String getDeviceName() { + return deviceName; + } + + + public void setDeviceName(String deviceName) { + this.deviceName = deviceName; + } + + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + EMDeviceResource deviceResource = (EMDeviceResource) o; + return Objects.equals(this.res, deviceResource.res) && + Objects.equals(this.deviceUuid, deviceResource.deviceUuid) && + Objects.equals(this.deviceName, deviceResource.deviceName); + } + + @Override + public int hashCode() { + return Objects.hash(res, deviceUuid, deviceName); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class EMDeviceResource {\n"); + sb.append(" res: ").append(toIndentedString(res)).append("\n"); + sb.append(" deviceUuid: ").append(toIndentedString(deviceUuid)).append("\n"); + sb.append(" deviceName: ").append(toIndentedString(deviceName)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("res"); + openapiFields.add("device_uuid"); + openapiFields.add("device_name"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to EMDeviceResource + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!EMDeviceResource.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format("The required field(s) %s in EMDeviceResource is not found in the empty JSON string", EMDeviceResource.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!EMDeviceResource.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `EMDeviceResource` properties. JSON: %s", entry.getKey(), jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + if ((jsonObj.get("res") != null && !jsonObj.get("res").isJsonNull()) && !jsonObj.get("res").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `res` to be a primitive type in the JSON string but got `%s`", jsonObj.get("res").toString())); + } + if ((jsonObj.get("device_uuid") != null && !jsonObj.get("device_uuid").isJsonNull()) && !jsonObj.get("device_uuid").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `device_uuid` to be a primitive type in the JSON string but got `%s`", jsonObj.get("device_uuid").toString())); + } + if ((jsonObj.get("device_name") != null && !jsonObj.get("device_name").isJsonNull()) && !jsonObj.get("device_name").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `device_name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("device_name").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!EMDeviceResource.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'EMDeviceResource' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(EMDeviceResource.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, EMDeviceResource value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public EMDeviceResource read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + return thisAdapter.fromJsonTree(jsonElement); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of EMDeviceResource given an JSON string + * + * @param jsonString JSON string + * @return An instance of EMDeviceResource + * @throws IOException if the JSON string is invalid with respect to EMDeviceResource + */ + public static EMDeviceResource fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, EMDeviceResource.class); + } + + /** + * Convert an instance of EMDeviceResource to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/com/easemob/im/api/model/EMDisableGroupResource.java b/src/main/java/com/easemob/im/api/model/EMDisableGroupResource.java new file mode 100644 index 000000000..9577dca7f --- /dev/null +++ b/src/main/java/com/easemob/im/api/model/EMDisableGroupResource.java @@ -0,0 +1,205 @@ +/* + * EMService + * Easemob Rest API + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.easemob.im.api.model; + +import java.util.Objects; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.Arrays; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import com.easemob.im.JSON; + +/** + * EMDisableGroupResource + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-01-25T14:51:53.998371+08:00[Asia/Shanghai]") +public class EMDisableGroupResource { + public static final String SERIALIZED_NAME_DISABLED = "disabled"; + @SerializedName(SERIALIZED_NAME_DISABLED) + private Boolean disabled; + + public EMDisableGroupResource() { + } + + public EMDisableGroupResource disabled(Boolean disabled) { + + this.disabled = disabled; + return this; + } + + /** + * Get disabled + * @return disabled + **/ + @javax.annotation.Nullable + public Boolean getDisabled() { + return disabled; + } + + + public void setDisabled(Boolean disabled) { + this.disabled = disabled; + } + + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + EMDisableGroupResource disableGroupResource = (EMDisableGroupResource) o; + return Objects.equals(this.disabled, disableGroupResource.disabled); + } + + @Override + public int hashCode() { + return Objects.hash(disabled); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class EMDisableGroupResource {\n"); + sb.append(" disabled: ").append(toIndentedString(disabled)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("disabled"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to EMDisableGroupResource + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!EMDisableGroupResource.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format("The required field(s) %s in EMDisableGroupResource is not found in the empty JSON string", EMDisableGroupResource.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!EMDisableGroupResource.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `EMDisableGroupResource` properties. JSON: %s", entry.getKey(), jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!EMDisableGroupResource.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'EMDisableGroupResource' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(EMDisableGroupResource.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, EMDisableGroupResource value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public EMDisableGroupResource read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + return thisAdapter.fromJsonTree(jsonElement); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of EMDisableGroupResource given an JSON string + * + * @param jsonString JSON string + * @return An instance of EMDisableGroupResource + * @throws IOException if the JSON string is invalid with respect to EMDisableGroupResource + */ + public static EMDisableGroupResource fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, EMDisableGroupResource.class); + } + + /** + * Convert an instance of EMDisableGroupResource to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/com/easemob/im/api/model/EMDisableGroupResult.java b/src/main/java/com/easemob/im/api/model/EMDisableGroupResult.java new file mode 100644 index 000000000..bb912ba66 --- /dev/null +++ b/src/main/java/com/easemob/im/api/model/EMDisableGroupResult.java @@ -0,0 +1,210 @@ +/* + * EMService + * Easemob Rest API + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.easemob.im.api.model; + +import java.util.Objects; +import com.easemob.im.api.model.EMDisableGroupResource; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.Arrays; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import com.easemob.im.JSON; + +/** + * EMDisableGroupResult + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-01-25T14:51:53.998371+08:00[Asia/Shanghai]") +public class EMDisableGroupResult { + public static final String SERIALIZED_NAME_DATA = "data"; + @SerializedName(SERIALIZED_NAME_DATA) + private EMDisableGroupResource data; + + public EMDisableGroupResult() { + } + + public EMDisableGroupResult data(EMDisableGroupResource data) { + + this.data = data; + return this; + } + + /** + * Get data + * @return data + **/ + @javax.annotation.Nullable + public EMDisableGroupResource getData() { + return data; + } + + + public void setData(EMDisableGroupResource data) { + this.data = data; + } + + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + EMDisableGroupResult disableGroupResult = (EMDisableGroupResult) o; + return Objects.equals(this.data, disableGroupResult.data); + } + + @Override + public int hashCode() { + return Objects.hash(data); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class EMDisableGroupResult {\n"); + sb.append(" data: ").append(toIndentedString(data)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("data"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to EMDisableGroupResult + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!EMDisableGroupResult.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format("The required field(s) %s in EMDisableGroupResult is not found in the empty JSON string", EMDisableGroupResult.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!EMDisableGroupResult.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `EMDisableGroupResult` properties. JSON: %s", entry.getKey(), jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // validate the optional field `data` + if (jsonObj.get("data") != null && !jsonObj.get("data").isJsonNull()) { + EMDisableGroupResource.validateJsonElement(jsonObj.get("data")); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!EMDisableGroupResult.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'EMDisableGroupResult' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(EMDisableGroupResult.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, EMDisableGroupResult value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public EMDisableGroupResult read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + return thisAdapter.fromJsonTree(jsonElement); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of EMDisableGroupResult given an JSON string + * + * @param jsonString JSON string + * @return An instance of EMDisableGroupResult + * @throws IOException if the JSON string is invalid with respect to EMDisableGroupResult + */ + public static EMDisableGroupResult fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, EMDisableGroupResult.class); + } + + /** + * Convert an instance of EMDisableGroupResult to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/com/easemob/im/api/model/EMEnableGroupResource.java b/src/main/java/com/easemob/im/api/model/EMEnableGroupResource.java new file mode 100644 index 000000000..514c60122 --- /dev/null +++ b/src/main/java/com/easemob/im/api/model/EMEnableGroupResource.java @@ -0,0 +1,205 @@ +/* + * EMService + * Easemob Rest API + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.easemob.im.api.model; + +import java.util.Objects; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.Arrays; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import com.easemob.im.JSON; + +/** + * EMEnableGroupResource + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-01-25T14:51:53.998371+08:00[Asia/Shanghai]") +public class EMEnableGroupResource { + public static final String SERIALIZED_NAME_DISABLED = "disabled"; + @SerializedName(SERIALIZED_NAME_DISABLED) + private Boolean disabled; + + public EMEnableGroupResource() { + } + + public EMEnableGroupResource disabled(Boolean disabled) { + + this.disabled = disabled; + return this; + } + + /** + * Get disabled + * @return disabled + **/ + @javax.annotation.Nullable + public Boolean getDisabled() { + return disabled; + } + + + public void setDisabled(Boolean disabled) { + this.disabled = disabled; + } + + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + EMEnableGroupResource enableGroupResource = (EMEnableGroupResource) o; + return Objects.equals(this.disabled, enableGroupResource.disabled); + } + + @Override + public int hashCode() { + return Objects.hash(disabled); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class EMEnableGroupResource {\n"); + sb.append(" disabled: ").append(toIndentedString(disabled)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("disabled"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to EMEnableGroupResource + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!EMEnableGroupResource.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format("The required field(s) %s in EMEnableGroupResource is not found in the empty JSON string", EMEnableGroupResource.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!EMEnableGroupResource.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `EMEnableGroupResource` properties. JSON: %s", entry.getKey(), jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!EMEnableGroupResource.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'EMEnableGroupResource' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(EMEnableGroupResource.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, EMEnableGroupResource value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public EMEnableGroupResource read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + return thisAdapter.fromJsonTree(jsonElement); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of EMEnableGroupResource given an JSON string + * + * @param jsonString JSON string + * @return An instance of EMEnableGroupResource + * @throws IOException if the JSON string is invalid with respect to EMEnableGroupResource + */ + public static EMEnableGroupResource fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, EMEnableGroupResource.class); + } + + /** + * Convert an instance of EMEnableGroupResource to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/com/easemob/im/api/model/EMEnableGroupResult.java b/src/main/java/com/easemob/im/api/model/EMEnableGroupResult.java new file mode 100644 index 000000000..3f56b43f2 --- /dev/null +++ b/src/main/java/com/easemob/im/api/model/EMEnableGroupResult.java @@ -0,0 +1,210 @@ +/* + * EMService + * Easemob Rest API + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.easemob.im.api.model; + +import java.util.Objects; +import com.easemob.im.api.model.EMEnableGroupResource; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.Arrays; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import com.easemob.im.JSON; + +/** + * EMEnableGroupResult + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-01-25T14:51:53.998371+08:00[Asia/Shanghai]") +public class EMEnableGroupResult { + public static final String SERIALIZED_NAME_DATA = "data"; + @SerializedName(SERIALIZED_NAME_DATA) + private EMEnableGroupResource data; + + public EMEnableGroupResult() { + } + + public EMEnableGroupResult data(EMEnableGroupResource data) { + + this.data = data; + return this; + } + + /** + * Get data + * @return data + **/ + @javax.annotation.Nullable + public EMEnableGroupResource getData() { + return data; + } + + + public void setData(EMEnableGroupResource data) { + this.data = data; + } + + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + EMEnableGroupResult enableGroupResult = (EMEnableGroupResult) o; + return Objects.equals(this.data, enableGroupResult.data); + } + + @Override + public int hashCode() { + return Objects.hash(data); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class EMEnableGroupResult {\n"); + sb.append(" data: ").append(toIndentedString(data)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("data"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to EMEnableGroupResult + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!EMEnableGroupResult.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format("The required field(s) %s in EMEnableGroupResult is not found in the empty JSON string", EMEnableGroupResult.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!EMEnableGroupResult.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `EMEnableGroupResult` properties. JSON: %s", entry.getKey(), jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // validate the optional field `data` + if (jsonObj.get("data") != null && !jsonObj.get("data").isJsonNull()) { + EMEnableGroupResource.validateJsonElement(jsonObj.get("data")); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!EMEnableGroupResult.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'EMEnableGroupResult' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(EMEnableGroupResult.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, EMEnableGroupResult value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public EMEnableGroupResult read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + return thisAdapter.fromJsonTree(jsonElement); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of EMEnableGroupResult given an JSON string + * + * @param jsonString JSON string + * @return An instance of EMEnableGroupResult + * @throws IOException if the JSON string is invalid with respect to EMEnableGroupResult + */ + public static EMEnableGroupResult fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, EMEnableGroupResult.class); + } + + /** + * Convert an instance of EMEnableGroupResult to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/com/easemob/im/api/model/EMForceDeleteRoomCustomAttributes.java b/src/main/java/com/easemob/im/api/model/EMForceDeleteRoomCustomAttributes.java new file mode 100644 index 000000000..35aa86079 --- /dev/null +++ b/src/main/java/com/easemob/im/api/model/EMForceDeleteRoomCustomAttributes.java @@ -0,0 +1,219 @@ +/* + * EMService + * Easemob Rest API + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.easemob.im.api.model; + +import java.util.Objects; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import com.easemob.im.JSON; + +/** + * EMForceDeleteRoomCustomAttributes + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-01-25T14:51:53.998371+08:00[Asia/Shanghai]") +public class EMForceDeleteRoomCustomAttributes { + public static final String SERIALIZED_NAME_KEYS = "keys"; + @SerializedName(SERIALIZED_NAME_KEYS) + private List keys; + + public EMForceDeleteRoomCustomAttributes() { + } + + public EMForceDeleteRoomCustomAttributes keys(List keys) { + + this.keys = keys; + return this; + } + + public EMForceDeleteRoomCustomAttributes addKeysItem(String keysItem) { + if (this.keys == null) { + this.keys = new ArrayList<>(); + } + this.keys.add(keysItem); + return this; + } + + /** + * 聊天室自定义属性的名称列表。每次最多可传 10 个自定义属性名称 + * @return keys + **/ + @javax.annotation.Nullable + public List getKeys() { + return keys; + } + + + public void setKeys(List keys) { + this.keys = keys; + } + + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + EMForceDeleteRoomCustomAttributes forceDeleteRoomCustomAttributes = (EMForceDeleteRoomCustomAttributes) o; + return Objects.equals(this.keys, forceDeleteRoomCustomAttributes.keys); + } + + @Override + public int hashCode() { + return Objects.hash(keys); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class EMForceDeleteRoomCustomAttributes {\n"); + sb.append(" keys: ").append(toIndentedString(keys)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("keys"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to EMForceDeleteRoomCustomAttributes + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!EMForceDeleteRoomCustomAttributes.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format("The required field(s) %s in EMForceDeleteRoomCustomAttributes is not found in the empty JSON string", EMForceDeleteRoomCustomAttributes.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!EMForceDeleteRoomCustomAttributes.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `EMForceDeleteRoomCustomAttributes` properties. JSON: %s", entry.getKey(), jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // ensure the optional json data is an array if present + if (jsonObj.get("keys") != null && !jsonObj.get("keys").isJsonNull() && !jsonObj.get("keys").isJsonArray()) { + throw new IllegalArgumentException(String.format("Expected the field `keys` to be an array in the JSON string but got `%s`", jsonObj.get("keys").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!EMForceDeleteRoomCustomAttributes.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'EMForceDeleteRoomCustomAttributes' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(EMForceDeleteRoomCustomAttributes.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, EMForceDeleteRoomCustomAttributes value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public EMForceDeleteRoomCustomAttributes read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + return thisAdapter.fromJsonTree(jsonElement); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of EMForceDeleteRoomCustomAttributes given an JSON string + * + * @param jsonString JSON string + * @return An instance of EMForceDeleteRoomCustomAttributes + * @throws IOException if the JSON string is invalid with respect to EMForceDeleteRoomCustomAttributes + */ + public static EMForceDeleteRoomCustomAttributes fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, EMForceDeleteRoomCustomAttributes.class); + } + + /** + * Convert an instance of EMForceDeleteRoomCustomAttributes to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/com/easemob/im/api/model/EMForceDeleteRoomCustomAttributesResource.java b/src/main/java/com/easemob/im/api/model/EMForceDeleteRoomCustomAttributesResource.java new file mode 100644 index 000000000..ccb0ab745 --- /dev/null +++ b/src/main/java/com/easemob/im/api/model/EMForceDeleteRoomCustomAttributesResource.java @@ -0,0 +1,247 @@ +/* + * EMService + * Easemob Rest API + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.easemob.im.api.model; + +import java.util.Objects; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import com.easemob.im.JSON; + +/** + * EMForceDeleteRoomCustomAttributesResource + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-01-25T14:51:53.998371+08:00[Asia/Shanghai]") +public class EMForceDeleteRoomCustomAttributesResource { + public static final String SERIALIZED_NAME_SUCCESS_KEYS = "successKeys"; + @SerializedName(SERIALIZED_NAME_SUCCESS_KEYS) + private List successKeys; + + public static final String SERIALIZED_NAME_ERROR_KEYS = "errorKeys"; + @SerializedName(SERIALIZED_NAME_ERROR_KEYS) + private Object errorKeys; + + public EMForceDeleteRoomCustomAttributesResource() { + } + + public EMForceDeleteRoomCustomAttributesResource successKeys(List successKeys) { + + this.successKeys = successKeys; + return this; + } + + public EMForceDeleteRoomCustomAttributesResource addSuccessKeysItem(String successKeysItem) { + if (this.successKeys == null) { + this.successKeys = new ArrayList<>(); + } + this.successKeys.add(successKeysItem); + return this; + } + + /** + * Get successKeys + * @return successKeys + **/ + @javax.annotation.Nullable + public List getSuccessKeys() { + return successKeys; + } + + + public void setSuccessKeys(List successKeys) { + this.successKeys = successKeys; + } + + + public EMForceDeleteRoomCustomAttributesResource errorKeys(Object errorKeys) { + + this.errorKeys = errorKeys; + return this; + } + + /** + * Get errorKeys + * @return errorKeys + **/ + @javax.annotation.Nullable + public Object getErrorKeys() { + return errorKeys; + } + + + public void setErrorKeys(Object errorKeys) { + this.errorKeys = errorKeys; + } + + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + EMForceDeleteRoomCustomAttributesResource forceDeleteRoomCustomAttributesResource = (EMForceDeleteRoomCustomAttributesResource) o; + return Objects.equals(this.successKeys, forceDeleteRoomCustomAttributesResource.successKeys) && + Objects.equals(this.errorKeys, forceDeleteRoomCustomAttributesResource.errorKeys); + } + + @Override + public int hashCode() { + return Objects.hash(successKeys, errorKeys); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class EMForceDeleteRoomCustomAttributesResource {\n"); + sb.append(" successKeys: ").append(toIndentedString(successKeys)).append("\n"); + sb.append(" errorKeys: ").append(toIndentedString(errorKeys)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("successKeys"); + openapiFields.add("errorKeys"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to EMForceDeleteRoomCustomAttributesResource + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!EMForceDeleteRoomCustomAttributesResource.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format("The required field(s) %s in EMForceDeleteRoomCustomAttributesResource is not found in the empty JSON string", EMForceDeleteRoomCustomAttributesResource.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!EMForceDeleteRoomCustomAttributesResource.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `EMForceDeleteRoomCustomAttributesResource` properties. JSON: %s", entry.getKey(), jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // ensure the optional json data is an array if present + if (jsonObj.get("successKeys") != null && !jsonObj.get("successKeys").isJsonNull() && !jsonObj.get("successKeys").isJsonArray()) { + throw new IllegalArgumentException(String.format("Expected the field `successKeys` to be an array in the JSON string but got `%s`", jsonObj.get("successKeys").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!EMForceDeleteRoomCustomAttributesResource.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'EMForceDeleteRoomCustomAttributesResource' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(EMForceDeleteRoomCustomAttributesResource.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, EMForceDeleteRoomCustomAttributesResource value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public EMForceDeleteRoomCustomAttributesResource read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + return thisAdapter.fromJsonTree(jsonElement); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of EMForceDeleteRoomCustomAttributesResource given an JSON string + * + * @param jsonString JSON string + * @return An instance of EMForceDeleteRoomCustomAttributesResource + * @throws IOException if the JSON string is invalid with respect to EMForceDeleteRoomCustomAttributesResource + */ + public static EMForceDeleteRoomCustomAttributesResource fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, EMForceDeleteRoomCustomAttributesResource.class); + } + + /** + * Convert an instance of EMForceDeleteRoomCustomAttributesResource to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/com/easemob/im/api/model/EMForceDeleteRoomCustomAttributesResult.java b/src/main/java/com/easemob/im/api/model/EMForceDeleteRoomCustomAttributesResult.java new file mode 100644 index 000000000..25574e0a7 --- /dev/null +++ b/src/main/java/com/easemob/im/api/model/EMForceDeleteRoomCustomAttributesResult.java @@ -0,0 +1,210 @@ +/* + * EMService + * Easemob Rest API + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.easemob.im.api.model; + +import java.util.Objects; +import com.easemob.im.api.model.EMForceDeleteRoomCustomAttributesResource; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.Arrays; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import com.easemob.im.JSON; + +/** + * EMForceDeleteRoomCustomAttributesResult + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-01-25T14:51:53.998371+08:00[Asia/Shanghai]") +public class EMForceDeleteRoomCustomAttributesResult { + public static final String SERIALIZED_NAME_DATA = "data"; + @SerializedName(SERIALIZED_NAME_DATA) + private EMForceDeleteRoomCustomAttributesResource data; + + public EMForceDeleteRoomCustomAttributesResult() { + } + + public EMForceDeleteRoomCustomAttributesResult data(EMForceDeleteRoomCustomAttributesResource data) { + + this.data = data; + return this; + } + + /** + * Get data + * @return data + **/ + @javax.annotation.Nullable + public EMForceDeleteRoomCustomAttributesResource getData() { + return data; + } + + + public void setData(EMForceDeleteRoomCustomAttributesResource data) { + this.data = data; + } + + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + EMForceDeleteRoomCustomAttributesResult forceDeleteRoomCustomAttributesResult = (EMForceDeleteRoomCustomAttributesResult) o; + return Objects.equals(this.data, forceDeleteRoomCustomAttributesResult.data); + } + + @Override + public int hashCode() { + return Objects.hash(data); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class EMForceDeleteRoomCustomAttributesResult {\n"); + sb.append(" data: ").append(toIndentedString(data)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("data"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to EMForceDeleteRoomCustomAttributesResult + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!EMForceDeleteRoomCustomAttributesResult.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format("The required field(s) %s in EMForceDeleteRoomCustomAttributesResult is not found in the empty JSON string", EMForceDeleteRoomCustomAttributesResult.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!EMForceDeleteRoomCustomAttributesResult.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `EMForceDeleteRoomCustomAttributesResult` properties. JSON: %s", entry.getKey(), jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // validate the optional field `data` + if (jsonObj.get("data") != null && !jsonObj.get("data").isJsonNull()) { + EMForceDeleteRoomCustomAttributesResource.validateJsonElement(jsonObj.get("data")); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!EMForceDeleteRoomCustomAttributesResult.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'EMForceDeleteRoomCustomAttributesResult' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(EMForceDeleteRoomCustomAttributesResult.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, EMForceDeleteRoomCustomAttributesResult value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public EMForceDeleteRoomCustomAttributesResult read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + return thisAdapter.fromJsonTree(jsonElement); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of EMForceDeleteRoomCustomAttributesResult given an JSON string + * + * @param jsonString JSON string + * @return An instance of EMForceDeleteRoomCustomAttributesResult + * @throws IOException if the JSON string is invalid with respect to EMForceDeleteRoomCustomAttributesResult + */ + public static EMForceDeleteRoomCustomAttributesResult fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, EMForceDeleteRoomCustomAttributesResult.class); + } + + /** + * Convert an instance of EMForceDeleteRoomCustomAttributesResult to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/com/easemob/im/api/model/EMForceSetRoomCustomAttributes.java b/src/main/java/com/easemob/im/api/model/EMForceSetRoomCustomAttributes.java new file mode 100644 index 000000000..7477ccef3 --- /dev/null +++ b/src/main/java/com/easemob/im/api/model/EMForceSetRoomCustomAttributes.java @@ -0,0 +1,236 @@ +/* + * EMService + * Easemob Rest API + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.easemob.im.api.model; + +import java.util.Objects; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.Arrays; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import com.easemob.im.JSON; + +/** + * EMForceSetRoomCustomAttributes + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-01-25T14:51:53.998371+08:00[Asia/Shanghai]") +public class EMForceSetRoomCustomAttributes { + public static final String SERIALIZED_NAME_META_DATA = "metaData"; + @SerializedName(SERIALIZED_NAME_META_DATA) + private Map metaData; + + public static final String SERIALIZED_NAME_AUTO_DELETE = "autoDelete"; + @SerializedName(SERIALIZED_NAME_AUTO_DELETE) + private String autoDelete; + + public EMForceSetRoomCustomAttributes() { + } + + public EMForceSetRoomCustomAttributes metaData(Map metaData) { + + this.metaData = metaData; + return this; + } + + /** + * 聊天室的自定义属性,存储为键值对(key-value)集合,即 Map<String,String>。该集合中最多可包含 10 个键值对,在每个键值对中,key 为属性名称,最多可包含 128 个字符;value 为属性值,不能超过 4096 个字符。每个聊天室最多可有 100 个自定义属性,每个应用的聊天室自定义属性总大小为 10 GB。 key 支持以下字符集: - 26 个小写英文字母 a-z; - 26 个大写英文字母 A-Z; - 10 个数字 0-9; - “_”, “-”, “.” + * @return metaData + **/ + @javax.annotation.Nullable + public Map getMetaData() { + return metaData; + } + + + public void setMetaData(Map metaData) { + this.metaData = metaData; + } + + + public EMForceSetRoomCustomAttributes autoDelete(String autoDelete) { + + this.autoDelete = autoDelete; + return this; + } + + /** + * 当前成员退出聊天室时是否自动删除该自定义属性。 -(默认)'DELETE':是; - 'NO_DELETE':否 + * @return autoDelete + **/ + @javax.annotation.Nullable + public String getAutoDelete() { + return autoDelete; + } + + + public void setAutoDelete(String autoDelete) { + this.autoDelete = autoDelete; + } + + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + EMForceSetRoomCustomAttributes forceSetRoomCustomAttributes = (EMForceSetRoomCustomAttributes) o; + return Objects.equals(this.metaData, forceSetRoomCustomAttributes.metaData) && + Objects.equals(this.autoDelete, forceSetRoomCustomAttributes.autoDelete); + } + + @Override + public int hashCode() { + return Objects.hash(metaData, autoDelete); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class EMForceSetRoomCustomAttributes {\n"); + sb.append(" metaData: ").append(toIndentedString(metaData)).append("\n"); + sb.append(" autoDelete: ").append(toIndentedString(autoDelete)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("metaData"); + openapiFields.add("autoDelete"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to EMForceSetRoomCustomAttributes + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!EMForceSetRoomCustomAttributes.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format("The required field(s) %s in EMForceSetRoomCustomAttributes is not found in the empty JSON string", EMForceSetRoomCustomAttributes.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!EMForceSetRoomCustomAttributes.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `EMForceSetRoomCustomAttributes` properties. JSON: %s", entry.getKey(), jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + if ((jsonObj.get("autoDelete") != null && !jsonObj.get("autoDelete").isJsonNull()) && !jsonObj.get("autoDelete").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `autoDelete` to be a primitive type in the JSON string but got `%s`", jsonObj.get("autoDelete").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!EMForceSetRoomCustomAttributes.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'EMForceSetRoomCustomAttributes' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(EMForceSetRoomCustomAttributes.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, EMForceSetRoomCustomAttributes value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public EMForceSetRoomCustomAttributes read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + return thisAdapter.fromJsonTree(jsonElement); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of EMForceSetRoomCustomAttributes given an JSON string + * + * @param jsonString JSON string + * @return An instance of EMForceSetRoomCustomAttributes + * @throws IOException if the JSON string is invalid with respect to EMForceSetRoomCustomAttributes + */ + public static EMForceSetRoomCustomAttributes fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, EMForceSetRoomCustomAttributes.class); + } + + /** + * Convert an instance of EMForceSetRoomCustomAttributes to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/com/easemob/im/api/model/EMForceSetRoomCustomAttributesResource.java b/src/main/java/com/easemob/im/api/model/EMForceSetRoomCustomAttributesResource.java new file mode 100644 index 000000000..a0b4a83e0 --- /dev/null +++ b/src/main/java/com/easemob/im/api/model/EMForceSetRoomCustomAttributesResource.java @@ -0,0 +1,247 @@ +/* + * EMService + * Easemob Rest API + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.easemob.im.api.model; + +import java.util.Objects; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import com.easemob.im.JSON; + +/** + * EMForceSetRoomCustomAttributesResource + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-01-25T14:51:53.998371+08:00[Asia/Shanghai]") +public class EMForceSetRoomCustomAttributesResource { + public static final String SERIALIZED_NAME_SUCCESS_KEYS = "successKeys"; + @SerializedName(SERIALIZED_NAME_SUCCESS_KEYS) + private List successKeys; + + public static final String SERIALIZED_NAME_ERROR_KEYS = "errorKeys"; + @SerializedName(SERIALIZED_NAME_ERROR_KEYS) + private Object errorKeys; + + public EMForceSetRoomCustomAttributesResource() { + } + + public EMForceSetRoomCustomAttributesResource successKeys(List successKeys) { + + this.successKeys = successKeys; + return this; + } + + public EMForceSetRoomCustomAttributesResource addSuccessKeysItem(String successKeysItem) { + if (this.successKeys == null) { + this.successKeys = new ArrayList<>(); + } + this.successKeys.add(successKeysItem); + return this; + } + + /** + * Get successKeys + * @return successKeys + **/ + @javax.annotation.Nullable + public List getSuccessKeys() { + return successKeys; + } + + + public void setSuccessKeys(List successKeys) { + this.successKeys = successKeys; + } + + + public EMForceSetRoomCustomAttributesResource errorKeys(Object errorKeys) { + + this.errorKeys = errorKeys; + return this; + } + + /** + * Get errorKeys + * @return errorKeys + **/ + @javax.annotation.Nullable + public Object getErrorKeys() { + return errorKeys; + } + + + public void setErrorKeys(Object errorKeys) { + this.errorKeys = errorKeys; + } + + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + EMForceSetRoomCustomAttributesResource forceSetRoomCustomAttributesResource = (EMForceSetRoomCustomAttributesResource) o; + return Objects.equals(this.successKeys, forceSetRoomCustomAttributesResource.successKeys) && + Objects.equals(this.errorKeys, forceSetRoomCustomAttributesResource.errorKeys); + } + + @Override + public int hashCode() { + return Objects.hash(successKeys, errorKeys); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class EMForceSetRoomCustomAttributesResource {\n"); + sb.append(" successKeys: ").append(toIndentedString(successKeys)).append("\n"); + sb.append(" errorKeys: ").append(toIndentedString(errorKeys)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("successKeys"); + openapiFields.add("errorKeys"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to EMForceSetRoomCustomAttributesResource + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!EMForceSetRoomCustomAttributesResource.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format("The required field(s) %s in EMForceSetRoomCustomAttributesResource is not found in the empty JSON string", EMForceSetRoomCustomAttributesResource.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!EMForceSetRoomCustomAttributesResource.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `EMForceSetRoomCustomAttributesResource` properties. JSON: %s", entry.getKey(), jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // ensure the optional json data is an array if present + if (jsonObj.get("successKeys") != null && !jsonObj.get("successKeys").isJsonNull() && !jsonObj.get("successKeys").isJsonArray()) { + throw new IllegalArgumentException(String.format("Expected the field `successKeys` to be an array in the JSON string but got `%s`", jsonObj.get("successKeys").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!EMForceSetRoomCustomAttributesResource.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'EMForceSetRoomCustomAttributesResource' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(EMForceSetRoomCustomAttributesResource.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, EMForceSetRoomCustomAttributesResource value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public EMForceSetRoomCustomAttributesResource read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + return thisAdapter.fromJsonTree(jsonElement); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of EMForceSetRoomCustomAttributesResource given an JSON string + * + * @param jsonString JSON string + * @return An instance of EMForceSetRoomCustomAttributesResource + * @throws IOException if the JSON string is invalid with respect to EMForceSetRoomCustomAttributesResource + */ + public static EMForceSetRoomCustomAttributesResource fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, EMForceSetRoomCustomAttributesResource.class); + } + + /** + * Convert an instance of EMForceSetRoomCustomAttributesResource to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/com/easemob/im/api/model/EMForceSetRoomCustomAttributesResult.java b/src/main/java/com/easemob/im/api/model/EMForceSetRoomCustomAttributesResult.java new file mode 100644 index 000000000..8d51bb81a --- /dev/null +++ b/src/main/java/com/easemob/im/api/model/EMForceSetRoomCustomAttributesResult.java @@ -0,0 +1,210 @@ +/* + * EMService + * Easemob Rest API + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.easemob.im.api.model; + +import java.util.Objects; +import com.easemob.im.api.model.EMForceSetRoomCustomAttributesResource; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.Arrays; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import com.easemob.im.JSON; + +/** + * EMForceSetRoomCustomAttributesResult + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-01-25T14:51:53.998371+08:00[Asia/Shanghai]") +public class EMForceSetRoomCustomAttributesResult { + public static final String SERIALIZED_NAME_DATA = "data"; + @SerializedName(SERIALIZED_NAME_DATA) + private EMForceSetRoomCustomAttributesResource data; + + public EMForceSetRoomCustomAttributesResult() { + } + + public EMForceSetRoomCustomAttributesResult data(EMForceSetRoomCustomAttributesResource data) { + + this.data = data; + return this; + } + + /** + * Get data + * @return data + **/ + @javax.annotation.Nullable + public EMForceSetRoomCustomAttributesResource getData() { + return data; + } + + + public void setData(EMForceSetRoomCustomAttributesResource data) { + this.data = data; + } + + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + EMForceSetRoomCustomAttributesResult forceSetRoomCustomAttributesResult = (EMForceSetRoomCustomAttributesResult) o; + return Objects.equals(this.data, forceSetRoomCustomAttributesResult.data); + } + + @Override + public int hashCode() { + return Objects.hash(data); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class EMForceSetRoomCustomAttributesResult {\n"); + sb.append(" data: ").append(toIndentedString(data)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("data"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to EMForceSetRoomCustomAttributesResult + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!EMForceSetRoomCustomAttributesResult.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format("The required field(s) %s in EMForceSetRoomCustomAttributesResult is not found in the empty JSON string", EMForceSetRoomCustomAttributesResult.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!EMForceSetRoomCustomAttributesResult.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `EMForceSetRoomCustomAttributesResult` properties. JSON: %s", entry.getKey(), jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // validate the optional field `data` + if (jsonObj.get("data") != null && !jsonObj.get("data").isJsonNull()) { + EMForceSetRoomCustomAttributesResource.validateJsonElement(jsonObj.get("data")); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!EMForceSetRoomCustomAttributesResult.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'EMForceSetRoomCustomAttributesResult' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(EMForceSetRoomCustomAttributesResult.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, EMForceSetRoomCustomAttributesResult value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public EMForceSetRoomCustomAttributesResult read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + return thisAdapter.fromJsonTree(jsonElement); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of EMForceSetRoomCustomAttributesResult given an JSON string + * + * @param jsonString JSON string + * @return An instance of EMForceSetRoomCustomAttributesResult + * @throws IOException if the JSON string is invalid with respect to EMForceSetRoomCustomAttributesResult + */ + public static EMForceSetRoomCustomAttributesResult fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, EMForceSetRoomCustomAttributesResult.class); + } + + /** + * Convert an instance of EMForceSetRoomCustomAttributesResult to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/com/easemob/im/api/model/EMForceUserLogoutResource.java b/src/main/java/com/easemob/im/api/model/EMForceUserLogoutResource.java new file mode 100644 index 000000000..19a045594 --- /dev/null +++ b/src/main/java/com/easemob/im/api/model/EMForceUserLogoutResource.java @@ -0,0 +1,205 @@ +/* + * EMService + * Easemob Rest API + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.easemob.im.api.model; + +import java.util.Objects; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.Arrays; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import com.easemob.im.JSON; + +/** + * EMForceUserLogoutResource + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-01-25T14:51:53.998371+08:00[Asia/Shanghai]") +public class EMForceUserLogoutResource { + public static final String SERIALIZED_NAME_RESULT = "result"; + @SerializedName(SERIALIZED_NAME_RESULT) + private Boolean result; + + public EMForceUserLogoutResource() { + } + + public EMForceUserLogoutResource result(Boolean result) { + + this.result = result; + return this; + } + + /** + * Get result + * @return result + **/ + @javax.annotation.Nullable + public Boolean getResult() { + return result; + } + + + public void setResult(Boolean result) { + this.result = result; + } + + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + EMForceUserLogoutResource forceUserLogoutResource = (EMForceUserLogoutResource) o; + return Objects.equals(this.result, forceUserLogoutResource.result); + } + + @Override + public int hashCode() { + return Objects.hash(result); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class EMForceUserLogoutResource {\n"); + sb.append(" result: ").append(toIndentedString(result)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("result"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to EMForceUserLogoutResource + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!EMForceUserLogoutResource.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format("The required field(s) %s in EMForceUserLogoutResource is not found in the empty JSON string", EMForceUserLogoutResource.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!EMForceUserLogoutResource.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `EMForceUserLogoutResource` properties. JSON: %s", entry.getKey(), jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!EMForceUserLogoutResource.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'EMForceUserLogoutResource' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(EMForceUserLogoutResource.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, EMForceUserLogoutResource value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public EMForceUserLogoutResource read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + return thisAdapter.fromJsonTree(jsonElement); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of EMForceUserLogoutResource given an JSON string + * + * @param jsonString JSON string + * @return An instance of EMForceUserLogoutResource + * @throws IOException if the JSON string is invalid with respect to EMForceUserLogoutResource + */ + public static EMForceUserLogoutResource fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, EMForceUserLogoutResource.class); + } + + /** + * Convert an instance of EMForceUserLogoutResource to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/com/easemob/im/api/model/EMForceUserLogoutResult.java b/src/main/java/com/easemob/im/api/model/EMForceUserLogoutResult.java new file mode 100644 index 000000000..a26dbed2b --- /dev/null +++ b/src/main/java/com/easemob/im/api/model/EMForceUserLogoutResult.java @@ -0,0 +1,210 @@ +/* + * EMService + * Easemob Rest API + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.easemob.im.api.model; + +import java.util.Objects; +import com.easemob.im.api.model.EMForceUserLogoutResource; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.Arrays; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import com.easemob.im.JSON; + +/** + * EMForceUserLogoutResult + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-01-25T14:51:53.998371+08:00[Asia/Shanghai]") +public class EMForceUserLogoutResult { + public static final String SERIALIZED_NAME_DATA = "data"; + @SerializedName(SERIALIZED_NAME_DATA) + private EMForceUserLogoutResource data; + + public EMForceUserLogoutResult() { + } + + public EMForceUserLogoutResult data(EMForceUserLogoutResource data) { + + this.data = data; + return this; + } + + /** + * Get data + * @return data + **/ + @javax.annotation.Nullable + public EMForceUserLogoutResource getData() { + return data; + } + + + public void setData(EMForceUserLogoutResource data) { + this.data = data; + } + + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + EMForceUserLogoutResult forceUserLogoutResult = (EMForceUserLogoutResult) o; + return Objects.equals(this.data, forceUserLogoutResult.data); + } + + @Override + public int hashCode() { + return Objects.hash(data); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class EMForceUserLogoutResult {\n"); + sb.append(" data: ").append(toIndentedString(data)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("data"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to EMForceUserLogoutResult + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!EMForceUserLogoutResult.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format("The required field(s) %s in EMForceUserLogoutResult is not found in the empty JSON string", EMForceUserLogoutResult.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!EMForceUserLogoutResult.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `EMForceUserLogoutResult` properties. JSON: %s", entry.getKey(), jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // validate the optional field `data` + if (jsonObj.get("data") != null && !jsonObj.get("data").isJsonNull()) { + EMForceUserLogoutResource.validateJsonElement(jsonObj.get("data")); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!EMForceUserLogoutResult.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'EMForceUserLogoutResult' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(EMForceUserLogoutResult.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, EMForceUserLogoutResult value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public EMForceUserLogoutResult read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + return thisAdapter.fromJsonTree(jsonElement); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of EMForceUserLogoutResult given an JSON string + * + * @param jsonString JSON string + * @return An instance of EMForceUserLogoutResult + * @throws IOException if the JSON string is invalid with respect to EMForceUserLogoutResult + */ + public static EMForceUserLogoutResult fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, EMForceUserLogoutResult.class); + } + + /** + * Convert an instance of EMForceUserLogoutResult to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/com/easemob/im/api/model/EMGetAllGloballyMutedUsersResult.java b/src/main/java/com/easemob/im/api/model/EMGetAllGloballyMutedUsersResult.java new file mode 100644 index 000000000..7ac830cbe --- /dev/null +++ b/src/main/java/com/easemob/im/api/model/EMGetAllGloballyMutedUsersResult.java @@ -0,0 +1,210 @@ +/* + * EMService + * Easemob Rest API + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.easemob.im.api.model; + +import java.util.Objects; +import com.easemob.im.api.model.EMAllGloballyMutedUsersResource; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.Arrays; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import com.easemob.im.JSON; + +/** + * EMGetAllGloballyMutedUsersResult + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-01-25T14:51:53.998371+08:00[Asia/Shanghai]") +public class EMGetAllGloballyMutedUsersResult { + public static final String SERIALIZED_NAME_DATA = "data"; + @SerializedName(SERIALIZED_NAME_DATA) + private EMAllGloballyMutedUsersResource data; + + public EMGetAllGloballyMutedUsersResult() { + } + + public EMGetAllGloballyMutedUsersResult data(EMAllGloballyMutedUsersResource data) { + + this.data = data; + return this; + } + + /** + * Get data + * @return data + **/ + @javax.annotation.Nullable + public EMAllGloballyMutedUsersResource getData() { + return data; + } + + + public void setData(EMAllGloballyMutedUsersResource data) { + this.data = data; + } + + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + EMGetAllGloballyMutedUsersResult getAllGloballyMutedUsersResult = (EMGetAllGloballyMutedUsersResult) o; + return Objects.equals(this.data, getAllGloballyMutedUsersResult.data); + } + + @Override + public int hashCode() { + return Objects.hash(data); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class EMGetAllGloballyMutedUsersResult {\n"); + sb.append(" data: ").append(toIndentedString(data)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("data"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to EMGetAllGloballyMutedUsersResult + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!EMGetAllGloballyMutedUsersResult.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format("The required field(s) %s in EMGetAllGloballyMutedUsersResult is not found in the empty JSON string", EMGetAllGloballyMutedUsersResult.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!EMGetAllGloballyMutedUsersResult.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `EMGetAllGloballyMutedUsersResult` properties. JSON: %s", entry.getKey(), jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // validate the optional field `data` + if (jsonObj.get("data") != null && !jsonObj.get("data").isJsonNull()) { + EMAllGloballyMutedUsersResource.validateJsonElement(jsonObj.get("data")); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!EMGetAllGloballyMutedUsersResult.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'EMGetAllGloballyMutedUsersResult' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(EMGetAllGloballyMutedUsersResult.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, EMGetAllGloballyMutedUsersResult value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public EMGetAllGloballyMutedUsersResult read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + return thisAdapter.fromJsonTree(jsonElement); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of EMGetAllGloballyMutedUsersResult given an JSON string + * + * @param jsonString JSON string + * @return An instance of EMGetAllGloballyMutedUsersResult + * @throws IOException if the JSON string is invalid with respect to EMGetAllGloballyMutedUsersResult + */ + public static EMGetAllGloballyMutedUsersResult fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, EMGetAllGloballyMutedUsersResult.class); + } + + /** + * Convert an instance of EMGetAllGloballyMutedUsersResult to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/com/easemob/im/api/model/EMGetAppGroupResource.java b/src/main/java/com/easemob/im/api/model/EMGetAppGroupResource.java new file mode 100644 index 000000000..dfd2ea5d4 --- /dev/null +++ b/src/main/java/com/easemob/im/api/model/EMGetAppGroupResource.java @@ -0,0 +1,386 @@ +/* + * EMService + * Easemob Rest API + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.easemob.im.api.model; + +import java.util.Objects; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.math.BigDecimal; +import java.util.Arrays; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import com.easemob.im.JSON; + +/** + * EMGetAppGroupResource + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-01-25T14:51:53.998371+08:00[Asia/Shanghai]") +public class EMGetAppGroupResource { + public static final String SERIALIZED_NAME_OWNER = "owner"; + @SerializedName(SERIALIZED_NAME_OWNER) + private String owner; + + public static final String SERIALIZED_NAME_GROUPID = "groupid"; + @SerializedName(SERIALIZED_NAME_GROUPID) + private String groupid; + + public static final String SERIALIZED_NAME_AFFILIATIONS = "affiliations"; + @SerializedName(SERIALIZED_NAME_AFFILIATIONS) + private Integer affiliations; + + public static final String SERIALIZED_NAME_TYPE = "type"; + @SerializedName(SERIALIZED_NAME_TYPE) + private String type; + + public static final String SERIALIZED_NAME_LAST_MODIFIED = "lastModified"; + @SerializedName(SERIALIZED_NAME_LAST_MODIFIED) + private BigDecimal lastModified; + + public static final String SERIALIZED_NAME_GROUPNAME = "groupname"; + @SerializedName(SERIALIZED_NAME_GROUPNAME) + private String groupname; + + public static final String SERIALIZED_NAME_CREATED = "created"; + @SerializedName(SERIALIZED_NAME_CREATED) + private BigDecimal created; + + public EMGetAppGroupResource() { + } + + public EMGetAppGroupResource owner(String owner) { + + this.owner = owner; + return this; + } + + /** + * 群主的用户 ID + * @return owner + **/ + @javax.annotation.Nullable + public String getOwner() { + return owner; + } + + + public void setOwner(String owner) { + this.owner = owner; + } + + + public EMGetAppGroupResource groupid(String groupid) { + + this.groupid = groupid; + return this; + } + + /** + * 群组 ID + * @return groupid + **/ + @javax.annotation.Nullable + public String getGroupid() { + return groupid; + } + + + public void setGroupid(String groupid) { + this.groupid = groupid; + } + + + public EMGetAppGroupResource affiliations(Integer affiliations) { + + this.affiliations = affiliations; + return this; + } + + /** + * 群组现有成员数 + * @return affiliations + **/ + @javax.annotation.Nullable + public Integer getAffiliations() { + return affiliations; + } + + + public void setAffiliations(Integer affiliations) { + this.affiliations = affiliations; + } + + + public EMGetAppGroupResource type(String type) { + + this.type = type; + return this; + } + + /** + * “group” 群组类型 + * @return type + **/ + @javax.annotation.Nullable + public String getType() { + return type; + } + + + public void setType(String type) { + this.type = type; + } + + + public EMGetAppGroupResource lastModified(BigDecimal lastModified) { + + this.lastModified = lastModified; + return this; + } + + /** + * 最近一次修改的时间戳,单位为毫秒 + * @return lastModified + **/ + @javax.annotation.Nullable + public BigDecimal getLastModified() { + return lastModified; + } + + + public void setLastModified(BigDecimal lastModified) { + this.lastModified = lastModified; + } + + + public EMGetAppGroupResource groupname(String groupname) { + + this.groupname = groupname; + return this; + } + + /** + * 群组名称 + * @return groupname + **/ + @javax.annotation.Nullable + public String getGroupname() { + return groupname; + } + + + public void setGroupname(String groupname) { + this.groupname = groupname; + } + + + public EMGetAppGroupResource created(BigDecimal created) { + + this.created = created; + return this; + } + + /** + * 群组创建的时间戳,单位为毫秒 + * @return created + **/ + @javax.annotation.Nullable + public BigDecimal getCreated() { + return created; + } + + + public void setCreated(BigDecimal created) { + this.created = created; + } + + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + EMGetAppGroupResource getAppGroupResource = (EMGetAppGroupResource) o; + return Objects.equals(this.owner, getAppGroupResource.owner) && + Objects.equals(this.groupid, getAppGroupResource.groupid) && + Objects.equals(this.affiliations, getAppGroupResource.affiliations) && + Objects.equals(this.type, getAppGroupResource.type) && + Objects.equals(this.lastModified, getAppGroupResource.lastModified) && + Objects.equals(this.groupname, getAppGroupResource.groupname) && + Objects.equals(this.created, getAppGroupResource.created); + } + + @Override + public int hashCode() { + return Objects.hash(owner, groupid, affiliations, type, lastModified, groupname, created); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class EMGetAppGroupResource {\n"); + sb.append(" owner: ").append(toIndentedString(owner)).append("\n"); + sb.append(" groupid: ").append(toIndentedString(groupid)).append("\n"); + sb.append(" affiliations: ").append(toIndentedString(affiliations)).append("\n"); + sb.append(" type: ").append(toIndentedString(type)).append("\n"); + sb.append(" lastModified: ").append(toIndentedString(lastModified)).append("\n"); + sb.append(" groupname: ").append(toIndentedString(groupname)).append("\n"); + sb.append(" created: ").append(toIndentedString(created)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("owner"); + openapiFields.add("groupid"); + openapiFields.add("affiliations"); + openapiFields.add("type"); + openapiFields.add("lastModified"); + openapiFields.add("groupname"); + openapiFields.add("created"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to EMGetAppGroupResource + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!EMGetAppGroupResource.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format("The required field(s) %s in EMGetAppGroupResource is not found in the empty JSON string", EMGetAppGroupResource.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!EMGetAppGroupResource.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `EMGetAppGroupResource` properties. JSON: %s", entry.getKey(), jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + if ((jsonObj.get("owner") != null && !jsonObj.get("owner").isJsonNull()) && !jsonObj.get("owner").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `owner` to be a primitive type in the JSON string but got `%s`", jsonObj.get("owner").toString())); + } + if ((jsonObj.get("groupid") != null && !jsonObj.get("groupid").isJsonNull()) && !jsonObj.get("groupid").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `groupid` to be a primitive type in the JSON string but got `%s`", jsonObj.get("groupid").toString())); + } + if ((jsonObj.get("type") != null && !jsonObj.get("type").isJsonNull()) && !jsonObj.get("type").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `type` to be a primitive type in the JSON string but got `%s`", jsonObj.get("type").toString())); + } + if ((jsonObj.get("groupname") != null && !jsonObj.get("groupname").isJsonNull()) && !jsonObj.get("groupname").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `groupname` to be a primitive type in the JSON string but got `%s`", jsonObj.get("groupname").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!EMGetAppGroupResource.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'EMGetAppGroupResource' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(EMGetAppGroupResource.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, EMGetAppGroupResource value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public EMGetAppGroupResource read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + return thisAdapter.fromJsonTree(jsonElement); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of EMGetAppGroupResource given an JSON string + * + * @param jsonString JSON string + * @return An instance of EMGetAppGroupResource + * @throws IOException if the JSON string is invalid with respect to EMGetAppGroupResource + */ + public static EMGetAppGroupResource fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, EMGetAppGroupResource.class); + } + + /** + * Convert an instance of EMGetAppGroupResource to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/com/easemob/im/api/model/EMGetAppGroupsResult.java b/src/main/java/com/easemob/im/api/model/EMGetAppGroupsResult.java new file mode 100644 index 000000000..7ff6ebc31 --- /dev/null +++ b/src/main/java/com/easemob/im/api/model/EMGetAppGroupsResult.java @@ -0,0 +1,289 @@ +/* + * EMService + * Easemob Rest API + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.easemob.im.api.model; + +import java.util.Objects; +import com.easemob.im.api.model.EMGetAppGroupResource; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import com.easemob.im.JSON; + +/** + * EMGetAppGroupsResult + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-01-25T14:51:53.998371+08:00[Asia/Shanghai]") +public class EMGetAppGroupsResult { + public static final String SERIALIZED_NAME_DATA = "data"; + @SerializedName(SERIALIZED_NAME_DATA) + private List data; + + public static final String SERIALIZED_NAME_CURSOR = "cursor"; + @SerializedName(SERIALIZED_NAME_CURSOR) + private String cursor; + + public static final String SERIALIZED_NAME_COUNT = "count"; + @SerializedName(SERIALIZED_NAME_COUNT) + private Integer count; + + public EMGetAppGroupsResult() { + } + + public EMGetAppGroupsResult data(List data) { + + this.data = data; + return this; + } + + public EMGetAppGroupsResult addDataItem(EMGetAppGroupResource dataItem) { + if (this.data == null) { + this.data = new ArrayList<>(); + } + this.data.add(dataItem); + return this; + } + + /** + * Get data + * @return data + **/ + @javax.annotation.Nullable + public List getData() { + return data; + } + + + public void setData(List data) { + this.data = data; + } + + + public EMGetAppGroupsResult cursor(String cursor) { + + this.cursor = cursor; + return this; + } + + /** + * Get cursor + * @return cursor + **/ + @javax.annotation.Nullable + public String getCursor() { + return cursor; + } + + + public void setCursor(String cursor) { + this.cursor = cursor; + } + + + public EMGetAppGroupsResult count(Integer count) { + + this.count = count; + return this; + } + + /** + * Get count + * @return count + **/ + @javax.annotation.Nullable + public Integer getCount() { + return count; + } + + + public void setCount(Integer count) { + this.count = count; + } + + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + EMGetAppGroupsResult getAppGroupsResult = (EMGetAppGroupsResult) o; + return Objects.equals(this.data, getAppGroupsResult.data) && + Objects.equals(this.cursor, getAppGroupsResult.cursor) && + Objects.equals(this.count, getAppGroupsResult.count); + } + + @Override + public int hashCode() { + return Objects.hash(data, cursor, count); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class EMGetAppGroupsResult {\n"); + sb.append(" data: ").append(toIndentedString(data)).append("\n"); + sb.append(" cursor: ").append(toIndentedString(cursor)).append("\n"); + sb.append(" count: ").append(toIndentedString(count)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("data"); + openapiFields.add("cursor"); + openapiFields.add("count"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to EMGetAppGroupsResult + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!EMGetAppGroupsResult.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format("The required field(s) %s in EMGetAppGroupsResult is not found in the empty JSON string", EMGetAppGroupsResult.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!EMGetAppGroupsResult.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `EMGetAppGroupsResult` properties. JSON: %s", entry.getKey(), jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + if (jsonObj.get("data") != null && !jsonObj.get("data").isJsonNull()) { + JsonArray jsonArraydata = jsonObj.getAsJsonArray("data"); + if (jsonArraydata != null) { + // ensure the json data is an array + if (!jsonObj.get("data").isJsonArray()) { + throw new IllegalArgumentException(String.format("Expected the field `data` to be an array in the JSON string but got `%s`", jsonObj.get("data").toString())); + } + + // validate the optional field `data` (array) + for (int i = 0; i < jsonArraydata.size(); i++) { + EMGetAppGroupResource.validateJsonElement(jsonArraydata.get(i)); + }; + } + } + if ((jsonObj.get("cursor") != null && !jsonObj.get("cursor").isJsonNull()) && !jsonObj.get("cursor").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `cursor` to be a primitive type in the JSON string but got `%s`", jsonObj.get("cursor").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!EMGetAppGroupsResult.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'EMGetAppGroupsResult' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(EMGetAppGroupsResult.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, EMGetAppGroupsResult value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public EMGetAppGroupsResult read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + return thisAdapter.fromJsonTree(jsonElement); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of EMGetAppGroupsResult given an JSON string + * + * @param jsonString JSON string + * @return An instance of EMGetAppGroupsResult + * @throws IOException if the JSON string is invalid with respect to EMGetAppGroupsResult + */ + public static EMGetAppGroupsResult fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, EMGetAppGroupsResult.class); + } + + /** + * Convert an instance of EMGetAppGroupsResult to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/com/easemob/im/api/model/EMGetBlockListResult.java b/src/main/java/com/easemob/im/api/model/EMGetBlockListResult.java new file mode 100644 index 000000000..158a912ac --- /dev/null +++ b/src/main/java/com/easemob/im/api/model/EMGetBlockListResult.java @@ -0,0 +1,278 @@ +/* + * EMService + * Easemob Rest API + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.easemob.im.api.model; + +import java.util.Objects; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import com.easemob.im.JSON; + +/** + * EMGetBlockListResult + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-01-25T14:51:53.998371+08:00[Asia/Shanghai]") +public class EMGetBlockListResult { + public static final String SERIALIZED_NAME_DATA = "data"; + @SerializedName(SERIALIZED_NAME_DATA) + private List data; + + public static final String SERIALIZED_NAME_COUNT = "count"; + @SerializedName(SERIALIZED_NAME_COUNT) + private Integer count; + + public static final String SERIALIZED_NAME_CURSOR = "cursor"; + @SerializedName(SERIALIZED_NAME_CURSOR) + private String cursor; + + public EMGetBlockListResult() { + } + + public EMGetBlockListResult data(List data) { + + this.data = data; + return this; + } + + public EMGetBlockListResult addDataItem(String dataItem) { + if (this.data == null) { + this.data = new ArrayList<>(); + } + this.data.add(dataItem); + return this; + } + + /** + * Get data + * @return data + **/ + @javax.annotation.Nullable + public List getData() { + return data; + } + + + public void setData(List data) { + this.data = data; + } + + + public EMGetBlockListResult count(Integer count) { + + this.count = count; + return this; + } + + /** + * Get count + * @return count + **/ + @javax.annotation.Nullable + public Integer getCount() { + return count; + } + + + public void setCount(Integer count) { + this.count = count; + } + + + public EMGetBlockListResult cursor(String cursor) { + + this.cursor = cursor; + return this; + } + + /** + * Get cursor + * @return cursor + **/ + @javax.annotation.Nullable + public String getCursor() { + return cursor; + } + + + public void setCursor(String cursor) { + this.cursor = cursor; + } + + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + EMGetBlockListResult getBlockListResult = (EMGetBlockListResult) o; + return Objects.equals(this.data, getBlockListResult.data) && + Objects.equals(this.count, getBlockListResult.count) && + Objects.equals(this.cursor, getBlockListResult.cursor); + } + + @Override + public int hashCode() { + return Objects.hash(data, count, cursor); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class EMGetBlockListResult {\n"); + sb.append(" data: ").append(toIndentedString(data)).append("\n"); + sb.append(" count: ").append(toIndentedString(count)).append("\n"); + sb.append(" cursor: ").append(toIndentedString(cursor)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("data"); + openapiFields.add("count"); + openapiFields.add("cursor"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to EMGetBlockListResult + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!EMGetBlockListResult.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format("The required field(s) %s in EMGetBlockListResult is not found in the empty JSON string", EMGetBlockListResult.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!EMGetBlockListResult.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `EMGetBlockListResult` properties. JSON: %s", entry.getKey(), jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // ensure the optional json data is an array if present + if (jsonObj.get("data") != null && !jsonObj.get("data").isJsonNull() && !jsonObj.get("data").isJsonArray()) { + throw new IllegalArgumentException(String.format("Expected the field `data` to be an array in the JSON string but got `%s`", jsonObj.get("data").toString())); + } + if ((jsonObj.get("cursor") != null && !jsonObj.get("cursor").isJsonNull()) && !jsonObj.get("cursor").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `cursor` to be a primitive type in the JSON string but got `%s`", jsonObj.get("cursor").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!EMGetBlockListResult.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'EMGetBlockListResult' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(EMGetBlockListResult.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, EMGetBlockListResult value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public EMGetBlockListResult read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + return thisAdapter.fromJsonTree(jsonElement); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of EMGetBlockListResult given an JSON string + * + * @param jsonString JSON string + * @return An instance of EMGetBlockListResult + * @throws IOException if the JSON string is invalid with respect to EMGetBlockListResult + */ + public static EMGetBlockListResult fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, EMGetBlockListResult.class); + } + + /** + * Convert an instance of EMGetBlockListResult to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/com/easemob/im/api/model/EMGetContactListResource.java b/src/main/java/com/easemob/im/api/model/EMGetContactListResource.java new file mode 100644 index 000000000..56d98a2d8 --- /dev/null +++ b/src/main/java/com/easemob/im/api/model/EMGetContactListResource.java @@ -0,0 +1,261 @@ +/* + * EMService + * Easemob Rest API + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.easemob.im.api.model; + +import java.util.Objects; +import com.easemob.im.api.model.EMContactRemarkResource; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import com.easemob.im.JSON; + +/** + * EMGetContactListResource + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-01-25T14:51:53.998371+08:00[Asia/Shanghai]") +public class EMGetContactListResource { + public static final String SERIALIZED_NAME_CONTACTS = "contacts"; + @SerializedName(SERIALIZED_NAME_CONTACTS) + private List contacts; + + public static final String SERIALIZED_NAME_CURSOR = "cursor"; + @SerializedName(SERIALIZED_NAME_CURSOR) + private String cursor; + + public EMGetContactListResource() { + } + + public EMGetContactListResource contacts(List contacts) { + + this.contacts = contacts; + return this; + } + + public EMGetContactListResource addContactsItem(EMContactRemarkResource contactsItem) { + if (this.contacts == null) { + this.contacts = new ArrayList<>(); + } + this.contacts.add(contactsItem); + return this; + } + + /** + * Get contacts + * @return contacts + **/ + @javax.annotation.Nullable + public List getContacts() { + return contacts; + } + + + public void setContacts(List contacts) { + this.contacts = contacts; + } + + + public EMGetContactListResource cursor(String cursor) { + + this.cursor = cursor; + return this; + } + + /** + * Get cursor + * @return cursor + **/ + @javax.annotation.Nullable + public String getCursor() { + return cursor; + } + + + public void setCursor(String cursor) { + this.cursor = cursor; + } + + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + EMGetContactListResource getContactListResource = (EMGetContactListResource) o; + return Objects.equals(this.contacts, getContactListResource.contacts) && + Objects.equals(this.cursor, getContactListResource.cursor); + } + + @Override + public int hashCode() { + return Objects.hash(contacts, cursor); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class EMGetContactListResource {\n"); + sb.append(" contacts: ").append(toIndentedString(contacts)).append("\n"); + sb.append(" cursor: ").append(toIndentedString(cursor)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("contacts"); + openapiFields.add("cursor"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to EMGetContactListResource + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!EMGetContactListResource.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format("The required field(s) %s in EMGetContactListResource is not found in the empty JSON string", EMGetContactListResource.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!EMGetContactListResource.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `EMGetContactListResource` properties. JSON: %s", entry.getKey(), jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + if (jsonObj.get("contacts") != null && !jsonObj.get("contacts").isJsonNull()) { + JsonArray jsonArraycontacts = jsonObj.getAsJsonArray("contacts"); + if (jsonArraycontacts != null) { + // ensure the json data is an array + if (!jsonObj.get("contacts").isJsonArray()) { + throw new IllegalArgumentException(String.format("Expected the field `contacts` to be an array in the JSON string but got `%s`", jsonObj.get("contacts").toString())); + } + + // validate the optional field `contacts` (array) + for (int i = 0; i < jsonArraycontacts.size(); i++) { + EMContactRemarkResource.validateJsonElement(jsonArraycontacts.get(i)); + }; + } + } + if ((jsonObj.get("cursor") != null && !jsonObj.get("cursor").isJsonNull()) && !jsonObj.get("cursor").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `cursor` to be a primitive type in the JSON string but got `%s`", jsonObj.get("cursor").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!EMGetContactListResource.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'EMGetContactListResource' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(EMGetContactListResource.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, EMGetContactListResource value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public EMGetContactListResource read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + return thisAdapter.fromJsonTree(jsonElement); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of EMGetContactListResource given an JSON string + * + * @param jsonString JSON string + * @return An instance of EMGetContactListResource + * @throws IOException if the JSON string is invalid with respect to EMGetContactListResource + */ + public static EMGetContactListResource fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, EMGetContactListResource.class); + } + + /** + * Convert an instance of EMGetContactListResource to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/com/easemob/im/api/model/EMGetContactListResult.java b/src/main/java/com/easemob/im/api/model/EMGetContactListResult.java new file mode 100644 index 000000000..bec8f1681 --- /dev/null +++ b/src/main/java/com/easemob/im/api/model/EMGetContactListResult.java @@ -0,0 +1,210 @@ +/* + * EMService + * Easemob Rest API + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.easemob.im.api.model; + +import java.util.Objects; +import com.easemob.im.api.model.EMGetContactListResource; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.Arrays; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import com.easemob.im.JSON; + +/** + * EMGetContactListResult + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-01-25T14:51:53.998371+08:00[Asia/Shanghai]") +public class EMGetContactListResult { + public static final String SERIALIZED_NAME_DATA = "data"; + @SerializedName(SERIALIZED_NAME_DATA) + private EMGetContactListResource data; + + public EMGetContactListResult() { + } + + public EMGetContactListResult data(EMGetContactListResource data) { + + this.data = data; + return this; + } + + /** + * Get data + * @return data + **/ + @javax.annotation.Nullable + public EMGetContactListResource getData() { + return data; + } + + + public void setData(EMGetContactListResource data) { + this.data = data; + } + + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + EMGetContactListResult getContactListResult = (EMGetContactListResult) o; + return Objects.equals(this.data, getContactListResult.data); + } + + @Override + public int hashCode() { + return Objects.hash(data); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class EMGetContactListResult {\n"); + sb.append(" data: ").append(toIndentedString(data)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("data"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to EMGetContactListResult + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!EMGetContactListResult.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format("The required field(s) %s in EMGetContactListResult is not found in the empty JSON string", EMGetContactListResult.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!EMGetContactListResult.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `EMGetContactListResult` properties. JSON: %s", entry.getKey(), jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // validate the optional field `data` + if (jsonObj.get("data") != null && !jsonObj.get("data").isJsonNull()) { + EMGetContactListResource.validateJsonElement(jsonObj.get("data")); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!EMGetContactListResult.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'EMGetContactListResult' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(EMGetContactListResult.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, EMGetContactListResult value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public EMGetContactListResult read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + return thisAdapter.fromJsonTree(jsonElement); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of EMGetContactListResult given an JSON string + * + * @param jsonString JSON string + * @return An instance of EMGetContactListResult + * @throws IOException if the JSON string is invalid with respect to EMGetContactListResult + */ + public static EMGetContactListResult fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, EMGetContactListResult.class); + } + + /** + * Convert an instance of EMGetContactListResult to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/com/easemob/im/api/model/EMGetGroupAdminListResult.java b/src/main/java/com/easemob/im/api/model/EMGetGroupAdminListResult.java new file mode 100644 index 000000000..52da15e90 --- /dev/null +++ b/src/main/java/com/easemob/im/api/model/EMGetGroupAdminListResult.java @@ -0,0 +1,219 @@ +/* + * EMService + * Easemob Rest API + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.easemob.im.api.model; + +import java.util.Objects; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import com.easemob.im.JSON; + +/** + * EMGetGroupAdminListResult + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-01-25T14:51:53.998371+08:00[Asia/Shanghai]") +public class EMGetGroupAdminListResult { + public static final String SERIALIZED_NAME_DATA = "data"; + @SerializedName(SERIALIZED_NAME_DATA) + private List data; + + public EMGetGroupAdminListResult() { + } + + public EMGetGroupAdminListResult data(List data) { + + this.data = data; + return this; + } + + public EMGetGroupAdminListResult addDataItem(String dataItem) { + if (this.data == null) { + this.data = new ArrayList<>(); + } + this.data.add(dataItem); + return this; + } + + /** + * Get data + * @return data + **/ + @javax.annotation.Nullable + public List getData() { + return data; + } + + + public void setData(List data) { + this.data = data; + } + + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + EMGetGroupAdminListResult getGroupAdminListResult = (EMGetGroupAdminListResult) o; + return Objects.equals(this.data, getGroupAdminListResult.data); + } + + @Override + public int hashCode() { + return Objects.hash(data); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class EMGetGroupAdminListResult {\n"); + sb.append(" data: ").append(toIndentedString(data)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("data"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to EMGetGroupAdminListResult + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!EMGetGroupAdminListResult.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format("The required field(s) %s in EMGetGroupAdminListResult is not found in the empty JSON string", EMGetGroupAdminListResult.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!EMGetGroupAdminListResult.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `EMGetGroupAdminListResult` properties. JSON: %s", entry.getKey(), jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // ensure the optional json data is an array if present + if (jsonObj.get("data") != null && !jsonObj.get("data").isJsonNull() && !jsonObj.get("data").isJsonArray()) { + throw new IllegalArgumentException(String.format("Expected the field `data` to be an array in the JSON string but got `%s`", jsonObj.get("data").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!EMGetGroupAdminListResult.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'EMGetGroupAdminListResult' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(EMGetGroupAdminListResult.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, EMGetGroupAdminListResult value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public EMGetGroupAdminListResult read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + return thisAdapter.fromJsonTree(jsonElement); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of EMGetGroupAdminListResult given an JSON string + * + * @param jsonString JSON string + * @return An instance of EMGetGroupAdminListResult + * @throws IOException if the JSON string is invalid with respect to EMGetGroupAdminListResult + */ + public static EMGetGroupAdminListResult fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, EMGetGroupAdminListResult.class); + } + + /** + * Convert an instance of EMGetGroupAdminListResult to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/com/easemob/im/api/model/EMGetGroupAnnouncementResource.java b/src/main/java/com/easemob/im/api/model/EMGetGroupAnnouncementResource.java new file mode 100644 index 000000000..e76d0fe14 --- /dev/null +++ b/src/main/java/com/easemob/im/api/model/EMGetGroupAnnouncementResource.java @@ -0,0 +1,208 @@ +/* + * EMService + * Easemob Rest API + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.easemob.im.api.model; + +import java.util.Objects; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.Arrays; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import com.easemob.im.JSON; + +/** + * EMGetGroupAnnouncementResource + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-01-25T14:51:53.998371+08:00[Asia/Shanghai]") +public class EMGetGroupAnnouncementResource { + public static final String SERIALIZED_NAME_ANNOUNCEMENT = "announcement"; + @SerializedName(SERIALIZED_NAME_ANNOUNCEMENT) + private String announcement; + + public EMGetGroupAnnouncementResource() { + } + + public EMGetGroupAnnouncementResource announcement(String announcement) { + + this.announcement = announcement; + return this; + } + + /** + * Get announcement + * @return announcement + **/ + @javax.annotation.Nullable + public String getAnnouncement() { + return announcement; + } + + + public void setAnnouncement(String announcement) { + this.announcement = announcement; + } + + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + EMGetGroupAnnouncementResource getGroupAnnouncementResource = (EMGetGroupAnnouncementResource) o; + return Objects.equals(this.announcement, getGroupAnnouncementResource.announcement); + } + + @Override + public int hashCode() { + return Objects.hash(announcement); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class EMGetGroupAnnouncementResource {\n"); + sb.append(" announcement: ").append(toIndentedString(announcement)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("announcement"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to EMGetGroupAnnouncementResource + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!EMGetGroupAnnouncementResource.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format("The required field(s) %s in EMGetGroupAnnouncementResource is not found in the empty JSON string", EMGetGroupAnnouncementResource.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!EMGetGroupAnnouncementResource.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `EMGetGroupAnnouncementResource` properties. JSON: %s", entry.getKey(), jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + if ((jsonObj.get("announcement") != null && !jsonObj.get("announcement").isJsonNull()) && !jsonObj.get("announcement").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `announcement` to be a primitive type in the JSON string but got `%s`", jsonObj.get("announcement").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!EMGetGroupAnnouncementResource.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'EMGetGroupAnnouncementResource' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(EMGetGroupAnnouncementResource.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, EMGetGroupAnnouncementResource value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public EMGetGroupAnnouncementResource read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + return thisAdapter.fromJsonTree(jsonElement); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of EMGetGroupAnnouncementResource given an JSON string + * + * @param jsonString JSON string + * @return An instance of EMGetGroupAnnouncementResource + * @throws IOException if the JSON string is invalid with respect to EMGetGroupAnnouncementResource + */ + public static EMGetGroupAnnouncementResource fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, EMGetGroupAnnouncementResource.class); + } + + /** + * Convert an instance of EMGetGroupAnnouncementResource to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/com/easemob/im/api/model/EMGetGroupAnnouncementResult.java b/src/main/java/com/easemob/im/api/model/EMGetGroupAnnouncementResult.java new file mode 100644 index 000000000..dd5fa0803 --- /dev/null +++ b/src/main/java/com/easemob/im/api/model/EMGetGroupAnnouncementResult.java @@ -0,0 +1,210 @@ +/* + * EMService + * Easemob Rest API + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.easemob.im.api.model; + +import java.util.Objects; +import com.easemob.im.api.model.EMGetGroupAnnouncementResource; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.Arrays; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import com.easemob.im.JSON; + +/** + * EMGetGroupAnnouncementResult + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-01-25T14:51:53.998371+08:00[Asia/Shanghai]") +public class EMGetGroupAnnouncementResult { + public static final String SERIALIZED_NAME_DATA = "data"; + @SerializedName(SERIALIZED_NAME_DATA) + private EMGetGroupAnnouncementResource data; + + public EMGetGroupAnnouncementResult() { + } + + public EMGetGroupAnnouncementResult data(EMGetGroupAnnouncementResource data) { + + this.data = data; + return this; + } + + /** + * Get data + * @return data + **/ + @javax.annotation.Nullable + public EMGetGroupAnnouncementResource getData() { + return data; + } + + + public void setData(EMGetGroupAnnouncementResource data) { + this.data = data; + } + + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + EMGetGroupAnnouncementResult getGroupAnnouncementResult = (EMGetGroupAnnouncementResult) o; + return Objects.equals(this.data, getGroupAnnouncementResult.data); + } + + @Override + public int hashCode() { + return Objects.hash(data); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class EMGetGroupAnnouncementResult {\n"); + sb.append(" data: ").append(toIndentedString(data)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("data"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to EMGetGroupAnnouncementResult + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!EMGetGroupAnnouncementResult.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format("The required field(s) %s in EMGetGroupAnnouncementResult is not found in the empty JSON string", EMGetGroupAnnouncementResult.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!EMGetGroupAnnouncementResult.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `EMGetGroupAnnouncementResult` properties. JSON: %s", entry.getKey(), jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // validate the optional field `data` + if (jsonObj.get("data") != null && !jsonObj.get("data").isJsonNull()) { + EMGetGroupAnnouncementResource.validateJsonElement(jsonObj.get("data")); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!EMGetGroupAnnouncementResult.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'EMGetGroupAnnouncementResult' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(EMGetGroupAnnouncementResult.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, EMGetGroupAnnouncementResult value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public EMGetGroupAnnouncementResult read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + return thisAdapter.fromJsonTree(jsonElement); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of EMGetGroupAnnouncementResult given an JSON string + * + * @param jsonString JSON string + * @return An instance of EMGetGroupAnnouncementResult + * @throws IOException if the JSON string is invalid with respect to EMGetGroupAnnouncementResult + */ + public static EMGetGroupAnnouncementResult fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, EMGetGroupAnnouncementResult.class); + } + + /** + * Convert an instance of EMGetGroupAnnouncementResult to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/com/easemob/im/api/model/EMGetGroupBlockListResult.java b/src/main/java/com/easemob/im/api/model/EMGetGroupBlockListResult.java new file mode 100644 index 000000000..7269b0e50 --- /dev/null +++ b/src/main/java/com/easemob/im/api/model/EMGetGroupBlockListResult.java @@ -0,0 +1,219 @@ +/* + * EMService + * Easemob Rest API + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.easemob.im.api.model; + +import java.util.Objects; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import com.easemob.im.JSON; + +/** + * EMGetGroupBlockListResult + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-01-25T14:51:53.998371+08:00[Asia/Shanghai]") +public class EMGetGroupBlockListResult { + public static final String SERIALIZED_NAME_DATA = "data"; + @SerializedName(SERIALIZED_NAME_DATA) + private List data; + + public EMGetGroupBlockListResult() { + } + + public EMGetGroupBlockListResult data(List data) { + + this.data = data; + return this; + } + + public EMGetGroupBlockListResult addDataItem(String dataItem) { + if (this.data == null) { + this.data = new ArrayList<>(); + } + this.data.add(dataItem); + return this; + } + + /** + * Get data + * @return data + **/ + @javax.annotation.Nullable + public List getData() { + return data; + } + + + public void setData(List data) { + this.data = data; + } + + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + EMGetGroupBlockListResult getGroupBlockListResult = (EMGetGroupBlockListResult) o; + return Objects.equals(this.data, getGroupBlockListResult.data); + } + + @Override + public int hashCode() { + return Objects.hash(data); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class EMGetGroupBlockListResult {\n"); + sb.append(" data: ").append(toIndentedString(data)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("data"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to EMGetGroupBlockListResult + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!EMGetGroupBlockListResult.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format("The required field(s) %s in EMGetGroupBlockListResult is not found in the empty JSON string", EMGetGroupBlockListResult.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!EMGetGroupBlockListResult.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `EMGetGroupBlockListResult` properties. JSON: %s", entry.getKey(), jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // ensure the optional json data is an array if present + if (jsonObj.get("data") != null && !jsonObj.get("data").isJsonNull() && !jsonObj.get("data").isJsonArray()) { + throw new IllegalArgumentException(String.format("Expected the field `data` to be an array in the JSON string but got `%s`", jsonObj.get("data").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!EMGetGroupBlockListResult.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'EMGetGroupBlockListResult' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(EMGetGroupBlockListResult.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, EMGetGroupBlockListResult value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public EMGetGroupBlockListResult read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + return thisAdapter.fromJsonTree(jsonElement); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of EMGetGroupBlockListResult given an JSON string + * + * @param jsonString JSON string + * @return An instance of EMGetGroupBlockListResult + * @throws IOException if the JSON string is invalid with respect to EMGetGroupBlockListResult + */ + public static EMGetGroupBlockListResult fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, EMGetGroupBlockListResult.class); + } + + /** + * Convert an instance of EMGetGroupBlockListResult to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/com/easemob/im/api/model/EMGetGroupInfoResult.java b/src/main/java/com/easemob/im/api/model/EMGetGroupInfoResult.java new file mode 100644 index 000000000..f93397fb0 --- /dev/null +++ b/src/main/java/com/easemob/im/api/model/EMGetGroupInfoResult.java @@ -0,0 +1,230 @@ +/* + * EMService + * Easemob Rest API + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.easemob.im.api.model; + +import java.util.Objects; +import com.easemob.im.api.model.EMGroupInfoResource; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import com.easemob.im.JSON; + +/** + * EMGetGroupInfoResult + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-01-25T14:51:53.998371+08:00[Asia/Shanghai]") +public class EMGetGroupInfoResult { + public static final String SERIALIZED_NAME_DATA = "data"; + @SerializedName(SERIALIZED_NAME_DATA) + private List data; + + public EMGetGroupInfoResult() { + } + + public EMGetGroupInfoResult data(List data) { + + this.data = data; + return this; + } + + public EMGetGroupInfoResult addDataItem(EMGroupInfoResource dataItem) { + if (this.data == null) { + this.data = new ArrayList<>(); + } + this.data.add(dataItem); + return this; + } + + /** + * Get data + * @return data + **/ + @javax.annotation.Nullable + public List getData() { + return data; + } + + + public void setData(List data) { + this.data = data; + } + + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + EMGetGroupInfoResult getGroupInfoResult = (EMGetGroupInfoResult) o; + return Objects.equals(this.data, getGroupInfoResult.data); + } + + @Override + public int hashCode() { + return Objects.hash(data); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class EMGetGroupInfoResult {\n"); + sb.append(" data: ").append(toIndentedString(data)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("data"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to EMGetGroupInfoResult + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!EMGetGroupInfoResult.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format("The required field(s) %s in EMGetGroupInfoResult is not found in the empty JSON string", EMGetGroupInfoResult.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!EMGetGroupInfoResult.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `EMGetGroupInfoResult` properties. JSON: %s", entry.getKey(), jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + if (jsonObj.get("data") != null && !jsonObj.get("data").isJsonNull()) { + JsonArray jsonArraydata = jsonObj.getAsJsonArray("data"); + if (jsonArraydata != null) { + // ensure the json data is an array + if (!jsonObj.get("data").isJsonArray()) { + throw new IllegalArgumentException(String.format("Expected the field `data` to be an array in the JSON string but got `%s`", jsonObj.get("data").toString())); + } + + // validate the optional field `data` (array) + for (int i = 0; i < jsonArraydata.size(); i++) { + EMGroupInfoResource.validateJsonElement(jsonArraydata.get(i)); + }; + } + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!EMGetGroupInfoResult.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'EMGetGroupInfoResult' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(EMGetGroupInfoResult.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, EMGetGroupInfoResult value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public EMGetGroupInfoResult read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + return thisAdapter.fromJsonTree(jsonElement); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of EMGetGroupInfoResult given an JSON string + * + * @param jsonString JSON string + * @return An instance of EMGetGroupInfoResult + * @throws IOException if the JSON string is invalid with respect to EMGetGroupInfoResult + */ + public static EMGetGroupInfoResult fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, EMGetGroupInfoResult.class); + } + + /** + * Convert an instance of EMGetGroupInfoResult to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/com/easemob/im/api/model/EMGetGroupMemberAllCustomAttributeResult.java b/src/main/java/com/easemob/im/api/model/EMGetGroupMemberAllCustomAttributeResult.java new file mode 100644 index 000000000..0bfd0a723 --- /dev/null +++ b/src/main/java/com/easemob/im/api/model/EMGetGroupMemberAllCustomAttributeResult.java @@ -0,0 +1,205 @@ +/* + * EMService + * Easemob Rest API + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.easemob.im.api.model; + +import java.util.Objects; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.Arrays; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import com.easemob.im.JSON; + +/** + * EMGetGroupMemberAllCustomAttributeResult + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-01-25T14:51:53.998371+08:00[Asia/Shanghai]") +public class EMGetGroupMemberAllCustomAttributeResult { + public static final String SERIALIZED_NAME_DATA = "data"; + @SerializedName(SERIALIZED_NAME_DATA) + private Object data; + + public EMGetGroupMemberAllCustomAttributeResult() { + } + + public EMGetGroupMemberAllCustomAttributeResult data(Object data) { + + this.data = data; + return this; + } + + /** + * Get data + * @return data + **/ + @javax.annotation.Nullable + public Object getData() { + return data; + } + + + public void setData(Object data) { + this.data = data; + } + + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + EMGetGroupMemberAllCustomAttributeResult getGroupMemberAllCustomAttributeResult = (EMGetGroupMemberAllCustomAttributeResult) o; + return Objects.equals(this.data, getGroupMemberAllCustomAttributeResult.data); + } + + @Override + public int hashCode() { + return Objects.hash(data); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class EMGetGroupMemberAllCustomAttributeResult {\n"); + sb.append(" data: ").append(toIndentedString(data)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("data"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to EMGetGroupMemberAllCustomAttributeResult + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!EMGetGroupMemberAllCustomAttributeResult.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format("The required field(s) %s in EMGetGroupMemberAllCustomAttributeResult is not found in the empty JSON string", EMGetGroupMemberAllCustomAttributeResult.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!EMGetGroupMemberAllCustomAttributeResult.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `EMGetGroupMemberAllCustomAttributeResult` properties. JSON: %s", entry.getKey(), jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!EMGetGroupMemberAllCustomAttributeResult.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'EMGetGroupMemberAllCustomAttributeResult' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(EMGetGroupMemberAllCustomAttributeResult.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, EMGetGroupMemberAllCustomAttributeResult value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public EMGetGroupMemberAllCustomAttributeResult read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + return thisAdapter.fromJsonTree(jsonElement); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of EMGetGroupMemberAllCustomAttributeResult given an JSON string + * + * @param jsonString JSON string + * @return An instance of EMGetGroupMemberAllCustomAttributeResult + * @throws IOException if the JSON string is invalid with respect to EMGetGroupMemberAllCustomAttributeResult + */ + public static EMGetGroupMemberAllCustomAttributeResult fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, EMGetGroupMemberAllCustomAttributeResult.class); + } + + /** + * Convert an instance of EMGetGroupMemberAllCustomAttributeResult to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/com/easemob/im/api/model/EMGetGroupMemberListResult.java b/src/main/java/com/easemob/im/api/model/EMGetGroupMemberListResult.java new file mode 100644 index 000000000..37b28955f --- /dev/null +++ b/src/main/java/com/easemob/im/api/model/EMGetGroupMemberListResult.java @@ -0,0 +1,219 @@ +/* + * EMService + * Easemob Rest API + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.easemob.im.api.model; + +import java.util.Objects; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import com.easemob.im.JSON; + +/** + * EMGetGroupMemberListResult + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-01-25T14:51:53.998371+08:00[Asia/Shanghai]") +public class EMGetGroupMemberListResult { + public static final String SERIALIZED_NAME_DATA = "data"; + @SerializedName(SERIALIZED_NAME_DATA) + private List data; + + public EMGetGroupMemberListResult() { + } + + public EMGetGroupMemberListResult data(List data) { + + this.data = data; + return this; + } + + public EMGetGroupMemberListResult addDataItem(Object dataItem) { + if (this.data == null) { + this.data = new ArrayList<>(); + } + this.data.add(dataItem); + return this; + } + + /** + * Get data + * @return data + **/ + @javax.annotation.Nullable + public List getData() { + return data; + } + + + public void setData(List data) { + this.data = data; + } + + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + EMGetGroupMemberListResult getGroupMemberListResult = (EMGetGroupMemberListResult) o; + return Objects.equals(this.data, getGroupMemberListResult.data); + } + + @Override + public int hashCode() { + return Objects.hash(data); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class EMGetGroupMemberListResult {\n"); + sb.append(" data: ").append(toIndentedString(data)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("data"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to EMGetGroupMemberListResult + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!EMGetGroupMemberListResult.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format("The required field(s) %s in EMGetGroupMemberListResult is not found in the empty JSON string", EMGetGroupMemberListResult.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!EMGetGroupMemberListResult.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `EMGetGroupMemberListResult` properties. JSON: %s", entry.getKey(), jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // ensure the optional json data is an array if present + if (jsonObj.get("data") != null && !jsonObj.get("data").isJsonNull() && !jsonObj.get("data").isJsonArray()) { + throw new IllegalArgumentException(String.format("Expected the field `data` to be an array in the JSON string but got `%s`", jsonObj.get("data").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!EMGetGroupMemberListResult.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'EMGetGroupMemberListResult' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(EMGetGroupMemberListResult.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, EMGetGroupMemberListResult value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public EMGetGroupMemberListResult read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + return thisAdapter.fromJsonTree(jsonElement); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of EMGetGroupMemberListResult given an JSON string + * + * @param jsonString JSON string + * @return An instance of EMGetGroupMemberListResult + * @throws IOException if the JSON string is invalid with respect to EMGetGroupMemberListResult + */ + public static EMGetGroupMemberListResult fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, EMGetGroupMemberListResult.class); + } + + /** + * Convert an instance of EMGetGroupMemberListResult to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/com/easemob/im/api/model/EMGetGroupMuteListResult.java b/src/main/java/com/easemob/im/api/model/EMGetGroupMuteListResult.java new file mode 100644 index 000000000..e07259e44 --- /dev/null +++ b/src/main/java/com/easemob/im/api/model/EMGetGroupMuteListResult.java @@ -0,0 +1,230 @@ +/* + * EMService + * Easemob Rest API + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.easemob.im.api.model; + +import java.util.Objects; +import com.easemob.im.api.model.EMGroupMuteResource; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import com.easemob.im.JSON; + +/** + * EMGetGroupMuteListResult + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-01-25T14:51:53.998371+08:00[Asia/Shanghai]") +public class EMGetGroupMuteListResult { + public static final String SERIALIZED_NAME_DATA = "data"; + @SerializedName(SERIALIZED_NAME_DATA) + private List data; + + public EMGetGroupMuteListResult() { + } + + public EMGetGroupMuteListResult data(List data) { + + this.data = data; + return this; + } + + public EMGetGroupMuteListResult addDataItem(EMGroupMuteResource dataItem) { + if (this.data == null) { + this.data = new ArrayList<>(); + } + this.data.add(dataItem); + return this; + } + + /** + * Get data + * @return data + **/ + @javax.annotation.Nullable + public List getData() { + return data; + } + + + public void setData(List data) { + this.data = data; + } + + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + EMGetGroupMuteListResult getGroupMuteListResult = (EMGetGroupMuteListResult) o; + return Objects.equals(this.data, getGroupMuteListResult.data); + } + + @Override + public int hashCode() { + return Objects.hash(data); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class EMGetGroupMuteListResult {\n"); + sb.append(" data: ").append(toIndentedString(data)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("data"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to EMGetGroupMuteListResult + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!EMGetGroupMuteListResult.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format("The required field(s) %s in EMGetGroupMuteListResult is not found in the empty JSON string", EMGetGroupMuteListResult.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!EMGetGroupMuteListResult.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `EMGetGroupMuteListResult` properties. JSON: %s", entry.getKey(), jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + if (jsonObj.get("data") != null && !jsonObj.get("data").isJsonNull()) { + JsonArray jsonArraydata = jsonObj.getAsJsonArray("data"); + if (jsonArraydata != null) { + // ensure the json data is an array + if (!jsonObj.get("data").isJsonArray()) { + throw new IllegalArgumentException(String.format("Expected the field `data` to be an array in the JSON string but got `%s`", jsonObj.get("data").toString())); + } + + // validate the optional field `data` (array) + for (int i = 0; i < jsonArraydata.size(); i++) { + EMGroupMuteResource.validateJsonElement(jsonArraydata.get(i)); + }; + } + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!EMGetGroupMuteListResult.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'EMGetGroupMuteListResult' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(EMGetGroupMuteListResult.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, EMGetGroupMuteListResult value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public EMGetGroupMuteListResult read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + return thisAdapter.fromJsonTree(jsonElement); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of EMGetGroupMuteListResult given an JSON string + * + * @param jsonString JSON string + * @return An instance of EMGetGroupMuteListResult + * @throws IOException if the JSON string is invalid with respect to EMGetGroupMuteListResult + */ + public static EMGetGroupMuteListResult fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, EMGetGroupMuteListResult.class); + } + + /** + * Convert an instance of EMGetGroupMuteListResult to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/com/easemob/im/api/model/EMGetGroupShareFileResult.java b/src/main/java/com/easemob/im/api/model/EMGetGroupShareFileResult.java new file mode 100644 index 000000000..a17dc3975 --- /dev/null +++ b/src/main/java/com/easemob/im/api/model/EMGetGroupShareFileResult.java @@ -0,0 +1,230 @@ +/* + * EMService + * Easemob Rest API + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.easemob.im.api.model; + +import java.util.Objects; +import com.easemob.im.api.model.EMGroupShareFileResource; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import com.easemob.im.JSON; + +/** + * EMGetGroupShareFileResult + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-01-25T14:51:53.998371+08:00[Asia/Shanghai]") +public class EMGetGroupShareFileResult { + public static final String SERIALIZED_NAME_DATA = "data"; + @SerializedName(SERIALIZED_NAME_DATA) + private List data; + + public EMGetGroupShareFileResult() { + } + + public EMGetGroupShareFileResult data(List data) { + + this.data = data; + return this; + } + + public EMGetGroupShareFileResult addDataItem(EMGroupShareFileResource dataItem) { + if (this.data == null) { + this.data = new ArrayList<>(); + } + this.data.add(dataItem); + return this; + } + + /** + * Get data + * @return data + **/ + @javax.annotation.Nullable + public List getData() { + return data; + } + + + public void setData(List data) { + this.data = data; + } + + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + EMGetGroupShareFileResult getGroupShareFileResult = (EMGetGroupShareFileResult) o; + return Objects.equals(this.data, getGroupShareFileResult.data); + } + + @Override + public int hashCode() { + return Objects.hash(data); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class EMGetGroupShareFileResult {\n"); + sb.append(" data: ").append(toIndentedString(data)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("data"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to EMGetGroupShareFileResult + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!EMGetGroupShareFileResult.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format("The required field(s) %s in EMGetGroupShareFileResult is not found in the empty JSON string", EMGetGroupShareFileResult.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!EMGetGroupShareFileResult.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `EMGetGroupShareFileResult` properties. JSON: %s", entry.getKey(), jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + if (jsonObj.get("data") != null && !jsonObj.get("data").isJsonNull()) { + JsonArray jsonArraydata = jsonObj.getAsJsonArray("data"); + if (jsonArraydata != null) { + // ensure the json data is an array + if (!jsonObj.get("data").isJsonArray()) { + throw new IllegalArgumentException(String.format("Expected the field `data` to be an array in the JSON string but got `%s`", jsonObj.get("data").toString())); + } + + // validate the optional field `data` (array) + for (int i = 0; i < jsonArraydata.size(); i++) { + EMGroupShareFileResource.validateJsonElement(jsonArraydata.get(i)); + }; + } + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!EMGetGroupShareFileResult.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'EMGetGroupShareFileResult' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(EMGetGroupShareFileResult.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, EMGetGroupShareFileResult value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public EMGetGroupShareFileResult read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + return thisAdapter.fromJsonTree(jsonElement); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of EMGetGroupShareFileResult given an JSON string + * + * @param jsonString JSON string + * @return An instance of EMGetGroupShareFileResult + * @throws IOException if the JSON string is invalid with respect to EMGetGroupShareFileResult + */ + public static EMGetGroupShareFileResult fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, EMGetGroupShareFileResult.class); + } + + /** + * Convert an instance of EMGetGroupShareFileResult to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/com/easemob/im/api/model/EMGetGroupWhiteListResult.java b/src/main/java/com/easemob/im/api/model/EMGetGroupWhiteListResult.java new file mode 100644 index 000000000..a14b61e40 --- /dev/null +++ b/src/main/java/com/easemob/im/api/model/EMGetGroupWhiteListResult.java @@ -0,0 +1,219 @@ +/* + * EMService + * Easemob Rest API + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.easemob.im.api.model; + +import java.util.Objects; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import com.easemob.im.JSON; + +/** + * EMGetGroupWhiteListResult + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-01-25T14:51:53.998371+08:00[Asia/Shanghai]") +public class EMGetGroupWhiteListResult { + public static final String SERIALIZED_NAME_DATA = "data"; + @SerializedName(SERIALIZED_NAME_DATA) + private List data; + + public EMGetGroupWhiteListResult() { + } + + public EMGetGroupWhiteListResult data(List data) { + + this.data = data; + return this; + } + + public EMGetGroupWhiteListResult addDataItem(String dataItem) { + if (this.data == null) { + this.data = new ArrayList<>(); + } + this.data.add(dataItem); + return this; + } + + /** + * Get data + * @return data + **/ + @javax.annotation.Nullable + public List getData() { + return data; + } + + + public void setData(List data) { + this.data = data; + } + + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + EMGetGroupWhiteListResult getGroupWhiteListResult = (EMGetGroupWhiteListResult) o; + return Objects.equals(this.data, getGroupWhiteListResult.data); + } + + @Override + public int hashCode() { + return Objects.hash(data); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class EMGetGroupWhiteListResult {\n"); + sb.append(" data: ").append(toIndentedString(data)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("data"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to EMGetGroupWhiteListResult + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!EMGetGroupWhiteListResult.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format("The required field(s) %s in EMGetGroupWhiteListResult is not found in the empty JSON string", EMGetGroupWhiteListResult.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!EMGetGroupWhiteListResult.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `EMGetGroupWhiteListResult` properties. JSON: %s", entry.getKey(), jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // ensure the optional json data is an array if present + if (jsonObj.get("data") != null && !jsonObj.get("data").isJsonNull() && !jsonObj.get("data").isJsonArray()) { + throw new IllegalArgumentException(String.format("Expected the field `data` to be an array in the JSON string but got `%s`", jsonObj.get("data").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!EMGetGroupWhiteListResult.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'EMGetGroupWhiteListResult' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(EMGetGroupWhiteListResult.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, EMGetGroupWhiteListResult value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public EMGetGroupWhiteListResult read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + return thisAdapter.fromJsonTree(jsonElement); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of EMGetGroupWhiteListResult given an JSON string + * + * @param jsonString JSON string + * @return An instance of EMGetGroupWhiteListResult + * @throws IOException if the JSON string is invalid with respect to EMGetGroupWhiteListResult + */ + public static EMGetGroupWhiteListResult fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, EMGetGroupWhiteListResult.class); + } + + /** + * Convert an instance of EMGetGroupWhiteListResult to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/com/easemob/im/api/model/EMGetHistoryMessageResource.java b/src/main/java/com/easemob/im/api/model/EMGetHistoryMessageResource.java new file mode 100644 index 000000000..58d8e290f --- /dev/null +++ b/src/main/java/com/easemob/im/api/model/EMGetHistoryMessageResource.java @@ -0,0 +1,208 @@ +/* + * EMService + * Easemob Rest API + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.easemob.im.api.model; + +import java.util.Objects; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.Arrays; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import com.easemob.im.JSON; + +/** + * EMGetHistoryMessageResource + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-01-25T14:51:53.998371+08:00[Asia/Shanghai]") +public class EMGetHistoryMessageResource { + public static final String SERIALIZED_NAME_URL = "url"; + @SerializedName(SERIALIZED_NAME_URL) + private String url; + + public EMGetHistoryMessageResource() { + } + + public EMGetHistoryMessageResource url(String url) { + + this.url = url; + return this; + } + + /** + * 历史消息记录的下载地址。该 URL 由历史消息记录的存储地址、到期 Unix 时间戳(Expires,单位为秒)、第三方云存储访问密钥(OSSAccessKeyId)和第三方云存储验证签名(Signature)组成。URL 仅在一定时间内有效,请及时通过 URL 下载聊天记录文件,URL 过期后会下载失败,需要重新调用该接口获取新的 URL + * @return url + **/ + @javax.annotation.Nullable + public String getUrl() { + return url; + } + + + public void setUrl(String url) { + this.url = url; + } + + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + EMGetHistoryMessageResource getHistoryMessageResource = (EMGetHistoryMessageResource) o; + return Objects.equals(this.url, getHistoryMessageResource.url); + } + + @Override + public int hashCode() { + return Objects.hash(url); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class EMGetHistoryMessageResource {\n"); + sb.append(" url: ").append(toIndentedString(url)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("url"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to EMGetHistoryMessageResource + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!EMGetHistoryMessageResource.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format("The required field(s) %s in EMGetHistoryMessageResource is not found in the empty JSON string", EMGetHistoryMessageResource.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!EMGetHistoryMessageResource.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `EMGetHistoryMessageResource` properties. JSON: %s", entry.getKey(), jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + if ((jsonObj.get("url") != null && !jsonObj.get("url").isJsonNull()) && !jsonObj.get("url").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `url` to be a primitive type in the JSON string but got `%s`", jsonObj.get("url").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!EMGetHistoryMessageResource.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'EMGetHistoryMessageResource' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(EMGetHistoryMessageResource.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, EMGetHistoryMessageResource value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public EMGetHistoryMessageResource read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + return thisAdapter.fromJsonTree(jsonElement); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of EMGetHistoryMessageResource given an JSON string + * + * @param jsonString JSON string + * @return An instance of EMGetHistoryMessageResource + * @throws IOException if the JSON string is invalid with respect to EMGetHistoryMessageResource + */ + public static EMGetHistoryMessageResource fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, EMGetHistoryMessageResource.class); + } + + /** + * Convert an instance of EMGetHistoryMessageResource to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/com/easemob/im/api/model/EMGetHistoryMessageResult.java b/src/main/java/com/easemob/im/api/model/EMGetHistoryMessageResult.java new file mode 100644 index 000000000..bdc01177b --- /dev/null +++ b/src/main/java/com/easemob/im/api/model/EMGetHistoryMessageResult.java @@ -0,0 +1,230 @@ +/* + * EMService + * Easemob Rest API + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.easemob.im.api.model; + +import java.util.Objects; +import com.easemob.im.api.model.EMGetHistoryMessageResource; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import com.easemob.im.JSON; + +/** + * EMGetHistoryMessageResult + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-01-25T14:51:53.998371+08:00[Asia/Shanghai]") +public class EMGetHistoryMessageResult { + public static final String SERIALIZED_NAME_DATA = "data"; + @SerializedName(SERIALIZED_NAME_DATA) + private List data; + + public EMGetHistoryMessageResult() { + } + + public EMGetHistoryMessageResult data(List data) { + + this.data = data; + return this; + } + + public EMGetHistoryMessageResult addDataItem(EMGetHistoryMessageResource dataItem) { + if (this.data == null) { + this.data = new ArrayList<>(); + } + this.data.add(dataItem); + return this; + } + + /** + * Get data + * @return data + **/ + @javax.annotation.Nullable + public List getData() { + return data; + } + + + public void setData(List data) { + this.data = data; + } + + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + EMGetHistoryMessageResult getHistoryMessageResult = (EMGetHistoryMessageResult) o; + return Objects.equals(this.data, getHistoryMessageResult.data); + } + + @Override + public int hashCode() { + return Objects.hash(data); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class EMGetHistoryMessageResult {\n"); + sb.append(" data: ").append(toIndentedString(data)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("data"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to EMGetHistoryMessageResult + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!EMGetHistoryMessageResult.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format("The required field(s) %s in EMGetHistoryMessageResult is not found in the empty JSON string", EMGetHistoryMessageResult.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!EMGetHistoryMessageResult.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `EMGetHistoryMessageResult` properties. JSON: %s", entry.getKey(), jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + if (jsonObj.get("data") != null && !jsonObj.get("data").isJsonNull()) { + JsonArray jsonArraydata = jsonObj.getAsJsonArray("data"); + if (jsonArraydata != null) { + // ensure the json data is an array + if (!jsonObj.get("data").isJsonArray()) { + throw new IllegalArgumentException(String.format("Expected the field `data` to be an array in the JSON string but got `%s`", jsonObj.get("data").toString())); + } + + // validate the optional field `data` (array) + for (int i = 0; i < jsonArraydata.size(); i++) { + EMGetHistoryMessageResource.validateJsonElement(jsonArraydata.get(i)); + }; + } + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!EMGetHistoryMessageResult.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'EMGetHistoryMessageResult' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(EMGetHistoryMessageResult.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, EMGetHistoryMessageResult value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public EMGetHistoryMessageResult read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + return thisAdapter.fromJsonTree(jsonElement); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of EMGetHistoryMessageResult given an JSON string + * + * @param jsonString JSON string + * @return An instance of EMGetHistoryMessageResult + * @throws IOException if the JSON string is invalid with respect to EMGetHistoryMessageResult + */ + public static EMGetHistoryMessageResult fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, EMGetHistoryMessageResult.class); + } + + /** + * Convert an instance of EMGetHistoryMessageResult to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/com/easemob/im/api/model/EMGetMultipleGroupMembersAttributes.java b/src/main/java/com/easemob/im/api/model/EMGetMultipleGroupMembersAttributes.java new file mode 100644 index 000000000..35b00ab48 --- /dev/null +++ b/src/main/java/com/easemob/im/api/model/EMGetMultipleGroupMembersAttributes.java @@ -0,0 +1,272 @@ +/* + * EMService + * Easemob Rest API + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.easemob.im.api.model; + +import java.util.Objects; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import com.easemob.im.JSON; + +/** + * EMGetMultipleGroupMembersAttributes + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-01-25T14:51:53.998371+08:00[Asia/Shanghai]") +public class EMGetMultipleGroupMembersAttributes { + public static final String SERIALIZED_NAME_TARGETS = "targets"; + @SerializedName(SERIALIZED_NAME_TARGETS) + private List targets = new ArrayList<>(); + + public static final String SERIALIZED_NAME_PROPERTIES = "properties"; + @SerializedName(SERIALIZED_NAME_PROPERTIES) + private List properties = new ArrayList<>(); + + public EMGetMultipleGroupMembersAttributes() { + } + + public EMGetMultipleGroupMembersAttributes targets(List targets) { + + this.targets = targets; + return this; + } + + public EMGetMultipleGroupMembersAttributes addTargetsItem(String targetsItem) { + if (this.targets == null) { + this.targets = new ArrayList<>(); + } + this.targets.add(targetsItem); + return this; + } + + /** + * 要获取自定义属性的群成员的用户 ID。一次最多可传 10 个用户 ID + * @return targets + **/ + @javax.annotation.Nonnull + public List getTargets() { + return targets; + } + + + public void setTargets(List targets) { + this.targets = targets; + } + + + public EMGetMultipleGroupMembersAttributes properties(List properties) { + + this.properties = properties; + return this; + } + + public EMGetMultipleGroupMembersAttributes addPropertiesItem(String propertiesItem) { + if (this.properties == null) { + this.properties = new ArrayList<>(); + } + this.properties.add(propertiesItem); + return this; + } + + /** + * 要获取自定义属性的群成员的用户 ID。一次最多可传 10 个用户 ID + * @return properties + **/ + @javax.annotation.Nonnull + public List getProperties() { + return properties; + } + + + public void setProperties(List properties) { + this.properties = properties; + } + + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + EMGetMultipleGroupMembersAttributes getMultipleGroupMembersAttributes = (EMGetMultipleGroupMembersAttributes) o; + return Objects.equals(this.targets, getMultipleGroupMembersAttributes.targets) && + Objects.equals(this.properties, getMultipleGroupMembersAttributes.properties); + } + + @Override + public int hashCode() { + return Objects.hash(targets, properties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class EMGetMultipleGroupMembersAttributes {\n"); + sb.append(" targets: ").append(toIndentedString(targets)).append("\n"); + sb.append(" properties: ").append(toIndentedString(properties)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("targets"); + openapiFields.add("properties"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + openapiRequiredFields.add("targets"); + openapiRequiredFields.add("properties"); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to EMGetMultipleGroupMembersAttributes + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!EMGetMultipleGroupMembersAttributes.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format("The required field(s) %s in EMGetMultipleGroupMembersAttributes is not found in the empty JSON string", EMGetMultipleGroupMembersAttributes.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!EMGetMultipleGroupMembersAttributes.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `EMGetMultipleGroupMembersAttributes` properties. JSON: %s", entry.getKey(), jsonElement.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : EMGetMultipleGroupMembersAttributes.openapiRequiredFields) { + if (jsonElement.getAsJsonObject().get(requiredField) == null) { + throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // ensure the required json array is present + if (jsonObj.get("targets") == null) { + throw new IllegalArgumentException("Expected the field `linkedContent` to be an array in the JSON string but got `null`"); + } else if (!jsonObj.get("targets").isJsonArray()) { + throw new IllegalArgumentException(String.format("Expected the field `targets` to be an array in the JSON string but got `%s`", jsonObj.get("targets").toString())); + } + // ensure the required json array is present + if (jsonObj.get("properties") == null) { + throw new IllegalArgumentException("Expected the field `linkedContent` to be an array in the JSON string but got `null`"); + } else if (!jsonObj.get("properties").isJsonArray()) { + throw new IllegalArgumentException(String.format("Expected the field `properties` to be an array in the JSON string but got `%s`", jsonObj.get("properties").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!EMGetMultipleGroupMembersAttributes.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'EMGetMultipleGroupMembersAttributes' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(EMGetMultipleGroupMembersAttributes.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, EMGetMultipleGroupMembersAttributes value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public EMGetMultipleGroupMembersAttributes read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + return thisAdapter.fromJsonTree(jsonElement); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of EMGetMultipleGroupMembersAttributes given an JSON string + * + * @param jsonString JSON string + * @return An instance of EMGetMultipleGroupMembersAttributes + * @throws IOException if the JSON string is invalid with respect to EMGetMultipleGroupMembersAttributes + */ + public static EMGetMultipleGroupMembersAttributes fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, EMGetMultipleGroupMembersAttributes.class); + } + + /** + * Convert an instance of EMGetMultipleGroupMembersAttributes to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/com/easemob/im/api/model/EMGetMultipleGroupMembersAttributesResult.java b/src/main/java/com/easemob/im/api/model/EMGetMultipleGroupMembersAttributesResult.java new file mode 100644 index 000000000..726f1bd6c --- /dev/null +++ b/src/main/java/com/easemob/im/api/model/EMGetMultipleGroupMembersAttributesResult.java @@ -0,0 +1,205 @@ +/* + * EMService + * Easemob Rest API + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.easemob.im.api.model; + +import java.util.Objects; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.Arrays; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import com.easemob.im.JSON; + +/** + * EMGetMultipleGroupMembersAttributesResult + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-01-25T14:51:53.998371+08:00[Asia/Shanghai]") +public class EMGetMultipleGroupMembersAttributesResult { + public static final String SERIALIZED_NAME_DATA = "data"; + @SerializedName(SERIALIZED_NAME_DATA) + private Object data; + + public EMGetMultipleGroupMembersAttributesResult() { + } + + public EMGetMultipleGroupMembersAttributesResult data(Object data) { + + this.data = data; + return this; + } + + /** + * Get data + * @return data + **/ + @javax.annotation.Nullable + public Object getData() { + return data; + } + + + public void setData(Object data) { + this.data = data; + } + + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + EMGetMultipleGroupMembersAttributesResult getMultipleGroupMembersAttributesResult = (EMGetMultipleGroupMembersAttributesResult) o; + return Objects.equals(this.data, getMultipleGroupMembersAttributesResult.data); + } + + @Override + public int hashCode() { + return Objects.hash(data); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class EMGetMultipleGroupMembersAttributesResult {\n"); + sb.append(" data: ").append(toIndentedString(data)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("data"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to EMGetMultipleGroupMembersAttributesResult + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!EMGetMultipleGroupMembersAttributesResult.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format("The required field(s) %s in EMGetMultipleGroupMembersAttributesResult is not found in the empty JSON string", EMGetMultipleGroupMembersAttributesResult.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!EMGetMultipleGroupMembersAttributesResult.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `EMGetMultipleGroupMembersAttributesResult` properties. JSON: %s", entry.getKey(), jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!EMGetMultipleGroupMembersAttributesResult.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'EMGetMultipleGroupMembersAttributesResult' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(EMGetMultipleGroupMembersAttributesResult.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, EMGetMultipleGroupMembersAttributesResult value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public EMGetMultipleGroupMembersAttributesResult read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + return thisAdapter.fromJsonTree(jsonElement); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of EMGetMultipleGroupMembersAttributesResult given an JSON string + * + * @param jsonString JSON string + * @return An instance of EMGetMultipleGroupMembersAttributesResult + * @throws IOException if the JSON string is invalid with respect to EMGetMultipleGroupMembersAttributesResult + */ + public static EMGetMultipleGroupMembersAttributesResult fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, EMGetMultipleGroupMembersAttributesResult.class); + } + + /** + * Convert an instance of EMGetMultipleGroupMembersAttributesResult to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/com/easemob/im/api/model/EMGetMultipleUserMetadata.java b/src/main/java/com/easemob/im/api/model/EMGetMultipleUserMetadata.java new file mode 100644 index 000000000..373598e6b --- /dev/null +++ b/src/main/java/com/easemob/im/api/model/EMGetMultipleUserMetadata.java @@ -0,0 +1,259 @@ +/* + * EMService + * Easemob Rest API + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.easemob.im.api.model; + +import java.util.Objects; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import com.easemob.im.JSON; + +/** + * EMGetMultipleUserMetadata + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-01-25T14:51:53.998371+08:00[Asia/Shanghai]") +public class EMGetMultipleUserMetadata { + public static final String SERIALIZED_NAME_TARGETS = "targets"; + @SerializedName(SERIALIZED_NAME_TARGETS) + private List targets; + + public static final String SERIALIZED_NAME_PROPERTIES = "properties"; + @SerializedName(SERIALIZED_NAME_PROPERTIES) + private List properties; + + public EMGetMultipleUserMetadata() { + } + + public EMGetMultipleUserMetadata targets(List targets) { + + this.targets = targets; + return this; + } + + public EMGetMultipleUserMetadata addTargetsItem(String targetsItem) { + if (this.targets == null) { + this.targets = new ArrayList<>(); + } + this.targets.add(targetsItem); + return this; + } + + /** + * 用户 ID 列表,最多可传 100 个用户 ID + * @return targets + **/ + @javax.annotation.Nullable + public List getTargets() { + return targets; + } + + + public void setTargets(List targets) { + this.targets = targets; + } + + + public EMGetMultipleUserMetadata properties(List properties) { + + this.properties = properties; + return this; + } + + public EMGetMultipleUserMetadata addPropertiesItem(String propertiesItem) { + if (this.properties == null) { + this.properties = new ArrayList<>(); + } + this.properties.add(propertiesItem); + return this; + } + + /** + * 属性名列表,查询结果只返回该列表中包含的属性,不在该列表中的属性将被忽略 + * @return properties + **/ + @javax.annotation.Nullable + public List getProperties() { + return properties; + } + + + public void setProperties(List properties) { + this.properties = properties; + } + + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + EMGetMultipleUserMetadata getMultipleUserMetadata = (EMGetMultipleUserMetadata) o; + return Objects.equals(this.targets, getMultipleUserMetadata.targets) && + Objects.equals(this.properties, getMultipleUserMetadata.properties); + } + + @Override + public int hashCode() { + return Objects.hash(targets, properties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class EMGetMultipleUserMetadata {\n"); + sb.append(" targets: ").append(toIndentedString(targets)).append("\n"); + sb.append(" properties: ").append(toIndentedString(properties)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("targets"); + openapiFields.add("properties"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to EMGetMultipleUserMetadata + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!EMGetMultipleUserMetadata.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format("The required field(s) %s in EMGetMultipleUserMetadata is not found in the empty JSON string", EMGetMultipleUserMetadata.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!EMGetMultipleUserMetadata.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `EMGetMultipleUserMetadata` properties. JSON: %s", entry.getKey(), jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // ensure the optional json data is an array if present + if (jsonObj.get("targets") != null && !jsonObj.get("targets").isJsonNull() && !jsonObj.get("targets").isJsonArray()) { + throw new IllegalArgumentException(String.format("Expected the field `targets` to be an array in the JSON string but got `%s`", jsonObj.get("targets").toString())); + } + // ensure the optional json data is an array if present + if (jsonObj.get("properties") != null && !jsonObj.get("properties").isJsonNull() && !jsonObj.get("properties").isJsonArray()) { + throw new IllegalArgumentException(String.format("Expected the field `properties` to be an array in the JSON string but got `%s`", jsonObj.get("properties").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!EMGetMultipleUserMetadata.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'EMGetMultipleUserMetadata' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(EMGetMultipleUserMetadata.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, EMGetMultipleUserMetadata value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public EMGetMultipleUserMetadata read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + return thisAdapter.fromJsonTree(jsonElement); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of EMGetMultipleUserMetadata given an JSON string + * + * @param jsonString JSON string + * @return An instance of EMGetMultipleUserMetadata + * @throws IOException if the JSON string is invalid with respect to EMGetMultipleUserMetadata + */ + public static EMGetMultipleUserMetadata fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, EMGetMultipleUserMetadata.class); + } + + /** + * Convert an instance of EMGetMultipleUserMetadata to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/com/easemob/im/api/model/EMGetMultipleUserMetadataResult.java b/src/main/java/com/easemob/im/api/model/EMGetMultipleUserMetadataResult.java new file mode 100644 index 000000000..702885c11 --- /dev/null +++ b/src/main/java/com/easemob/im/api/model/EMGetMultipleUserMetadataResult.java @@ -0,0 +1,205 @@ +/* + * EMService + * Easemob Rest API + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.easemob.im.api.model; + +import java.util.Objects; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.Arrays; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import com.easemob.im.JSON; + +/** + * EMGetMultipleUserMetadataResult + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-01-25T14:51:53.998371+08:00[Asia/Shanghai]") +public class EMGetMultipleUserMetadataResult { + public static final String SERIALIZED_NAME_DATA = "data"; + @SerializedName(SERIALIZED_NAME_DATA) + private Object data; + + public EMGetMultipleUserMetadataResult() { + } + + public EMGetMultipleUserMetadataResult data(Object data) { + + this.data = data; + return this; + } + + /** + * Get data + * @return data + **/ + @javax.annotation.Nullable + public Object getData() { + return data; + } + + + public void setData(Object data) { + this.data = data; + } + + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + EMGetMultipleUserMetadataResult getMultipleUserMetadataResult = (EMGetMultipleUserMetadataResult) o; + return Objects.equals(this.data, getMultipleUserMetadataResult.data); + } + + @Override + public int hashCode() { + return Objects.hash(data); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class EMGetMultipleUserMetadataResult {\n"); + sb.append(" data: ").append(toIndentedString(data)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("data"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to EMGetMultipleUserMetadataResult + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!EMGetMultipleUserMetadataResult.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format("The required field(s) %s in EMGetMultipleUserMetadataResult is not found in the empty JSON string", EMGetMultipleUserMetadataResult.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!EMGetMultipleUserMetadataResult.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `EMGetMultipleUserMetadataResult` properties. JSON: %s", entry.getKey(), jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!EMGetMultipleUserMetadataResult.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'EMGetMultipleUserMetadataResult' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(EMGetMultipleUserMetadataResult.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, EMGetMultipleUserMetadataResult value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public EMGetMultipleUserMetadataResult read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + return thisAdapter.fromJsonTree(jsonElement); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of EMGetMultipleUserMetadataResult given an JSON string + * + * @param jsonString JSON string + * @return An instance of EMGetMultipleUserMetadataResult + * @throws IOException if the JSON string is invalid with respect to EMGetMultipleUserMetadataResult + */ + public static EMGetMultipleUserMetadataResult fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, EMGetMultipleUserMetadataResult.class); + } + + /** + * Convert an instance of EMGetMultipleUserMetadataResult to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/com/easemob/im/api/model/EMGetMuteRoomMemberListResult.java b/src/main/java/com/easemob/im/api/model/EMGetMuteRoomMemberListResult.java new file mode 100644 index 000000000..cd3ea8671 --- /dev/null +++ b/src/main/java/com/easemob/im/api/model/EMGetMuteRoomMemberListResult.java @@ -0,0 +1,230 @@ +/* + * EMService + * Easemob Rest API + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.easemob.im.api.model; + +import java.util.Objects; +import com.easemob.im.api.model.EMRoomMuteMemberResource; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import com.easemob.im.JSON; + +/** + * EMGetMuteRoomMemberListResult + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-01-25T14:51:53.998371+08:00[Asia/Shanghai]") +public class EMGetMuteRoomMemberListResult { + public static final String SERIALIZED_NAME_DATA = "data"; + @SerializedName(SERIALIZED_NAME_DATA) + private List data; + + public EMGetMuteRoomMemberListResult() { + } + + public EMGetMuteRoomMemberListResult data(List data) { + + this.data = data; + return this; + } + + public EMGetMuteRoomMemberListResult addDataItem(EMRoomMuteMemberResource dataItem) { + if (this.data == null) { + this.data = new ArrayList<>(); + } + this.data.add(dataItem); + return this; + } + + /** + * Get data + * @return data + **/ + @javax.annotation.Nullable + public List getData() { + return data; + } + + + public void setData(List data) { + this.data = data; + } + + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + EMGetMuteRoomMemberListResult getMuteRoomMemberListResult = (EMGetMuteRoomMemberListResult) o; + return Objects.equals(this.data, getMuteRoomMemberListResult.data); + } + + @Override + public int hashCode() { + return Objects.hash(data); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class EMGetMuteRoomMemberListResult {\n"); + sb.append(" data: ").append(toIndentedString(data)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("data"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to EMGetMuteRoomMemberListResult + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!EMGetMuteRoomMemberListResult.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format("The required field(s) %s in EMGetMuteRoomMemberListResult is not found in the empty JSON string", EMGetMuteRoomMemberListResult.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!EMGetMuteRoomMemberListResult.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `EMGetMuteRoomMemberListResult` properties. JSON: %s", entry.getKey(), jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + if (jsonObj.get("data") != null && !jsonObj.get("data").isJsonNull()) { + JsonArray jsonArraydata = jsonObj.getAsJsonArray("data"); + if (jsonArraydata != null) { + // ensure the json data is an array + if (!jsonObj.get("data").isJsonArray()) { + throw new IllegalArgumentException(String.format("Expected the field `data` to be an array in the JSON string but got `%s`", jsonObj.get("data").toString())); + } + + // validate the optional field `data` (array) + for (int i = 0; i < jsonArraydata.size(); i++) { + EMRoomMuteMemberResource.validateJsonElement(jsonArraydata.get(i)); + }; + } + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!EMGetMuteRoomMemberListResult.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'EMGetMuteRoomMemberListResult' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(EMGetMuteRoomMemberListResult.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, EMGetMuteRoomMemberListResult value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public EMGetMuteRoomMemberListResult read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + return thisAdapter.fromJsonTree(jsonElement); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of EMGetMuteRoomMemberListResult given an JSON string + * + * @param jsonString JSON string + * @return An instance of EMGetMuteRoomMemberListResult + * @throws IOException if the JSON string is invalid with respect to EMGetMuteRoomMemberListResult + */ + public static EMGetMuteRoomMemberListResult fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, EMGetMuteRoomMemberListResult.class); + } + + /** + * Convert an instance of EMGetMuteRoomMemberListResult to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/com/easemob/im/api/model/EMGetOfflineMessageStatusResult.java b/src/main/java/com/easemob/im/api/model/EMGetOfflineMessageStatusResult.java new file mode 100644 index 000000000..aec717ae9 --- /dev/null +++ b/src/main/java/com/easemob/im/api/model/EMGetOfflineMessageStatusResult.java @@ -0,0 +1,205 @@ +/* + * EMService + * Easemob Rest API + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.easemob.im.api.model; + +import java.util.Objects; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.Arrays; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import com.easemob.im.JSON; + +/** + * EMGetOfflineMessageStatusResult + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-01-25T14:51:53.998371+08:00[Asia/Shanghai]") +public class EMGetOfflineMessageStatusResult { + public static final String SERIALIZED_NAME_DATA = "data"; + @SerializedName(SERIALIZED_NAME_DATA) + private Object data; + + public EMGetOfflineMessageStatusResult() { + } + + public EMGetOfflineMessageStatusResult data(Object data) { + + this.data = data; + return this; + } + + /** + * Get data + * @return data + **/ + @javax.annotation.Nullable + public Object getData() { + return data; + } + + + public void setData(Object data) { + this.data = data; + } + + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + EMGetOfflineMessageStatusResult getOfflineMessageStatusResult = (EMGetOfflineMessageStatusResult) o; + return Objects.equals(this.data, getOfflineMessageStatusResult.data); + } + + @Override + public int hashCode() { + return Objects.hash(data); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class EMGetOfflineMessageStatusResult {\n"); + sb.append(" data: ").append(toIndentedString(data)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("data"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to EMGetOfflineMessageStatusResult + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!EMGetOfflineMessageStatusResult.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format("The required field(s) %s in EMGetOfflineMessageStatusResult is not found in the empty JSON string", EMGetOfflineMessageStatusResult.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!EMGetOfflineMessageStatusResult.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `EMGetOfflineMessageStatusResult` properties. JSON: %s", entry.getKey(), jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!EMGetOfflineMessageStatusResult.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'EMGetOfflineMessageStatusResult' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(EMGetOfflineMessageStatusResult.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, EMGetOfflineMessageStatusResult value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public EMGetOfflineMessageStatusResult read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + return thisAdapter.fromJsonTree(jsonElement); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of EMGetOfflineMessageStatusResult given an JSON string + * + * @param jsonString JSON string + * @return An instance of EMGetOfflineMessageStatusResult + * @throws IOException if the JSON string is invalid with respect to EMGetOfflineMessageStatusResult + */ + public static EMGetOfflineMessageStatusResult fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, EMGetOfflineMessageStatusResult.class); + } + + /** + * Convert an instance of EMGetOfflineMessageStatusResult to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/com/easemob/im/api/model/EMGetRoomAdminListResult.java b/src/main/java/com/easemob/im/api/model/EMGetRoomAdminListResult.java new file mode 100644 index 000000000..4747cedd5 --- /dev/null +++ b/src/main/java/com/easemob/im/api/model/EMGetRoomAdminListResult.java @@ -0,0 +1,219 @@ +/* + * EMService + * Easemob Rest API + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.easemob.im.api.model; + +import java.util.Objects; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import com.easemob.im.JSON; + +/** + * EMGetRoomAdminListResult + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-01-25T14:51:53.998371+08:00[Asia/Shanghai]") +public class EMGetRoomAdminListResult { + public static final String SERIALIZED_NAME_DATA = "data"; + @SerializedName(SERIALIZED_NAME_DATA) + private List data; + + public EMGetRoomAdminListResult() { + } + + public EMGetRoomAdminListResult data(List data) { + + this.data = data; + return this; + } + + public EMGetRoomAdminListResult addDataItem(String dataItem) { + if (this.data == null) { + this.data = new ArrayList<>(); + } + this.data.add(dataItem); + return this; + } + + /** + * Get data + * @return data + **/ + @javax.annotation.Nullable + public List getData() { + return data; + } + + + public void setData(List data) { + this.data = data; + } + + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + EMGetRoomAdminListResult getRoomAdminListResult = (EMGetRoomAdminListResult) o; + return Objects.equals(this.data, getRoomAdminListResult.data); + } + + @Override + public int hashCode() { + return Objects.hash(data); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class EMGetRoomAdminListResult {\n"); + sb.append(" data: ").append(toIndentedString(data)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("data"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to EMGetRoomAdminListResult + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!EMGetRoomAdminListResult.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format("The required field(s) %s in EMGetRoomAdminListResult is not found in the empty JSON string", EMGetRoomAdminListResult.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!EMGetRoomAdminListResult.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `EMGetRoomAdminListResult` properties. JSON: %s", entry.getKey(), jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // ensure the optional json data is an array if present + if (jsonObj.get("data") != null && !jsonObj.get("data").isJsonNull() && !jsonObj.get("data").isJsonArray()) { + throw new IllegalArgumentException(String.format("Expected the field `data` to be an array in the JSON string but got `%s`", jsonObj.get("data").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!EMGetRoomAdminListResult.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'EMGetRoomAdminListResult' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(EMGetRoomAdminListResult.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, EMGetRoomAdminListResult value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public EMGetRoomAdminListResult read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + return thisAdapter.fromJsonTree(jsonElement); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of EMGetRoomAdminListResult given an JSON string + * + * @param jsonString JSON string + * @return An instance of EMGetRoomAdminListResult + * @throws IOException if the JSON string is invalid with respect to EMGetRoomAdminListResult + */ + public static EMGetRoomAdminListResult fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, EMGetRoomAdminListResult.class); + } + + /** + * Convert an instance of EMGetRoomAdminListResult to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/com/easemob/im/api/model/EMGetRoomAnnouncementResult.java b/src/main/java/com/easemob/im/api/model/EMGetRoomAnnouncementResult.java new file mode 100644 index 000000000..d1d694c9e --- /dev/null +++ b/src/main/java/com/easemob/im/api/model/EMGetRoomAnnouncementResult.java @@ -0,0 +1,210 @@ +/* + * EMService + * Easemob Rest API + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.easemob.im.api.model; + +import java.util.Objects; +import com.easemob.im.api.model.EMModifyRoomResource; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.Arrays; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import com.easemob.im.JSON; + +/** + * EMGetRoomAnnouncementResult + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-01-25T14:51:53.998371+08:00[Asia/Shanghai]") +public class EMGetRoomAnnouncementResult { + public static final String SERIALIZED_NAME_DATA = "data"; + @SerializedName(SERIALIZED_NAME_DATA) + private EMModifyRoomResource data; + + public EMGetRoomAnnouncementResult() { + } + + public EMGetRoomAnnouncementResult data(EMModifyRoomResource data) { + + this.data = data; + return this; + } + + /** + * Get data + * @return data + **/ + @javax.annotation.Nullable + public EMModifyRoomResource getData() { + return data; + } + + + public void setData(EMModifyRoomResource data) { + this.data = data; + } + + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + EMGetRoomAnnouncementResult getRoomAnnouncementResult = (EMGetRoomAnnouncementResult) o; + return Objects.equals(this.data, getRoomAnnouncementResult.data); + } + + @Override + public int hashCode() { + return Objects.hash(data); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class EMGetRoomAnnouncementResult {\n"); + sb.append(" data: ").append(toIndentedString(data)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("data"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to EMGetRoomAnnouncementResult + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!EMGetRoomAnnouncementResult.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format("The required field(s) %s in EMGetRoomAnnouncementResult is not found in the empty JSON string", EMGetRoomAnnouncementResult.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!EMGetRoomAnnouncementResult.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `EMGetRoomAnnouncementResult` properties. JSON: %s", entry.getKey(), jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // validate the optional field `data` + if (jsonObj.get("data") != null && !jsonObj.get("data").isJsonNull()) { + EMModifyRoomResource.validateJsonElement(jsonObj.get("data")); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!EMGetRoomAnnouncementResult.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'EMGetRoomAnnouncementResult' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(EMGetRoomAnnouncementResult.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, EMGetRoomAnnouncementResult value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public EMGetRoomAnnouncementResult read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + return thisAdapter.fromJsonTree(jsonElement); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of EMGetRoomAnnouncementResult given an JSON string + * + * @param jsonString JSON string + * @return An instance of EMGetRoomAnnouncementResult + * @throws IOException if the JSON string is invalid with respect to EMGetRoomAnnouncementResult + */ + public static EMGetRoomAnnouncementResult fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, EMGetRoomAnnouncementResult.class); + } + + /** + * Convert an instance of EMGetRoomAnnouncementResult to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/com/easemob/im/api/model/EMGetRoomBlockListResult.java b/src/main/java/com/easemob/im/api/model/EMGetRoomBlockListResult.java new file mode 100644 index 000000000..49f6a34ed --- /dev/null +++ b/src/main/java/com/easemob/im/api/model/EMGetRoomBlockListResult.java @@ -0,0 +1,219 @@ +/* + * EMService + * Easemob Rest API + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.easemob.im.api.model; + +import java.util.Objects; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import com.easemob.im.JSON; + +/** + * EMGetRoomBlockListResult + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-01-25T14:51:53.998371+08:00[Asia/Shanghai]") +public class EMGetRoomBlockListResult { + public static final String SERIALIZED_NAME_DATA = "data"; + @SerializedName(SERIALIZED_NAME_DATA) + private List data; + + public EMGetRoomBlockListResult() { + } + + public EMGetRoomBlockListResult data(List data) { + + this.data = data; + return this; + } + + public EMGetRoomBlockListResult addDataItem(String dataItem) { + if (this.data == null) { + this.data = new ArrayList<>(); + } + this.data.add(dataItem); + return this; + } + + /** + * Get data + * @return data + **/ + @javax.annotation.Nullable + public List getData() { + return data; + } + + + public void setData(List data) { + this.data = data; + } + + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + EMGetRoomBlockListResult getRoomBlockListResult = (EMGetRoomBlockListResult) o; + return Objects.equals(this.data, getRoomBlockListResult.data); + } + + @Override + public int hashCode() { + return Objects.hash(data); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class EMGetRoomBlockListResult {\n"); + sb.append(" data: ").append(toIndentedString(data)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("data"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to EMGetRoomBlockListResult + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!EMGetRoomBlockListResult.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format("The required field(s) %s in EMGetRoomBlockListResult is not found in the empty JSON string", EMGetRoomBlockListResult.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!EMGetRoomBlockListResult.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `EMGetRoomBlockListResult` properties. JSON: %s", entry.getKey(), jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // ensure the optional json data is an array if present + if (jsonObj.get("data") != null && !jsonObj.get("data").isJsonNull() && !jsonObj.get("data").isJsonArray()) { + throw new IllegalArgumentException(String.format("Expected the field `data` to be an array in the JSON string but got `%s`", jsonObj.get("data").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!EMGetRoomBlockListResult.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'EMGetRoomBlockListResult' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(EMGetRoomBlockListResult.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, EMGetRoomBlockListResult value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public EMGetRoomBlockListResult read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + return thisAdapter.fromJsonTree(jsonElement); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of EMGetRoomBlockListResult given an JSON string + * + * @param jsonString JSON string + * @return An instance of EMGetRoomBlockListResult + * @throws IOException if the JSON string is invalid with respect to EMGetRoomBlockListResult + */ + public static EMGetRoomBlockListResult fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, EMGetRoomBlockListResult.class); + } + + /** + * Convert an instance of EMGetRoomBlockListResult to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/com/easemob/im/api/model/EMGetRoomCustomAttributes.java b/src/main/java/com/easemob/im/api/model/EMGetRoomCustomAttributes.java new file mode 100644 index 000000000..fea3bb415 --- /dev/null +++ b/src/main/java/com/easemob/im/api/model/EMGetRoomCustomAttributes.java @@ -0,0 +1,219 @@ +/* + * EMService + * Easemob Rest API + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.easemob.im.api.model; + +import java.util.Objects; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import com.easemob.im.JSON; + +/** + * EMGetRoomCustomAttributes + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-01-25T14:51:53.998371+08:00[Asia/Shanghai]") +public class EMGetRoomCustomAttributes { + public static final String SERIALIZED_NAME_KEYS = "keys"; + @SerializedName(SERIALIZED_NAME_KEYS) + private List keys; + + public EMGetRoomCustomAttributes() { + } + + public EMGetRoomCustomAttributes keys(List keys) { + + this.keys = keys; + return this; + } + + public EMGetRoomCustomAttributes addKeysItem(String keysItem) { + if (this.keys == null) { + this.keys = new ArrayList<>(); + } + this.keys.add(keysItem); + return this; + } + + /** + * 聊天室自定义属性,为键值对格式,key 为属性名称,value 为属性值 + * @return keys + **/ + @javax.annotation.Nullable + public List getKeys() { + return keys; + } + + + public void setKeys(List keys) { + this.keys = keys; + } + + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + EMGetRoomCustomAttributes getRoomCustomAttributes = (EMGetRoomCustomAttributes) o; + return Objects.equals(this.keys, getRoomCustomAttributes.keys); + } + + @Override + public int hashCode() { + return Objects.hash(keys); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class EMGetRoomCustomAttributes {\n"); + sb.append(" keys: ").append(toIndentedString(keys)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("keys"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to EMGetRoomCustomAttributes + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!EMGetRoomCustomAttributes.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format("The required field(s) %s in EMGetRoomCustomAttributes is not found in the empty JSON string", EMGetRoomCustomAttributes.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!EMGetRoomCustomAttributes.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `EMGetRoomCustomAttributes` properties. JSON: %s", entry.getKey(), jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // ensure the optional json data is an array if present + if (jsonObj.get("keys") != null && !jsonObj.get("keys").isJsonNull() && !jsonObj.get("keys").isJsonArray()) { + throw new IllegalArgumentException(String.format("Expected the field `keys` to be an array in the JSON string but got `%s`", jsonObj.get("keys").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!EMGetRoomCustomAttributes.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'EMGetRoomCustomAttributes' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(EMGetRoomCustomAttributes.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, EMGetRoomCustomAttributes value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public EMGetRoomCustomAttributes read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + return thisAdapter.fromJsonTree(jsonElement); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of EMGetRoomCustomAttributes given an JSON string + * + * @param jsonString JSON string + * @return An instance of EMGetRoomCustomAttributes + * @throws IOException if the JSON string is invalid with respect to EMGetRoomCustomAttributes + */ + public static EMGetRoomCustomAttributes fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, EMGetRoomCustomAttributes.class); + } + + /** + * Convert an instance of EMGetRoomCustomAttributes to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/com/easemob/im/api/model/EMGetRoomCustomAttributesResult.java b/src/main/java/com/easemob/im/api/model/EMGetRoomCustomAttributesResult.java new file mode 100644 index 000000000..f3404a6b9 --- /dev/null +++ b/src/main/java/com/easemob/im/api/model/EMGetRoomCustomAttributesResult.java @@ -0,0 +1,205 @@ +/* + * EMService + * Easemob Rest API + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.easemob.im.api.model; + +import java.util.Objects; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.Arrays; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import com.easemob.im.JSON; + +/** + * EMGetRoomCustomAttributesResult + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-01-25T14:51:53.998371+08:00[Asia/Shanghai]") +public class EMGetRoomCustomAttributesResult { + public static final String SERIALIZED_NAME_DATA = "data"; + @SerializedName(SERIALIZED_NAME_DATA) + private Object data; + + public EMGetRoomCustomAttributesResult() { + } + + public EMGetRoomCustomAttributesResult data(Object data) { + + this.data = data; + return this; + } + + /** + * Get data + * @return data + **/ + @javax.annotation.Nullable + public Object getData() { + return data; + } + + + public void setData(Object data) { + this.data = data; + } + + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + EMGetRoomCustomAttributesResult getRoomCustomAttributesResult = (EMGetRoomCustomAttributesResult) o; + return Objects.equals(this.data, getRoomCustomAttributesResult.data); + } + + @Override + public int hashCode() { + return Objects.hash(data); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class EMGetRoomCustomAttributesResult {\n"); + sb.append(" data: ").append(toIndentedString(data)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("data"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to EMGetRoomCustomAttributesResult + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!EMGetRoomCustomAttributesResult.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format("The required field(s) %s in EMGetRoomCustomAttributesResult is not found in the empty JSON string", EMGetRoomCustomAttributesResult.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!EMGetRoomCustomAttributesResult.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `EMGetRoomCustomAttributesResult` properties. JSON: %s", entry.getKey(), jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!EMGetRoomCustomAttributesResult.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'EMGetRoomCustomAttributesResult' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(EMGetRoomCustomAttributesResult.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, EMGetRoomCustomAttributesResult value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public EMGetRoomCustomAttributesResult read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + return thisAdapter.fromJsonTree(jsonElement); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of EMGetRoomCustomAttributesResult given an JSON string + * + * @param jsonString JSON string + * @return An instance of EMGetRoomCustomAttributesResult + * @throws IOException if the JSON string is invalid with respect to EMGetRoomCustomAttributesResult + */ + public static EMGetRoomCustomAttributesResult fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, EMGetRoomCustomAttributesResult.class); + } + + /** + * Convert an instance of EMGetRoomCustomAttributesResult to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/com/easemob/im/api/model/EMGetRoomInfoResource.java b/src/main/java/com/easemob/im/api/model/EMGetRoomInfoResource.java new file mode 100644 index 000000000..757d0e59b --- /dev/null +++ b/src/main/java/com/easemob/im/api/model/EMGetRoomInfoResource.java @@ -0,0 +1,599 @@ +/* + * EMService + * Easemob Rest API + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.easemob.im.api.model; + +import java.util.Objects; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.math.BigDecimal; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import com.easemob.im.JSON; + +/** + * EMGetRoomInfoResource + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-01-25T14:51:53.998371+08:00[Asia/Shanghai]") +public class EMGetRoomInfoResource { + public static final String SERIALIZED_NAME_ID = "id"; + @SerializedName(SERIALIZED_NAME_ID) + private String id; + + public static final String SERIALIZED_NAME_NAME = "name"; + @SerializedName(SERIALIZED_NAME_NAME) + private String name; + + public static final String SERIALIZED_NAME_DESCRIPTION = "description"; + @SerializedName(SERIALIZED_NAME_DESCRIPTION) + private String description; + + public static final String SERIALIZED_NAME_MEMBERSONLY = "membersonly"; + @SerializedName(SERIALIZED_NAME_MEMBERSONLY) + private Boolean membersonly; + + public static final String SERIALIZED_NAME_ALLOWINVITES = "allowinvites"; + @SerializedName(SERIALIZED_NAME_ALLOWINVITES) + private Boolean allowinvites; + + public static final String SERIALIZED_NAME_MAXUSERS = "maxusers"; + @SerializedName(SERIALIZED_NAME_MAXUSERS) + private Integer maxusers; + + public static final String SERIALIZED_NAME_OWNER = "owner"; + @SerializedName(SERIALIZED_NAME_OWNER) + private String owner; + + public static final String SERIALIZED_NAME_CREATED = "created"; + @SerializedName(SERIALIZED_NAME_CREATED) + private BigDecimal created; + + public static final String SERIALIZED_NAME_CUSTOM = "custom"; + @SerializedName(SERIALIZED_NAME_CUSTOM) + private String custom; + + public static final String SERIALIZED_NAME_MUTE = "mute"; + @SerializedName(SERIALIZED_NAME_MUTE) + private Boolean mute; + + public static final String SERIALIZED_NAME_AFFILIATIONS_COUNT = "affiliations_count"; + @SerializedName(SERIALIZED_NAME_AFFILIATIONS_COUNT) + private Integer affiliationsCount; + + public static final String SERIALIZED_NAME_AFFILIATIONS = "affiliations"; + @SerializedName(SERIALIZED_NAME_AFFILIATIONS) + private List affiliations; + + public static final String SERIALIZED_NAME_DISABLED = "disabled"; + @SerializedName(SERIALIZED_NAME_DISABLED) + private Boolean disabled; + + public static final String SERIALIZED_NAME_PUBLIC = "public"; + @SerializedName(SERIALIZED_NAME_PUBLIC) + private Boolean _public; + + public EMGetRoomInfoResource() { + } + + public EMGetRoomInfoResource id(String id) { + + this.id = id; + return this; + } + + /** + * 聊天室 ID,聊天室唯一标识 + * @return id + **/ + @javax.annotation.Nullable + public String getId() { + return id; + } + + + public void setId(String id) { + this.id = id; + } + + + public EMGetRoomInfoResource name(String name) { + + this.name = name; + return this; + } + + /** + * 聊天室名称 + * @return name + **/ + @javax.annotation.Nullable + public String getName() { + return name; + } + + + public void setName(String name) { + this.name = name; + } + + + public EMGetRoomInfoResource description(String description) { + + this.description = description; + return this; + } + + /** + * 聊天室描述 + * @return description + **/ + @javax.annotation.Nullable + public String getDescription() { + return description; + } + + + public void setDescription(String description) { + this.description = description; + } + + + public EMGetRoomInfoResource membersonly(Boolean membersonly) { + + this.membersonly = membersonly; + return this; + } + + /** + * 加入聊天室是否需要群主或者群管理员审批: - true:是。 - false:否 + * @return membersonly + **/ + @javax.annotation.Nullable + public Boolean getMembersonly() { + return membersonly; + } + + + public void setMembersonly(Boolean membersonly) { + this.membersonly = membersonly; + } + + + public EMGetRoomInfoResource allowinvites(Boolean allowinvites) { + + this.allowinvites = allowinvites; + return this; + } + + /** + * 是否允许聊天室成员邀请其他用户加入该聊天室: - true:允许聊天室成员邀请他人加入该聊天室。 - false:仅聊天室所有者和管理员可邀请他人加入该聊天室 + * @return allowinvites + **/ + @javax.annotation.Nullable + public Boolean getAllowinvites() { + return allowinvites; + } + + + public void setAllowinvites(Boolean allowinvites) { + this.allowinvites = allowinvites; + } + + + public EMGetRoomInfoResource maxusers(Integer maxusers) { + + this.maxusers = maxusers; + return this; + } + + /** + * 聊天室成员数上限,创建聊天室时设置 + * @return maxusers + **/ + @javax.annotation.Nullable + public Integer getMaxusers() { + return maxusers; + } + + + public void setMaxusers(Integer maxusers) { + this.maxusers = maxusers; + } + + + public EMGetRoomInfoResource owner(String owner) { + + this.owner = owner; + return this; + } + + /** + * 聊天室所有者的用户 ID + * @return owner + **/ + @javax.annotation.Nullable + public String getOwner() { + return owner; + } + + + public void setOwner(String owner) { + this.owner = owner; + } + + + public EMGetRoomInfoResource created(BigDecimal created) { + + this.created = created; + return this; + } + + /** + * 创建聊天室时间,Unix 时间戳,单位为毫秒 + * @return created + **/ + @javax.annotation.Nullable + public BigDecimal getCreated() { + return created; + } + + + public void setCreated(BigDecimal created) { + this.created = created; + } + + + public EMGetRoomInfoResource custom(String custom) { + + this.custom = custom; + return this; + } + + /** + * 聊天室扩展信息 + * @return custom + **/ + @javax.annotation.Nullable + public String getCustom() { + return custom; + } + + + public void setCustom(String custom) { + this.custom = custom; + } + + + public EMGetRoomInfoResource mute(Boolean mute) { + + this.mute = mute; + return this; + } + + /** + * 聊天室是否禁言 + * @return mute + **/ + @javax.annotation.Nullable + public Boolean getMute() { + return mute; + } + + + public void setMute(Boolean mute) { + this.mute = mute; + } + + + public EMGetRoomInfoResource affiliationsCount(Integer affiliationsCount) { + + this.affiliationsCount = affiliationsCount; + return this; + } + + /** + * 现有聊天室成员总数 + * @return affiliationsCount + **/ + @javax.annotation.Nullable + public Integer getAffiliationsCount() { + return affiliationsCount; + } + + + public void setAffiliationsCount(Integer affiliationsCount) { + this.affiliationsCount = affiliationsCount; + } + + + public EMGetRoomInfoResource affiliations(List affiliations) { + + this.affiliations = affiliations; + return this; + } + + public EMGetRoomInfoResource addAffiliationsItem(Object affiliationsItem) { + if (this.affiliations == null) { + this.affiliations = new ArrayList<>(); + } + this.affiliations.add(affiliationsItem); + return this; + } + + /** + * 现有聊天室成员列表,包含聊天室所有者和成员(包括聊天室管理员) + * @return affiliations + **/ + @javax.annotation.Nullable + public List getAffiliations() { + return affiliations; + } + + + public void setAffiliations(List affiliations) { + this.affiliations = affiliations; + } + + + public EMGetRoomInfoResource disabled(Boolean disabled) { + + this.disabled = disabled; + return this; + } + + /** + * 聊天室是否封禁 + * @return disabled + **/ + @javax.annotation.Nullable + public Boolean getDisabled() { + return disabled; + } + + + public void setDisabled(Boolean disabled) { + this.disabled = disabled; + } + + + public EMGetRoomInfoResource _public(Boolean _public) { + + this._public = _public; + return this; + } + + /** + * 预留字段,无需关注 + * @return _public + **/ + @javax.annotation.Nullable + public Boolean getPublic() { + return _public; + } + + + public void setPublic(Boolean _public) { + this._public = _public; + } + + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + EMGetRoomInfoResource getRoomInfoResource = (EMGetRoomInfoResource) o; + return Objects.equals(this.id, getRoomInfoResource.id) && + Objects.equals(this.name, getRoomInfoResource.name) && + Objects.equals(this.description, getRoomInfoResource.description) && + Objects.equals(this.membersonly, getRoomInfoResource.membersonly) && + Objects.equals(this.allowinvites, getRoomInfoResource.allowinvites) && + Objects.equals(this.maxusers, getRoomInfoResource.maxusers) && + Objects.equals(this.owner, getRoomInfoResource.owner) && + Objects.equals(this.created, getRoomInfoResource.created) && + Objects.equals(this.custom, getRoomInfoResource.custom) && + Objects.equals(this.mute, getRoomInfoResource.mute) && + Objects.equals(this.affiliationsCount, getRoomInfoResource.affiliationsCount) && + Objects.equals(this.affiliations, getRoomInfoResource.affiliations) && + Objects.equals(this.disabled, getRoomInfoResource.disabled) && + Objects.equals(this._public, getRoomInfoResource._public); + } + + @Override + public int hashCode() { + return Objects.hash(id, name, description, membersonly, allowinvites, maxusers, owner, created, custom, mute, affiliationsCount, affiliations, disabled, _public); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class EMGetRoomInfoResource {\n"); + sb.append(" id: ").append(toIndentedString(id)).append("\n"); + sb.append(" name: ").append(toIndentedString(name)).append("\n"); + sb.append(" description: ").append(toIndentedString(description)).append("\n"); + sb.append(" membersonly: ").append(toIndentedString(membersonly)).append("\n"); + sb.append(" allowinvites: ").append(toIndentedString(allowinvites)).append("\n"); + sb.append(" maxusers: ").append(toIndentedString(maxusers)).append("\n"); + sb.append(" owner: ").append(toIndentedString(owner)).append("\n"); + sb.append(" created: ").append(toIndentedString(created)).append("\n"); + sb.append(" custom: ").append(toIndentedString(custom)).append("\n"); + sb.append(" mute: ").append(toIndentedString(mute)).append("\n"); + sb.append(" affiliationsCount: ").append(toIndentedString(affiliationsCount)).append("\n"); + sb.append(" affiliations: ").append(toIndentedString(affiliations)).append("\n"); + sb.append(" disabled: ").append(toIndentedString(disabled)).append("\n"); + sb.append(" _public: ").append(toIndentedString(_public)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("id"); + openapiFields.add("name"); + openapiFields.add("description"); + openapiFields.add("membersonly"); + openapiFields.add("allowinvites"); + openapiFields.add("maxusers"); + openapiFields.add("owner"); + openapiFields.add("created"); + openapiFields.add("custom"); + openapiFields.add("mute"); + openapiFields.add("affiliations_count"); + openapiFields.add("affiliations"); + openapiFields.add("disabled"); + openapiFields.add("public"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to EMGetRoomInfoResource + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!EMGetRoomInfoResource.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format("The required field(s) %s in EMGetRoomInfoResource is not found in the empty JSON string", EMGetRoomInfoResource.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!EMGetRoomInfoResource.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `EMGetRoomInfoResource` properties. JSON: %s", entry.getKey(), jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + if ((jsonObj.get("id") != null && !jsonObj.get("id").isJsonNull()) && !jsonObj.get("id").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `id` to be a primitive type in the JSON string but got `%s`", jsonObj.get("id").toString())); + } + if ((jsonObj.get("name") != null && !jsonObj.get("name").isJsonNull()) && !jsonObj.get("name").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("name").toString())); + } + if ((jsonObj.get("description") != null && !jsonObj.get("description").isJsonNull()) && !jsonObj.get("description").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `description` to be a primitive type in the JSON string but got `%s`", jsonObj.get("description").toString())); + } + if ((jsonObj.get("owner") != null && !jsonObj.get("owner").isJsonNull()) && !jsonObj.get("owner").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `owner` to be a primitive type in the JSON string but got `%s`", jsonObj.get("owner").toString())); + } + if ((jsonObj.get("custom") != null && !jsonObj.get("custom").isJsonNull()) && !jsonObj.get("custom").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `custom` to be a primitive type in the JSON string but got `%s`", jsonObj.get("custom").toString())); + } + // ensure the optional json data is an array if present + if (jsonObj.get("affiliations") != null && !jsonObj.get("affiliations").isJsonNull() && !jsonObj.get("affiliations").isJsonArray()) { + throw new IllegalArgumentException(String.format("Expected the field `affiliations` to be an array in the JSON string but got `%s`", jsonObj.get("affiliations").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!EMGetRoomInfoResource.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'EMGetRoomInfoResource' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(EMGetRoomInfoResource.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, EMGetRoomInfoResource value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public EMGetRoomInfoResource read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + return thisAdapter.fromJsonTree(jsonElement); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of EMGetRoomInfoResource given an JSON string + * + * @param jsonString JSON string + * @return An instance of EMGetRoomInfoResource + * @throws IOException if the JSON string is invalid with respect to EMGetRoomInfoResource + */ + public static EMGetRoomInfoResource fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, EMGetRoomInfoResource.class); + } + + /** + * Convert an instance of EMGetRoomInfoResource to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/com/easemob/im/api/model/EMGetRoomInfoResult.java b/src/main/java/com/easemob/im/api/model/EMGetRoomInfoResult.java new file mode 100644 index 000000000..cafdebe97 --- /dev/null +++ b/src/main/java/com/easemob/im/api/model/EMGetRoomInfoResult.java @@ -0,0 +1,230 @@ +/* + * EMService + * Easemob Rest API + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.easemob.im.api.model; + +import java.util.Objects; +import com.easemob.im.api.model.EMGetRoomInfoResource; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import com.easemob.im.JSON; + +/** + * EMGetRoomInfoResult + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-01-25T14:51:53.998371+08:00[Asia/Shanghai]") +public class EMGetRoomInfoResult { + public static final String SERIALIZED_NAME_DATA = "data"; + @SerializedName(SERIALIZED_NAME_DATA) + private List data; + + public EMGetRoomInfoResult() { + } + + public EMGetRoomInfoResult data(List data) { + + this.data = data; + return this; + } + + public EMGetRoomInfoResult addDataItem(EMGetRoomInfoResource dataItem) { + if (this.data == null) { + this.data = new ArrayList<>(); + } + this.data.add(dataItem); + return this; + } + + /** + * Get data + * @return data + **/ + @javax.annotation.Nullable + public List getData() { + return data; + } + + + public void setData(List data) { + this.data = data; + } + + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + EMGetRoomInfoResult getRoomInfoResult = (EMGetRoomInfoResult) o; + return Objects.equals(this.data, getRoomInfoResult.data); + } + + @Override + public int hashCode() { + return Objects.hash(data); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class EMGetRoomInfoResult {\n"); + sb.append(" data: ").append(toIndentedString(data)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("data"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to EMGetRoomInfoResult + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!EMGetRoomInfoResult.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format("The required field(s) %s in EMGetRoomInfoResult is not found in the empty JSON string", EMGetRoomInfoResult.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!EMGetRoomInfoResult.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `EMGetRoomInfoResult` properties. JSON: %s", entry.getKey(), jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + if (jsonObj.get("data") != null && !jsonObj.get("data").isJsonNull()) { + JsonArray jsonArraydata = jsonObj.getAsJsonArray("data"); + if (jsonArraydata != null) { + // ensure the json data is an array + if (!jsonObj.get("data").isJsonArray()) { + throw new IllegalArgumentException(String.format("Expected the field `data` to be an array in the JSON string but got `%s`", jsonObj.get("data").toString())); + } + + // validate the optional field `data` (array) + for (int i = 0; i < jsonArraydata.size(); i++) { + EMGetRoomInfoResource.validateJsonElement(jsonArraydata.get(i)); + }; + } + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!EMGetRoomInfoResult.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'EMGetRoomInfoResult' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(EMGetRoomInfoResult.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, EMGetRoomInfoResult value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public EMGetRoomInfoResult read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + return thisAdapter.fromJsonTree(jsonElement); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of EMGetRoomInfoResult given an JSON string + * + * @param jsonString JSON string + * @return An instance of EMGetRoomInfoResult + * @throws IOException if the JSON string is invalid with respect to EMGetRoomInfoResult + */ + public static EMGetRoomInfoResult fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, EMGetRoomInfoResult.class); + } + + /** + * Convert an instance of EMGetRoomInfoResult to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/com/easemob/im/api/model/EMGetRoomListResource.java b/src/main/java/com/easemob/im/api/model/EMGetRoomListResource.java new file mode 100644 index 000000000..43a02df2a --- /dev/null +++ b/src/main/java/com/easemob/im/api/model/EMGetRoomListResource.java @@ -0,0 +1,326 @@ +/* + * EMService + * Easemob Rest API + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.easemob.im.api.model; + +import java.util.Objects; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.Arrays; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import com.easemob.im.JSON; + +/** + * EMGetRoomListResource + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-01-25T14:51:53.998371+08:00[Asia/Shanghai]") +public class EMGetRoomListResource { + public static final String SERIALIZED_NAME_ID = "id"; + @SerializedName(SERIALIZED_NAME_ID) + private String id; + + public static final String SERIALIZED_NAME_NAME = "name"; + @SerializedName(SERIALIZED_NAME_NAME) + private String name; + + public static final String SERIALIZED_NAME_OWNER = "owner"; + @SerializedName(SERIALIZED_NAME_OWNER) + private String owner; + + public static final String SERIALIZED_NAME_AFFILIATIONS_COUNT = "affiliations_count"; + @SerializedName(SERIALIZED_NAME_AFFILIATIONS_COUNT) + private Integer affiliationsCount; + + public static final String SERIALIZED_NAME_DISABLED = "disabled"; + @SerializedName(SERIALIZED_NAME_DISABLED) + private Boolean disabled; + + public EMGetRoomListResource() { + } + + public EMGetRoomListResource id(String id) { + + this.id = id; + return this; + } + + /** + * 聊天室 ID,聊天室唯一标识 + * @return id + **/ + @javax.annotation.Nullable + public String getId() { + return id; + } + + + public void setId(String id) { + this.id = id; + } + + + public EMGetRoomListResource name(String name) { + + this.name = name; + return this; + } + + /** + * 聊天室名称 + * @return name + **/ + @javax.annotation.Nullable + public String getName() { + return name; + } + + + public void setName(String name) { + this.name = name; + } + + + public EMGetRoomListResource owner(String owner) { + + this.owner = owner; + return this; + } + + /** + * 聊天室创建者的用户 ID + * @return owner + **/ + @javax.annotation.Nullable + public String getOwner() { + return owner; + } + + + public void setOwner(String owner) { + this.owner = owner; + } + + + public EMGetRoomListResource affiliationsCount(Integer affiliationsCount) { + + this.affiliationsCount = affiliationsCount; + return this; + } + + /** + * 聊天室现有成员总数(包含聊天室创建者) + * @return affiliationsCount + **/ + @javax.annotation.Nullable + public Integer getAffiliationsCount() { + return affiliationsCount; + } + + + public void setAffiliationsCount(Integer affiliationsCount) { + this.affiliationsCount = affiliationsCount; + } + + + public EMGetRoomListResource disabled(Boolean disabled) { + + this.disabled = disabled; + return this; + } + + /** + * Get disabled + * @return disabled + **/ + @javax.annotation.Nullable + public Boolean getDisabled() { + return disabled; + } + + + public void setDisabled(Boolean disabled) { + this.disabled = disabled; + } + + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + EMGetRoomListResource getRoomListResource = (EMGetRoomListResource) o; + return Objects.equals(this.id, getRoomListResource.id) && + Objects.equals(this.name, getRoomListResource.name) && + Objects.equals(this.owner, getRoomListResource.owner) && + Objects.equals(this.affiliationsCount, getRoomListResource.affiliationsCount) && + Objects.equals(this.disabled, getRoomListResource.disabled); + } + + @Override + public int hashCode() { + return Objects.hash(id, name, owner, affiliationsCount, disabled); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class EMGetRoomListResource {\n"); + sb.append(" id: ").append(toIndentedString(id)).append("\n"); + sb.append(" name: ").append(toIndentedString(name)).append("\n"); + sb.append(" owner: ").append(toIndentedString(owner)).append("\n"); + sb.append(" affiliationsCount: ").append(toIndentedString(affiliationsCount)).append("\n"); + sb.append(" disabled: ").append(toIndentedString(disabled)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("id"); + openapiFields.add("name"); + openapiFields.add("owner"); + openapiFields.add("affiliations_count"); + openapiFields.add("disabled"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to EMGetRoomListResource + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!EMGetRoomListResource.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format("The required field(s) %s in EMGetRoomListResource is not found in the empty JSON string", EMGetRoomListResource.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!EMGetRoomListResource.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `EMGetRoomListResource` properties. JSON: %s", entry.getKey(), jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + if ((jsonObj.get("id") != null && !jsonObj.get("id").isJsonNull()) && !jsonObj.get("id").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `id` to be a primitive type in the JSON string but got `%s`", jsonObj.get("id").toString())); + } + if ((jsonObj.get("name") != null && !jsonObj.get("name").isJsonNull()) && !jsonObj.get("name").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("name").toString())); + } + if ((jsonObj.get("owner") != null && !jsonObj.get("owner").isJsonNull()) && !jsonObj.get("owner").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `owner` to be a primitive type in the JSON string but got `%s`", jsonObj.get("owner").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!EMGetRoomListResource.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'EMGetRoomListResource' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(EMGetRoomListResource.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, EMGetRoomListResource value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public EMGetRoomListResource read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + return thisAdapter.fromJsonTree(jsonElement); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of EMGetRoomListResource given an JSON string + * + * @param jsonString JSON string + * @return An instance of EMGetRoomListResource + * @throws IOException if the JSON string is invalid with respect to EMGetRoomListResource + */ + public static EMGetRoomListResource fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, EMGetRoomListResource.class); + } + + /** + * Convert an instance of EMGetRoomListResource to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/com/easemob/im/api/model/EMGetRoomListResult.java b/src/main/java/com/easemob/im/api/model/EMGetRoomListResult.java new file mode 100644 index 000000000..d850c5616 --- /dev/null +++ b/src/main/java/com/easemob/im/api/model/EMGetRoomListResult.java @@ -0,0 +1,261 @@ +/* + * EMService + * Easemob Rest API + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.easemob.im.api.model; + +import java.util.Objects; +import com.easemob.im.api.model.EMGetRoomListResource; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import com.easemob.im.JSON; + +/** + * EMGetRoomListResult + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-01-25T14:51:53.998371+08:00[Asia/Shanghai]") +public class EMGetRoomListResult { + public static final String SERIALIZED_NAME_DATA = "data"; + @SerializedName(SERIALIZED_NAME_DATA) + private List data; + + public static final String SERIALIZED_NAME_CURSOR = "cursor"; + @SerializedName(SERIALIZED_NAME_CURSOR) + private String cursor; + + public EMGetRoomListResult() { + } + + public EMGetRoomListResult data(List data) { + + this.data = data; + return this; + } + + public EMGetRoomListResult addDataItem(EMGetRoomListResource dataItem) { + if (this.data == null) { + this.data = new ArrayList<>(); + } + this.data.add(dataItem); + return this; + } + + /** + * Get data + * @return data + **/ + @javax.annotation.Nullable + public List getData() { + return data; + } + + + public void setData(List data) { + this.data = data; + } + + + public EMGetRoomListResult cursor(String cursor) { + + this.cursor = cursor; + return this; + } + + /** + * Get cursor + * @return cursor + **/ + @javax.annotation.Nullable + public String getCursor() { + return cursor; + } + + + public void setCursor(String cursor) { + this.cursor = cursor; + } + + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + EMGetRoomListResult getRoomListResult = (EMGetRoomListResult) o; + return Objects.equals(this.data, getRoomListResult.data) && + Objects.equals(this.cursor, getRoomListResult.cursor); + } + + @Override + public int hashCode() { + return Objects.hash(data, cursor); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class EMGetRoomListResult {\n"); + sb.append(" data: ").append(toIndentedString(data)).append("\n"); + sb.append(" cursor: ").append(toIndentedString(cursor)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("data"); + openapiFields.add("cursor"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to EMGetRoomListResult + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!EMGetRoomListResult.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format("The required field(s) %s in EMGetRoomListResult is not found in the empty JSON string", EMGetRoomListResult.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!EMGetRoomListResult.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `EMGetRoomListResult` properties. JSON: %s", entry.getKey(), jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + if (jsonObj.get("data") != null && !jsonObj.get("data").isJsonNull()) { + JsonArray jsonArraydata = jsonObj.getAsJsonArray("data"); + if (jsonArraydata != null) { + // ensure the json data is an array + if (!jsonObj.get("data").isJsonArray()) { + throw new IllegalArgumentException(String.format("Expected the field `data` to be an array in the JSON string but got `%s`", jsonObj.get("data").toString())); + } + + // validate the optional field `data` (array) + for (int i = 0; i < jsonArraydata.size(); i++) { + EMGetRoomListResource.validateJsonElement(jsonArraydata.get(i)); + }; + } + } + if ((jsonObj.get("cursor") != null && !jsonObj.get("cursor").isJsonNull()) && !jsonObj.get("cursor").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `cursor` to be a primitive type in the JSON string but got `%s`", jsonObj.get("cursor").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!EMGetRoomListResult.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'EMGetRoomListResult' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(EMGetRoomListResult.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, EMGetRoomListResult value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public EMGetRoomListResult read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + return thisAdapter.fromJsonTree(jsonElement); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of EMGetRoomListResult given an JSON string + * + * @param jsonString JSON string + * @return An instance of EMGetRoomListResult + * @throws IOException if the JSON string is invalid with respect to EMGetRoomListResult + */ + public static EMGetRoomListResult fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, EMGetRoomListResult.class); + } + + /** + * Convert an instance of EMGetRoomListResult to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/com/easemob/im/api/model/EMGetRoomMemberListResult.java b/src/main/java/com/easemob/im/api/model/EMGetRoomMemberListResult.java new file mode 100644 index 000000000..422376340 --- /dev/null +++ b/src/main/java/com/easemob/im/api/model/EMGetRoomMemberListResult.java @@ -0,0 +1,205 @@ +/* + * EMService + * Easemob Rest API + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.easemob.im.api.model; + +import java.util.Objects; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.Arrays; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import com.easemob.im.JSON; + +/** + * EMGetRoomMemberListResult + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-01-25T14:51:53.998371+08:00[Asia/Shanghai]") +public class EMGetRoomMemberListResult { + public static final String SERIALIZED_NAME_DATA = "data"; + @SerializedName(SERIALIZED_NAME_DATA) + private Object data; + + public EMGetRoomMemberListResult() { + } + + public EMGetRoomMemberListResult data(Object data) { + + this.data = data; + return this; + } + + /** + * Get data + * @return data + **/ + @javax.annotation.Nullable + public Object getData() { + return data; + } + + + public void setData(Object data) { + this.data = data; + } + + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + EMGetRoomMemberListResult getRoomMemberListResult = (EMGetRoomMemberListResult) o; + return Objects.equals(this.data, getRoomMemberListResult.data); + } + + @Override + public int hashCode() { + return Objects.hash(data); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class EMGetRoomMemberListResult {\n"); + sb.append(" data: ").append(toIndentedString(data)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("data"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to EMGetRoomMemberListResult + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!EMGetRoomMemberListResult.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format("The required field(s) %s in EMGetRoomMemberListResult is not found in the empty JSON string", EMGetRoomMemberListResult.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!EMGetRoomMemberListResult.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `EMGetRoomMemberListResult` properties. JSON: %s", entry.getKey(), jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!EMGetRoomMemberListResult.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'EMGetRoomMemberListResult' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(EMGetRoomMemberListResult.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, EMGetRoomMemberListResult value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public EMGetRoomMemberListResult read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + return thisAdapter.fromJsonTree(jsonElement); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of EMGetRoomMemberListResult given an JSON string + * + * @param jsonString JSON string + * @return An instance of EMGetRoomMemberListResult + * @throws IOException if the JSON string is invalid with respect to EMGetRoomMemberListResult + */ + public static EMGetRoomMemberListResult fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, EMGetRoomMemberListResult.class); + } + + /** + * Convert an instance of EMGetRoomMemberListResult to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/com/easemob/im/api/model/EMGetRoomSuperAdminListResult.java b/src/main/java/com/easemob/im/api/model/EMGetRoomSuperAdminListResult.java new file mode 100644 index 000000000..15ec9fa63 --- /dev/null +++ b/src/main/java/com/easemob/im/api/model/EMGetRoomSuperAdminListResult.java @@ -0,0 +1,219 @@ +/* + * EMService + * Easemob Rest API + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.easemob.im.api.model; + +import java.util.Objects; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import com.easemob.im.JSON; + +/** + * EMGetRoomSuperAdminListResult + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-01-25T14:51:53.998371+08:00[Asia/Shanghai]") +public class EMGetRoomSuperAdminListResult { + public static final String SERIALIZED_NAME_DATA = "data"; + @SerializedName(SERIALIZED_NAME_DATA) + private List data; + + public EMGetRoomSuperAdminListResult() { + } + + public EMGetRoomSuperAdminListResult data(List data) { + + this.data = data; + return this; + } + + public EMGetRoomSuperAdminListResult addDataItem(String dataItem) { + if (this.data == null) { + this.data = new ArrayList<>(); + } + this.data.add(dataItem); + return this; + } + + /** + * Get data + * @return data + **/ + @javax.annotation.Nullable + public List getData() { + return data; + } + + + public void setData(List data) { + this.data = data; + } + + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + EMGetRoomSuperAdminListResult getRoomSuperAdminListResult = (EMGetRoomSuperAdminListResult) o; + return Objects.equals(this.data, getRoomSuperAdminListResult.data); + } + + @Override + public int hashCode() { + return Objects.hash(data); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class EMGetRoomSuperAdminListResult {\n"); + sb.append(" data: ").append(toIndentedString(data)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("data"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to EMGetRoomSuperAdminListResult + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!EMGetRoomSuperAdminListResult.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format("The required field(s) %s in EMGetRoomSuperAdminListResult is not found in the empty JSON string", EMGetRoomSuperAdminListResult.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!EMGetRoomSuperAdminListResult.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `EMGetRoomSuperAdminListResult` properties. JSON: %s", entry.getKey(), jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // ensure the optional json data is an array if present + if (jsonObj.get("data") != null && !jsonObj.get("data").isJsonNull() && !jsonObj.get("data").isJsonArray()) { + throw new IllegalArgumentException(String.format("Expected the field `data` to be an array in the JSON string but got `%s`", jsonObj.get("data").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!EMGetRoomSuperAdminListResult.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'EMGetRoomSuperAdminListResult' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(EMGetRoomSuperAdminListResult.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, EMGetRoomSuperAdminListResult value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public EMGetRoomSuperAdminListResult read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + return thisAdapter.fromJsonTree(jsonElement); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of EMGetRoomSuperAdminListResult given an JSON string + * + * @param jsonString JSON string + * @return An instance of EMGetRoomSuperAdminListResult + * @throws IOException if the JSON string is invalid with respect to EMGetRoomSuperAdminListResult + */ + public static EMGetRoomSuperAdminListResult fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, EMGetRoomSuperAdminListResult.class); + } + + /** + * Convert an instance of EMGetRoomSuperAdminListResult to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/com/easemob/im/api/model/EMGetRoomWhiteListResult.java b/src/main/java/com/easemob/im/api/model/EMGetRoomWhiteListResult.java new file mode 100644 index 000000000..2835cae11 --- /dev/null +++ b/src/main/java/com/easemob/im/api/model/EMGetRoomWhiteListResult.java @@ -0,0 +1,219 @@ +/* + * EMService + * Easemob Rest API + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.easemob.im.api.model; + +import java.util.Objects; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import com.easemob.im.JSON; + +/** + * EMGetRoomWhiteListResult + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-01-25T14:51:53.998371+08:00[Asia/Shanghai]") +public class EMGetRoomWhiteListResult { + public static final String SERIALIZED_NAME_DATA = "data"; + @SerializedName(SERIALIZED_NAME_DATA) + private List data; + + public EMGetRoomWhiteListResult() { + } + + public EMGetRoomWhiteListResult data(List data) { + + this.data = data; + return this; + } + + public EMGetRoomWhiteListResult addDataItem(String dataItem) { + if (this.data == null) { + this.data = new ArrayList<>(); + } + this.data.add(dataItem); + return this; + } + + /** + * Get data + * @return data + **/ + @javax.annotation.Nullable + public List getData() { + return data; + } + + + public void setData(List data) { + this.data = data; + } + + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + EMGetRoomWhiteListResult getRoomWhiteListResult = (EMGetRoomWhiteListResult) o; + return Objects.equals(this.data, getRoomWhiteListResult.data); + } + + @Override + public int hashCode() { + return Objects.hash(data); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class EMGetRoomWhiteListResult {\n"); + sb.append(" data: ").append(toIndentedString(data)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("data"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to EMGetRoomWhiteListResult + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!EMGetRoomWhiteListResult.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format("The required field(s) %s in EMGetRoomWhiteListResult is not found in the empty JSON string", EMGetRoomWhiteListResult.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!EMGetRoomWhiteListResult.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `EMGetRoomWhiteListResult` properties. JSON: %s", entry.getKey(), jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // ensure the optional json data is an array if present + if (jsonObj.get("data") != null && !jsonObj.get("data").isJsonNull() && !jsonObj.get("data").isJsonArray()) { + throw new IllegalArgumentException(String.format("Expected the field `data` to be an array in the JSON string but got `%s`", jsonObj.get("data").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!EMGetRoomWhiteListResult.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'EMGetRoomWhiteListResult' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(EMGetRoomWhiteListResult.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, EMGetRoomWhiteListResult value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public EMGetRoomWhiteListResult read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + return thisAdapter.fromJsonTree(jsonElement); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of EMGetRoomWhiteListResult given an JSON string + * + * @param jsonString JSON string + * @return An instance of EMGetRoomWhiteListResult + * @throws IOException if the JSON string is invalid with respect to EMGetRoomWhiteListResult + */ + public static EMGetRoomWhiteListResult fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, EMGetRoomWhiteListResult.class); + } + + /** + * Convert an instance of EMGetRoomWhiteListResult to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/com/easemob/im/api/model/EMGetThreadMemberListResult.java b/src/main/java/com/easemob/im/api/model/EMGetThreadMemberListResult.java new file mode 100644 index 000000000..d3ae7de8d --- /dev/null +++ b/src/main/java/com/easemob/im/api/model/EMGetThreadMemberListResult.java @@ -0,0 +1,243 @@ +/* + * EMService + * Easemob Rest API + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.easemob.im.api.model; + +import java.util.Objects; +import com.easemob.im.api.model.EMGetThreadMemberListResultData; +import com.easemob.im.api.model.EMGetThreadsUnderAppResultProperties; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.Arrays; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import com.easemob.im.JSON; + +/** + * EMGetThreadMemberListResult + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-01-25T14:51:53.998371+08:00[Asia/Shanghai]") +public class EMGetThreadMemberListResult { + public static final String SERIALIZED_NAME_DATA = "data"; + @SerializedName(SERIALIZED_NAME_DATA) + private EMGetThreadMemberListResultData data; + + public static final String SERIALIZED_NAME_PROPERTIES = "properties"; + @SerializedName(SERIALIZED_NAME_PROPERTIES) + private EMGetThreadsUnderAppResultProperties properties; + + public EMGetThreadMemberListResult() { + } + + public EMGetThreadMemberListResult data(EMGetThreadMemberListResultData data) { + + this.data = data; + return this; + } + + /** + * Get data + * @return data + **/ + @javax.annotation.Nullable + public EMGetThreadMemberListResultData getData() { + return data; + } + + + public void setData(EMGetThreadMemberListResultData data) { + this.data = data; + } + + + public EMGetThreadMemberListResult properties(EMGetThreadsUnderAppResultProperties properties) { + + this.properties = properties; + return this; + } + + /** + * Get properties + * @return properties + **/ + @javax.annotation.Nullable + public EMGetThreadsUnderAppResultProperties getProperties() { + return properties; + } + + + public void setProperties(EMGetThreadsUnderAppResultProperties properties) { + this.properties = properties; + } + + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + EMGetThreadMemberListResult getThreadMemberListResult = (EMGetThreadMemberListResult) o; + return Objects.equals(this.data, getThreadMemberListResult.data) && + Objects.equals(this.properties, getThreadMemberListResult.properties); + } + + @Override + public int hashCode() { + return Objects.hash(data, properties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class EMGetThreadMemberListResult {\n"); + sb.append(" data: ").append(toIndentedString(data)).append("\n"); + sb.append(" properties: ").append(toIndentedString(properties)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("data"); + openapiFields.add("properties"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to EMGetThreadMemberListResult + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!EMGetThreadMemberListResult.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format("The required field(s) %s in EMGetThreadMemberListResult is not found in the empty JSON string", EMGetThreadMemberListResult.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!EMGetThreadMemberListResult.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `EMGetThreadMemberListResult` properties. JSON: %s", entry.getKey(), jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // validate the optional field `data` + if (jsonObj.get("data") != null && !jsonObj.get("data").isJsonNull()) { + EMGetThreadMemberListResultData.validateJsonElement(jsonObj.get("data")); + } + // validate the optional field `properties` + if (jsonObj.get("properties") != null && !jsonObj.get("properties").isJsonNull()) { + EMGetThreadsUnderAppResultProperties.validateJsonElement(jsonObj.get("properties")); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!EMGetThreadMemberListResult.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'EMGetThreadMemberListResult' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(EMGetThreadMemberListResult.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, EMGetThreadMemberListResult value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public EMGetThreadMemberListResult read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + return thisAdapter.fromJsonTree(jsonElement); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of EMGetThreadMemberListResult given an JSON string + * + * @param jsonString JSON string + * @return An instance of EMGetThreadMemberListResult + * @throws IOException if the JSON string is invalid with respect to EMGetThreadMemberListResult + */ + public static EMGetThreadMemberListResult fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, EMGetThreadMemberListResult.class); + } + + /** + * Convert an instance of EMGetThreadMemberListResult to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/com/easemob/im/api/model/EMGetThreadMemberListResultData.java b/src/main/java/com/easemob/im/api/model/EMGetThreadMemberListResultData.java new file mode 100644 index 000000000..e8b942b61 --- /dev/null +++ b/src/main/java/com/easemob/im/api/model/EMGetThreadMemberListResultData.java @@ -0,0 +1,219 @@ +/* + * EMService + * Easemob Rest API + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.easemob.im.api.model; + +import java.util.Objects; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import com.easemob.im.JSON; + +/** + * EMGetThreadMemberListResultData + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-01-25T14:51:53.998371+08:00[Asia/Shanghai]") +public class EMGetThreadMemberListResultData { + public static final String SERIALIZED_NAME_AFFILIATIONS = "affiliations"; + @SerializedName(SERIALIZED_NAME_AFFILIATIONS) + private List affiliations; + + public EMGetThreadMemberListResultData() { + } + + public EMGetThreadMemberListResultData affiliations(List affiliations) { + + this.affiliations = affiliations; + return this; + } + + public EMGetThreadMemberListResultData addAffiliationsItem(String affiliationsItem) { + if (this.affiliations == null) { + this.affiliations = new ArrayList<>(); + } + this.affiliations.add(affiliationsItem); + return this; + } + + /** + * Get affiliations + * @return affiliations + **/ + @javax.annotation.Nullable + public List getAffiliations() { + return affiliations; + } + + + public void setAffiliations(List affiliations) { + this.affiliations = affiliations; + } + + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + EMGetThreadMemberListResultData getThreadMemberListResultData = (EMGetThreadMemberListResultData) o; + return Objects.equals(this.affiliations, getThreadMemberListResultData.affiliations); + } + + @Override + public int hashCode() { + return Objects.hash(affiliations); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class EMGetThreadMemberListResultData {\n"); + sb.append(" affiliations: ").append(toIndentedString(affiliations)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("affiliations"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to EMGetThreadMemberListResultData + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!EMGetThreadMemberListResultData.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format("The required field(s) %s in EMGetThreadMemberListResultData is not found in the empty JSON string", EMGetThreadMemberListResultData.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!EMGetThreadMemberListResultData.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `EMGetThreadMemberListResultData` properties. JSON: %s", entry.getKey(), jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // ensure the optional json data is an array if present + if (jsonObj.get("affiliations") != null && !jsonObj.get("affiliations").isJsonNull() && !jsonObj.get("affiliations").isJsonArray()) { + throw new IllegalArgumentException(String.format("Expected the field `affiliations` to be an array in the JSON string but got `%s`", jsonObj.get("affiliations").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!EMGetThreadMemberListResultData.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'EMGetThreadMemberListResultData' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(EMGetThreadMemberListResultData.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, EMGetThreadMemberListResultData value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public EMGetThreadMemberListResultData read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + return thisAdapter.fromJsonTree(jsonElement); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of EMGetThreadMemberListResultData given an JSON string + * + * @param jsonString JSON string + * @return An instance of EMGetThreadMemberListResultData + * @throws IOException if the JSON string is invalid with respect to EMGetThreadMemberListResultData + */ + public static EMGetThreadMemberListResultData fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, EMGetThreadMemberListResultData.class); + } + + /** + * Convert an instance of EMGetThreadMemberListResultData to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/com/easemob/im/api/model/EMGetThreadsUnderAppResource.java b/src/main/java/com/easemob/im/api/model/EMGetThreadsUnderAppResource.java new file mode 100644 index 000000000..d92709e2f --- /dev/null +++ b/src/main/java/com/easemob/im/api/model/EMGetThreadsUnderAppResource.java @@ -0,0 +1,208 @@ +/* + * EMService + * Easemob Rest API + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.easemob.im.api.model; + +import java.util.Objects; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.Arrays; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import com.easemob.im.JSON; + +/** + * EMGetThreadsUnderAppResource + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-01-25T14:51:53.998371+08:00[Asia/Shanghai]") +public class EMGetThreadsUnderAppResource { + public static final String SERIALIZED_NAME_ID = "id"; + @SerializedName(SERIALIZED_NAME_ID) + private String id; + + public EMGetThreadsUnderAppResource() { + } + + public EMGetThreadsUnderAppResource id(String id) { + + this.id = id; + return this; + } + + /** + * Get id + * @return id + **/ + @javax.annotation.Nullable + public String getId() { + return id; + } + + + public void setId(String id) { + this.id = id; + } + + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + EMGetThreadsUnderAppResource getThreadsUnderAppResource = (EMGetThreadsUnderAppResource) o; + return Objects.equals(this.id, getThreadsUnderAppResource.id); + } + + @Override + public int hashCode() { + return Objects.hash(id); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class EMGetThreadsUnderAppResource {\n"); + sb.append(" id: ").append(toIndentedString(id)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("id"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to EMGetThreadsUnderAppResource + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!EMGetThreadsUnderAppResource.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format("The required field(s) %s in EMGetThreadsUnderAppResource is not found in the empty JSON string", EMGetThreadsUnderAppResource.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!EMGetThreadsUnderAppResource.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `EMGetThreadsUnderAppResource` properties. JSON: %s", entry.getKey(), jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + if ((jsonObj.get("id") != null && !jsonObj.get("id").isJsonNull()) && !jsonObj.get("id").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `id` to be a primitive type in the JSON string but got `%s`", jsonObj.get("id").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!EMGetThreadsUnderAppResource.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'EMGetThreadsUnderAppResource' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(EMGetThreadsUnderAppResource.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, EMGetThreadsUnderAppResource value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public EMGetThreadsUnderAppResource read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + return thisAdapter.fromJsonTree(jsonElement); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of EMGetThreadsUnderAppResource given an JSON string + * + * @param jsonString JSON string + * @return An instance of EMGetThreadsUnderAppResource + * @throws IOException if the JSON string is invalid with respect to EMGetThreadsUnderAppResource + */ + public static EMGetThreadsUnderAppResource fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, EMGetThreadsUnderAppResource.class); + } + + /** + * Convert an instance of EMGetThreadsUnderAppResource to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/com/easemob/im/api/model/EMGetThreadsUnderAppResult.java b/src/main/java/com/easemob/im/api/model/EMGetThreadsUnderAppResult.java new file mode 100644 index 000000000..a0d1e23d9 --- /dev/null +++ b/src/main/java/com/easemob/im/api/model/EMGetThreadsUnderAppResult.java @@ -0,0 +1,263 @@ +/* + * EMService + * Easemob Rest API + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.easemob.im.api.model; + +import java.util.Objects; +import com.easemob.im.api.model.EMGetThreadsUnderAppResource; +import com.easemob.im.api.model.EMGetThreadsUnderAppResultProperties; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import com.easemob.im.JSON; + +/** + * EMGetThreadsUnderAppResult + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-01-25T14:51:53.998371+08:00[Asia/Shanghai]") +public class EMGetThreadsUnderAppResult { + public static final String SERIALIZED_NAME_ENTITIES = "entities"; + @SerializedName(SERIALIZED_NAME_ENTITIES) + private List entities; + + public static final String SERIALIZED_NAME_PROPERTIES = "properties"; + @SerializedName(SERIALIZED_NAME_PROPERTIES) + private EMGetThreadsUnderAppResultProperties properties; + + public EMGetThreadsUnderAppResult() { + } + + public EMGetThreadsUnderAppResult entities(List entities) { + + this.entities = entities; + return this; + } + + public EMGetThreadsUnderAppResult addEntitiesItem(EMGetThreadsUnderAppResource entitiesItem) { + if (this.entities == null) { + this.entities = new ArrayList<>(); + } + this.entities.add(entitiesItem); + return this; + } + + /** + * Get entities + * @return entities + **/ + @javax.annotation.Nullable + public List getEntities() { + return entities; + } + + + public void setEntities(List entities) { + this.entities = entities; + } + + + public EMGetThreadsUnderAppResult properties(EMGetThreadsUnderAppResultProperties properties) { + + this.properties = properties; + return this; + } + + /** + * Get properties + * @return properties + **/ + @javax.annotation.Nullable + public EMGetThreadsUnderAppResultProperties getProperties() { + return properties; + } + + + public void setProperties(EMGetThreadsUnderAppResultProperties properties) { + this.properties = properties; + } + + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + EMGetThreadsUnderAppResult getThreadsUnderAppResult = (EMGetThreadsUnderAppResult) o; + return Objects.equals(this.entities, getThreadsUnderAppResult.entities) && + Objects.equals(this.properties, getThreadsUnderAppResult.properties); + } + + @Override + public int hashCode() { + return Objects.hash(entities, properties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class EMGetThreadsUnderAppResult {\n"); + sb.append(" entities: ").append(toIndentedString(entities)).append("\n"); + sb.append(" properties: ").append(toIndentedString(properties)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("entities"); + openapiFields.add("properties"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to EMGetThreadsUnderAppResult + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!EMGetThreadsUnderAppResult.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format("The required field(s) %s in EMGetThreadsUnderAppResult is not found in the empty JSON string", EMGetThreadsUnderAppResult.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!EMGetThreadsUnderAppResult.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `EMGetThreadsUnderAppResult` properties. JSON: %s", entry.getKey(), jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + if (jsonObj.get("entities") != null && !jsonObj.get("entities").isJsonNull()) { + JsonArray jsonArrayentities = jsonObj.getAsJsonArray("entities"); + if (jsonArrayentities != null) { + // ensure the json data is an array + if (!jsonObj.get("entities").isJsonArray()) { + throw new IllegalArgumentException(String.format("Expected the field `entities` to be an array in the JSON string but got `%s`", jsonObj.get("entities").toString())); + } + + // validate the optional field `entities` (array) + for (int i = 0; i < jsonArrayentities.size(); i++) { + EMGetThreadsUnderAppResource.validateJsonElement(jsonArrayentities.get(i)); + }; + } + } + // validate the optional field `properties` + if (jsonObj.get("properties") != null && !jsonObj.get("properties").isJsonNull()) { + EMGetThreadsUnderAppResultProperties.validateJsonElement(jsonObj.get("properties")); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!EMGetThreadsUnderAppResult.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'EMGetThreadsUnderAppResult' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(EMGetThreadsUnderAppResult.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, EMGetThreadsUnderAppResult value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public EMGetThreadsUnderAppResult read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + return thisAdapter.fromJsonTree(jsonElement); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of EMGetThreadsUnderAppResult given an JSON string + * + * @param jsonString JSON string + * @return An instance of EMGetThreadsUnderAppResult + * @throws IOException if the JSON string is invalid with respect to EMGetThreadsUnderAppResult + */ + public static EMGetThreadsUnderAppResult fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, EMGetThreadsUnderAppResult.class); + } + + /** + * Convert an instance of EMGetThreadsUnderAppResult to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/com/easemob/im/api/model/EMGetThreadsUnderAppResultProperties.java b/src/main/java/com/easemob/im/api/model/EMGetThreadsUnderAppResultProperties.java new file mode 100644 index 000000000..87014d67b --- /dev/null +++ b/src/main/java/com/easemob/im/api/model/EMGetThreadsUnderAppResultProperties.java @@ -0,0 +1,208 @@ +/* + * EMService + * Easemob Rest API + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.easemob.im.api.model; + +import java.util.Objects; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.Arrays; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import com.easemob.im.JSON; + +/** + * EMGetThreadsUnderAppResultProperties + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-01-25T14:51:53.998371+08:00[Asia/Shanghai]") +public class EMGetThreadsUnderAppResultProperties { + public static final String SERIALIZED_NAME_CURSOR = "cursor"; + @SerializedName(SERIALIZED_NAME_CURSOR) + private String cursor; + + public EMGetThreadsUnderAppResultProperties() { + } + + public EMGetThreadsUnderAppResultProperties cursor(String cursor) { + + this.cursor = cursor; + return this; + } + + /** + * Get cursor + * @return cursor + **/ + @javax.annotation.Nullable + public String getCursor() { + return cursor; + } + + + public void setCursor(String cursor) { + this.cursor = cursor; + } + + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + EMGetThreadsUnderAppResultProperties getThreadsUnderAppResultProperties = (EMGetThreadsUnderAppResultProperties) o; + return Objects.equals(this.cursor, getThreadsUnderAppResultProperties.cursor); + } + + @Override + public int hashCode() { + return Objects.hash(cursor); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class EMGetThreadsUnderAppResultProperties {\n"); + sb.append(" cursor: ").append(toIndentedString(cursor)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("cursor"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to EMGetThreadsUnderAppResultProperties + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!EMGetThreadsUnderAppResultProperties.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format("The required field(s) %s in EMGetThreadsUnderAppResultProperties is not found in the empty JSON string", EMGetThreadsUnderAppResultProperties.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!EMGetThreadsUnderAppResultProperties.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `EMGetThreadsUnderAppResultProperties` properties. JSON: %s", entry.getKey(), jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + if ((jsonObj.get("cursor") != null && !jsonObj.get("cursor").isJsonNull()) && !jsonObj.get("cursor").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `cursor` to be a primitive type in the JSON string but got `%s`", jsonObj.get("cursor").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!EMGetThreadsUnderAppResultProperties.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'EMGetThreadsUnderAppResultProperties' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(EMGetThreadsUnderAppResultProperties.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, EMGetThreadsUnderAppResultProperties value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public EMGetThreadsUnderAppResultProperties read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + return thisAdapter.fromJsonTree(jsonElement); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of EMGetThreadsUnderAppResultProperties given an JSON string + * + * @param jsonString JSON string + * @return An instance of EMGetThreadsUnderAppResultProperties + * @throws IOException if the JSON string is invalid with respect to EMGetThreadsUnderAppResultProperties + */ + public static EMGetThreadsUnderAppResultProperties fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, EMGetThreadsUnderAppResultProperties.class); + } + + /** + * Convert an instance of EMGetThreadsUnderAppResultProperties to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/com/easemob/im/api/model/EMGetToken.java b/src/main/java/com/easemob/im/api/model/EMGetToken.java new file mode 100644 index 000000000..1d92db000 --- /dev/null +++ b/src/main/java/com/easemob/im/api/model/EMGetToken.java @@ -0,0 +1,208 @@ +/* + * EMService + * Easemob Rest API + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.easemob.im.api.model; + +import java.util.Objects; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.Arrays; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import com.easemob.im.JSON; + +/** + * EMGetToken + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-01-25T14:51:53.998371+08:00[Asia/Shanghai]") +public class EMGetToken { + public static final String SERIALIZED_NAME_ACCESS_TOKEN = "access_token"; + @SerializedName(SERIALIZED_NAME_ACCESS_TOKEN) + private String accessToken; + + public EMGetToken() { + } + + public EMGetToken accessToken(String accessToken) { + + this.accessToken = accessToken; + return this; + } + + /** + * Get accessToken + * @return accessToken + **/ + @javax.annotation.Nullable + public String getAccessToken() { + return accessToken; + } + + + public void setAccessToken(String accessToken) { + this.accessToken = accessToken; + } + + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + EMGetToken getToken = (EMGetToken) o; + return Objects.equals(this.accessToken, getToken.accessToken); + } + + @Override + public int hashCode() { + return Objects.hash(accessToken); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class EMGetToken {\n"); + sb.append(" accessToken: ").append(toIndentedString(accessToken)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("access_token"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to EMGetToken + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!EMGetToken.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format("The required field(s) %s in EMGetToken is not found in the empty JSON string", EMGetToken.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!EMGetToken.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `EMGetToken` properties. JSON: %s", entry.getKey(), jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + if ((jsonObj.get("access_token") != null && !jsonObj.get("access_token").isJsonNull()) && !jsonObj.get("access_token").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `access_token` to be a primitive type in the JSON string but got `%s`", jsonObj.get("access_token").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!EMGetToken.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'EMGetToken' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(EMGetToken.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, EMGetToken value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public EMGetToken read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + return thisAdapter.fromJsonTree(jsonElement); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of EMGetToken given an JSON string + * + * @param jsonString JSON string + * @return An instance of EMGetToken + * @throws IOException if the JSON string is invalid with respect to EMGetToken + */ + public static EMGetToken fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, EMGetToken.class); + } + + /** + * Convert an instance of EMGetToken to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/com/easemob/im/api/model/EMGetUserGlobalMuteResult.java b/src/main/java/com/easemob/im/api/model/EMGetUserGlobalMuteResult.java new file mode 100644 index 000000000..3c5775e95 --- /dev/null +++ b/src/main/java/com/easemob/im/api/model/EMGetUserGlobalMuteResult.java @@ -0,0 +1,210 @@ +/* + * EMService + * Easemob Rest API + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.easemob.im.api.model; + +import java.util.Objects; +import com.easemob.im.api.model.EMUserGlobalMuteResource; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.Arrays; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import com.easemob.im.JSON; + +/** + * EMGetUserGlobalMuteResult + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-01-25T14:51:53.998371+08:00[Asia/Shanghai]") +public class EMGetUserGlobalMuteResult { + public static final String SERIALIZED_NAME_DATA = "data"; + @SerializedName(SERIALIZED_NAME_DATA) + private EMUserGlobalMuteResource data; + + public EMGetUserGlobalMuteResult() { + } + + public EMGetUserGlobalMuteResult data(EMUserGlobalMuteResource data) { + + this.data = data; + return this; + } + + /** + * Get data + * @return data + **/ + @javax.annotation.Nullable + public EMUserGlobalMuteResource getData() { + return data; + } + + + public void setData(EMUserGlobalMuteResource data) { + this.data = data; + } + + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + EMGetUserGlobalMuteResult getUserGlobalMuteResult = (EMGetUserGlobalMuteResult) o; + return Objects.equals(this.data, getUserGlobalMuteResult.data); + } + + @Override + public int hashCode() { + return Objects.hash(data); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class EMGetUserGlobalMuteResult {\n"); + sb.append(" data: ").append(toIndentedString(data)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("data"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to EMGetUserGlobalMuteResult + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!EMGetUserGlobalMuteResult.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format("The required field(s) %s in EMGetUserGlobalMuteResult is not found in the empty JSON string", EMGetUserGlobalMuteResult.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!EMGetUserGlobalMuteResult.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `EMGetUserGlobalMuteResult` properties. JSON: %s", entry.getKey(), jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // validate the optional field `data` + if (jsonObj.get("data") != null && !jsonObj.get("data").isJsonNull()) { + EMUserGlobalMuteResource.validateJsonElement(jsonObj.get("data")); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!EMGetUserGlobalMuteResult.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'EMGetUserGlobalMuteResult' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(EMGetUserGlobalMuteResult.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, EMGetUserGlobalMuteResult value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public EMGetUserGlobalMuteResult read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + return thisAdapter.fromJsonTree(jsonElement); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of EMGetUserGlobalMuteResult given an JSON string + * + * @param jsonString JSON string + * @return An instance of EMGetUserGlobalMuteResult + * @throws IOException if the JSON string is invalid with respect to EMGetUserGlobalMuteResult + */ + public static EMGetUserGlobalMuteResult fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, EMGetUserGlobalMuteResult.class); + } + + /** + * Convert an instance of EMGetUserGlobalMuteResult to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/com/easemob/im/api/model/EMGetUserJoinedGroupsResult.java b/src/main/java/com/easemob/im/api/model/EMGetUserJoinedGroupsResult.java new file mode 100644 index 000000000..2f45159f1 --- /dev/null +++ b/src/main/java/com/easemob/im/api/model/EMGetUserJoinedGroupsResult.java @@ -0,0 +1,230 @@ +/* + * EMService + * Easemob Rest API + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.easemob.im.api.model; + +import java.util.Objects; +import com.easemob.im.api.model.EMUserJoinedGroupResource; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import com.easemob.im.JSON; + +/** + * EMGetUserJoinedGroupsResult + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-01-25T14:51:53.998371+08:00[Asia/Shanghai]") +public class EMGetUserJoinedGroupsResult { + public static final String SERIALIZED_NAME_ENTITIES = "entities"; + @SerializedName(SERIALIZED_NAME_ENTITIES) + private List entities; + + public EMGetUserJoinedGroupsResult() { + } + + public EMGetUserJoinedGroupsResult entities(List entities) { + + this.entities = entities; + return this; + } + + public EMGetUserJoinedGroupsResult addEntitiesItem(EMUserJoinedGroupResource entitiesItem) { + if (this.entities == null) { + this.entities = new ArrayList<>(); + } + this.entities.add(entitiesItem); + return this; + } + + /** + * Get entities + * @return entities + **/ + @javax.annotation.Nullable + public List getEntities() { + return entities; + } + + + public void setEntities(List entities) { + this.entities = entities; + } + + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + EMGetUserJoinedGroupsResult getUserJoinedGroupsResult = (EMGetUserJoinedGroupsResult) o; + return Objects.equals(this.entities, getUserJoinedGroupsResult.entities); + } + + @Override + public int hashCode() { + return Objects.hash(entities); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class EMGetUserJoinedGroupsResult {\n"); + sb.append(" entities: ").append(toIndentedString(entities)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("entities"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to EMGetUserJoinedGroupsResult + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!EMGetUserJoinedGroupsResult.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format("The required field(s) %s in EMGetUserJoinedGroupsResult is not found in the empty JSON string", EMGetUserJoinedGroupsResult.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!EMGetUserJoinedGroupsResult.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `EMGetUserJoinedGroupsResult` properties. JSON: %s", entry.getKey(), jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + if (jsonObj.get("entities") != null && !jsonObj.get("entities").isJsonNull()) { + JsonArray jsonArrayentities = jsonObj.getAsJsonArray("entities"); + if (jsonArrayentities != null) { + // ensure the json data is an array + if (!jsonObj.get("entities").isJsonArray()) { + throw new IllegalArgumentException(String.format("Expected the field `entities` to be an array in the JSON string but got `%s`", jsonObj.get("entities").toString())); + } + + // validate the optional field `entities` (array) + for (int i = 0; i < jsonArrayentities.size(); i++) { + EMUserJoinedGroupResource.validateJsonElement(jsonArrayentities.get(i)); + }; + } + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!EMGetUserJoinedGroupsResult.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'EMGetUserJoinedGroupsResult' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(EMGetUserJoinedGroupsResult.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, EMGetUserJoinedGroupsResult value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public EMGetUserJoinedGroupsResult read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + return thisAdapter.fromJsonTree(jsonElement); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of EMGetUserJoinedGroupsResult given an JSON string + * + * @param jsonString JSON string + * @return An instance of EMGetUserJoinedGroupsResult + * @throws IOException if the JSON string is invalid with respect to EMGetUserJoinedGroupsResult + */ + public static EMGetUserJoinedGroupsResult fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, EMGetUserJoinedGroupsResult.class); + } + + /** + * Convert an instance of EMGetUserJoinedGroupsResult to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/com/easemob/im/api/model/EMGetUserJoinedRoomListResource.java b/src/main/java/com/easemob/im/api/model/EMGetUserJoinedRoomListResource.java new file mode 100644 index 000000000..ad92dee36 --- /dev/null +++ b/src/main/java/com/easemob/im/api/model/EMGetUserJoinedRoomListResource.java @@ -0,0 +1,267 @@ +/* + * EMService + * Easemob Rest API + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.easemob.im.api.model; + +import java.util.Objects; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.Arrays; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import com.easemob.im.JSON; + +/** + * EMGetUserJoinedRoomListResource + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-01-25T14:51:53.998371+08:00[Asia/Shanghai]") +public class EMGetUserJoinedRoomListResource { + public static final String SERIALIZED_NAME_ID = "id"; + @SerializedName(SERIALIZED_NAME_ID) + private String id; + + public static final String SERIALIZED_NAME_NAME = "name"; + @SerializedName(SERIALIZED_NAME_NAME) + private String name; + + public static final String SERIALIZED_NAME_DISABLED = "disabled"; + @SerializedName(SERIALIZED_NAME_DISABLED) + private Boolean disabled; + + public EMGetUserJoinedRoomListResource() { + } + + public EMGetUserJoinedRoomListResource id(String id) { + + this.id = id; + return this; + } + + /** + * 聊天室 ID,聊天室唯一标识 + * @return id + **/ + @javax.annotation.Nullable + public String getId() { + return id; + } + + + public void setId(String id) { + this.id = id; + } + + + public EMGetUserJoinedRoomListResource name(String name) { + + this.name = name; + return this; + } + + /** + * 聊天室名称 + * @return name + **/ + @javax.annotation.Nullable + public String getName() { + return name; + } + + + public void setName(String name) { + this.name = name; + } + + + public EMGetUserJoinedRoomListResource disabled(Boolean disabled) { + + this.disabled = disabled; + return this; + } + + /** + * Get disabled + * @return disabled + **/ + @javax.annotation.Nullable + public Boolean getDisabled() { + return disabled; + } + + + public void setDisabled(Boolean disabled) { + this.disabled = disabled; + } + + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + EMGetUserJoinedRoomListResource getUserJoinedRoomListResource = (EMGetUserJoinedRoomListResource) o; + return Objects.equals(this.id, getUserJoinedRoomListResource.id) && + Objects.equals(this.name, getUserJoinedRoomListResource.name) && + Objects.equals(this.disabled, getUserJoinedRoomListResource.disabled); + } + + @Override + public int hashCode() { + return Objects.hash(id, name, disabled); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class EMGetUserJoinedRoomListResource {\n"); + sb.append(" id: ").append(toIndentedString(id)).append("\n"); + sb.append(" name: ").append(toIndentedString(name)).append("\n"); + sb.append(" disabled: ").append(toIndentedString(disabled)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("id"); + openapiFields.add("name"); + openapiFields.add("disabled"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to EMGetUserJoinedRoomListResource + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!EMGetUserJoinedRoomListResource.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format("The required field(s) %s in EMGetUserJoinedRoomListResource is not found in the empty JSON string", EMGetUserJoinedRoomListResource.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!EMGetUserJoinedRoomListResource.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `EMGetUserJoinedRoomListResource` properties. JSON: %s", entry.getKey(), jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + if ((jsonObj.get("id") != null && !jsonObj.get("id").isJsonNull()) && !jsonObj.get("id").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `id` to be a primitive type in the JSON string but got `%s`", jsonObj.get("id").toString())); + } + if ((jsonObj.get("name") != null && !jsonObj.get("name").isJsonNull()) && !jsonObj.get("name").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("name").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!EMGetUserJoinedRoomListResource.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'EMGetUserJoinedRoomListResource' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(EMGetUserJoinedRoomListResource.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, EMGetUserJoinedRoomListResource value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public EMGetUserJoinedRoomListResource read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + return thisAdapter.fromJsonTree(jsonElement); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of EMGetUserJoinedRoomListResource given an JSON string + * + * @param jsonString JSON string + * @return An instance of EMGetUserJoinedRoomListResource + * @throws IOException if the JSON string is invalid with respect to EMGetUserJoinedRoomListResource + */ + public static EMGetUserJoinedRoomListResource fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, EMGetUserJoinedRoomListResource.class); + } + + /** + * Convert an instance of EMGetUserJoinedRoomListResource to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/com/easemob/im/api/model/EMGetUserJoinedRoomListResult.java b/src/main/java/com/easemob/im/api/model/EMGetUserJoinedRoomListResult.java new file mode 100644 index 000000000..0d7bee8d0 --- /dev/null +++ b/src/main/java/com/easemob/im/api/model/EMGetUserJoinedRoomListResult.java @@ -0,0 +1,230 @@ +/* + * EMService + * Easemob Rest API + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.easemob.im.api.model; + +import java.util.Objects; +import com.easemob.im.api.model.EMGetUserJoinedRoomListResource; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import com.easemob.im.JSON; + +/** + * EMGetUserJoinedRoomListResult + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-01-25T14:51:53.998371+08:00[Asia/Shanghai]") +public class EMGetUserJoinedRoomListResult { + public static final String SERIALIZED_NAME_DATA = "data"; + @SerializedName(SERIALIZED_NAME_DATA) + private List data; + + public EMGetUserJoinedRoomListResult() { + } + + public EMGetUserJoinedRoomListResult data(List data) { + + this.data = data; + return this; + } + + public EMGetUserJoinedRoomListResult addDataItem(EMGetUserJoinedRoomListResource dataItem) { + if (this.data == null) { + this.data = new ArrayList<>(); + } + this.data.add(dataItem); + return this; + } + + /** + * Get data + * @return data + **/ + @javax.annotation.Nullable + public List getData() { + return data; + } + + + public void setData(List data) { + this.data = data; + } + + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + EMGetUserJoinedRoomListResult getUserJoinedRoomListResult = (EMGetUserJoinedRoomListResult) o; + return Objects.equals(this.data, getUserJoinedRoomListResult.data); + } + + @Override + public int hashCode() { + return Objects.hash(data); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class EMGetUserJoinedRoomListResult {\n"); + sb.append(" data: ").append(toIndentedString(data)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("data"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to EMGetUserJoinedRoomListResult + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!EMGetUserJoinedRoomListResult.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format("The required field(s) %s in EMGetUserJoinedRoomListResult is not found in the empty JSON string", EMGetUserJoinedRoomListResult.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!EMGetUserJoinedRoomListResult.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `EMGetUserJoinedRoomListResult` properties. JSON: %s", entry.getKey(), jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + if (jsonObj.get("data") != null && !jsonObj.get("data").isJsonNull()) { + JsonArray jsonArraydata = jsonObj.getAsJsonArray("data"); + if (jsonArraydata != null) { + // ensure the json data is an array + if (!jsonObj.get("data").isJsonArray()) { + throw new IllegalArgumentException(String.format("Expected the field `data` to be an array in the JSON string but got `%s`", jsonObj.get("data").toString())); + } + + // validate the optional field `data` (array) + for (int i = 0; i < jsonArraydata.size(); i++) { + EMGetUserJoinedRoomListResource.validateJsonElement(jsonArraydata.get(i)); + }; + } + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!EMGetUserJoinedRoomListResult.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'EMGetUserJoinedRoomListResult' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(EMGetUserJoinedRoomListResult.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, EMGetUserJoinedRoomListResult value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public EMGetUserJoinedRoomListResult read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + return thisAdapter.fromJsonTree(jsonElement); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of EMGetUserJoinedRoomListResult given an JSON string + * + * @param jsonString JSON string + * @return An instance of EMGetUserJoinedRoomListResult + * @throws IOException if the JSON string is invalid with respect to EMGetUserJoinedRoomListResult + */ + public static EMGetUserJoinedRoomListResult fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, EMGetUserJoinedRoomListResult.class); + } + + /** + * Convert an instance of EMGetUserJoinedRoomListResult to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/com/easemob/im/api/model/EMGetUserJoinedThreadsResult.java b/src/main/java/com/easemob/im/api/model/EMGetUserJoinedThreadsResult.java new file mode 100644 index 000000000..9b55b1bce --- /dev/null +++ b/src/main/java/com/easemob/im/api/model/EMGetUserJoinedThreadsResult.java @@ -0,0 +1,263 @@ +/* + * EMService + * Easemob Rest API + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.easemob.im.api.model; + +import java.util.Objects; +import com.easemob.im.api.model.EMGetThreadsUnderAppResultProperties; +import com.easemob.im.api.model.EMThreadResource; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import com.easemob.im.JSON; + +/** + * EMGetUserJoinedThreadsResult + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-01-25T14:51:53.998371+08:00[Asia/Shanghai]") +public class EMGetUserJoinedThreadsResult { + public static final String SERIALIZED_NAME_ENTITIES = "entities"; + @SerializedName(SERIALIZED_NAME_ENTITIES) + private List entities; + + public static final String SERIALIZED_NAME_PROPERTIES = "properties"; + @SerializedName(SERIALIZED_NAME_PROPERTIES) + private EMGetThreadsUnderAppResultProperties properties; + + public EMGetUserJoinedThreadsResult() { + } + + public EMGetUserJoinedThreadsResult entities(List entities) { + + this.entities = entities; + return this; + } + + public EMGetUserJoinedThreadsResult addEntitiesItem(EMThreadResource entitiesItem) { + if (this.entities == null) { + this.entities = new ArrayList<>(); + } + this.entities.add(entitiesItem); + return this; + } + + /** + * Get entities + * @return entities + **/ + @javax.annotation.Nullable + public List getEntities() { + return entities; + } + + + public void setEntities(List entities) { + this.entities = entities; + } + + + public EMGetUserJoinedThreadsResult properties(EMGetThreadsUnderAppResultProperties properties) { + + this.properties = properties; + return this; + } + + /** + * Get properties + * @return properties + **/ + @javax.annotation.Nullable + public EMGetThreadsUnderAppResultProperties getProperties() { + return properties; + } + + + public void setProperties(EMGetThreadsUnderAppResultProperties properties) { + this.properties = properties; + } + + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + EMGetUserJoinedThreadsResult getUserJoinedThreadsResult = (EMGetUserJoinedThreadsResult) o; + return Objects.equals(this.entities, getUserJoinedThreadsResult.entities) && + Objects.equals(this.properties, getUserJoinedThreadsResult.properties); + } + + @Override + public int hashCode() { + return Objects.hash(entities, properties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class EMGetUserJoinedThreadsResult {\n"); + sb.append(" entities: ").append(toIndentedString(entities)).append("\n"); + sb.append(" properties: ").append(toIndentedString(properties)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("entities"); + openapiFields.add("properties"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to EMGetUserJoinedThreadsResult + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!EMGetUserJoinedThreadsResult.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format("The required field(s) %s in EMGetUserJoinedThreadsResult is not found in the empty JSON string", EMGetUserJoinedThreadsResult.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!EMGetUserJoinedThreadsResult.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `EMGetUserJoinedThreadsResult` properties. JSON: %s", entry.getKey(), jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + if (jsonObj.get("entities") != null && !jsonObj.get("entities").isJsonNull()) { + JsonArray jsonArrayentities = jsonObj.getAsJsonArray("entities"); + if (jsonArrayentities != null) { + // ensure the json data is an array + if (!jsonObj.get("entities").isJsonArray()) { + throw new IllegalArgumentException(String.format("Expected the field `entities` to be an array in the JSON string but got `%s`", jsonObj.get("entities").toString())); + } + + // validate the optional field `entities` (array) + for (int i = 0; i < jsonArrayentities.size(); i++) { + EMThreadResource.validateJsonElement(jsonArrayentities.get(i)); + }; + } + } + // validate the optional field `properties` + if (jsonObj.get("properties") != null && !jsonObj.get("properties").isJsonNull()) { + EMGetThreadsUnderAppResultProperties.validateJsonElement(jsonObj.get("properties")); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!EMGetUserJoinedThreadsResult.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'EMGetUserJoinedThreadsResult' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(EMGetUserJoinedThreadsResult.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, EMGetUserJoinedThreadsResult value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public EMGetUserJoinedThreadsResult read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + return thisAdapter.fromJsonTree(jsonElement); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of EMGetUserJoinedThreadsResult given an JSON string + * + * @param jsonString JSON string + * @return An instance of EMGetUserJoinedThreadsResult + * @throws IOException if the JSON string is invalid with respect to EMGetUserJoinedThreadsResult + */ + public static EMGetUserJoinedThreadsResult fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, EMGetUserJoinedThreadsResult.class); + } + + /** + * Convert an instance of EMGetUserJoinedThreadsResult to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/com/easemob/im/api/model/EMGetUserJoinedThreadsUnderGroupResult.java b/src/main/java/com/easemob/im/api/model/EMGetUserJoinedThreadsUnderGroupResult.java new file mode 100644 index 000000000..6a3028e5b --- /dev/null +++ b/src/main/java/com/easemob/im/api/model/EMGetUserJoinedThreadsUnderGroupResult.java @@ -0,0 +1,263 @@ +/* + * EMService + * Easemob Rest API + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.easemob.im.api.model; + +import java.util.Objects; +import com.easemob.im.api.model.EMGetThreadsUnderAppResultProperties; +import com.easemob.im.api.model.EMThreadResource; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import com.easemob.im.JSON; + +/** + * EMGetUserJoinedThreadsUnderGroupResult + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-01-25T14:51:53.998371+08:00[Asia/Shanghai]") +public class EMGetUserJoinedThreadsUnderGroupResult { + public static final String SERIALIZED_NAME_ENTITIES = "entities"; + @SerializedName(SERIALIZED_NAME_ENTITIES) + private List entities; + + public static final String SERIALIZED_NAME_PROPERTIES = "properties"; + @SerializedName(SERIALIZED_NAME_PROPERTIES) + private EMGetThreadsUnderAppResultProperties properties; + + public EMGetUserJoinedThreadsUnderGroupResult() { + } + + public EMGetUserJoinedThreadsUnderGroupResult entities(List entities) { + + this.entities = entities; + return this; + } + + public EMGetUserJoinedThreadsUnderGroupResult addEntitiesItem(EMThreadResource entitiesItem) { + if (this.entities == null) { + this.entities = new ArrayList<>(); + } + this.entities.add(entitiesItem); + return this; + } + + /** + * Get entities + * @return entities + **/ + @javax.annotation.Nullable + public List getEntities() { + return entities; + } + + + public void setEntities(List entities) { + this.entities = entities; + } + + + public EMGetUserJoinedThreadsUnderGroupResult properties(EMGetThreadsUnderAppResultProperties properties) { + + this.properties = properties; + return this; + } + + /** + * Get properties + * @return properties + **/ + @javax.annotation.Nullable + public EMGetThreadsUnderAppResultProperties getProperties() { + return properties; + } + + + public void setProperties(EMGetThreadsUnderAppResultProperties properties) { + this.properties = properties; + } + + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + EMGetUserJoinedThreadsUnderGroupResult getUserJoinedThreadsUnderGroupResult = (EMGetUserJoinedThreadsUnderGroupResult) o; + return Objects.equals(this.entities, getUserJoinedThreadsUnderGroupResult.entities) && + Objects.equals(this.properties, getUserJoinedThreadsUnderGroupResult.properties); + } + + @Override + public int hashCode() { + return Objects.hash(entities, properties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class EMGetUserJoinedThreadsUnderGroupResult {\n"); + sb.append(" entities: ").append(toIndentedString(entities)).append("\n"); + sb.append(" properties: ").append(toIndentedString(properties)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("entities"); + openapiFields.add("properties"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to EMGetUserJoinedThreadsUnderGroupResult + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!EMGetUserJoinedThreadsUnderGroupResult.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format("The required field(s) %s in EMGetUserJoinedThreadsUnderGroupResult is not found in the empty JSON string", EMGetUserJoinedThreadsUnderGroupResult.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!EMGetUserJoinedThreadsUnderGroupResult.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `EMGetUserJoinedThreadsUnderGroupResult` properties. JSON: %s", entry.getKey(), jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + if (jsonObj.get("entities") != null && !jsonObj.get("entities").isJsonNull()) { + JsonArray jsonArrayentities = jsonObj.getAsJsonArray("entities"); + if (jsonArrayentities != null) { + // ensure the json data is an array + if (!jsonObj.get("entities").isJsonArray()) { + throw new IllegalArgumentException(String.format("Expected the field `entities` to be an array in the JSON string but got `%s`", jsonObj.get("entities").toString())); + } + + // validate the optional field `entities` (array) + for (int i = 0; i < jsonArrayentities.size(); i++) { + EMThreadResource.validateJsonElement(jsonArrayentities.get(i)); + }; + } + } + // validate the optional field `properties` + if (jsonObj.get("properties") != null && !jsonObj.get("properties").isJsonNull()) { + EMGetThreadsUnderAppResultProperties.validateJsonElement(jsonObj.get("properties")); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!EMGetUserJoinedThreadsUnderGroupResult.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'EMGetUserJoinedThreadsUnderGroupResult' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(EMGetUserJoinedThreadsUnderGroupResult.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, EMGetUserJoinedThreadsUnderGroupResult value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public EMGetUserJoinedThreadsUnderGroupResult read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + return thisAdapter.fromJsonTree(jsonElement); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of EMGetUserJoinedThreadsUnderGroupResult given an JSON string + * + * @param jsonString JSON string + * @return An instance of EMGetUserJoinedThreadsUnderGroupResult + * @throws IOException if the JSON string is invalid with respect to EMGetUserJoinedThreadsUnderGroupResult + */ + public static EMGetUserJoinedThreadsUnderGroupResult fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, EMGetUserJoinedThreadsUnderGroupResult.class); + } + + /** + * Convert an instance of EMGetUserJoinedThreadsUnderGroupResult to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/com/easemob/im/api/model/EMGetUserMetadataCapacityResult.java b/src/main/java/com/easemob/im/api/model/EMGetUserMetadataCapacityResult.java new file mode 100644 index 000000000..13a481fcd --- /dev/null +++ b/src/main/java/com/easemob/im/api/model/EMGetUserMetadataCapacityResult.java @@ -0,0 +1,206 @@ +/* + * EMService + * Easemob Rest API + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.easemob.im.api.model; + +import java.util.Objects; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.math.BigDecimal; +import java.util.Arrays; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import com.easemob.im.JSON; + +/** + * EMGetUserMetadataCapacityResult + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-01-25T14:51:53.998371+08:00[Asia/Shanghai]") +public class EMGetUserMetadataCapacityResult { + public static final String SERIALIZED_NAME_DATA = "data"; + @SerializedName(SERIALIZED_NAME_DATA) + private BigDecimal data; + + public EMGetUserMetadataCapacityResult() { + } + + public EMGetUserMetadataCapacityResult data(BigDecimal data) { + + this.data = data; + return this; + } + + /** + * Get data + * @return data + **/ + @javax.annotation.Nullable + public BigDecimal getData() { + return data; + } + + + public void setData(BigDecimal data) { + this.data = data; + } + + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + EMGetUserMetadataCapacityResult getUserMetadataCapacityResult = (EMGetUserMetadataCapacityResult) o; + return Objects.equals(this.data, getUserMetadataCapacityResult.data); + } + + @Override + public int hashCode() { + return Objects.hash(data); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class EMGetUserMetadataCapacityResult {\n"); + sb.append(" data: ").append(toIndentedString(data)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("data"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to EMGetUserMetadataCapacityResult + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!EMGetUserMetadataCapacityResult.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format("The required field(s) %s in EMGetUserMetadataCapacityResult is not found in the empty JSON string", EMGetUserMetadataCapacityResult.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!EMGetUserMetadataCapacityResult.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `EMGetUserMetadataCapacityResult` properties. JSON: %s", entry.getKey(), jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!EMGetUserMetadataCapacityResult.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'EMGetUserMetadataCapacityResult' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(EMGetUserMetadataCapacityResult.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, EMGetUserMetadataCapacityResult value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public EMGetUserMetadataCapacityResult read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + return thisAdapter.fromJsonTree(jsonElement); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of EMGetUserMetadataCapacityResult given an JSON string + * + * @param jsonString JSON string + * @return An instance of EMGetUserMetadataCapacityResult + * @throws IOException if the JSON string is invalid with respect to EMGetUserMetadataCapacityResult + */ + public static EMGetUserMetadataCapacityResult fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, EMGetUserMetadataCapacityResult.class); + } + + /** + * Convert an instance of EMGetUserMetadataCapacityResult to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/com/easemob/im/api/model/EMGetUserMetadataResult.java b/src/main/java/com/easemob/im/api/model/EMGetUserMetadataResult.java new file mode 100644 index 000000000..c6db2df44 --- /dev/null +++ b/src/main/java/com/easemob/im/api/model/EMGetUserMetadataResult.java @@ -0,0 +1,205 @@ +/* + * EMService + * Easemob Rest API + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.easemob.im.api.model; + +import java.util.Objects; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.Arrays; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import com.easemob.im.JSON; + +/** + * EMGetUserMetadataResult + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-01-25T14:51:53.998371+08:00[Asia/Shanghai]") +public class EMGetUserMetadataResult { + public static final String SERIALIZED_NAME_DATA = "data"; + @SerializedName(SERIALIZED_NAME_DATA) + private Object data; + + public EMGetUserMetadataResult() { + } + + public EMGetUserMetadataResult data(Object data) { + + this.data = data; + return this; + } + + /** + * Get data + * @return data + **/ + @javax.annotation.Nullable + public Object getData() { + return data; + } + + + public void setData(Object data) { + this.data = data; + } + + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + EMGetUserMetadataResult getUserMetadataResult = (EMGetUserMetadataResult) o; + return Objects.equals(this.data, getUserMetadataResult.data); + } + + @Override + public int hashCode() { + return Objects.hash(data); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class EMGetUserMetadataResult {\n"); + sb.append(" data: ").append(toIndentedString(data)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("data"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to EMGetUserMetadataResult + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!EMGetUserMetadataResult.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format("The required field(s) %s in EMGetUserMetadataResult is not found in the empty JSON string", EMGetUserMetadataResult.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!EMGetUserMetadataResult.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `EMGetUserMetadataResult` properties. JSON: %s", entry.getKey(), jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!EMGetUserMetadataResult.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'EMGetUserMetadataResult' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(EMGetUserMetadataResult.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, EMGetUserMetadataResult value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public EMGetUserMetadataResult read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + return thisAdapter.fromJsonTree(jsonElement); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of EMGetUserMetadataResult given an JSON string + * + * @param jsonString JSON string + * @return An instance of EMGetUserMetadataResult + * @throws IOException if the JSON string is invalid with respect to EMGetUserMetadataResult + */ + public static EMGetUserMetadataResult fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, EMGetUserMetadataResult.class); + } + + /** + * Convert an instance of EMGetUserMetadataResult to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/com/easemob/im/api/model/EMGetUserOfflineMessageCountResult.java b/src/main/java/com/easemob/im/api/model/EMGetUserOfflineMessageCountResult.java new file mode 100644 index 000000000..cae3751d2 --- /dev/null +++ b/src/main/java/com/easemob/im/api/model/EMGetUserOfflineMessageCountResult.java @@ -0,0 +1,205 @@ +/* + * EMService + * Easemob Rest API + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.easemob.im.api.model; + +import java.util.Objects; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.Arrays; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import com.easemob.im.JSON; + +/** + * EMGetUserOfflineMessageCountResult + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-01-25T14:51:53.998371+08:00[Asia/Shanghai]") +public class EMGetUserOfflineMessageCountResult { + public static final String SERIALIZED_NAME_DATA = "data"; + @SerializedName(SERIALIZED_NAME_DATA) + private Object data; + + public EMGetUserOfflineMessageCountResult() { + } + + public EMGetUserOfflineMessageCountResult data(Object data) { + + this.data = data; + return this; + } + + /** + * Get data + * @return data + **/ + @javax.annotation.Nullable + public Object getData() { + return data; + } + + + public void setData(Object data) { + this.data = data; + } + + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + EMGetUserOfflineMessageCountResult getUserOfflineMessageCountResult = (EMGetUserOfflineMessageCountResult) o; + return Objects.equals(this.data, getUserOfflineMessageCountResult.data); + } + + @Override + public int hashCode() { + return Objects.hash(data); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class EMGetUserOfflineMessageCountResult {\n"); + sb.append(" data: ").append(toIndentedString(data)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("data"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to EMGetUserOfflineMessageCountResult + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!EMGetUserOfflineMessageCountResult.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format("The required field(s) %s in EMGetUserOfflineMessageCountResult is not found in the empty JSON string", EMGetUserOfflineMessageCountResult.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!EMGetUserOfflineMessageCountResult.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `EMGetUserOfflineMessageCountResult` properties. JSON: %s", entry.getKey(), jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!EMGetUserOfflineMessageCountResult.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'EMGetUserOfflineMessageCountResult' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(EMGetUserOfflineMessageCountResult.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, EMGetUserOfflineMessageCountResult value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public EMGetUserOfflineMessageCountResult read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + return thisAdapter.fromJsonTree(jsonElement); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of EMGetUserOfflineMessageCountResult given an JSON string + * + * @param jsonString JSON string + * @return An instance of EMGetUserOfflineMessageCountResult + * @throws IOException if the JSON string is invalid with respect to EMGetUserOfflineMessageCountResult + */ + public static EMGetUserOfflineMessageCountResult fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, EMGetUserOfflineMessageCountResult.class); + } + + /** + * Convert an instance of EMGetUserOfflineMessageCountResult to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/com/easemob/im/api/model/EMGetUserOnlineLoginDeviceListResult.java b/src/main/java/com/easemob/im/api/model/EMGetUserOnlineLoginDeviceListResult.java new file mode 100644 index 000000000..c21cfea52 --- /dev/null +++ b/src/main/java/com/easemob/im/api/model/EMGetUserOnlineLoginDeviceListResult.java @@ -0,0 +1,230 @@ +/* + * EMService + * Easemob Rest API + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.easemob.im.api.model; + +import java.util.Objects; +import com.easemob.im.api.model.EMDeviceResource; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import com.easemob.im.JSON; + +/** + * EMGetUserOnlineLoginDeviceListResult + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-01-25T14:51:53.998371+08:00[Asia/Shanghai]") +public class EMGetUserOnlineLoginDeviceListResult { + public static final String SERIALIZED_NAME_DATA = "data"; + @SerializedName(SERIALIZED_NAME_DATA) + private List data; + + public EMGetUserOnlineLoginDeviceListResult() { + } + + public EMGetUserOnlineLoginDeviceListResult data(List data) { + + this.data = data; + return this; + } + + public EMGetUserOnlineLoginDeviceListResult addDataItem(EMDeviceResource dataItem) { + if (this.data == null) { + this.data = new ArrayList<>(); + } + this.data.add(dataItem); + return this; + } + + /** + * Get data + * @return data + **/ + @javax.annotation.Nullable + public List getData() { + return data; + } + + + public void setData(List data) { + this.data = data; + } + + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + EMGetUserOnlineLoginDeviceListResult getUserOnlineLoginDeviceListResult = (EMGetUserOnlineLoginDeviceListResult) o; + return Objects.equals(this.data, getUserOnlineLoginDeviceListResult.data); + } + + @Override + public int hashCode() { + return Objects.hash(data); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class EMGetUserOnlineLoginDeviceListResult {\n"); + sb.append(" data: ").append(toIndentedString(data)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("data"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to EMGetUserOnlineLoginDeviceListResult + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!EMGetUserOnlineLoginDeviceListResult.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format("The required field(s) %s in EMGetUserOnlineLoginDeviceListResult is not found in the empty JSON string", EMGetUserOnlineLoginDeviceListResult.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!EMGetUserOnlineLoginDeviceListResult.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `EMGetUserOnlineLoginDeviceListResult` properties. JSON: %s", entry.getKey(), jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + if (jsonObj.get("data") != null && !jsonObj.get("data").isJsonNull()) { + JsonArray jsonArraydata = jsonObj.getAsJsonArray("data"); + if (jsonArraydata != null) { + // ensure the json data is an array + if (!jsonObj.get("data").isJsonArray()) { + throw new IllegalArgumentException(String.format("Expected the field `data` to be an array in the JSON string but got `%s`", jsonObj.get("data").toString())); + } + + // validate the optional field `data` (array) + for (int i = 0; i < jsonArraydata.size(); i++) { + EMDeviceResource.validateJsonElement(jsonArraydata.get(i)); + }; + } + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!EMGetUserOnlineLoginDeviceListResult.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'EMGetUserOnlineLoginDeviceListResult' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(EMGetUserOnlineLoginDeviceListResult.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, EMGetUserOnlineLoginDeviceListResult value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public EMGetUserOnlineLoginDeviceListResult read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + return thisAdapter.fromJsonTree(jsonElement); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of EMGetUserOnlineLoginDeviceListResult given an JSON string + * + * @param jsonString JSON string + * @return An instance of EMGetUserOnlineLoginDeviceListResult + * @throws IOException if the JSON string is invalid with respect to EMGetUserOnlineLoginDeviceListResult + */ + public static EMGetUserOnlineLoginDeviceListResult fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, EMGetUserOnlineLoginDeviceListResult.class); + } + + /** + * Convert an instance of EMGetUserOnlineLoginDeviceListResult to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/com/easemob/im/api/model/EMGetUserOnlineStateResult.java b/src/main/java/com/easemob/im/api/model/EMGetUserOnlineStateResult.java new file mode 100644 index 000000000..abaedaab1 --- /dev/null +++ b/src/main/java/com/easemob/im/api/model/EMGetUserOnlineStateResult.java @@ -0,0 +1,205 @@ +/* + * EMService + * Easemob Rest API + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.easemob.im.api.model; + +import java.util.Objects; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.Arrays; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import com.easemob.im.JSON; + +/** + * EMGetUserOnlineStateResult + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-01-25T14:51:53.998371+08:00[Asia/Shanghai]") +public class EMGetUserOnlineStateResult { + public static final String SERIALIZED_NAME_DATA = "data"; + @SerializedName(SERIALIZED_NAME_DATA) + private Object data; + + public EMGetUserOnlineStateResult() { + } + + public EMGetUserOnlineStateResult data(Object data) { + + this.data = data; + return this; + } + + /** + * Get data + * @return data + **/ + @javax.annotation.Nullable + public Object getData() { + return data; + } + + + public void setData(Object data) { + this.data = data; + } + + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + EMGetUserOnlineStateResult getUserOnlineStateResult = (EMGetUserOnlineStateResult) o; + return Objects.equals(this.data, getUserOnlineStateResult.data); + } + + @Override + public int hashCode() { + return Objects.hash(data); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class EMGetUserOnlineStateResult {\n"); + sb.append(" data: ").append(toIndentedString(data)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("data"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to EMGetUserOnlineStateResult + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!EMGetUserOnlineStateResult.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format("The required field(s) %s in EMGetUserOnlineStateResult is not found in the empty JSON string", EMGetUserOnlineStateResult.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!EMGetUserOnlineStateResult.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `EMGetUserOnlineStateResult` properties. JSON: %s", entry.getKey(), jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!EMGetUserOnlineStateResult.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'EMGetUserOnlineStateResult' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(EMGetUserOnlineStateResult.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, EMGetUserOnlineStateResult value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public EMGetUserOnlineStateResult read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + return thisAdapter.fromJsonTree(jsonElement); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of EMGetUserOnlineStateResult given an JSON string + * + * @param jsonString JSON string + * @return An instance of EMGetUserOnlineStateResult + * @throws IOException if the JSON string is invalid with respect to EMGetUserOnlineStateResult + */ + public static EMGetUserOnlineStateResult fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, EMGetUserOnlineStateResult.class); + } + + /** + * Convert an instance of EMGetUserOnlineStateResult to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/com/easemob/im/api/model/EMGetUserResult.java b/src/main/java/com/easemob/im/api/model/EMGetUserResult.java new file mode 100644 index 000000000..8b3c8c432 --- /dev/null +++ b/src/main/java/com/easemob/im/api/model/EMGetUserResult.java @@ -0,0 +1,230 @@ +/* + * EMService + * Easemob Rest API + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.easemob.im.api.model; + +import java.util.Objects; +import com.easemob.im.api.model.EMUserResource; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import com.easemob.im.JSON; + +/** + * EMGetUserResult + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-01-25T14:51:53.998371+08:00[Asia/Shanghai]") +public class EMGetUserResult { + public static final String SERIALIZED_NAME_ENTITIES = "entities"; + @SerializedName(SERIALIZED_NAME_ENTITIES) + private List entities; + + public EMGetUserResult() { + } + + public EMGetUserResult entities(List entities) { + + this.entities = entities; + return this; + } + + public EMGetUserResult addEntitiesItem(EMUserResource entitiesItem) { + if (this.entities == null) { + this.entities = new ArrayList<>(); + } + this.entities.add(entitiesItem); + return this; + } + + /** + * Get entities + * @return entities + **/ + @javax.annotation.Nullable + public List getEntities() { + return entities; + } + + + public void setEntities(List entities) { + this.entities = entities; + } + + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + EMGetUserResult getUserResult = (EMGetUserResult) o; + return Objects.equals(this.entities, getUserResult.entities); + } + + @Override + public int hashCode() { + return Objects.hash(entities); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class EMGetUserResult {\n"); + sb.append(" entities: ").append(toIndentedString(entities)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("entities"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to EMGetUserResult + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!EMGetUserResult.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format("The required field(s) %s in EMGetUserResult is not found in the empty JSON string", EMGetUserResult.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!EMGetUserResult.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `EMGetUserResult` properties. JSON: %s", entry.getKey(), jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + if (jsonObj.get("entities") != null && !jsonObj.get("entities").isJsonNull()) { + JsonArray jsonArrayentities = jsonObj.getAsJsonArray("entities"); + if (jsonArrayentities != null) { + // ensure the json data is an array + if (!jsonObj.get("entities").isJsonArray()) { + throw new IllegalArgumentException(String.format("Expected the field `entities` to be an array in the JSON string but got `%s`", jsonObj.get("entities").toString())); + } + + // validate the optional field `entities` (array) + for (int i = 0; i < jsonArrayentities.size(); i++) { + EMUserResource.validateJsonElement(jsonArrayentities.get(i)); + }; + } + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!EMGetUserResult.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'EMGetUserResult' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(EMGetUserResult.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, EMGetUserResult value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public EMGetUserResult read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + return thisAdapter.fromJsonTree(jsonElement); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of EMGetUserResult given an JSON string + * + * @param jsonString JSON string + * @return An instance of EMGetUserResult + * @throws IOException if the JSON string is invalid with respect to EMGetUserResult + */ + public static EMGetUserResult fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, EMGetUserResult.class); + } + + /** + * Convert an instance of EMGetUserResult to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/com/easemob/im/api/model/EMGetUsersOnlineState.java b/src/main/java/com/easemob/im/api/model/EMGetUsersOnlineState.java new file mode 100644 index 000000000..2a89f0265 --- /dev/null +++ b/src/main/java/com/easemob/im/api/model/EMGetUsersOnlineState.java @@ -0,0 +1,219 @@ +/* + * EMService + * Easemob Rest API + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.easemob.im.api.model; + +import java.util.Objects; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import com.easemob.im.JSON; + +/** + * EMGetUsersOnlineState + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-01-25T14:51:53.998371+08:00[Asia/Shanghai]") +public class EMGetUsersOnlineState { + public static final String SERIALIZED_NAME_USERNAMES = "usernames"; + @SerializedName(SERIALIZED_NAME_USERNAMES) + private List usernames; + + public EMGetUsersOnlineState() { + } + + public EMGetUsersOnlineState usernames(List usernames) { + + this.usernames = usernames; + return this; + } + + public EMGetUsersOnlineState addUsernamesItem(String usernamesItem) { + if (this.usernames == null) { + this.usernames = new ArrayList<>(); + } + this.usernames.add(usernamesItem); + return this; + } + + /** + * Get usernames + * @return usernames + **/ + @javax.annotation.Nullable + public List getUsernames() { + return usernames; + } + + + public void setUsernames(List usernames) { + this.usernames = usernames; + } + + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + EMGetUsersOnlineState getUsersOnlineState = (EMGetUsersOnlineState) o; + return Objects.equals(this.usernames, getUsersOnlineState.usernames); + } + + @Override + public int hashCode() { + return Objects.hash(usernames); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class EMGetUsersOnlineState {\n"); + sb.append(" usernames: ").append(toIndentedString(usernames)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("usernames"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to EMGetUsersOnlineState + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!EMGetUsersOnlineState.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format("The required field(s) %s in EMGetUsersOnlineState is not found in the empty JSON string", EMGetUsersOnlineState.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!EMGetUsersOnlineState.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `EMGetUsersOnlineState` properties. JSON: %s", entry.getKey(), jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // ensure the optional json data is an array if present + if (jsonObj.get("usernames") != null && !jsonObj.get("usernames").isJsonNull() && !jsonObj.get("usernames").isJsonArray()) { + throw new IllegalArgumentException(String.format("Expected the field `usernames` to be an array in the JSON string but got `%s`", jsonObj.get("usernames").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!EMGetUsersOnlineState.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'EMGetUsersOnlineState' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(EMGetUsersOnlineState.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, EMGetUsersOnlineState value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public EMGetUsersOnlineState read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + return thisAdapter.fromJsonTree(jsonElement); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of EMGetUsersOnlineState given an JSON string + * + * @param jsonString JSON string + * @return An instance of EMGetUsersOnlineState + * @throws IOException if the JSON string is invalid with respect to EMGetUsersOnlineState + */ + public static EMGetUsersOnlineState fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, EMGetUsersOnlineState.class); + } + + /** + * Convert an instance of EMGetUsersOnlineState to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/com/easemob/im/api/model/EMGetUsersOnlineStateResult.java b/src/main/java/com/easemob/im/api/model/EMGetUsersOnlineStateResult.java new file mode 100644 index 000000000..c0e477826 --- /dev/null +++ b/src/main/java/com/easemob/im/api/model/EMGetUsersOnlineStateResult.java @@ -0,0 +1,219 @@ +/* + * EMService + * Easemob Rest API + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.easemob.im.api.model; + +import java.util.Objects; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import com.easemob.im.JSON; + +/** + * EMGetUsersOnlineStateResult + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-01-25T14:51:53.998371+08:00[Asia/Shanghai]") +public class EMGetUsersOnlineStateResult { + public static final String SERIALIZED_NAME_DATA = "data"; + @SerializedName(SERIALIZED_NAME_DATA) + private List data; + + public EMGetUsersOnlineStateResult() { + } + + public EMGetUsersOnlineStateResult data(List data) { + + this.data = data; + return this; + } + + public EMGetUsersOnlineStateResult addDataItem(Object dataItem) { + if (this.data == null) { + this.data = new ArrayList<>(); + } + this.data.add(dataItem); + return this; + } + + /** + * Get data + * @return data + **/ + @javax.annotation.Nullable + public List getData() { + return data; + } + + + public void setData(List data) { + this.data = data; + } + + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + EMGetUsersOnlineStateResult getUsersOnlineStateResult = (EMGetUsersOnlineStateResult) o; + return Objects.equals(this.data, getUsersOnlineStateResult.data); + } + + @Override + public int hashCode() { + return Objects.hash(data); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class EMGetUsersOnlineStateResult {\n"); + sb.append(" data: ").append(toIndentedString(data)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("data"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to EMGetUsersOnlineStateResult + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!EMGetUsersOnlineStateResult.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format("The required field(s) %s in EMGetUsersOnlineStateResult is not found in the empty JSON string", EMGetUsersOnlineStateResult.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!EMGetUsersOnlineStateResult.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `EMGetUsersOnlineStateResult` properties. JSON: %s", entry.getKey(), jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // ensure the optional json data is an array if present + if (jsonObj.get("data") != null && !jsonObj.get("data").isJsonNull() && !jsonObj.get("data").isJsonArray()) { + throw new IllegalArgumentException(String.format("Expected the field `data` to be an array in the JSON string but got `%s`", jsonObj.get("data").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!EMGetUsersOnlineStateResult.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'EMGetUsersOnlineStateResult' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(EMGetUsersOnlineStateResult.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, EMGetUsersOnlineStateResult value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public EMGetUsersOnlineStateResult read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + return thisAdapter.fromJsonTree(jsonElement); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of EMGetUsersOnlineStateResult given an JSON string + * + * @param jsonString JSON string + * @return An instance of EMGetUsersOnlineStateResult + * @throws IOException if the JSON string is invalid with respect to EMGetUsersOnlineStateResult + */ + public static EMGetUsersOnlineStateResult fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, EMGetUsersOnlineStateResult.class); + } + + /** + * Convert an instance of EMGetUsersOnlineStateResult to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/com/easemob/im/api/model/EMGetUsersResult.java b/src/main/java/com/easemob/im/api/model/EMGetUsersResult.java new file mode 100644 index 000000000..33b4fee4b --- /dev/null +++ b/src/main/java/com/easemob/im/api/model/EMGetUsersResult.java @@ -0,0 +1,261 @@ +/* + * EMService + * Easemob Rest API + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.easemob.im.api.model; + +import java.util.Objects; +import com.easemob.im.api.model.EMUserResource; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import com.easemob.im.JSON; + +/** + * EMGetUsersResult + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-01-25T14:51:53.998371+08:00[Asia/Shanghai]") +public class EMGetUsersResult { + public static final String SERIALIZED_NAME_ENTITIES = "entities"; + @SerializedName(SERIALIZED_NAME_ENTITIES) + private List entities; + + public static final String SERIALIZED_NAME_CURSOR = "cursor"; + @SerializedName(SERIALIZED_NAME_CURSOR) + private String cursor; + + public EMGetUsersResult() { + } + + public EMGetUsersResult entities(List entities) { + + this.entities = entities; + return this; + } + + public EMGetUsersResult addEntitiesItem(EMUserResource entitiesItem) { + if (this.entities == null) { + this.entities = new ArrayList<>(); + } + this.entities.add(entitiesItem); + return this; + } + + /** + * Get entities + * @return entities + **/ + @javax.annotation.Nullable + public List getEntities() { + return entities; + } + + + public void setEntities(List entities) { + this.entities = entities; + } + + + public EMGetUsersResult cursor(String cursor) { + + this.cursor = cursor; + return this; + } + + /** + * Get cursor + * @return cursor + **/ + @javax.annotation.Nullable + public String getCursor() { + return cursor; + } + + + public void setCursor(String cursor) { + this.cursor = cursor; + } + + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + EMGetUsersResult getUsersResult = (EMGetUsersResult) o; + return Objects.equals(this.entities, getUsersResult.entities) && + Objects.equals(this.cursor, getUsersResult.cursor); + } + + @Override + public int hashCode() { + return Objects.hash(entities, cursor); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class EMGetUsersResult {\n"); + sb.append(" entities: ").append(toIndentedString(entities)).append("\n"); + sb.append(" cursor: ").append(toIndentedString(cursor)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("entities"); + openapiFields.add("cursor"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to EMGetUsersResult + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!EMGetUsersResult.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format("The required field(s) %s in EMGetUsersResult is not found in the empty JSON string", EMGetUsersResult.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!EMGetUsersResult.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `EMGetUsersResult` properties. JSON: %s", entry.getKey(), jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + if (jsonObj.get("entities") != null && !jsonObj.get("entities").isJsonNull()) { + JsonArray jsonArrayentities = jsonObj.getAsJsonArray("entities"); + if (jsonArrayentities != null) { + // ensure the json data is an array + if (!jsonObj.get("entities").isJsonArray()) { + throw new IllegalArgumentException(String.format("Expected the field `entities` to be an array in the JSON string but got `%s`", jsonObj.get("entities").toString())); + } + + // validate the optional field `entities` (array) + for (int i = 0; i < jsonArrayentities.size(); i++) { + EMUserResource.validateJsonElement(jsonArrayentities.get(i)); + }; + } + } + if ((jsonObj.get("cursor") != null && !jsonObj.get("cursor").isJsonNull()) && !jsonObj.get("cursor").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `cursor` to be a primitive type in the JSON string but got `%s`", jsonObj.get("cursor").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!EMGetUsersResult.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'EMGetUsersResult' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(EMGetUsersResult.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, EMGetUsersResult value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public EMGetUsersResult read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + return thisAdapter.fromJsonTree(jsonElement); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of EMGetUsersResult given an JSON string + * + * @param jsonString JSON string + * @return An instance of EMGetUsersResult + * @throws IOException if the JSON string is invalid with respect to EMGetUsersResult + */ + public static EMGetUsersResult fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, EMGetUsersResult.class); + } + + /** + * Convert an instance of EMGetUsersResult to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/com/easemob/im/api/model/EMGroupInfoResource.java b/src/main/java/com/easemob/im/api/model/EMGroupInfoResource.java new file mode 100644 index 000000000..9cb322420 --- /dev/null +++ b/src/main/java/com/easemob/im/api/model/EMGroupInfoResource.java @@ -0,0 +1,599 @@ +/* + * EMService + * Easemob Rest API + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.easemob.im.api.model; + +import java.util.Objects; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.math.BigDecimal; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import com.easemob.im.JSON; + +/** + * EMGroupInfoResource + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-01-25T14:51:53.998371+08:00[Asia/Shanghai]") +public class EMGroupInfoResource { + public static final String SERIALIZED_NAME_ID = "id"; + @SerializedName(SERIALIZED_NAME_ID) + private String id; + + public static final String SERIALIZED_NAME_NAME = "name"; + @SerializedName(SERIALIZED_NAME_NAME) + private String name; + + public static final String SERIALIZED_NAME_DESCRIPTION = "description"; + @SerializedName(SERIALIZED_NAME_DESCRIPTION) + private String description; + + public static final String SERIALIZED_NAME_MEMBERSONLY = "membersonly"; + @SerializedName(SERIALIZED_NAME_MEMBERSONLY) + private Boolean membersonly; + + public static final String SERIALIZED_NAME_ALLOWINVITES = "allowinvites"; + @SerializedName(SERIALIZED_NAME_ALLOWINVITES) + private Boolean allowinvites; + + public static final String SERIALIZED_NAME_MAXUSERS = "maxusers"; + @SerializedName(SERIALIZED_NAME_MAXUSERS) + private Integer maxusers; + + public static final String SERIALIZED_NAME_AFFILIATIONS = "affiliations"; + @SerializedName(SERIALIZED_NAME_AFFILIATIONS) + private List affiliations; + + public static final String SERIALIZED_NAME_OWNER = "owner"; + @SerializedName(SERIALIZED_NAME_OWNER) + private String owner; + + public static final String SERIALIZED_NAME_CREATED = "created"; + @SerializedName(SERIALIZED_NAME_CREATED) + private BigDecimal created; + + public static final String SERIALIZED_NAME_AFFILIATIONS_COUNT = "affiliations_count"; + @SerializedName(SERIALIZED_NAME_AFFILIATIONS_COUNT) + private Integer affiliationsCount; + + public static final String SERIALIZED_NAME_DISABLED = "disabled"; + @SerializedName(SERIALIZED_NAME_DISABLED) + private Boolean disabled; + + public static final String SERIALIZED_NAME_MUTE = "mute"; + @SerializedName(SERIALIZED_NAME_MUTE) + private Boolean mute; + + public static final String SERIALIZED_NAME_PUBLIC = "public"; + @SerializedName(SERIALIZED_NAME_PUBLIC) + private Boolean _public; + + public static final String SERIALIZED_NAME_CUSTOM = "custom"; + @SerializedName(SERIALIZED_NAME_CUSTOM) + private String custom; + + public EMGroupInfoResource() { + } + + public EMGroupInfoResource id(String id) { + + this.id = id; + return this; + } + + /** + * 群组 ID,群组唯一标识符 + * @return id + **/ + @javax.annotation.Nullable + public String getId() { + return id; + } + + + public void setId(String id) { + this.id = id; + } + + + public EMGroupInfoResource name(String name) { + + this.name = name; + return this; + } + + /** + * 群组名称 + * @return name + **/ + @javax.annotation.Nullable + public String getName() { + return name; + } + + + public void setName(String name) { + this.name = name; + } + + + public EMGroupInfoResource description(String description) { + + this.description = description; + return this; + } + + /** + * 群组描述 + * @return description + **/ + @javax.annotation.Nullable + public String getDescription() { + return description; + } + + + public void setDescription(String description) { + this.description = description; + } + + + public EMGroupInfoResource membersonly(Boolean membersonly) { + + this.membersonly = membersonly; + return this; + } + + /** + * 加入群组是否需要群主或者群管理员审批: - true:是; - false:否 + * @return membersonly + **/ + @javax.annotation.Nullable + public Boolean getMembersonly() { + return membersonly; + } + + + public void setMembersonly(Boolean membersonly) { + this.membersonly = membersonly; + } + + + public EMGroupInfoResource allowinvites(Boolean allowinvites) { + + this.allowinvites = allowinvites; + return this; + } + + /** + * 是否允许群成员邀请其他用户加入此群。 - true:允许群成员邀请其他用户加入此群; - false:只有群主可以邀请其他用户入群。 注:该参数仅对私有群有效,因为公开群不允许群成员邀请其他用户入群 + * @return allowinvites + **/ + @javax.annotation.Nullable + public Boolean getAllowinvites() { + return allowinvites; + } + + + public void setAllowinvites(Boolean allowinvites) { + this.allowinvites = allowinvites; + } + + + public EMGroupInfoResource maxusers(Integer maxusers) { + + this.maxusers = maxusers; + return this; + } + + /** + * 群组最大成员数,创建群组的时候设置,可修改 + * @return maxusers + **/ + @javax.annotation.Nullable + public Integer getMaxusers() { + return maxusers; + } + + + public void setMaxusers(Integer maxusers) { + this.maxusers = maxusers; + } + + + public EMGroupInfoResource affiliations(List affiliations) { + + this.affiliations = affiliations; + return this; + } + + public EMGroupInfoResource addAffiliationsItem(Object affiliationsItem) { + if (this.affiliations == null) { + this.affiliations = new ArrayList<>(); + } + this.affiliations.add(affiliationsItem); + return this; + } + + /** + * 群组成员列表以及对应的角色: - owner:群主; - member:普通成员 + * @return affiliations + **/ + @javax.annotation.Nullable + public List getAffiliations() { + return affiliations; + } + + + public void setAffiliations(List affiliations) { + this.affiliations = affiliations; + } + + + public EMGroupInfoResource owner(String owner) { + + this.owner = owner; + return this; + } + + /** + * 群主的用户 ID + * @return owner + **/ + @javax.annotation.Nullable + public String getOwner() { + return owner; + } + + + public void setOwner(String owner) { + this.owner = owner; + } + + + public EMGroupInfoResource created(BigDecimal created) { + + this.created = created; + return this; + } + + /** + * 创建该群组的 Unix 时间戳 + * @return created + **/ + @javax.annotation.Nullable + public BigDecimal getCreated() { + return created; + } + + + public void setCreated(BigDecimal created) { + this.created = created; + } + + + public EMGroupInfoResource affiliationsCount(Integer affiliationsCount) { + + this.affiliationsCount = affiliationsCount; + return this; + } + + /** + * 群组现有成员总数 + * @return affiliationsCount + **/ + @javax.annotation.Nullable + public Integer getAffiliationsCount() { + return affiliationsCount; + } + + + public void setAffiliationsCount(Integer affiliationsCount) { + this.affiliationsCount = affiliationsCount; + } + + + public EMGroupInfoResource disabled(Boolean disabled) { + + this.disabled = disabled; + return this; + } + + /** + * 群组是否为禁用状态: - true:群组被禁用; - false:群组为启用状态 + * @return disabled + **/ + @javax.annotation.Nullable + public Boolean getDisabled() { + return disabled; + } + + + public void setDisabled(Boolean disabled) { + this.disabled = disabled; + } + + + public EMGroupInfoResource mute(Boolean mute) { + + this.mute = mute; + return this; + } + + /** + * 是否处于全员禁言状态: - true:是; - (默认)false:否 + * @return mute + **/ + @javax.annotation.Nullable + public Boolean getMute() { + return mute; + } + + + public void setMute(Boolean mute) { + this.mute = mute; + } + + + public EMGroupInfoResource _public(Boolean _public) { + + this._public = _public; + return this; + } + + /** + * 是否是公开群: - true:公开群; - false:私有群 + * @return _public + **/ + @javax.annotation.Nullable + public Boolean getPublic() { + return _public; + } + + + public void setPublic(Boolean _public) { + this._public = _public; + } + + + public EMGroupInfoResource custom(String custom) { + + this.custom = custom; + return this; + } + + /** + * 群组扩展信息,例如,可以给群组添加业务相关的标记,不要超过 1,024 字符 + * @return custom + **/ + @javax.annotation.Nullable + public String getCustom() { + return custom; + } + + + public void setCustom(String custom) { + this.custom = custom; + } + + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + EMGroupInfoResource groupInfoResource = (EMGroupInfoResource) o; + return Objects.equals(this.id, groupInfoResource.id) && + Objects.equals(this.name, groupInfoResource.name) && + Objects.equals(this.description, groupInfoResource.description) && + Objects.equals(this.membersonly, groupInfoResource.membersonly) && + Objects.equals(this.allowinvites, groupInfoResource.allowinvites) && + Objects.equals(this.maxusers, groupInfoResource.maxusers) && + Objects.equals(this.affiliations, groupInfoResource.affiliations) && + Objects.equals(this.owner, groupInfoResource.owner) && + Objects.equals(this.created, groupInfoResource.created) && + Objects.equals(this.affiliationsCount, groupInfoResource.affiliationsCount) && + Objects.equals(this.disabled, groupInfoResource.disabled) && + Objects.equals(this.mute, groupInfoResource.mute) && + Objects.equals(this._public, groupInfoResource._public) && + Objects.equals(this.custom, groupInfoResource.custom); + } + + @Override + public int hashCode() { + return Objects.hash(id, name, description, membersonly, allowinvites, maxusers, affiliations, owner, created, affiliationsCount, disabled, mute, _public, custom); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class EMGroupInfoResource {\n"); + sb.append(" id: ").append(toIndentedString(id)).append("\n"); + sb.append(" name: ").append(toIndentedString(name)).append("\n"); + sb.append(" description: ").append(toIndentedString(description)).append("\n"); + sb.append(" membersonly: ").append(toIndentedString(membersonly)).append("\n"); + sb.append(" allowinvites: ").append(toIndentedString(allowinvites)).append("\n"); + sb.append(" maxusers: ").append(toIndentedString(maxusers)).append("\n"); + sb.append(" affiliations: ").append(toIndentedString(affiliations)).append("\n"); + sb.append(" owner: ").append(toIndentedString(owner)).append("\n"); + sb.append(" created: ").append(toIndentedString(created)).append("\n"); + sb.append(" affiliationsCount: ").append(toIndentedString(affiliationsCount)).append("\n"); + sb.append(" disabled: ").append(toIndentedString(disabled)).append("\n"); + sb.append(" mute: ").append(toIndentedString(mute)).append("\n"); + sb.append(" _public: ").append(toIndentedString(_public)).append("\n"); + sb.append(" custom: ").append(toIndentedString(custom)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("id"); + openapiFields.add("name"); + openapiFields.add("description"); + openapiFields.add("membersonly"); + openapiFields.add("allowinvites"); + openapiFields.add("maxusers"); + openapiFields.add("affiliations"); + openapiFields.add("owner"); + openapiFields.add("created"); + openapiFields.add("affiliations_count"); + openapiFields.add("disabled"); + openapiFields.add("mute"); + openapiFields.add("public"); + openapiFields.add("custom"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to EMGroupInfoResource + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!EMGroupInfoResource.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format("The required field(s) %s in EMGroupInfoResource is not found in the empty JSON string", EMGroupInfoResource.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!EMGroupInfoResource.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `EMGroupInfoResource` properties. JSON: %s", entry.getKey(), jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + if ((jsonObj.get("id") != null && !jsonObj.get("id").isJsonNull()) && !jsonObj.get("id").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `id` to be a primitive type in the JSON string but got `%s`", jsonObj.get("id").toString())); + } + if ((jsonObj.get("name") != null && !jsonObj.get("name").isJsonNull()) && !jsonObj.get("name").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("name").toString())); + } + if ((jsonObj.get("description") != null && !jsonObj.get("description").isJsonNull()) && !jsonObj.get("description").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `description` to be a primitive type in the JSON string but got `%s`", jsonObj.get("description").toString())); + } + // ensure the optional json data is an array if present + if (jsonObj.get("affiliations") != null && !jsonObj.get("affiliations").isJsonNull() && !jsonObj.get("affiliations").isJsonArray()) { + throw new IllegalArgumentException(String.format("Expected the field `affiliations` to be an array in the JSON string but got `%s`", jsonObj.get("affiliations").toString())); + } + if ((jsonObj.get("owner") != null && !jsonObj.get("owner").isJsonNull()) && !jsonObj.get("owner").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `owner` to be a primitive type in the JSON string but got `%s`", jsonObj.get("owner").toString())); + } + if ((jsonObj.get("custom") != null && !jsonObj.get("custom").isJsonNull()) && !jsonObj.get("custom").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `custom` to be a primitive type in the JSON string but got `%s`", jsonObj.get("custom").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!EMGroupInfoResource.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'EMGroupInfoResource' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(EMGroupInfoResource.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, EMGroupInfoResource value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public EMGroupInfoResource read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + return thisAdapter.fromJsonTree(jsonElement); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of EMGroupInfoResource given an JSON string + * + * @param jsonString JSON string + * @return An instance of EMGroupInfoResource + * @throws IOException if the JSON string is invalid with respect to EMGroupInfoResource + */ + public static EMGroupInfoResource fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, EMGroupInfoResource.class); + } + + /** + * Convert an instance of EMGroupInfoResource to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/com/easemob/im/api/model/EMGroupMuteResource.java b/src/main/java/com/easemob/im/api/model/EMGroupMuteResource.java new file mode 100644 index 000000000..52bd8c7d6 --- /dev/null +++ b/src/main/java/com/easemob/im/api/model/EMGroupMuteResource.java @@ -0,0 +1,237 @@ +/* + * EMService + * Easemob Rest API + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.easemob.im.api.model; + +import java.util.Objects; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.math.BigDecimal; +import java.util.Arrays; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import com.easemob.im.JSON; + +/** + * EMGroupMuteResource + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-01-25T14:51:53.998371+08:00[Asia/Shanghai]") +public class EMGroupMuteResource { + public static final String SERIALIZED_NAME_EXPIRE = "expire"; + @SerializedName(SERIALIZED_NAME_EXPIRE) + private BigDecimal expire; + + public static final String SERIALIZED_NAME_USER = "user"; + @SerializedName(SERIALIZED_NAME_USER) + private String user; + + public EMGroupMuteResource() { + } + + public EMGroupMuteResource expire(BigDecimal expire) { + + this.expire = expire; + return this; + } + + /** + * 禁言到期的时间,单位为毫秒 + * @return expire + **/ + @javax.annotation.Nullable + public BigDecimal getExpire() { + return expire; + } + + + public void setExpire(BigDecimal expire) { + this.expire = expire; + } + + + public EMGroupMuteResource user(String user) { + + this.user = user; + return this; + } + + /** + * 被禁言用户的 ID + * @return user + **/ + @javax.annotation.Nullable + public String getUser() { + return user; + } + + + public void setUser(String user) { + this.user = user; + } + + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + EMGroupMuteResource groupMuteResource = (EMGroupMuteResource) o; + return Objects.equals(this.expire, groupMuteResource.expire) && + Objects.equals(this.user, groupMuteResource.user); + } + + @Override + public int hashCode() { + return Objects.hash(expire, user); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class EMGroupMuteResource {\n"); + sb.append(" expire: ").append(toIndentedString(expire)).append("\n"); + sb.append(" user: ").append(toIndentedString(user)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("expire"); + openapiFields.add("user"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to EMGroupMuteResource + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!EMGroupMuteResource.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format("The required field(s) %s in EMGroupMuteResource is not found in the empty JSON string", EMGroupMuteResource.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!EMGroupMuteResource.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `EMGroupMuteResource` properties. JSON: %s", entry.getKey(), jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + if ((jsonObj.get("user") != null && !jsonObj.get("user").isJsonNull()) && !jsonObj.get("user").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `user` to be a primitive type in the JSON string but got `%s`", jsonObj.get("user").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!EMGroupMuteResource.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'EMGroupMuteResource' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(EMGroupMuteResource.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, EMGroupMuteResource value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public EMGroupMuteResource read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + return thisAdapter.fromJsonTree(jsonElement); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of EMGroupMuteResource given an JSON string + * + * @param jsonString JSON string + * @return An instance of EMGroupMuteResource + * @throws IOException if the JSON string is invalid with respect to EMGroupMuteResource + */ + public static EMGroupMuteResource fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, EMGroupMuteResource.class); + } + + /** + * Convert an instance of EMGroupMuteResource to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/com/easemob/im/api/model/EMGroupShareFileResource.java b/src/main/java/com/easemob/im/api/model/EMGroupShareFileResource.java new file mode 100644 index 000000000..01031e72b --- /dev/null +++ b/src/main/java/com/easemob/im/api/model/EMGroupShareFileResource.java @@ -0,0 +1,358 @@ +/* + * EMService + * Easemob Rest API + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.easemob.im.api.model; + +import java.util.Objects; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.math.BigDecimal; +import java.util.Arrays; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import com.easemob.im.JSON; + +/** + * EMGroupShareFileResource + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-01-25T14:51:53.998371+08:00[Asia/Shanghai]") +public class EMGroupShareFileResource { + public static final String SERIALIZED_NAME_GROUP_ID = "group_id"; + @SerializedName(SERIALIZED_NAME_GROUP_ID) + private String groupId; + + public static final String SERIALIZED_NAME_FILE_ID = "file_id"; + @SerializedName(SERIALIZED_NAME_FILE_ID) + private String fileId; + + public static final String SERIALIZED_NAME_FILE_NAME = "file_name"; + @SerializedName(SERIALIZED_NAME_FILE_NAME) + private String fileName; + + public static final String SERIALIZED_NAME_FILE_OWNER = "file_owner"; + @SerializedName(SERIALIZED_NAME_FILE_OWNER) + private String fileOwner; + + public static final String SERIALIZED_NAME_FILE_SIZE = "file_size"; + @SerializedName(SERIALIZED_NAME_FILE_SIZE) + private BigDecimal fileSize; + + public static final String SERIALIZED_NAME_CREATED = "created"; + @SerializedName(SERIALIZED_NAME_CREATED) + private BigDecimal created; + + public EMGroupShareFileResource() { + } + + public EMGroupShareFileResource groupId(String groupId) { + + this.groupId = groupId; + return this; + } + + /** + * 群组 ID + * @return groupId + **/ + @javax.annotation.Nullable + public String getGroupId() { + return groupId; + } + + + public void setGroupId(String groupId) { + this.groupId = groupId; + } + + + public EMGroupShareFileResource fileId(String fileId) { + + this.fileId = fileId; + return this; + } + + /** + * 群组共享文件的 ID,若要下载或删除该文件需要使用该参数 + * @return fileId + **/ + @javax.annotation.Nullable + public String getFileId() { + return fileId; + } + + + public void setFileId(String fileId) { + this.fileId = fileId; + } + + + public EMGroupShareFileResource fileName(String fileName) { + + this.fileName = fileName; + return this; + } + + /** + * 群组共享文件名称 + * @return fileName + **/ + @javax.annotation.Nullable + public String getFileName() { + return fileName; + } + + + public void setFileName(String fileName) { + this.fileName = fileName; + } + + + public EMGroupShareFileResource fileOwner(String fileOwner) { + + this.fileOwner = fileOwner; + return this; + } + + /** + * 上传群组共享文件的用户 ID + * @return fileOwner + **/ + @javax.annotation.Nullable + public String getFileOwner() { + return fileOwner; + } + + + public void setFileOwner(String fileOwner) { + this.fileOwner = fileOwner; + } + + + public EMGroupShareFileResource fileSize(BigDecimal fileSize) { + + this.fileSize = fileSize; + return this; + } + + /** + * 群组共享文件大小,单位为字节 + * @return fileSize + **/ + @javax.annotation.Nullable + public BigDecimal getFileSize() { + return fileSize; + } + + + public void setFileSize(BigDecimal fileSize) { + this.fileSize = fileSize; + } + + + public EMGroupShareFileResource created(BigDecimal created) { + + this.created = created; + return this; + } + + /** + * 上传群组共享文件的时间 + * @return created + **/ + @javax.annotation.Nullable + public BigDecimal getCreated() { + return created; + } + + + public void setCreated(BigDecimal created) { + this.created = created; + } + + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + EMGroupShareFileResource groupShareFileResource = (EMGroupShareFileResource) o; + return Objects.equals(this.groupId, groupShareFileResource.groupId) && + Objects.equals(this.fileId, groupShareFileResource.fileId) && + Objects.equals(this.fileName, groupShareFileResource.fileName) && + Objects.equals(this.fileOwner, groupShareFileResource.fileOwner) && + Objects.equals(this.fileSize, groupShareFileResource.fileSize) && + Objects.equals(this.created, groupShareFileResource.created); + } + + @Override + public int hashCode() { + return Objects.hash(groupId, fileId, fileName, fileOwner, fileSize, created); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class EMGroupShareFileResource {\n"); + sb.append(" groupId: ").append(toIndentedString(groupId)).append("\n"); + sb.append(" fileId: ").append(toIndentedString(fileId)).append("\n"); + sb.append(" fileName: ").append(toIndentedString(fileName)).append("\n"); + sb.append(" fileOwner: ").append(toIndentedString(fileOwner)).append("\n"); + sb.append(" fileSize: ").append(toIndentedString(fileSize)).append("\n"); + sb.append(" created: ").append(toIndentedString(created)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("group_id"); + openapiFields.add("file_id"); + openapiFields.add("file_name"); + openapiFields.add("file_owner"); + openapiFields.add("file_size"); + openapiFields.add("created"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to EMGroupShareFileResource + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!EMGroupShareFileResource.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format("The required field(s) %s in EMGroupShareFileResource is not found in the empty JSON string", EMGroupShareFileResource.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!EMGroupShareFileResource.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `EMGroupShareFileResource` properties. JSON: %s", entry.getKey(), jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + if ((jsonObj.get("group_id") != null && !jsonObj.get("group_id").isJsonNull()) && !jsonObj.get("group_id").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `group_id` to be a primitive type in the JSON string but got `%s`", jsonObj.get("group_id").toString())); + } + if ((jsonObj.get("file_id") != null && !jsonObj.get("file_id").isJsonNull()) && !jsonObj.get("file_id").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `file_id` to be a primitive type in the JSON string but got `%s`", jsonObj.get("file_id").toString())); + } + if ((jsonObj.get("file_name") != null && !jsonObj.get("file_name").isJsonNull()) && !jsonObj.get("file_name").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `file_name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("file_name").toString())); + } + if ((jsonObj.get("file_owner") != null && !jsonObj.get("file_owner").isJsonNull()) && !jsonObj.get("file_owner").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `file_owner` to be a primitive type in the JSON string but got `%s`", jsonObj.get("file_owner").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!EMGroupShareFileResource.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'EMGroupShareFileResource' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(EMGroupShareFileResource.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, EMGroupShareFileResource value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public EMGroupShareFileResource read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + return thisAdapter.fromJsonTree(jsonElement); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of EMGroupShareFileResource given an JSON string + * + * @param jsonString JSON string + * @return An instance of EMGroupShareFileResource + * @throws IOException if the JSON string is invalid with respect to EMGroupShareFileResource + */ + public static EMGroupShareFileResource fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, EMGroupShareFileResource.class); + } + + /** + * Convert an instance of EMGroupShareFileResource to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/com/easemob/im/api/model/EMImageSize.java b/src/main/java/com/easemob/im/api/model/EMImageSize.java new file mode 100644 index 000000000..466e11182 --- /dev/null +++ b/src/main/java/com/easemob/im/api/model/EMImageSize.java @@ -0,0 +1,233 @@ +/* + * EMService + * Easemob Rest API + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.easemob.im.api.model; + +import java.util.Objects; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.Arrays; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import com.easemob.im.JSON; + +/** + * 图片尺寸,单位为像素 + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-01-25T14:51:53.998371+08:00[Asia/Shanghai]") +public class EMImageSize { + public static final String SERIALIZED_NAME_HEIGHT = "height"; + @SerializedName(SERIALIZED_NAME_HEIGHT) + private Integer height; + + public static final String SERIALIZED_NAME_WIDTH = "width"; + @SerializedName(SERIALIZED_NAME_WIDTH) + private Integer width; + + public EMImageSize() { + } + + public EMImageSize height(Integer height) { + + this.height = height; + return this; + } + + /** + * 图片高度 + * @return height + **/ + @javax.annotation.Nullable + public Integer getHeight() { + return height; + } + + + public void setHeight(Integer height) { + this.height = height; + } + + + public EMImageSize width(Integer width) { + + this.width = width; + return this; + } + + /** + * 图片宽度 + * @return width + **/ + @javax.annotation.Nullable + public Integer getWidth() { + return width; + } + + + public void setWidth(Integer width) { + this.width = width; + } + + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + EMImageSize imageSize = (EMImageSize) o; + return Objects.equals(this.height, imageSize.height) && + Objects.equals(this.width, imageSize.width); + } + + @Override + public int hashCode() { + return Objects.hash(height, width); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class EMImageSize {\n"); + sb.append(" height: ").append(toIndentedString(height)).append("\n"); + sb.append(" width: ").append(toIndentedString(width)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("height"); + openapiFields.add("width"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to EMImageSize + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!EMImageSize.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format("The required field(s) %s in EMImageSize is not found in the empty JSON string", EMImageSize.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!EMImageSize.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `EMImageSize` properties. JSON: %s", entry.getKey(), jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!EMImageSize.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'EMImageSize' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(EMImageSize.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, EMImageSize value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public EMImageSize read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + return thisAdapter.fromJsonTree(jsonElement); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of EMImageSize given an JSON string + * + * @param jsonString JSON string + * @return An instance of EMImageSize + * @throws IOException if the JSON string is invalid with respect to EMImageSize + */ + public static EMImageSize fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, EMImageSize.class); + } + + /** + * Convert an instance of EMImageSize to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/com/easemob/im/api/model/EMImportChatGroupMessage.java b/src/main/java/com/easemob/im/api/model/EMImportChatGroupMessage.java new file mode 100644 index 000000000..244047dfa --- /dev/null +++ b/src/main/java/com/easemob/im/api/model/EMImportChatGroupMessage.java @@ -0,0 +1,397 @@ +/* + * EMService + * Easemob Rest API + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.easemob.im.api.model; + +import java.util.Objects; +import com.easemob.im.api.model.EMMessageContent; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.math.BigDecimal; +import java.util.Arrays; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import com.easemob.im.JSON; + +/** + * EMImportChatGroupMessage + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-01-25T14:51:53.998371+08:00[Asia/Shanghai]") +public class EMImportChatGroupMessage { + public static final String SERIALIZED_NAME_FROM = "from"; + @SerializedName(SERIALIZED_NAME_FROM) + private String from; + + public static final String SERIALIZED_NAME_TARGET = "target"; + @SerializedName(SERIALIZED_NAME_TARGET) + private String target; + + public static final String SERIALIZED_NAME_TYPE = "type"; + @SerializedName(SERIALIZED_NAME_TYPE) + private String type; + + public static final String SERIALIZED_NAME_BODY = "body"; + @SerializedName(SERIALIZED_NAME_BODY) + private EMMessageContent body; + + public static final String SERIALIZED_NAME_IS_ACK_READ = "is_ack_read"; + @SerializedName(SERIALIZED_NAME_IS_ACK_READ) + private Boolean isAckRead; + + public static final String SERIALIZED_NAME_MSG_TIMESTAMP = "msg_timestamp"; + @SerializedName(SERIALIZED_NAME_MSG_TIMESTAMP) + private BigDecimal msgTimestamp; + + public static final String SERIALIZED_NAME_NEED_DOWNLOAD = "need_download"; + @SerializedName(SERIALIZED_NAME_NEED_DOWNLOAD) + private Boolean needDownload; + + public EMImportChatGroupMessage() { + } + + public EMImportChatGroupMessage from(String from) { + + this.from = from; + return this; + } + + /** + * 消息发送方的用户 ID + * @return from + **/ + @javax.annotation.Nonnull + public String getFrom() { + return from; + } + + + public void setFrom(String from) { + this.from = from; + } + + + public EMImportChatGroupMessage target(String target) { + + this.target = target; + return this; + } + + /** + * 群组 ID + * @return target + **/ + @javax.annotation.Nonnull + public String getTarget() { + return target; + } + + + public void setTarget(String target) { + this.target = target; + } + + + public EMImportChatGroupMessage type(String type) { + + this.type = type; + return this; + } + + /** + * 消息类型: - txt:文本消息; - img:图片消息; - audio:语音消息; - video:视频消息; - file:文件消息; - loc:位置消息; - cmd:透传消息; - custom:自定义消息 + * @return type + **/ + @javax.annotation.Nonnull + public String getType() { + return type; + } + + + public void setType(String type) { + this.type = type; + } + + + public EMImportChatGroupMessage body(EMMessageContent body) { + + this.body = body; + return this; + } + + /** + * Get body + * @return body + **/ + @javax.annotation.Nonnull + public EMMessageContent getBody() { + return body; + } + + + public void setBody(EMMessageContent body) { + this.body = body; + } + + + public EMImportChatGroupMessage isAckRead(Boolean isAckRead) { + + this.isAckRead = isAckRead; + return this; + } + + /** + * 是否设置消息为已读。 - true:是; - false:否 + * @return isAckRead + **/ + @javax.annotation.Nullable + public Boolean getIsAckRead() { + return isAckRead; + } + + + public void setIsAckRead(Boolean isAckRead) { + this.isAckRead = isAckRead; + } + + + public EMImportChatGroupMessage msgTimestamp(BigDecimal msgTimestamp) { + + this.msgTimestamp = msgTimestamp; + return this; + } + + /** + * 要导入的消息的时间戳,单位为毫秒。若不传该参数,环信服务器会将导入的消息的时间戳设置为当前时间 + * @return msgTimestamp + **/ + @javax.annotation.Nullable + public BigDecimal getMsgTimestamp() { + return msgTimestamp; + } + + + public void setMsgTimestamp(BigDecimal msgTimestamp) { + this.msgTimestamp = msgTimestamp; + } + + + public EMImportChatGroupMessage needDownload(Boolean needDownload) { + + this.needDownload = needDownload; + return this; + } + + /** + * 是否需要下载附件并上传到服务器。 - true:是。这种情况下,需确保附件地址可直接访问,没有访问权限的限制。 - (默认)false:否 + * @return needDownload + **/ + @javax.annotation.Nullable + public Boolean getNeedDownload() { + return needDownload; + } + + + public void setNeedDownload(Boolean needDownload) { + this.needDownload = needDownload; + } + + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + EMImportChatGroupMessage importChatGroupMessage = (EMImportChatGroupMessage) o; + return Objects.equals(this.from, importChatGroupMessage.from) && + Objects.equals(this.target, importChatGroupMessage.target) && + Objects.equals(this.type, importChatGroupMessage.type) && + Objects.equals(this.body, importChatGroupMessage.body) && + Objects.equals(this.isAckRead, importChatGroupMessage.isAckRead) && + Objects.equals(this.msgTimestamp, importChatGroupMessage.msgTimestamp) && + Objects.equals(this.needDownload, importChatGroupMessage.needDownload); + } + + @Override + public int hashCode() { + return Objects.hash(from, target, type, body, isAckRead, msgTimestamp, needDownload); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class EMImportChatGroupMessage {\n"); + sb.append(" from: ").append(toIndentedString(from)).append("\n"); + sb.append(" target: ").append(toIndentedString(target)).append("\n"); + sb.append(" type: ").append(toIndentedString(type)).append("\n"); + sb.append(" body: ").append(toIndentedString(body)).append("\n"); + sb.append(" isAckRead: ").append(toIndentedString(isAckRead)).append("\n"); + sb.append(" msgTimestamp: ").append(toIndentedString(msgTimestamp)).append("\n"); + sb.append(" needDownload: ").append(toIndentedString(needDownload)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("from"); + openapiFields.add("target"); + openapiFields.add("type"); + openapiFields.add("body"); + openapiFields.add("is_ack_read"); + openapiFields.add("msg_timestamp"); + openapiFields.add("need_download"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + openapiRequiredFields.add("from"); + openapiRequiredFields.add("target"); + openapiRequiredFields.add("type"); + openapiRequiredFields.add("body"); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to EMImportChatGroupMessage + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!EMImportChatGroupMessage.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format("The required field(s) %s in EMImportChatGroupMessage is not found in the empty JSON string", EMImportChatGroupMessage.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!EMImportChatGroupMessage.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `EMImportChatGroupMessage` properties. JSON: %s", entry.getKey(), jsonElement.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : EMImportChatGroupMessage.openapiRequiredFields) { + if (jsonElement.getAsJsonObject().get(requiredField) == null) { + throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + if (!jsonObj.get("from").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `from` to be a primitive type in the JSON string but got `%s`", jsonObj.get("from").toString())); + } + if (!jsonObj.get("target").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `target` to be a primitive type in the JSON string but got `%s`", jsonObj.get("target").toString())); + } + if (!jsonObj.get("type").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `type` to be a primitive type in the JSON string but got `%s`", jsonObj.get("type").toString())); + } + // validate the required field `body` + EMMessageContent.validateJsonElement(jsonObj.get("body")); + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!EMImportChatGroupMessage.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'EMImportChatGroupMessage' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(EMImportChatGroupMessage.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, EMImportChatGroupMessage value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public EMImportChatGroupMessage read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + return thisAdapter.fromJsonTree(jsonElement); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of EMImportChatGroupMessage given an JSON string + * + * @param jsonString JSON string + * @return An instance of EMImportChatGroupMessage + * @throws IOException if the JSON string is invalid with respect to EMImportChatGroupMessage + */ + public static EMImportChatGroupMessage fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, EMImportChatGroupMessage.class); + } + + /** + * Convert an instance of EMImportChatGroupMessage to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/com/easemob/im/api/model/EMImportChatGroupMessageResource.java b/src/main/java/com/easemob/im/api/model/EMImportChatGroupMessageResource.java new file mode 100644 index 000000000..fac5c7644 --- /dev/null +++ b/src/main/java/com/easemob/im/api/model/EMImportChatGroupMessageResource.java @@ -0,0 +1,208 @@ +/* + * EMService + * Easemob Rest API + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.easemob.im.api.model; + +import java.util.Objects; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.Arrays; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import com.easemob.im.JSON; + +/** + * EMImportChatGroupMessageResource + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-01-25T14:51:53.998371+08:00[Asia/Shanghai]") +public class EMImportChatGroupMessageResource { + public static final String SERIALIZED_NAME_MSG_ID = "msg_id"; + @SerializedName(SERIALIZED_NAME_MSG_ID) + private String msgId; + + public EMImportChatGroupMessageResource() { + } + + public EMImportChatGroupMessageResource msgId(String msgId) { + + this.msgId = msgId; + return this; + } + + /** + * Get msgId + * @return msgId + **/ + @javax.annotation.Nullable + public String getMsgId() { + return msgId; + } + + + public void setMsgId(String msgId) { + this.msgId = msgId; + } + + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + EMImportChatGroupMessageResource importChatGroupMessageResource = (EMImportChatGroupMessageResource) o; + return Objects.equals(this.msgId, importChatGroupMessageResource.msgId); + } + + @Override + public int hashCode() { + return Objects.hash(msgId); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class EMImportChatGroupMessageResource {\n"); + sb.append(" msgId: ").append(toIndentedString(msgId)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("msg_id"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to EMImportChatGroupMessageResource + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!EMImportChatGroupMessageResource.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format("The required field(s) %s in EMImportChatGroupMessageResource is not found in the empty JSON string", EMImportChatGroupMessageResource.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!EMImportChatGroupMessageResource.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `EMImportChatGroupMessageResource` properties. JSON: %s", entry.getKey(), jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + if ((jsonObj.get("msg_id") != null && !jsonObj.get("msg_id").isJsonNull()) && !jsonObj.get("msg_id").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `msg_id` to be a primitive type in the JSON string but got `%s`", jsonObj.get("msg_id").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!EMImportChatGroupMessageResource.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'EMImportChatGroupMessageResource' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(EMImportChatGroupMessageResource.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, EMImportChatGroupMessageResource value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public EMImportChatGroupMessageResource read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + return thisAdapter.fromJsonTree(jsonElement); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of EMImportChatGroupMessageResource given an JSON string + * + * @param jsonString JSON string + * @return An instance of EMImportChatGroupMessageResource + * @throws IOException if the JSON string is invalid with respect to EMImportChatGroupMessageResource + */ + public static EMImportChatGroupMessageResource fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, EMImportChatGroupMessageResource.class); + } + + /** + * Convert an instance of EMImportChatGroupMessageResource to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/com/easemob/im/api/model/EMImportChatGroupMessageResult.java b/src/main/java/com/easemob/im/api/model/EMImportChatGroupMessageResult.java new file mode 100644 index 000000000..2e984b044 --- /dev/null +++ b/src/main/java/com/easemob/im/api/model/EMImportChatGroupMessageResult.java @@ -0,0 +1,210 @@ +/* + * EMService + * Easemob Rest API + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.easemob.im.api.model; + +import java.util.Objects; +import com.easemob.im.api.model.EMImportChatGroupMessageResource; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.Arrays; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import com.easemob.im.JSON; + +/** + * EMImportChatGroupMessageResult + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-01-25T14:51:53.998371+08:00[Asia/Shanghai]") +public class EMImportChatGroupMessageResult { + public static final String SERIALIZED_NAME_DATA = "data"; + @SerializedName(SERIALIZED_NAME_DATA) + private EMImportChatGroupMessageResource data; + + public EMImportChatGroupMessageResult() { + } + + public EMImportChatGroupMessageResult data(EMImportChatGroupMessageResource data) { + + this.data = data; + return this; + } + + /** + * Get data + * @return data + **/ + @javax.annotation.Nullable + public EMImportChatGroupMessageResource getData() { + return data; + } + + + public void setData(EMImportChatGroupMessageResource data) { + this.data = data; + } + + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + EMImportChatGroupMessageResult importChatGroupMessageResult = (EMImportChatGroupMessageResult) o; + return Objects.equals(this.data, importChatGroupMessageResult.data); + } + + @Override + public int hashCode() { + return Objects.hash(data); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class EMImportChatGroupMessageResult {\n"); + sb.append(" data: ").append(toIndentedString(data)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("data"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to EMImportChatGroupMessageResult + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!EMImportChatGroupMessageResult.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format("The required field(s) %s in EMImportChatGroupMessageResult is not found in the empty JSON string", EMImportChatGroupMessageResult.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!EMImportChatGroupMessageResult.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `EMImportChatGroupMessageResult` properties. JSON: %s", entry.getKey(), jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // validate the optional field `data` + if (jsonObj.get("data") != null && !jsonObj.get("data").isJsonNull()) { + EMImportChatGroupMessageResource.validateJsonElement(jsonObj.get("data")); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!EMImportChatGroupMessageResult.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'EMImportChatGroupMessageResult' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(EMImportChatGroupMessageResult.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, EMImportChatGroupMessageResult value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public EMImportChatGroupMessageResult read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + return thisAdapter.fromJsonTree(jsonElement); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of EMImportChatGroupMessageResult given an JSON string + * + * @param jsonString JSON string + * @return An instance of EMImportChatGroupMessageResult + * @throws IOException if the JSON string is invalid with respect to EMImportChatGroupMessageResult + */ + public static EMImportChatGroupMessageResult fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, EMImportChatGroupMessageResult.class); + } + + /** + * Convert an instance of EMImportChatGroupMessageResult to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/com/easemob/im/api/model/EMImportChatUserMessage.java b/src/main/java/com/easemob/im/api/model/EMImportChatUserMessage.java new file mode 100644 index 000000000..e2789d4c8 --- /dev/null +++ b/src/main/java/com/easemob/im/api/model/EMImportChatUserMessage.java @@ -0,0 +1,397 @@ +/* + * EMService + * Easemob Rest API + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.easemob.im.api.model; + +import java.util.Objects; +import com.easemob.im.api.model.EMMessageContent; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.math.BigDecimal; +import java.util.Arrays; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import com.easemob.im.JSON; + +/** + * EMImportChatUserMessage + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-01-25T14:51:53.998371+08:00[Asia/Shanghai]") +public class EMImportChatUserMessage { + public static final String SERIALIZED_NAME_FROM = "from"; + @SerializedName(SERIALIZED_NAME_FROM) + private String from; + + public static final String SERIALIZED_NAME_TARGET = "target"; + @SerializedName(SERIALIZED_NAME_TARGET) + private String target; + + public static final String SERIALIZED_NAME_TYPE = "type"; + @SerializedName(SERIALIZED_NAME_TYPE) + private String type; + + public static final String SERIALIZED_NAME_BODY = "body"; + @SerializedName(SERIALIZED_NAME_BODY) + private EMMessageContent body; + + public static final String SERIALIZED_NAME_IS_ACK_READ = "is_ack_read"; + @SerializedName(SERIALIZED_NAME_IS_ACK_READ) + private Boolean isAckRead; + + public static final String SERIALIZED_NAME_MSG_TIMESTAMP = "msg_timestamp"; + @SerializedName(SERIALIZED_NAME_MSG_TIMESTAMP) + private BigDecimal msgTimestamp; + + public static final String SERIALIZED_NAME_NEED_DOWNLOAD = "need_download"; + @SerializedName(SERIALIZED_NAME_NEED_DOWNLOAD) + private Boolean needDownload; + + public EMImportChatUserMessage() { + } + + public EMImportChatUserMessage from(String from) { + + this.from = from; + return this; + } + + /** + * 消息发送方的用户 ID + * @return from + **/ + @javax.annotation.Nonnull + public String getFrom() { + return from; + } + + + public void setFrom(String from) { + this.from = from; + } + + + public EMImportChatUserMessage target(String target) { + + this.target = target; + return this; + } + + /** + * 消息接收方的用户 ID + * @return target + **/ + @javax.annotation.Nonnull + public String getTarget() { + return target; + } + + + public void setTarget(String target) { + this.target = target; + } + + + public EMImportChatUserMessage type(String type) { + + this.type = type; + return this; + } + + /** + * 消息类型: - txt:文本消息; - img:图片消息; - audio:语音消息; - video:视频消息; - file:文件消息; - loc:位置消息; - cmd:透传消息; - custom:自定义消息 + * @return type + **/ + @javax.annotation.Nonnull + public String getType() { + return type; + } + + + public void setType(String type) { + this.type = type; + } + + + public EMImportChatUserMessage body(EMMessageContent body) { + + this.body = body; + return this; + } + + /** + * Get body + * @return body + **/ + @javax.annotation.Nonnull + public EMMessageContent getBody() { + return body; + } + + + public void setBody(EMMessageContent body) { + this.body = body; + } + + + public EMImportChatUserMessage isAckRead(Boolean isAckRead) { + + this.isAckRead = isAckRead; + return this; + } + + /** + * 是否设置消息为已读。 - true:是; - false:否 + * @return isAckRead + **/ + @javax.annotation.Nullable + public Boolean getIsAckRead() { + return isAckRead; + } + + + public void setIsAckRead(Boolean isAckRead) { + this.isAckRead = isAckRead; + } + + + public EMImportChatUserMessage msgTimestamp(BigDecimal msgTimestamp) { + + this.msgTimestamp = msgTimestamp; + return this; + } + + /** + * 要导入的消息的时间戳,单位为毫秒。若不传该参数,环信服务器会将导入的消息的时间戳设置为当前时间 + * @return msgTimestamp + **/ + @javax.annotation.Nullable + public BigDecimal getMsgTimestamp() { + return msgTimestamp; + } + + + public void setMsgTimestamp(BigDecimal msgTimestamp) { + this.msgTimestamp = msgTimestamp; + } + + + public EMImportChatUserMessage needDownload(Boolean needDownload) { + + this.needDownload = needDownload; + return this; + } + + /** + * 是否需要下载附件并上传到服务器。 - true:是。这种情况下,需确保附件地址可直接访问,没有访问权限的限制。 - (默认)false:否 + * @return needDownload + **/ + @javax.annotation.Nullable + public Boolean getNeedDownload() { + return needDownload; + } + + + public void setNeedDownload(Boolean needDownload) { + this.needDownload = needDownload; + } + + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + EMImportChatUserMessage importChatUserMessage = (EMImportChatUserMessage) o; + return Objects.equals(this.from, importChatUserMessage.from) && + Objects.equals(this.target, importChatUserMessage.target) && + Objects.equals(this.type, importChatUserMessage.type) && + Objects.equals(this.body, importChatUserMessage.body) && + Objects.equals(this.isAckRead, importChatUserMessage.isAckRead) && + Objects.equals(this.msgTimestamp, importChatUserMessage.msgTimestamp) && + Objects.equals(this.needDownload, importChatUserMessage.needDownload); + } + + @Override + public int hashCode() { + return Objects.hash(from, target, type, body, isAckRead, msgTimestamp, needDownload); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class EMImportChatUserMessage {\n"); + sb.append(" from: ").append(toIndentedString(from)).append("\n"); + sb.append(" target: ").append(toIndentedString(target)).append("\n"); + sb.append(" type: ").append(toIndentedString(type)).append("\n"); + sb.append(" body: ").append(toIndentedString(body)).append("\n"); + sb.append(" isAckRead: ").append(toIndentedString(isAckRead)).append("\n"); + sb.append(" msgTimestamp: ").append(toIndentedString(msgTimestamp)).append("\n"); + sb.append(" needDownload: ").append(toIndentedString(needDownload)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("from"); + openapiFields.add("target"); + openapiFields.add("type"); + openapiFields.add("body"); + openapiFields.add("is_ack_read"); + openapiFields.add("msg_timestamp"); + openapiFields.add("need_download"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + openapiRequiredFields.add("from"); + openapiRequiredFields.add("target"); + openapiRequiredFields.add("type"); + openapiRequiredFields.add("body"); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to EMImportChatUserMessage + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!EMImportChatUserMessage.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format("The required field(s) %s in EMImportChatUserMessage is not found in the empty JSON string", EMImportChatUserMessage.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!EMImportChatUserMessage.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `EMImportChatUserMessage` properties. JSON: %s", entry.getKey(), jsonElement.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : EMImportChatUserMessage.openapiRequiredFields) { + if (jsonElement.getAsJsonObject().get(requiredField) == null) { + throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + if (!jsonObj.get("from").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `from` to be a primitive type in the JSON string but got `%s`", jsonObj.get("from").toString())); + } + if (!jsonObj.get("target").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `target` to be a primitive type in the JSON string but got `%s`", jsonObj.get("target").toString())); + } + if (!jsonObj.get("type").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `type` to be a primitive type in the JSON string but got `%s`", jsonObj.get("type").toString())); + } + // validate the required field `body` + EMMessageContent.validateJsonElement(jsonObj.get("body")); + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!EMImportChatUserMessage.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'EMImportChatUserMessage' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(EMImportChatUserMessage.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, EMImportChatUserMessage value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public EMImportChatUserMessage read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + return thisAdapter.fromJsonTree(jsonElement); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of EMImportChatUserMessage given an JSON string + * + * @param jsonString JSON string + * @return An instance of EMImportChatUserMessage + * @throws IOException if the JSON string is invalid with respect to EMImportChatUserMessage + */ + public static EMImportChatUserMessage fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, EMImportChatUserMessage.class); + } + + /** + * Convert an instance of EMImportChatUserMessage to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/com/easemob/im/api/model/EMImportChatUserMessageResource.java b/src/main/java/com/easemob/im/api/model/EMImportChatUserMessageResource.java new file mode 100644 index 000000000..a955f25a1 --- /dev/null +++ b/src/main/java/com/easemob/im/api/model/EMImportChatUserMessageResource.java @@ -0,0 +1,208 @@ +/* + * EMService + * Easemob Rest API + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.easemob.im.api.model; + +import java.util.Objects; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.Arrays; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import com.easemob.im.JSON; + +/** + * EMImportChatUserMessageResource + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-01-25T14:51:53.998371+08:00[Asia/Shanghai]") +public class EMImportChatUserMessageResource { + public static final String SERIALIZED_NAME_MSG_ID = "msg_id"; + @SerializedName(SERIALIZED_NAME_MSG_ID) + private String msgId; + + public EMImportChatUserMessageResource() { + } + + public EMImportChatUserMessageResource msgId(String msgId) { + + this.msgId = msgId; + return this; + } + + /** + * Get msgId + * @return msgId + **/ + @javax.annotation.Nullable + public String getMsgId() { + return msgId; + } + + + public void setMsgId(String msgId) { + this.msgId = msgId; + } + + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + EMImportChatUserMessageResource importChatUserMessageResource = (EMImportChatUserMessageResource) o; + return Objects.equals(this.msgId, importChatUserMessageResource.msgId); + } + + @Override + public int hashCode() { + return Objects.hash(msgId); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class EMImportChatUserMessageResource {\n"); + sb.append(" msgId: ").append(toIndentedString(msgId)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("msg_id"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to EMImportChatUserMessageResource + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!EMImportChatUserMessageResource.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format("The required field(s) %s in EMImportChatUserMessageResource is not found in the empty JSON string", EMImportChatUserMessageResource.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!EMImportChatUserMessageResource.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `EMImportChatUserMessageResource` properties. JSON: %s", entry.getKey(), jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + if ((jsonObj.get("msg_id") != null && !jsonObj.get("msg_id").isJsonNull()) && !jsonObj.get("msg_id").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `msg_id` to be a primitive type in the JSON string but got `%s`", jsonObj.get("msg_id").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!EMImportChatUserMessageResource.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'EMImportChatUserMessageResource' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(EMImportChatUserMessageResource.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, EMImportChatUserMessageResource value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public EMImportChatUserMessageResource read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + return thisAdapter.fromJsonTree(jsonElement); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of EMImportChatUserMessageResource given an JSON string + * + * @param jsonString JSON string + * @return An instance of EMImportChatUserMessageResource + * @throws IOException if the JSON string is invalid with respect to EMImportChatUserMessageResource + */ + public static EMImportChatUserMessageResource fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, EMImportChatUserMessageResource.class); + } + + /** + * Convert an instance of EMImportChatUserMessageResource to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/com/easemob/im/api/model/EMImportChatUserMessageResult.java b/src/main/java/com/easemob/im/api/model/EMImportChatUserMessageResult.java new file mode 100644 index 000000000..cf23013da --- /dev/null +++ b/src/main/java/com/easemob/im/api/model/EMImportChatUserMessageResult.java @@ -0,0 +1,210 @@ +/* + * EMService + * Easemob Rest API + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.easemob.im.api.model; + +import java.util.Objects; +import com.easemob.im.api.model.EMImportChatUserMessageResource; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.Arrays; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import com.easemob.im.JSON; + +/** + * EMImportChatUserMessageResult + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-01-25T14:51:53.998371+08:00[Asia/Shanghai]") +public class EMImportChatUserMessageResult { + public static final String SERIALIZED_NAME_DATA = "data"; + @SerializedName(SERIALIZED_NAME_DATA) + private EMImportChatUserMessageResource data; + + public EMImportChatUserMessageResult() { + } + + public EMImportChatUserMessageResult data(EMImportChatUserMessageResource data) { + + this.data = data; + return this; + } + + /** + * Get data + * @return data + **/ + @javax.annotation.Nullable + public EMImportChatUserMessageResource getData() { + return data; + } + + + public void setData(EMImportChatUserMessageResource data) { + this.data = data; + } + + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + EMImportChatUserMessageResult importChatUserMessageResult = (EMImportChatUserMessageResult) o; + return Objects.equals(this.data, importChatUserMessageResult.data); + } + + @Override + public int hashCode() { + return Objects.hash(data); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class EMImportChatUserMessageResult {\n"); + sb.append(" data: ").append(toIndentedString(data)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("data"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to EMImportChatUserMessageResult + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!EMImportChatUserMessageResult.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format("The required field(s) %s in EMImportChatUserMessageResult is not found in the empty JSON string", EMImportChatUserMessageResult.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!EMImportChatUserMessageResult.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `EMImportChatUserMessageResult` properties. JSON: %s", entry.getKey(), jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // validate the optional field `data` + if (jsonObj.get("data") != null && !jsonObj.get("data").isJsonNull()) { + EMImportChatUserMessageResource.validateJsonElement(jsonObj.get("data")); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!EMImportChatUserMessageResult.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'EMImportChatUserMessageResult' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(EMImportChatUserMessageResult.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, EMImportChatUserMessageResult value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public EMImportChatUserMessageResult read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + return thisAdapter.fromJsonTree(jsonElement); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of EMImportChatUserMessageResult given an JSON string + * + * @param jsonString JSON string + * @return An instance of EMImportChatUserMessageResult + * @throws IOException if the JSON string is invalid with respect to EMImportChatUserMessageResult + */ + public static EMImportChatUserMessageResult fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, EMImportChatUserMessageResult.class); + } + + /** + * Convert an instance of EMImportChatUserMessageResult to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/com/easemob/im/api/model/EMMessageContent.java b/src/main/java/com/easemob/im/api/model/EMMessageContent.java new file mode 100644 index 000000000..9bbe3cb7f --- /dev/null +++ b/src/main/java/com/easemob/im/api/model/EMMessageContent.java @@ -0,0 +1,635 @@ +/* + * EMService + * Easemob Rest API + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.easemob.im.api.model; + +import java.util.Objects; +import com.easemob.im.api.model.EMImageSize; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.Arrays; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import com.easemob.im.JSON; + +/** + * 消息内容 + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-01-25T14:51:53.998371+08:00[Asia/Shanghai]") +public class EMMessageContent { + public static final String SERIALIZED_NAME_MSG = "msg"; + @SerializedName(SERIALIZED_NAME_MSG) + private String msg; + + public static final String SERIALIZED_NAME_FILENAME = "filename"; + @SerializedName(SERIALIZED_NAME_FILENAME) + private String filename; + + public static final String SERIALIZED_NAME_SECRET = "secret"; + @SerializedName(SERIALIZED_NAME_SECRET) + private String secret; + + public static final String SERIALIZED_NAME_SIZE = "size"; + @SerializedName(SERIALIZED_NAME_SIZE) + private EMImageSize size; + + public static final String SERIALIZED_NAME_URL = "url"; + @SerializedName(SERIALIZED_NAME_URL) + private String url; + + public static final String SERIALIZED_NAME_LENGTH = "length"; + @SerializedName(SERIALIZED_NAME_LENGTH) + private Integer length; + + public static final String SERIALIZED_NAME_THUMB = "thumb"; + @SerializedName(SERIALIZED_NAME_THUMB) + private String thumb; + + public static final String SERIALIZED_NAME_FILE_LENGTH = "file_length"; + @SerializedName(SERIALIZED_NAME_FILE_LENGTH) + private Integer fileLength; + + public static final String SERIALIZED_NAME_THUMB_SECRET = "thumb_secret"; + @SerializedName(SERIALIZED_NAME_THUMB_SECRET) + private String thumbSecret; + + public static final String SERIALIZED_NAME_LAT = "lat"; + @SerializedName(SERIALIZED_NAME_LAT) + private String lat; + + public static final String SERIALIZED_NAME_LNG = "lng"; + @SerializedName(SERIALIZED_NAME_LNG) + private String lng; + + public static final String SERIALIZED_NAME_ADDR = "addr"; + @SerializedName(SERIALIZED_NAME_ADDR) + private String addr; + + public static final String SERIALIZED_NAME_ACTION = "action"; + @SerializedName(SERIALIZED_NAME_ACTION) + private String action; + + public static final String SERIALIZED_NAME_CUSTOM_EVENT = "customEvent"; + @SerializedName(SERIALIZED_NAME_CUSTOM_EVENT) + private String customEvent; + + public static final String SERIALIZED_NAME_CUSTOM_EXTS = "customExts"; + @SerializedName(SERIALIZED_NAME_CUSTOM_EXTS) + private Object customExts; + + public EMMessageContent() { + } + + public EMMessageContent msg(String msg) { + + this.msg = msg; + return this; + } + + /** + * 消息内容 + * @return msg + **/ + @javax.annotation.Nullable + public String getMsg() { + return msg; + } + + + public void setMsg(String msg) { + this.msg = msg; + } + + + public EMMessageContent filename(String filename) { + + this.filename = filename; + return this; + } + + /** + * 图片名称/语音文件的名称/视频文件的名称/文件名称 + * @return filename + **/ + @javax.annotation.Nullable + public String getFilename() { + return filename; + } + + + public void setFilename(String filename) { + this.filename = filename; + } + + + public EMMessageContent secret(String secret) { + + this.secret = secret; + return this; + } + + /** + * 图片/语音/视频/文件的访问密钥,即成功上传图片/语音/视频/文件后,从 文件上传 的响应 body 中获取的 share-secret。如果图片/语音/视频/文件上传时设置了文件访问限制(restrict-access),则该字段为必填 + * @return secret + **/ + @javax.annotation.Nullable + public String getSecret() { + return secret; + } + + + public void setSecret(String secret) { + this.secret = secret; + } + + + public EMMessageContent size(EMImageSize size) { + + this.size = size; + return this; + } + + /** + * Get size + * @return size + **/ + @javax.annotation.Nullable + public EMImageSize getSize() { + return size; + } + + + public void setSize(EMImageSize size) { + this.size = size; + } + + + public EMMessageContent url(String url) { + + this.url = url; + return this; + } + + /** + * 图片/语音/视频/文件 URL 地址:https://{host}/{org_name}/{app_name}/chatfiles/{file_uuid}。其中 file_uud 为文件 ID,成功上传图片/语音/视频/文件后,从 文件上传 的响应 body 中获取 + * @return url + **/ + @javax.annotation.Nullable + public String getUrl() { + return url; + } + + + public void setUrl(String url) { + this.url = url; + } + + + public EMMessageContent length(Integer length) { + + this.length = length; + return this; + } + + /** + * 语音/视频时长,单位为秒 + * @return length + **/ + @javax.annotation.Nullable + public Integer getLength() { + return length; + } + + + public void setLength(Integer length) { + this.length = length; + } + + + public EMMessageContent thumb(String thumb) { + + this.thumb = thumb; + return this; + } + + /** + * 视频缩略图 URL 地址:https://{host}/{org_name}/{app_name}/chatfiles/{file_uuid}。file_uuid 为视频缩略图唯一标识,成功上传缩略图文件后,从 文件上传 的响应 body 中获取 + * @return thumb + **/ + @javax.annotation.Nullable + public String getThumb() { + return thumb; + } + + + public void setThumb(String thumb) { + this.thumb = thumb; + } + + + public EMMessageContent fileLength(Integer fileLength) { + + this.fileLength = fileLength; + return this; + } + + /** + * 视频文件大小,单位为字节 + * @return fileLength + **/ + @javax.annotation.Nullable + public Integer getFileLength() { + return fileLength; + } + + + public void setFileLength(Integer fileLength) { + this.fileLength = fileLength; + } + + + public EMMessageContent thumbSecret(String thumbSecret) { + + this.thumbSecret = thumbSecret; + return this; + } + + /** + * 视频缩略图访问密钥,即成功上传视频文件后,从 文件上传 的响应 body 中获取的 share-secret。如果缩略图文件上传时设置了文件访问限制(restrict-access),则该字段为必填 + * @return thumbSecret + **/ + @javax.annotation.Nullable + public String getThumbSecret() { + return thumbSecret; + } + + + public void setThumbSecret(String thumbSecret) { + this.thumbSecret = thumbSecret; + } + + + public EMMessageContent lat(String lat) { + + this.lat = lat; + return this; + } + + /** + * 位置的纬度,单位为度 + * @return lat + **/ + @javax.annotation.Nullable + public String getLat() { + return lat; + } + + + public void setLat(String lat) { + this.lat = lat; + } + + + public EMMessageContent lng(String lng) { + + this.lng = lng; + return this; + } + + /** + * 位置的经度,单位为度 + * @return lng + **/ + @javax.annotation.Nullable + public String getLng() { + return lng; + } + + + public void setLng(String lng) { + this.lng = lng; + } + + + public EMMessageContent addr(String addr) { + + this.addr = addr; + return this; + } + + /** + * 位置的文字描述 + * @return addr + **/ + @javax.annotation.Nullable + public String getAddr() { + return addr; + } + + + public void setAddr(String addr) { + this.addr = addr; + } + + + public EMMessageContent action(String action) { + + this.action = action; + return this; + } + + /** + * 命令内容 + * @return action + **/ + @javax.annotation.Nullable + public String getAction() { + return action; + } + + + public void setAction(String action) { + this.action = action; + } + + + public EMMessageContent customEvent(String customEvent) { + + this.customEvent = customEvent; + return this; + } + + /** + * 用户自定义的事件类型。该参数的值必须满足正则表达式 [a-zA-Z0-9-_/\\.]{1,32},长度为 1-32 个字符 + * @return customEvent + **/ + @javax.annotation.Nullable + public String getCustomEvent() { + return customEvent; + } + + + public void setCustomEvent(String customEvent) { + this.customEvent = customEvent; + } + + + public EMMessageContent customExts(Object customExts) { + + this.customExts = customExts; + return this; + } + + /** + * 用户自定义的事件属性,类型必须是 Map<String,String>,最多可以包含 16 个元素。customExts 是可选的,不需要可以不传 + * @return customExts + **/ + @javax.annotation.Nullable + public Object getCustomExts() { + return customExts; + } + + + public void setCustomExts(Object customExts) { + this.customExts = customExts; + } + + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + EMMessageContent messageContent = (EMMessageContent) o; + return Objects.equals(this.msg, messageContent.msg) && + Objects.equals(this.filename, messageContent.filename) && + Objects.equals(this.secret, messageContent.secret) && + Objects.equals(this.size, messageContent.size) && + Objects.equals(this.url, messageContent.url) && + Objects.equals(this.length, messageContent.length) && + Objects.equals(this.thumb, messageContent.thumb) && + Objects.equals(this.fileLength, messageContent.fileLength) && + Objects.equals(this.thumbSecret, messageContent.thumbSecret) && + Objects.equals(this.lat, messageContent.lat) && + Objects.equals(this.lng, messageContent.lng) && + Objects.equals(this.addr, messageContent.addr) && + Objects.equals(this.action, messageContent.action) && + Objects.equals(this.customEvent, messageContent.customEvent) && + Objects.equals(this.customExts, messageContent.customExts); + } + + @Override + public int hashCode() { + return Objects.hash(msg, filename, secret, size, url, length, thumb, fileLength, thumbSecret, lat, lng, addr, action, customEvent, customExts); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class EMMessageContent {\n"); + sb.append(" msg: ").append(toIndentedString(msg)).append("\n"); + sb.append(" filename: ").append(toIndentedString(filename)).append("\n"); + sb.append(" secret: ").append(toIndentedString(secret)).append("\n"); + sb.append(" size: ").append(toIndentedString(size)).append("\n"); + sb.append(" url: ").append(toIndentedString(url)).append("\n"); + sb.append(" length: ").append(toIndentedString(length)).append("\n"); + sb.append(" thumb: ").append(toIndentedString(thumb)).append("\n"); + sb.append(" fileLength: ").append(toIndentedString(fileLength)).append("\n"); + sb.append(" thumbSecret: ").append(toIndentedString(thumbSecret)).append("\n"); + sb.append(" lat: ").append(toIndentedString(lat)).append("\n"); + sb.append(" lng: ").append(toIndentedString(lng)).append("\n"); + sb.append(" addr: ").append(toIndentedString(addr)).append("\n"); + sb.append(" action: ").append(toIndentedString(action)).append("\n"); + sb.append(" customEvent: ").append(toIndentedString(customEvent)).append("\n"); + sb.append(" customExts: ").append(toIndentedString(customExts)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("msg"); + openapiFields.add("filename"); + openapiFields.add("secret"); + openapiFields.add("size"); + openapiFields.add("url"); + openapiFields.add("length"); + openapiFields.add("thumb"); + openapiFields.add("file_length"); + openapiFields.add("thumb_secret"); + openapiFields.add("lat"); + openapiFields.add("lng"); + openapiFields.add("addr"); + openapiFields.add("action"); + openapiFields.add("customEvent"); + openapiFields.add("customExts"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to EMMessageContent + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!EMMessageContent.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format("The required field(s) %s in EMMessageContent is not found in the empty JSON string", EMMessageContent.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!EMMessageContent.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `EMMessageContent` properties. JSON: %s", entry.getKey(), jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + if ((jsonObj.get("msg") != null && !jsonObj.get("msg").isJsonNull()) && !jsonObj.get("msg").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `msg` to be a primitive type in the JSON string but got `%s`", jsonObj.get("msg").toString())); + } + if ((jsonObj.get("filename") != null && !jsonObj.get("filename").isJsonNull()) && !jsonObj.get("filename").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `filename` to be a primitive type in the JSON string but got `%s`", jsonObj.get("filename").toString())); + } + if ((jsonObj.get("secret") != null && !jsonObj.get("secret").isJsonNull()) && !jsonObj.get("secret").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `secret` to be a primitive type in the JSON string but got `%s`", jsonObj.get("secret").toString())); + } + // validate the optional field `size` + if (jsonObj.get("size") != null && !jsonObj.get("size").isJsonNull()) { + EMImageSize.validateJsonElement(jsonObj.get("size")); + } + if ((jsonObj.get("url") != null && !jsonObj.get("url").isJsonNull()) && !jsonObj.get("url").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `url` to be a primitive type in the JSON string but got `%s`", jsonObj.get("url").toString())); + } + if ((jsonObj.get("thumb") != null && !jsonObj.get("thumb").isJsonNull()) && !jsonObj.get("thumb").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `thumb` to be a primitive type in the JSON string but got `%s`", jsonObj.get("thumb").toString())); + } + if ((jsonObj.get("thumb_secret") != null && !jsonObj.get("thumb_secret").isJsonNull()) && !jsonObj.get("thumb_secret").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `thumb_secret` to be a primitive type in the JSON string but got `%s`", jsonObj.get("thumb_secret").toString())); + } + if ((jsonObj.get("lat") != null && !jsonObj.get("lat").isJsonNull()) && !jsonObj.get("lat").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `lat` to be a primitive type in the JSON string but got `%s`", jsonObj.get("lat").toString())); + } + if ((jsonObj.get("lng") != null && !jsonObj.get("lng").isJsonNull()) && !jsonObj.get("lng").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `lng` to be a primitive type in the JSON string but got `%s`", jsonObj.get("lng").toString())); + } + if ((jsonObj.get("addr") != null && !jsonObj.get("addr").isJsonNull()) && !jsonObj.get("addr").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `addr` to be a primitive type in the JSON string but got `%s`", jsonObj.get("addr").toString())); + } + if ((jsonObj.get("action") != null && !jsonObj.get("action").isJsonNull()) && !jsonObj.get("action").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `action` to be a primitive type in the JSON string but got `%s`", jsonObj.get("action").toString())); + } + if ((jsonObj.get("customEvent") != null && !jsonObj.get("customEvent").isJsonNull()) && !jsonObj.get("customEvent").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `customEvent` to be a primitive type in the JSON string but got `%s`", jsonObj.get("customEvent").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!EMMessageContent.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'EMMessageContent' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(EMMessageContent.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, EMMessageContent value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public EMMessageContent read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + return thisAdapter.fromJsonTree(jsonElement); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of EMMessageContent given an JSON string + * + * @param jsonString JSON string + * @return An instance of EMMessageContent + * @throws IOException if the JSON string is invalid with respect to EMMessageContent + */ + public static EMMessageContent fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, EMMessageContent.class); + } + + /** + * Convert an instance of EMMessageContent to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/com/easemob/im/api/model/EMModifyGroup.java b/src/main/java/com/easemob/im/api/model/EMModifyGroup.java new file mode 100644 index 000000000..8e1e8ff53 --- /dev/null +++ b/src/main/java/com/easemob/im/api/model/EMModifyGroup.java @@ -0,0 +1,441 @@ +/* + * EMService + * Easemob Rest API + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.easemob.im.api.model; + +import java.util.Objects; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.Arrays; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import com.easemob.im.JSON; + +/** + * EMModifyGroup + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-01-25T14:51:53.998371+08:00[Asia/Shanghai]") +public class EMModifyGroup { + public static final String SERIALIZED_NAME_GROUPNAME = "groupname"; + @SerializedName(SERIALIZED_NAME_GROUPNAME) + private String groupname; + + public static final String SERIALIZED_NAME_DESCRIPTION = "description"; + @SerializedName(SERIALIZED_NAME_DESCRIPTION) + private String description; + + public static final String SERIALIZED_NAME_PUBLIC = "public"; + @SerializedName(SERIALIZED_NAME_PUBLIC) + private Boolean _public; + + public static final String SERIALIZED_NAME_MAXUSERS = "maxusers"; + @SerializedName(SERIALIZED_NAME_MAXUSERS) + private Integer maxusers; + + public static final String SERIALIZED_NAME_ALLOWINVITES = "allowinvites"; + @SerializedName(SERIALIZED_NAME_ALLOWINVITES) + private Boolean allowinvites; + + public static final String SERIALIZED_NAME_MEMBERSONLY = "membersonly"; + @SerializedName(SERIALIZED_NAME_MEMBERSONLY) + private Boolean membersonly; + + public static final String SERIALIZED_NAME_INVITE_NEED_CONFIRM = "invite_need_confirm"; + @SerializedName(SERIALIZED_NAME_INVITE_NEED_CONFIRM) + private Boolean inviteNeedConfirm; + + public static final String SERIALIZED_NAME_CUSTOM = "custom"; + @SerializedName(SERIALIZED_NAME_CUSTOM) + private String custom; + + public static final String SERIALIZED_NAME_NEWOWNER = "newowner"; + @SerializedName(SERIALIZED_NAME_NEWOWNER) + private String newowner; + + public EMModifyGroup() { + } + + public EMModifyGroup groupname(String groupname) { + + this.groupname = groupname; + return this; + } + + /** + * 群组名称,最大长度为 128 字符 + * @return groupname + **/ + @javax.annotation.Nullable + public String getGroupname() { + return groupname; + } + + + public void setGroupname(String groupname) { + this.groupname = groupname; + } + + + public EMModifyGroup description(String description) { + + this.description = description; + return this; + } + + /** + * 群组描述,最大长度为 512 字符 + * @return description + **/ + @javax.annotation.Nullable + public String getDescription() { + return description; + } + + + public void setDescription(String description) { + this.description = description; + } + + + public EMModifyGroup _public(Boolean _public) { + + this._public = _public; + return this; + } + + /** + * 是否是公开群。 - true:公开群; - false:私有群 + * @return _public + **/ + @javax.annotation.Nullable + public Boolean getPublic() { + return _public; + } + + + public void setPublic(Boolean _public) { + this._public = _public; + } + + + public EMModifyGroup maxusers(Integer maxusers) { + + this.maxusers = maxusers; + return this; + } + + /** + * 群组最大成员数(包括群主)。对于普通群,该参数的默认值为 200,大型群为 1000。不同套餐支持的人数上限不同,详见 产品价格 + * @return maxusers + **/ + @javax.annotation.Nullable + public Integer getMaxusers() { + return maxusers; + } + + + public void setMaxusers(Integer maxusers) { + this.maxusers = maxusers; + } + + + public EMModifyGroup allowinvites(Boolean allowinvites) { + + this.allowinvites = allowinvites; + return this; + } + + /** + * 是否允许群成员邀请用户加入群组: - true:群成员可拉人入群; - (默认)false:只有群主或者管理员才可以拉人入群。 注:该参数仅对私有群有效,因为公开群不允许群成员邀请其他用户入群 + * @return allowinvites + **/ + @javax.annotation.Nullable + public Boolean getAllowinvites() { + return allowinvites; + } + + + public void setAllowinvites(Boolean allowinvites) { + this.allowinvites = allowinvites; + } + + + public EMModifyGroup membersonly(Boolean membersonly) { + + this.membersonly = membersonly; + return this; + } + + /** + * 群组最大成员数(包括群主)。对于普通群,该参数的默认值为 200,大型群为 1000。不同套餐支持的人数上限不同,详见 产品价格 + * @return membersonly + **/ + @javax.annotation.Nullable + public Boolean getMembersonly() { + return membersonly; + } + + + public void setMembersonly(Boolean membersonly) { + this.membersonly = membersonly; + } + + + public EMModifyGroup inviteNeedConfirm(Boolean inviteNeedConfirm) { + + this.inviteNeedConfirm = inviteNeedConfirm; + return this; + } + + /** + * 邀请用户入群时是否需要被邀用户同意。 - (默认)true:是; - false:否 + * @return inviteNeedConfirm + **/ + @javax.annotation.Nullable + public Boolean getInviteNeedConfirm() { + return inviteNeedConfirm; + } + + + public void setInviteNeedConfirm(Boolean inviteNeedConfirm) { + this.inviteNeedConfirm = inviteNeedConfirm; + } + + + public EMModifyGroup custom(String custom) { + + this.custom = custom; + return this; + } + + /** + * 群组扩展信息,例如可以给群组添加业务相关的标记,不要超过 1,024 字符 + * @return custom + **/ + @javax.annotation.Nullable + public String getCustom() { + return custom; + } + + + public void setCustom(String custom) { + this.custom = custom; + } + + + public EMModifyGroup newowner(String newowner) { + + this.newowner = newowner; + return this; + } + + /** + * 群组的新管理员的用户 ID + * @return newowner + **/ + @javax.annotation.Nullable + public String getNewowner() { + return newowner; + } + + + public void setNewowner(String newowner) { + this.newowner = newowner; + } + + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + EMModifyGroup modifyGroup = (EMModifyGroup) o; + return Objects.equals(this.groupname, modifyGroup.groupname) && + Objects.equals(this.description, modifyGroup.description) && + Objects.equals(this._public, modifyGroup._public) && + Objects.equals(this.maxusers, modifyGroup.maxusers) && + Objects.equals(this.allowinvites, modifyGroup.allowinvites) && + Objects.equals(this.membersonly, modifyGroup.membersonly) && + Objects.equals(this.inviteNeedConfirm, modifyGroup.inviteNeedConfirm) && + Objects.equals(this.custom, modifyGroup.custom) && + Objects.equals(this.newowner, modifyGroup.newowner); + } + + @Override + public int hashCode() { + return Objects.hash(groupname, description, _public, maxusers, allowinvites, membersonly, inviteNeedConfirm, custom, newowner); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class EMModifyGroup {\n"); + sb.append(" groupname: ").append(toIndentedString(groupname)).append("\n"); + sb.append(" description: ").append(toIndentedString(description)).append("\n"); + sb.append(" _public: ").append(toIndentedString(_public)).append("\n"); + sb.append(" maxusers: ").append(toIndentedString(maxusers)).append("\n"); + sb.append(" allowinvites: ").append(toIndentedString(allowinvites)).append("\n"); + sb.append(" membersonly: ").append(toIndentedString(membersonly)).append("\n"); + sb.append(" inviteNeedConfirm: ").append(toIndentedString(inviteNeedConfirm)).append("\n"); + sb.append(" custom: ").append(toIndentedString(custom)).append("\n"); + sb.append(" newowner: ").append(toIndentedString(newowner)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("groupname"); + openapiFields.add("description"); + openapiFields.add("public"); + openapiFields.add("maxusers"); + openapiFields.add("allowinvites"); + openapiFields.add("membersonly"); + openapiFields.add("invite_need_confirm"); + openapiFields.add("custom"); + openapiFields.add("newowner"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to EMModifyGroup + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!EMModifyGroup.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format("The required field(s) %s in EMModifyGroup is not found in the empty JSON string", EMModifyGroup.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!EMModifyGroup.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `EMModifyGroup` properties. JSON: %s", entry.getKey(), jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + if ((jsonObj.get("groupname") != null && !jsonObj.get("groupname").isJsonNull()) && !jsonObj.get("groupname").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `groupname` to be a primitive type in the JSON string but got `%s`", jsonObj.get("groupname").toString())); + } + if ((jsonObj.get("description") != null && !jsonObj.get("description").isJsonNull()) && !jsonObj.get("description").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `description` to be a primitive type in the JSON string but got `%s`", jsonObj.get("description").toString())); + } + if ((jsonObj.get("custom") != null && !jsonObj.get("custom").isJsonNull()) && !jsonObj.get("custom").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `custom` to be a primitive type in the JSON string but got `%s`", jsonObj.get("custom").toString())); + } + if ((jsonObj.get("newowner") != null && !jsonObj.get("newowner").isJsonNull()) && !jsonObj.get("newowner").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `newowner` to be a primitive type in the JSON string but got `%s`", jsonObj.get("newowner").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!EMModifyGroup.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'EMModifyGroup' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(EMModifyGroup.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, EMModifyGroup value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public EMModifyGroup read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + return thisAdapter.fromJsonTree(jsonElement); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of EMModifyGroup given an JSON string + * + * @param jsonString JSON string + * @return An instance of EMModifyGroup + * @throws IOException if the JSON string is invalid with respect to EMModifyGroup + */ + public static EMModifyGroup fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, EMModifyGroup.class); + } + + /** + * Convert an instance of EMModifyGroup to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/com/easemob/im/api/model/EMModifyGroupAnnouncement.java b/src/main/java/com/easemob/im/api/model/EMModifyGroupAnnouncement.java new file mode 100644 index 000000000..78ec124e5 --- /dev/null +++ b/src/main/java/com/easemob/im/api/model/EMModifyGroupAnnouncement.java @@ -0,0 +1,208 @@ +/* + * EMService + * Easemob Rest API + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.easemob.im.api.model; + +import java.util.Objects; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.Arrays; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import com.easemob.im.JSON; + +/** + * EMModifyGroupAnnouncement + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-01-25T14:51:53.998371+08:00[Asia/Shanghai]") +public class EMModifyGroupAnnouncement { + public static final String SERIALIZED_NAME_ANNOUNCEMENT = "announcement"; + @SerializedName(SERIALIZED_NAME_ANNOUNCEMENT) + private String announcement; + + public EMModifyGroupAnnouncement() { + } + + public EMModifyGroupAnnouncement announcement(String announcement) { + + this.announcement = announcement; + return this; + } + + /** + * 群组公告内容,不能超过 512 个字符 + * @return announcement + **/ + @javax.annotation.Nullable + public String getAnnouncement() { + return announcement; + } + + + public void setAnnouncement(String announcement) { + this.announcement = announcement; + } + + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + EMModifyGroupAnnouncement modifyGroupAnnouncement = (EMModifyGroupAnnouncement) o; + return Objects.equals(this.announcement, modifyGroupAnnouncement.announcement); + } + + @Override + public int hashCode() { + return Objects.hash(announcement); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class EMModifyGroupAnnouncement {\n"); + sb.append(" announcement: ").append(toIndentedString(announcement)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("announcement"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to EMModifyGroupAnnouncement + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!EMModifyGroupAnnouncement.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format("The required field(s) %s in EMModifyGroupAnnouncement is not found in the empty JSON string", EMModifyGroupAnnouncement.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!EMModifyGroupAnnouncement.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `EMModifyGroupAnnouncement` properties. JSON: %s", entry.getKey(), jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + if ((jsonObj.get("announcement") != null && !jsonObj.get("announcement").isJsonNull()) && !jsonObj.get("announcement").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `announcement` to be a primitive type in the JSON string but got `%s`", jsonObj.get("announcement").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!EMModifyGroupAnnouncement.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'EMModifyGroupAnnouncement' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(EMModifyGroupAnnouncement.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, EMModifyGroupAnnouncement value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public EMModifyGroupAnnouncement read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + return thisAdapter.fromJsonTree(jsonElement); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of EMModifyGroupAnnouncement given an JSON string + * + * @param jsonString JSON string + * @return An instance of EMModifyGroupAnnouncement + * @throws IOException if the JSON string is invalid with respect to EMModifyGroupAnnouncement + */ + public static EMModifyGroupAnnouncement fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, EMModifyGroupAnnouncement.class); + } + + /** + * Convert an instance of EMModifyGroupAnnouncement to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/com/easemob/im/api/model/EMModifyGroupAnnouncementResource.java b/src/main/java/com/easemob/im/api/model/EMModifyGroupAnnouncementResource.java new file mode 100644 index 000000000..17de16aa2 --- /dev/null +++ b/src/main/java/com/easemob/im/api/model/EMModifyGroupAnnouncementResource.java @@ -0,0 +1,236 @@ +/* + * EMService + * Easemob Rest API + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.easemob.im.api.model; + +import java.util.Objects; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.Arrays; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import com.easemob.im.JSON; + +/** + * EMModifyGroupAnnouncementResource + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-01-25T14:51:53.998371+08:00[Asia/Shanghai]") +public class EMModifyGroupAnnouncementResource { + public static final String SERIALIZED_NAME_ID = "id"; + @SerializedName(SERIALIZED_NAME_ID) + private String id; + + public static final String SERIALIZED_NAME_RESULT = "result"; + @SerializedName(SERIALIZED_NAME_RESULT) + private Boolean result; + + public EMModifyGroupAnnouncementResource() { + } + + public EMModifyGroupAnnouncementResource id(String id) { + + this.id = id; + return this; + } + + /** + * Get id + * @return id + **/ + @javax.annotation.Nullable + public String getId() { + return id; + } + + + public void setId(String id) { + this.id = id; + } + + + public EMModifyGroupAnnouncementResource result(Boolean result) { + + this.result = result; + return this; + } + + /** + * Get result + * @return result + **/ + @javax.annotation.Nullable + public Boolean getResult() { + return result; + } + + + public void setResult(Boolean result) { + this.result = result; + } + + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + EMModifyGroupAnnouncementResource modifyGroupAnnouncementResource = (EMModifyGroupAnnouncementResource) o; + return Objects.equals(this.id, modifyGroupAnnouncementResource.id) && + Objects.equals(this.result, modifyGroupAnnouncementResource.result); + } + + @Override + public int hashCode() { + return Objects.hash(id, result); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class EMModifyGroupAnnouncementResource {\n"); + sb.append(" id: ").append(toIndentedString(id)).append("\n"); + sb.append(" result: ").append(toIndentedString(result)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("id"); + openapiFields.add("result"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to EMModifyGroupAnnouncementResource + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!EMModifyGroupAnnouncementResource.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format("The required field(s) %s in EMModifyGroupAnnouncementResource is not found in the empty JSON string", EMModifyGroupAnnouncementResource.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!EMModifyGroupAnnouncementResource.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `EMModifyGroupAnnouncementResource` properties. JSON: %s", entry.getKey(), jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + if ((jsonObj.get("id") != null && !jsonObj.get("id").isJsonNull()) && !jsonObj.get("id").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `id` to be a primitive type in the JSON string but got `%s`", jsonObj.get("id").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!EMModifyGroupAnnouncementResource.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'EMModifyGroupAnnouncementResource' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(EMModifyGroupAnnouncementResource.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, EMModifyGroupAnnouncementResource value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public EMModifyGroupAnnouncementResource read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + return thisAdapter.fromJsonTree(jsonElement); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of EMModifyGroupAnnouncementResource given an JSON string + * + * @param jsonString JSON string + * @return An instance of EMModifyGroupAnnouncementResource + * @throws IOException if the JSON string is invalid with respect to EMModifyGroupAnnouncementResource + */ + public static EMModifyGroupAnnouncementResource fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, EMModifyGroupAnnouncementResource.class); + } + + /** + * Convert an instance of EMModifyGroupAnnouncementResource to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/com/easemob/im/api/model/EMModifyGroupAnnouncementResult.java b/src/main/java/com/easemob/im/api/model/EMModifyGroupAnnouncementResult.java new file mode 100644 index 000000000..bc33a0cdd --- /dev/null +++ b/src/main/java/com/easemob/im/api/model/EMModifyGroupAnnouncementResult.java @@ -0,0 +1,210 @@ +/* + * EMService + * Easemob Rest API + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.easemob.im.api.model; + +import java.util.Objects; +import com.easemob.im.api.model.EMModifyGroupAnnouncementResource; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.Arrays; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import com.easemob.im.JSON; + +/** + * EMModifyGroupAnnouncementResult + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-01-25T14:51:53.998371+08:00[Asia/Shanghai]") +public class EMModifyGroupAnnouncementResult { + public static final String SERIALIZED_NAME_DATA = "data"; + @SerializedName(SERIALIZED_NAME_DATA) + private EMModifyGroupAnnouncementResource data; + + public EMModifyGroupAnnouncementResult() { + } + + public EMModifyGroupAnnouncementResult data(EMModifyGroupAnnouncementResource data) { + + this.data = data; + return this; + } + + /** + * Get data + * @return data + **/ + @javax.annotation.Nullable + public EMModifyGroupAnnouncementResource getData() { + return data; + } + + + public void setData(EMModifyGroupAnnouncementResource data) { + this.data = data; + } + + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + EMModifyGroupAnnouncementResult modifyGroupAnnouncementResult = (EMModifyGroupAnnouncementResult) o; + return Objects.equals(this.data, modifyGroupAnnouncementResult.data); + } + + @Override + public int hashCode() { + return Objects.hash(data); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class EMModifyGroupAnnouncementResult {\n"); + sb.append(" data: ").append(toIndentedString(data)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("data"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to EMModifyGroupAnnouncementResult + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!EMModifyGroupAnnouncementResult.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format("The required field(s) %s in EMModifyGroupAnnouncementResult is not found in the empty JSON string", EMModifyGroupAnnouncementResult.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!EMModifyGroupAnnouncementResult.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `EMModifyGroupAnnouncementResult` properties. JSON: %s", entry.getKey(), jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // validate the optional field `data` + if (jsonObj.get("data") != null && !jsonObj.get("data").isJsonNull()) { + EMModifyGroupAnnouncementResource.validateJsonElement(jsonObj.get("data")); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!EMModifyGroupAnnouncementResult.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'EMModifyGroupAnnouncementResult' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(EMModifyGroupAnnouncementResult.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, EMModifyGroupAnnouncementResult value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public EMModifyGroupAnnouncementResult read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + return thisAdapter.fromJsonTree(jsonElement); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of EMModifyGroupAnnouncementResult given an JSON string + * + * @param jsonString JSON string + * @return An instance of EMModifyGroupAnnouncementResult + * @throws IOException if the JSON string is invalid with respect to EMModifyGroupAnnouncementResult + */ + public static EMModifyGroupAnnouncementResult fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, EMModifyGroupAnnouncementResult.class); + } + + /** + * Convert an instance of EMModifyGroupAnnouncementResult to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/com/easemob/im/api/model/EMModifyGroupResult.java b/src/main/java/com/easemob/im/api/model/EMModifyGroupResult.java new file mode 100644 index 000000000..330e86619 --- /dev/null +++ b/src/main/java/com/easemob/im/api/model/EMModifyGroupResult.java @@ -0,0 +1,205 @@ +/* + * EMService + * Easemob Rest API + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.easemob.im.api.model; + +import java.util.Objects; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.Arrays; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import com.easemob.im.JSON; + +/** + * EMModifyGroupResult + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-01-25T14:51:53.998371+08:00[Asia/Shanghai]") +public class EMModifyGroupResult { + public static final String SERIALIZED_NAME_DATA = "data"; + @SerializedName(SERIALIZED_NAME_DATA) + private Object data; + + public EMModifyGroupResult() { + } + + public EMModifyGroupResult data(Object data) { + + this.data = data; + return this; + } + + /** + * Get data + * @return data + **/ + @javax.annotation.Nullable + public Object getData() { + return data; + } + + + public void setData(Object data) { + this.data = data; + } + + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + EMModifyGroupResult modifyGroupResult = (EMModifyGroupResult) o; + return Objects.equals(this.data, modifyGroupResult.data); + } + + @Override + public int hashCode() { + return Objects.hash(data); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class EMModifyGroupResult {\n"); + sb.append(" data: ").append(toIndentedString(data)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("data"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to EMModifyGroupResult + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!EMModifyGroupResult.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format("The required field(s) %s in EMModifyGroupResult is not found in the empty JSON string", EMModifyGroupResult.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!EMModifyGroupResult.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `EMModifyGroupResult` properties. JSON: %s", entry.getKey(), jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!EMModifyGroupResult.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'EMModifyGroupResult' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(EMModifyGroupResult.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, EMModifyGroupResult value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public EMModifyGroupResult read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + return thisAdapter.fromJsonTree(jsonElement); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of EMModifyGroupResult given an JSON string + * + * @param jsonString JSON string + * @return An instance of EMModifyGroupResult + * @throws IOException if the JSON string is invalid with respect to EMModifyGroupResult + */ + public static EMModifyGroupResult fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, EMModifyGroupResult.class); + } + + /** + * Convert an instance of EMModifyGroupResult to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/com/easemob/im/api/model/EMModifyRoom.java b/src/main/java/com/easemob/im/api/model/EMModifyRoom.java new file mode 100644 index 000000000..1f451f56b --- /dev/null +++ b/src/main/java/com/easemob/im/api/model/EMModifyRoom.java @@ -0,0 +1,267 @@ +/* + * EMService + * Easemob Rest API + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.easemob.im.api.model; + +import java.util.Objects; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.Arrays; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import com.easemob.im.JSON; + +/** + * EMModifyRoom + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-01-25T14:51:53.998371+08:00[Asia/Shanghai]") +public class EMModifyRoom { + public static final String SERIALIZED_NAME_NAME = "name"; + @SerializedName(SERIALIZED_NAME_NAME) + private String name; + + public static final String SERIALIZED_NAME_DESCRIPTION = "description"; + @SerializedName(SERIALIZED_NAME_DESCRIPTION) + private String description; + + public static final String SERIALIZED_NAME_MAXUSERS = "maxusers"; + @SerializedName(SERIALIZED_NAME_MAXUSERS) + private Integer maxusers; + + public EMModifyRoom() { + } + + public EMModifyRoom name(String name) { + + this.name = name; + return this; + } + + /** + * 聊天室名称,最大长度为 128 个字符 + * @return name + **/ + @javax.annotation.Nullable + public String getName() { + return name; + } + + + public void setName(String name) { + this.name = name; + } + + + public EMModifyRoom description(String description) { + + this.description = description; + return this; + } + + /** + * 聊天室描述,最大长度为 512 个字符 + * @return description + **/ + @javax.annotation.Nullable + public String getDescription() { + return description; + } + + + public void setDescription(String description) { + this.description = description; + } + + + public EMModifyRoom maxusers(Integer maxusers) { + + this.maxusers = maxusers; + return this; + } + + /** + * 聊天室最大成员数(包括聊天室所有者)。取值范围为 [1,10,000],默认值为 1000。如需调整请联系商务 + * @return maxusers + **/ + @javax.annotation.Nullable + public Integer getMaxusers() { + return maxusers; + } + + + public void setMaxusers(Integer maxusers) { + this.maxusers = maxusers; + } + + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + EMModifyRoom modifyRoom = (EMModifyRoom) o; + return Objects.equals(this.name, modifyRoom.name) && + Objects.equals(this.description, modifyRoom.description) && + Objects.equals(this.maxusers, modifyRoom.maxusers); + } + + @Override + public int hashCode() { + return Objects.hash(name, description, maxusers); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class EMModifyRoom {\n"); + sb.append(" name: ").append(toIndentedString(name)).append("\n"); + sb.append(" description: ").append(toIndentedString(description)).append("\n"); + sb.append(" maxusers: ").append(toIndentedString(maxusers)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("name"); + openapiFields.add("description"); + openapiFields.add("maxusers"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to EMModifyRoom + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!EMModifyRoom.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format("The required field(s) %s in EMModifyRoom is not found in the empty JSON string", EMModifyRoom.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!EMModifyRoom.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `EMModifyRoom` properties. JSON: %s", entry.getKey(), jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + if ((jsonObj.get("name") != null && !jsonObj.get("name").isJsonNull()) && !jsonObj.get("name").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("name").toString())); + } + if ((jsonObj.get("description") != null && !jsonObj.get("description").isJsonNull()) && !jsonObj.get("description").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `description` to be a primitive type in the JSON string but got `%s`", jsonObj.get("description").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!EMModifyRoom.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'EMModifyRoom' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(EMModifyRoom.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, EMModifyRoom value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public EMModifyRoom read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + return thisAdapter.fromJsonTree(jsonElement); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of EMModifyRoom given an JSON string + * + * @param jsonString JSON string + * @return An instance of EMModifyRoom + * @throws IOException if the JSON string is invalid with respect to EMModifyRoom + */ + public static EMModifyRoom fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, EMModifyRoom.class); + } + + /** + * Convert an instance of EMModifyRoom to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/com/easemob/im/api/model/EMModifyRoomAnnouncement.java b/src/main/java/com/easemob/im/api/model/EMModifyRoomAnnouncement.java new file mode 100644 index 000000000..8c220fdc5 --- /dev/null +++ b/src/main/java/com/easemob/im/api/model/EMModifyRoomAnnouncement.java @@ -0,0 +1,208 @@ +/* + * EMService + * Easemob Rest API + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.easemob.im.api.model; + +import java.util.Objects; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.Arrays; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import com.easemob.im.JSON; + +/** + * EMModifyRoomAnnouncement + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-01-25T14:51:53.998371+08:00[Asia/Shanghai]") +public class EMModifyRoomAnnouncement { + public static final String SERIALIZED_NAME_ANNOUNCEMENT = "announcement"; + @SerializedName(SERIALIZED_NAME_ANNOUNCEMENT) + private String announcement; + + public EMModifyRoomAnnouncement() { + } + + public EMModifyRoomAnnouncement announcement(String announcement) { + + this.announcement = announcement; + return this; + } + + /** + * 修改后的聊天室公告 + * @return announcement + **/ + @javax.annotation.Nullable + public String getAnnouncement() { + return announcement; + } + + + public void setAnnouncement(String announcement) { + this.announcement = announcement; + } + + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + EMModifyRoomAnnouncement modifyRoomAnnouncement = (EMModifyRoomAnnouncement) o; + return Objects.equals(this.announcement, modifyRoomAnnouncement.announcement); + } + + @Override + public int hashCode() { + return Objects.hash(announcement); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class EMModifyRoomAnnouncement {\n"); + sb.append(" announcement: ").append(toIndentedString(announcement)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("announcement"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to EMModifyRoomAnnouncement + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!EMModifyRoomAnnouncement.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format("The required field(s) %s in EMModifyRoomAnnouncement is not found in the empty JSON string", EMModifyRoomAnnouncement.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!EMModifyRoomAnnouncement.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `EMModifyRoomAnnouncement` properties. JSON: %s", entry.getKey(), jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + if ((jsonObj.get("announcement") != null && !jsonObj.get("announcement").isJsonNull()) && !jsonObj.get("announcement").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `announcement` to be a primitive type in the JSON string but got `%s`", jsonObj.get("announcement").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!EMModifyRoomAnnouncement.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'EMModifyRoomAnnouncement' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(EMModifyRoomAnnouncement.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, EMModifyRoomAnnouncement value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public EMModifyRoomAnnouncement read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + return thisAdapter.fromJsonTree(jsonElement); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of EMModifyRoomAnnouncement given an JSON string + * + * @param jsonString JSON string + * @return An instance of EMModifyRoomAnnouncement + * @throws IOException if the JSON string is invalid with respect to EMModifyRoomAnnouncement + */ + public static EMModifyRoomAnnouncement fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, EMModifyRoomAnnouncement.class); + } + + /** + * Convert an instance of EMModifyRoomAnnouncement to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/com/easemob/im/api/model/EMModifyRoomAnnouncementResource.java b/src/main/java/com/easemob/im/api/model/EMModifyRoomAnnouncementResource.java new file mode 100644 index 000000000..4367ab0d7 --- /dev/null +++ b/src/main/java/com/easemob/im/api/model/EMModifyRoomAnnouncementResource.java @@ -0,0 +1,205 @@ +/* + * EMService + * Easemob Rest API + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.easemob.im.api.model; + +import java.util.Objects; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.Arrays; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import com.easemob.im.JSON; + +/** + * EMModifyRoomAnnouncementResource + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-01-25T14:51:53.998371+08:00[Asia/Shanghai]") +public class EMModifyRoomAnnouncementResource { + public static final String SERIALIZED_NAME_RESULT = "result"; + @SerializedName(SERIALIZED_NAME_RESULT) + private Boolean result; + + public EMModifyRoomAnnouncementResource() { + } + + public EMModifyRoomAnnouncementResource result(Boolean result) { + + this.result = result; + return this; + } + + /** + * Get result + * @return result + **/ + @javax.annotation.Nullable + public Boolean getResult() { + return result; + } + + + public void setResult(Boolean result) { + this.result = result; + } + + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + EMModifyRoomAnnouncementResource modifyRoomAnnouncementResource = (EMModifyRoomAnnouncementResource) o; + return Objects.equals(this.result, modifyRoomAnnouncementResource.result); + } + + @Override + public int hashCode() { + return Objects.hash(result); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class EMModifyRoomAnnouncementResource {\n"); + sb.append(" result: ").append(toIndentedString(result)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("result"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to EMModifyRoomAnnouncementResource + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!EMModifyRoomAnnouncementResource.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format("The required field(s) %s in EMModifyRoomAnnouncementResource is not found in the empty JSON string", EMModifyRoomAnnouncementResource.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!EMModifyRoomAnnouncementResource.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `EMModifyRoomAnnouncementResource` properties. JSON: %s", entry.getKey(), jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!EMModifyRoomAnnouncementResource.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'EMModifyRoomAnnouncementResource' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(EMModifyRoomAnnouncementResource.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, EMModifyRoomAnnouncementResource value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public EMModifyRoomAnnouncementResource read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + return thisAdapter.fromJsonTree(jsonElement); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of EMModifyRoomAnnouncementResource given an JSON string + * + * @param jsonString JSON string + * @return An instance of EMModifyRoomAnnouncementResource + * @throws IOException if the JSON string is invalid with respect to EMModifyRoomAnnouncementResource + */ + public static EMModifyRoomAnnouncementResource fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, EMModifyRoomAnnouncementResource.class); + } + + /** + * Convert an instance of EMModifyRoomAnnouncementResource to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/com/easemob/im/api/model/EMModifyRoomAnnouncementResult.java b/src/main/java/com/easemob/im/api/model/EMModifyRoomAnnouncementResult.java new file mode 100644 index 000000000..effde0ceb --- /dev/null +++ b/src/main/java/com/easemob/im/api/model/EMModifyRoomAnnouncementResult.java @@ -0,0 +1,210 @@ +/* + * EMService + * Easemob Rest API + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.easemob.im.api.model; + +import java.util.Objects; +import com.easemob.im.api.model.EMModifyRoomAnnouncementResource; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.Arrays; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import com.easemob.im.JSON; + +/** + * EMModifyRoomAnnouncementResult + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-01-25T14:51:53.998371+08:00[Asia/Shanghai]") +public class EMModifyRoomAnnouncementResult { + public static final String SERIALIZED_NAME_DATA = "data"; + @SerializedName(SERIALIZED_NAME_DATA) + private EMModifyRoomAnnouncementResource data; + + public EMModifyRoomAnnouncementResult() { + } + + public EMModifyRoomAnnouncementResult data(EMModifyRoomAnnouncementResource data) { + + this.data = data; + return this; + } + + /** + * Get data + * @return data + **/ + @javax.annotation.Nullable + public EMModifyRoomAnnouncementResource getData() { + return data; + } + + + public void setData(EMModifyRoomAnnouncementResource data) { + this.data = data; + } + + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + EMModifyRoomAnnouncementResult modifyRoomAnnouncementResult = (EMModifyRoomAnnouncementResult) o; + return Objects.equals(this.data, modifyRoomAnnouncementResult.data); + } + + @Override + public int hashCode() { + return Objects.hash(data); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class EMModifyRoomAnnouncementResult {\n"); + sb.append(" data: ").append(toIndentedString(data)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("data"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to EMModifyRoomAnnouncementResult + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!EMModifyRoomAnnouncementResult.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format("The required field(s) %s in EMModifyRoomAnnouncementResult is not found in the empty JSON string", EMModifyRoomAnnouncementResult.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!EMModifyRoomAnnouncementResult.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `EMModifyRoomAnnouncementResult` properties. JSON: %s", entry.getKey(), jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // validate the optional field `data` + if (jsonObj.get("data") != null && !jsonObj.get("data").isJsonNull()) { + EMModifyRoomAnnouncementResource.validateJsonElement(jsonObj.get("data")); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!EMModifyRoomAnnouncementResult.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'EMModifyRoomAnnouncementResult' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(EMModifyRoomAnnouncementResult.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, EMModifyRoomAnnouncementResult value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public EMModifyRoomAnnouncementResult read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + return thisAdapter.fromJsonTree(jsonElement); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of EMModifyRoomAnnouncementResult given an JSON string + * + * @param jsonString JSON string + * @return An instance of EMModifyRoomAnnouncementResult + * @throws IOException if the JSON string is invalid with respect to EMModifyRoomAnnouncementResult + */ + public static EMModifyRoomAnnouncementResult fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, EMModifyRoomAnnouncementResult.class); + } + + /** + * Convert an instance of EMModifyRoomAnnouncementResult to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/com/easemob/im/api/model/EMModifyRoomResource.java b/src/main/java/com/easemob/im/api/model/EMModifyRoomResource.java new file mode 100644 index 000000000..41f4f93b3 --- /dev/null +++ b/src/main/java/com/easemob/im/api/model/EMModifyRoomResource.java @@ -0,0 +1,208 @@ +/* + * EMService + * Easemob Rest API + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.easemob.im.api.model; + +import java.util.Objects; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.Arrays; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import com.easemob.im.JSON; + +/** + * EMModifyRoomResource + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-01-25T14:51:53.998371+08:00[Asia/Shanghai]") +public class EMModifyRoomResource { + public static final String SERIALIZED_NAME_ANNOUNCEMENT = "announcement"; + @SerializedName(SERIALIZED_NAME_ANNOUNCEMENT) + private String announcement; + + public EMModifyRoomResource() { + } + + public EMModifyRoomResource announcement(String announcement) { + + this.announcement = announcement; + return this; + } + + /** + * Get announcement + * @return announcement + **/ + @javax.annotation.Nullable + public String getAnnouncement() { + return announcement; + } + + + public void setAnnouncement(String announcement) { + this.announcement = announcement; + } + + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + EMModifyRoomResource modifyRoomResource = (EMModifyRoomResource) o; + return Objects.equals(this.announcement, modifyRoomResource.announcement); + } + + @Override + public int hashCode() { + return Objects.hash(announcement); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class EMModifyRoomResource {\n"); + sb.append(" announcement: ").append(toIndentedString(announcement)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("announcement"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to EMModifyRoomResource + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!EMModifyRoomResource.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format("The required field(s) %s in EMModifyRoomResource is not found in the empty JSON string", EMModifyRoomResource.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!EMModifyRoomResource.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `EMModifyRoomResource` properties. JSON: %s", entry.getKey(), jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + if ((jsonObj.get("announcement") != null && !jsonObj.get("announcement").isJsonNull()) && !jsonObj.get("announcement").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `announcement` to be a primitive type in the JSON string but got `%s`", jsonObj.get("announcement").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!EMModifyRoomResource.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'EMModifyRoomResource' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(EMModifyRoomResource.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, EMModifyRoomResource value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public EMModifyRoomResource read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + return thisAdapter.fromJsonTree(jsonElement); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of EMModifyRoomResource given an JSON string + * + * @param jsonString JSON string + * @return An instance of EMModifyRoomResource + * @throws IOException if the JSON string is invalid with respect to EMModifyRoomResource + */ + public static EMModifyRoomResource fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, EMModifyRoomResource.class); + } + + /** + * Convert an instance of EMModifyRoomResource to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/com/easemob/im/api/model/EMModifyRoomResult.java b/src/main/java/com/easemob/im/api/model/EMModifyRoomResult.java new file mode 100644 index 000000000..ed962968c --- /dev/null +++ b/src/main/java/com/easemob/im/api/model/EMModifyRoomResult.java @@ -0,0 +1,205 @@ +/* + * EMService + * Easemob Rest API + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.easemob.im.api.model; + +import java.util.Objects; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.Arrays; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import com.easemob.im.JSON; + +/** + * EMModifyRoomResult + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-01-25T14:51:53.998371+08:00[Asia/Shanghai]") +public class EMModifyRoomResult { + public static final String SERIALIZED_NAME_DATA = "data"; + @SerializedName(SERIALIZED_NAME_DATA) + private Object data; + + public EMModifyRoomResult() { + } + + public EMModifyRoomResult data(Object data) { + + this.data = data; + return this; + } + + /** + * Get data + * @return data + **/ + @javax.annotation.Nullable + public Object getData() { + return data; + } + + + public void setData(Object data) { + this.data = data; + } + + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + EMModifyRoomResult modifyRoomResult = (EMModifyRoomResult) o; + return Objects.equals(this.data, modifyRoomResult.data); + } + + @Override + public int hashCode() { + return Objects.hash(data); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class EMModifyRoomResult {\n"); + sb.append(" data: ").append(toIndentedString(data)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("data"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to EMModifyRoomResult + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!EMModifyRoomResult.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format("The required field(s) %s in EMModifyRoomResult is not found in the empty JSON string", EMModifyRoomResult.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!EMModifyRoomResult.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `EMModifyRoomResult` properties. JSON: %s", entry.getKey(), jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!EMModifyRoomResult.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'EMModifyRoomResult' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(EMModifyRoomResult.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, EMModifyRoomResult value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public EMModifyRoomResult read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + return thisAdapter.fromJsonTree(jsonElement); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of EMModifyRoomResult given an JSON string + * + * @param jsonString JSON string + * @return An instance of EMModifyRoomResult + * @throws IOException if the JSON string is invalid with respect to EMModifyRoomResult + */ + public static EMModifyRoomResult fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, EMModifyRoomResult.class); + } + + /** + * Convert an instance of EMModifyRoomResult to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/com/easemob/im/api/model/EMModifyThread.java b/src/main/java/com/easemob/im/api/model/EMModifyThread.java new file mode 100644 index 000000000..b08024604 --- /dev/null +++ b/src/main/java/com/easemob/im/api/model/EMModifyThread.java @@ -0,0 +1,208 @@ +/* + * EMService + * Easemob Rest API + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.easemob.im.api.model; + +import java.util.Objects; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.Arrays; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import com.easemob.im.JSON; + +/** + * EMModifyThread + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-01-25T14:51:53.998371+08:00[Asia/Shanghai]") +public class EMModifyThread { + public static final String SERIALIZED_NAME_NAME = "name"; + @SerializedName(SERIALIZED_NAME_NAME) + private String name; + + public EMModifyThread() { + } + + public EMModifyThread name(String name) { + + this.name = name; + return this; + } + + /** + * 修改后的子区名称,不能超过 64 个字符 + * @return name + **/ + @javax.annotation.Nullable + public String getName() { + return name; + } + + + public void setName(String name) { + this.name = name; + } + + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + EMModifyThread modifyThread = (EMModifyThread) o; + return Objects.equals(this.name, modifyThread.name); + } + + @Override + public int hashCode() { + return Objects.hash(name); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class EMModifyThread {\n"); + sb.append(" name: ").append(toIndentedString(name)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("name"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to EMModifyThread + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!EMModifyThread.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format("The required field(s) %s in EMModifyThread is not found in the empty JSON string", EMModifyThread.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!EMModifyThread.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `EMModifyThread` properties. JSON: %s", entry.getKey(), jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + if ((jsonObj.get("name") != null && !jsonObj.get("name").isJsonNull()) && !jsonObj.get("name").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("name").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!EMModifyThread.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'EMModifyThread' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(EMModifyThread.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, EMModifyThread value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public EMModifyThread read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + return thisAdapter.fromJsonTree(jsonElement); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of EMModifyThread given an JSON string + * + * @param jsonString JSON string + * @return An instance of EMModifyThread + * @throws IOException if the JSON string is invalid with respect to EMModifyThread + */ + public static EMModifyThread fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, EMModifyThread.class); + } + + /** + * Convert an instance of EMModifyThread to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/com/easemob/im/api/model/EMModifyThreadResource.java b/src/main/java/com/easemob/im/api/model/EMModifyThreadResource.java new file mode 100644 index 000000000..9fb9810a6 --- /dev/null +++ b/src/main/java/com/easemob/im/api/model/EMModifyThreadResource.java @@ -0,0 +1,208 @@ +/* + * EMService + * Easemob Rest API + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.easemob.im.api.model; + +import java.util.Objects; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.Arrays; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import com.easemob.im.JSON; + +/** + * EMModifyThreadResource + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-01-25T14:51:53.998371+08:00[Asia/Shanghai]") +public class EMModifyThreadResource { + public static final String SERIALIZED_NAME_NAME = "name"; + @SerializedName(SERIALIZED_NAME_NAME) + private String name; + + public EMModifyThreadResource() { + } + + public EMModifyThreadResource name(String name) { + + this.name = name; + return this; + } + + /** + * Get name + * @return name + **/ + @javax.annotation.Nullable + public String getName() { + return name; + } + + + public void setName(String name) { + this.name = name; + } + + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + EMModifyThreadResource modifyThreadResource = (EMModifyThreadResource) o; + return Objects.equals(this.name, modifyThreadResource.name); + } + + @Override + public int hashCode() { + return Objects.hash(name); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class EMModifyThreadResource {\n"); + sb.append(" name: ").append(toIndentedString(name)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("name"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to EMModifyThreadResource + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!EMModifyThreadResource.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format("The required field(s) %s in EMModifyThreadResource is not found in the empty JSON string", EMModifyThreadResource.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!EMModifyThreadResource.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `EMModifyThreadResource` properties. JSON: %s", entry.getKey(), jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + if ((jsonObj.get("name") != null && !jsonObj.get("name").isJsonNull()) && !jsonObj.get("name").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("name").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!EMModifyThreadResource.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'EMModifyThreadResource' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(EMModifyThreadResource.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, EMModifyThreadResource value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public EMModifyThreadResource read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + return thisAdapter.fromJsonTree(jsonElement); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of EMModifyThreadResource given an JSON string + * + * @param jsonString JSON string + * @return An instance of EMModifyThreadResource + * @throws IOException if the JSON string is invalid with respect to EMModifyThreadResource + */ + public static EMModifyThreadResource fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, EMModifyThreadResource.class); + } + + /** + * Convert an instance of EMModifyThreadResource to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/com/easemob/im/api/model/EMModifyThreadResult.java b/src/main/java/com/easemob/im/api/model/EMModifyThreadResult.java new file mode 100644 index 000000000..edd16c2d3 --- /dev/null +++ b/src/main/java/com/easemob/im/api/model/EMModifyThreadResult.java @@ -0,0 +1,210 @@ +/* + * EMService + * Easemob Rest API + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.easemob.im.api.model; + +import java.util.Objects; +import com.easemob.im.api.model.EMModifyThreadResource; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.Arrays; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import com.easemob.im.JSON; + +/** + * EMModifyThreadResult + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-01-25T14:51:53.998371+08:00[Asia/Shanghai]") +public class EMModifyThreadResult { + public static final String SERIALIZED_NAME_DATA = "data"; + @SerializedName(SERIALIZED_NAME_DATA) + private EMModifyThreadResource data; + + public EMModifyThreadResult() { + } + + public EMModifyThreadResult data(EMModifyThreadResource data) { + + this.data = data; + return this; + } + + /** + * Get data + * @return data + **/ + @javax.annotation.Nullable + public EMModifyThreadResource getData() { + return data; + } + + + public void setData(EMModifyThreadResource data) { + this.data = data; + } + + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + EMModifyThreadResult modifyThreadResult = (EMModifyThreadResult) o; + return Objects.equals(this.data, modifyThreadResult.data); + } + + @Override + public int hashCode() { + return Objects.hash(data); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class EMModifyThreadResult {\n"); + sb.append(" data: ").append(toIndentedString(data)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("data"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to EMModifyThreadResult + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!EMModifyThreadResult.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format("The required field(s) %s in EMModifyThreadResult is not found in the empty JSON string", EMModifyThreadResult.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!EMModifyThreadResult.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `EMModifyThreadResult` properties. JSON: %s", entry.getKey(), jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // validate the optional field `data` + if (jsonObj.get("data") != null && !jsonObj.get("data").isJsonNull()) { + EMModifyThreadResource.validateJsonElement(jsonObj.get("data")); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!EMModifyThreadResult.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'EMModifyThreadResult' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(EMModifyThreadResult.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, EMModifyThreadResult value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public EMModifyThreadResult read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + return thisAdapter.fromJsonTree(jsonElement); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of EMModifyThreadResult given an JSON string + * + * @param jsonString JSON string + * @return An instance of EMModifyThreadResult + * @throws IOException if the JSON string is invalid with respect to EMModifyThreadResult + */ + public static EMModifyThreadResult fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, EMModifyThreadResult.class); + } + + /** + * Convert an instance of EMModifyThreadResult to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/com/easemob/im/api/model/EMModifyUserPassword.java b/src/main/java/com/easemob/im/api/model/EMModifyUserPassword.java new file mode 100644 index 000000000..45542af2a --- /dev/null +++ b/src/main/java/com/easemob/im/api/model/EMModifyUserPassword.java @@ -0,0 +1,208 @@ +/* + * EMService + * Easemob Rest API + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.easemob.im.api.model; + +import java.util.Objects; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.Arrays; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import com.easemob.im.JSON; + +/** + * EMModifyUserPassword + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-01-25T14:51:53.998371+08:00[Asia/Shanghai]") +public class EMModifyUserPassword { + public static final String SERIALIZED_NAME_NEWPASSWORD = "newpassword"; + @SerializedName(SERIALIZED_NAME_NEWPASSWORD) + private String newpassword; + + public EMModifyUserPassword() { + } + + public EMModifyUserPassword newpassword(String newpassword) { + + this.newpassword = newpassword; + return this; + } + + /** + * 用户的新登录密码,长度不可超过 64 个字符 + * @return newpassword + **/ + @javax.annotation.Nullable + public String getNewpassword() { + return newpassword; + } + + + public void setNewpassword(String newpassword) { + this.newpassword = newpassword; + } + + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + EMModifyUserPassword modifyUserPassword = (EMModifyUserPassword) o; + return Objects.equals(this.newpassword, modifyUserPassword.newpassword); + } + + @Override + public int hashCode() { + return Objects.hash(newpassword); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class EMModifyUserPassword {\n"); + sb.append(" newpassword: ").append(toIndentedString(newpassword)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("newpassword"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to EMModifyUserPassword + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!EMModifyUserPassword.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format("The required field(s) %s in EMModifyUserPassword is not found in the empty JSON string", EMModifyUserPassword.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!EMModifyUserPassword.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `EMModifyUserPassword` properties. JSON: %s", entry.getKey(), jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + if ((jsonObj.get("newpassword") != null && !jsonObj.get("newpassword").isJsonNull()) && !jsonObj.get("newpassword").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `newpassword` to be a primitive type in the JSON string but got `%s`", jsonObj.get("newpassword").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!EMModifyUserPassword.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'EMModifyUserPassword' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(EMModifyUserPassword.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, EMModifyUserPassword value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public EMModifyUserPassword read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + return thisAdapter.fromJsonTree(jsonElement); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of EMModifyUserPassword given an JSON string + * + * @param jsonString JSON string + * @return An instance of EMModifyUserPassword + * @throws IOException if the JSON string is invalid with respect to EMModifyUserPassword + */ + public static EMModifyUserPassword fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, EMModifyUserPassword.class); + } + + /** + * Convert an instance of EMModifyUserPassword to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/com/easemob/im/api/model/EMMuteAllGroupMembersResource.java b/src/main/java/com/easemob/im/api/model/EMMuteAllGroupMembersResource.java new file mode 100644 index 000000000..971e6d184 --- /dev/null +++ b/src/main/java/com/easemob/im/api/model/EMMuteAllGroupMembersResource.java @@ -0,0 +1,205 @@ +/* + * EMService + * Easemob Rest API + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.easemob.im.api.model; + +import java.util.Objects; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.Arrays; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import com.easemob.im.JSON; + +/** + * EMMuteAllGroupMembersResource + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-01-25T14:51:53.998371+08:00[Asia/Shanghai]") +public class EMMuteAllGroupMembersResource { + public static final String SERIALIZED_NAME_MUTE = "mute"; + @SerializedName(SERIALIZED_NAME_MUTE) + private Boolean mute; + + public EMMuteAllGroupMembersResource() { + } + + public EMMuteAllGroupMembersResource mute(Boolean mute) { + + this.mute = mute; + return this; + } + + /** + * Get mute + * @return mute + **/ + @javax.annotation.Nullable + public Boolean getMute() { + return mute; + } + + + public void setMute(Boolean mute) { + this.mute = mute; + } + + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + EMMuteAllGroupMembersResource muteAllGroupMembersResource = (EMMuteAllGroupMembersResource) o; + return Objects.equals(this.mute, muteAllGroupMembersResource.mute); + } + + @Override + public int hashCode() { + return Objects.hash(mute); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class EMMuteAllGroupMembersResource {\n"); + sb.append(" mute: ").append(toIndentedString(mute)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("mute"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to EMMuteAllGroupMembersResource + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!EMMuteAllGroupMembersResource.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format("The required field(s) %s in EMMuteAllGroupMembersResource is not found in the empty JSON string", EMMuteAllGroupMembersResource.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!EMMuteAllGroupMembersResource.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `EMMuteAllGroupMembersResource` properties. JSON: %s", entry.getKey(), jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!EMMuteAllGroupMembersResource.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'EMMuteAllGroupMembersResource' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(EMMuteAllGroupMembersResource.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, EMMuteAllGroupMembersResource value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public EMMuteAllGroupMembersResource read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + return thisAdapter.fromJsonTree(jsonElement); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of EMMuteAllGroupMembersResource given an JSON string + * + * @param jsonString JSON string + * @return An instance of EMMuteAllGroupMembersResource + * @throws IOException if the JSON string is invalid with respect to EMMuteAllGroupMembersResource + */ + public static EMMuteAllGroupMembersResource fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, EMMuteAllGroupMembersResource.class); + } + + /** + * Convert an instance of EMMuteAllGroupMembersResource to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/com/easemob/im/api/model/EMMuteAllGroupMembersResult.java b/src/main/java/com/easemob/im/api/model/EMMuteAllGroupMembersResult.java new file mode 100644 index 000000000..6e6cff15e --- /dev/null +++ b/src/main/java/com/easemob/im/api/model/EMMuteAllGroupMembersResult.java @@ -0,0 +1,210 @@ +/* + * EMService + * Easemob Rest API + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.easemob.im.api.model; + +import java.util.Objects; +import com.easemob.im.api.model.EMMuteAllGroupMembersResource; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.Arrays; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import com.easemob.im.JSON; + +/** + * EMMuteAllGroupMembersResult + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-01-25T14:51:53.998371+08:00[Asia/Shanghai]") +public class EMMuteAllGroupMembersResult { + public static final String SERIALIZED_NAME_DATA = "data"; + @SerializedName(SERIALIZED_NAME_DATA) + private EMMuteAllGroupMembersResource data; + + public EMMuteAllGroupMembersResult() { + } + + public EMMuteAllGroupMembersResult data(EMMuteAllGroupMembersResource data) { + + this.data = data; + return this; + } + + /** + * Get data + * @return data + **/ + @javax.annotation.Nullable + public EMMuteAllGroupMembersResource getData() { + return data; + } + + + public void setData(EMMuteAllGroupMembersResource data) { + this.data = data; + } + + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + EMMuteAllGroupMembersResult muteAllGroupMembersResult = (EMMuteAllGroupMembersResult) o; + return Objects.equals(this.data, muteAllGroupMembersResult.data); + } + + @Override + public int hashCode() { + return Objects.hash(data); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class EMMuteAllGroupMembersResult {\n"); + sb.append(" data: ").append(toIndentedString(data)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("data"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to EMMuteAllGroupMembersResult + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!EMMuteAllGroupMembersResult.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format("The required field(s) %s in EMMuteAllGroupMembersResult is not found in the empty JSON string", EMMuteAllGroupMembersResult.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!EMMuteAllGroupMembersResult.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `EMMuteAllGroupMembersResult` properties. JSON: %s", entry.getKey(), jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // validate the optional field `data` + if (jsonObj.get("data") != null && !jsonObj.get("data").isJsonNull()) { + EMMuteAllGroupMembersResource.validateJsonElement(jsonObj.get("data")); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!EMMuteAllGroupMembersResult.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'EMMuteAllGroupMembersResult' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(EMMuteAllGroupMembersResult.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, EMMuteAllGroupMembersResult value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public EMMuteAllGroupMembersResult read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + return thisAdapter.fromJsonTree(jsonElement); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of EMMuteAllGroupMembersResult given an JSON string + * + * @param jsonString JSON string + * @return An instance of EMMuteAllGroupMembersResult + * @throws IOException if the JSON string is invalid with respect to EMMuteAllGroupMembersResult + */ + public static EMMuteAllGroupMembersResult fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, EMMuteAllGroupMembersResult.class); + } + + /** + * Convert an instance of EMMuteAllGroupMembersResult to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/com/easemob/im/api/model/EMMuteAllRoomMemberResource.java b/src/main/java/com/easemob/im/api/model/EMMuteAllRoomMemberResource.java new file mode 100644 index 000000000..40402daa1 --- /dev/null +++ b/src/main/java/com/easemob/im/api/model/EMMuteAllRoomMemberResource.java @@ -0,0 +1,205 @@ +/* + * EMService + * Easemob Rest API + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.easemob.im.api.model; + +import java.util.Objects; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.Arrays; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import com.easemob.im.JSON; + +/** + * EMMuteAllRoomMemberResource + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-01-25T14:51:53.998371+08:00[Asia/Shanghai]") +public class EMMuteAllRoomMemberResource { + public static final String SERIALIZED_NAME_MUTE = "mute"; + @SerializedName(SERIALIZED_NAME_MUTE) + private Boolean mute; + + public EMMuteAllRoomMemberResource() { + } + + public EMMuteAllRoomMemberResource mute(Boolean mute) { + + this.mute = mute; + return this; + } + + /** + * Get mute + * @return mute + **/ + @javax.annotation.Nullable + public Boolean getMute() { + return mute; + } + + + public void setMute(Boolean mute) { + this.mute = mute; + } + + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + EMMuteAllRoomMemberResource muteAllRoomMemberResource = (EMMuteAllRoomMemberResource) o; + return Objects.equals(this.mute, muteAllRoomMemberResource.mute); + } + + @Override + public int hashCode() { + return Objects.hash(mute); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class EMMuteAllRoomMemberResource {\n"); + sb.append(" mute: ").append(toIndentedString(mute)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("mute"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to EMMuteAllRoomMemberResource + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!EMMuteAllRoomMemberResource.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format("The required field(s) %s in EMMuteAllRoomMemberResource is not found in the empty JSON string", EMMuteAllRoomMemberResource.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!EMMuteAllRoomMemberResource.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `EMMuteAllRoomMemberResource` properties. JSON: %s", entry.getKey(), jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!EMMuteAllRoomMemberResource.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'EMMuteAllRoomMemberResource' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(EMMuteAllRoomMemberResource.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, EMMuteAllRoomMemberResource value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public EMMuteAllRoomMemberResource read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + return thisAdapter.fromJsonTree(jsonElement); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of EMMuteAllRoomMemberResource given an JSON string + * + * @param jsonString JSON string + * @return An instance of EMMuteAllRoomMemberResource + * @throws IOException if the JSON string is invalid with respect to EMMuteAllRoomMemberResource + */ + public static EMMuteAllRoomMemberResource fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, EMMuteAllRoomMemberResource.class); + } + + /** + * Convert an instance of EMMuteAllRoomMemberResource to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/com/easemob/im/api/model/EMMuteAllRoomMemberResult.java b/src/main/java/com/easemob/im/api/model/EMMuteAllRoomMemberResult.java new file mode 100644 index 000000000..d41b98ceb --- /dev/null +++ b/src/main/java/com/easemob/im/api/model/EMMuteAllRoomMemberResult.java @@ -0,0 +1,210 @@ +/* + * EMService + * Easemob Rest API + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.easemob.im.api.model; + +import java.util.Objects; +import com.easemob.im.api.model.EMMuteAllRoomMemberResource; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.Arrays; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import com.easemob.im.JSON; + +/** + * EMMuteAllRoomMemberResult + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-01-25T14:51:53.998371+08:00[Asia/Shanghai]") +public class EMMuteAllRoomMemberResult { + public static final String SERIALIZED_NAME_DATA = "data"; + @SerializedName(SERIALIZED_NAME_DATA) + private EMMuteAllRoomMemberResource data; + + public EMMuteAllRoomMemberResult() { + } + + public EMMuteAllRoomMemberResult data(EMMuteAllRoomMemberResource data) { + + this.data = data; + return this; + } + + /** + * Get data + * @return data + **/ + @javax.annotation.Nullable + public EMMuteAllRoomMemberResource getData() { + return data; + } + + + public void setData(EMMuteAllRoomMemberResource data) { + this.data = data; + } + + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + EMMuteAllRoomMemberResult muteAllRoomMemberResult = (EMMuteAllRoomMemberResult) o; + return Objects.equals(this.data, muteAllRoomMemberResult.data); + } + + @Override + public int hashCode() { + return Objects.hash(data); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class EMMuteAllRoomMemberResult {\n"); + sb.append(" data: ").append(toIndentedString(data)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("data"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to EMMuteAllRoomMemberResult + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!EMMuteAllRoomMemberResult.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format("The required field(s) %s in EMMuteAllRoomMemberResult is not found in the empty JSON string", EMMuteAllRoomMemberResult.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!EMMuteAllRoomMemberResult.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `EMMuteAllRoomMemberResult` properties. JSON: %s", entry.getKey(), jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // validate the optional field `data` + if (jsonObj.get("data") != null && !jsonObj.get("data").isJsonNull()) { + EMMuteAllRoomMemberResource.validateJsonElement(jsonObj.get("data")); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!EMMuteAllRoomMemberResult.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'EMMuteAllRoomMemberResult' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(EMMuteAllRoomMemberResult.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, EMMuteAllRoomMemberResult value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public EMMuteAllRoomMemberResult read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + return thisAdapter.fromJsonTree(jsonElement); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of EMMuteAllRoomMemberResult given an JSON string + * + * @param jsonString JSON string + * @return An instance of EMMuteAllRoomMemberResult + * @throws IOException if the JSON string is invalid with respect to EMMuteAllRoomMemberResult + */ + public static EMMuteAllRoomMemberResult fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, EMMuteAllRoomMemberResult.class); + } + + /** + * Convert an instance of EMMuteAllRoomMemberResult to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/com/easemob/im/api/model/EMMuteGroupMember.java b/src/main/java/com/easemob/im/api/model/EMMuteGroupMember.java new file mode 100644 index 000000000..6f6b1c81a --- /dev/null +++ b/src/main/java/com/easemob/im/api/model/EMMuteGroupMember.java @@ -0,0 +1,248 @@ +/* + * EMService + * Easemob Rest API + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.easemob.im.api.model; + +import java.util.Objects; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.math.BigDecimal; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import com.easemob.im.JSON; + +/** + * EMMuteGroupMember + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-01-25T14:51:53.998371+08:00[Asia/Shanghai]") +public class EMMuteGroupMember { + public static final String SERIALIZED_NAME_USERNAMES = "usernames"; + @SerializedName(SERIALIZED_NAME_USERNAMES) + private List usernames; + + public static final String SERIALIZED_NAME_MUTE_DURATION = "mute_duration"; + @SerializedName(SERIALIZED_NAME_MUTE_DURATION) + private BigDecimal muteDuration; + + public EMMuteGroupMember() { + } + + public EMMuteGroupMember usernames(List usernames) { + + this.usernames = usernames; + return this; + } + + public EMMuteGroupMember addUsernamesItem(String usernamesItem) { + if (this.usernames == null) { + this.usernames = new ArrayList<>(); + } + this.usernames.add(usernamesItem); + return this; + } + + /** + * 要添加到禁言列表的用户 ID 列表,每次最多可添加 60 个 + * @return usernames + **/ + @javax.annotation.Nullable + public List getUsernames() { + return usernames; + } + + + public void setUsernames(List usernames) { + this.usernames = usernames; + } + + + public EMMuteGroupMember muteDuration(BigDecimal muteDuration) { + + this.muteDuration = muteDuration; + return this; + } + + /** + * 禁言时长,单位为毫秒 + * @return muteDuration + **/ + @javax.annotation.Nullable + public BigDecimal getMuteDuration() { + return muteDuration; + } + + + public void setMuteDuration(BigDecimal muteDuration) { + this.muteDuration = muteDuration; + } + + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + EMMuteGroupMember muteGroupMember = (EMMuteGroupMember) o; + return Objects.equals(this.usernames, muteGroupMember.usernames) && + Objects.equals(this.muteDuration, muteGroupMember.muteDuration); + } + + @Override + public int hashCode() { + return Objects.hash(usernames, muteDuration); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class EMMuteGroupMember {\n"); + sb.append(" usernames: ").append(toIndentedString(usernames)).append("\n"); + sb.append(" muteDuration: ").append(toIndentedString(muteDuration)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("usernames"); + openapiFields.add("mute_duration"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to EMMuteGroupMember + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!EMMuteGroupMember.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format("The required field(s) %s in EMMuteGroupMember is not found in the empty JSON string", EMMuteGroupMember.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!EMMuteGroupMember.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `EMMuteGroupMember` properties. JSON: %s", entry.getKey(), jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // ensure the optional json data is an array if present + if (jsonObj.get("usernames") != null && !jsonObj.get("usernames").isJsonNull() && !jsonObj.get("usernames").isJsonArray()) { + throw new IllegalArgumentException(String.format("Expected the field `usernames` to be an array in the JSON string but got `%s`", jsonObj.get("usernames").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!EMMuteGroupMember.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'EMMuteGroupMember' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(EMMuteGroupMember.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, EMMuteGroupMember value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public EMMuteGroupMember read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + return thisAdapter.fromJsonTree(jsonElement); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of EMMuteGroupMember given an JSON string + * + * @param jsonString JSON string + * @return An instance of EMMuteGroupMember + * @throws IOException if the JSON string is invalid with respect to EMMuteGroupMember + */ + public static EMMuteGroupMember fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, EMMuteGroupMember.class); + } + + /** + * Convert an instance of EMMuteGroupMember to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/com/easemob/im/api/model/EMMuteGroupMemberResource.java b/src/main/java/com/easemob/im/api/model/EMMuteGroupMemberResource.java new file mode 100644 index 000000000..38d8d06c4 --- /dev/null +++ b/src/main/java/com/easemob/im/api/model/EMMuteGroupMemberResource.java @@ -0,0 +1,265 @@ +/* + * EMService + * Easemob Rest API + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.easemob.im.api.model; + +import java.util.Objects; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.math.BigDecimal; +import java.util.Arrays; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import com.easemob.im.JSON; + +/** + * EMMuteGroupMemberResource + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-01-25T14:51:53.998371+08:00[Asia/Shanghai]") +public class EMMuteGroupMemberResource { + public static final String SERIALIZED_NAME_RESULT = "result"; + @SerializedName(SERIALIZED_NAME_RESULT) + private Boolean result; + + public static final String SERIALIZED_NAME_EXPIRE = "expire"; + @SerializedName(SERIALIZED_NAME_EXPIRE) + private BigDecimal expire; + + public static final String SERIALIZED_NAME_USER = "user"; + @SerializedName(SERIALIZED_NAME_USER) + private String user; + + public EMMuteGroupMemberResource() { + } + + public EMMuteGroupMemberResource result(Boolean result) { + + this.result = result; + return this; + } + + /** + * 操作结果: - true:添加成功; - false:添加失败 + * @return result + **/ + @javax.annotation.Nullable + public Boolean getResult() { + return result; + } + + + public void setResult(Boolean result) { + this.result = result; + } + + + public EMMuteGroupMemberResource expire(BigDecimal expire) { + + this.expire = expire; + return this; + } + + /** + * 禁言到期的时间,单位为毫秒 + * @return expire + **/ + @javax.annotation.Nullable + public BigDecimal getExpire() { + return expire; + } + + + public void setExpire(BigDecimal expire) { + this.expire = expire; + } + + + public EMMuteGroupMemberResource user(String user) { + + this.user = user; + return this; + } + + /** + * 被禁言用户的 ID + * @return user + **/ + @javax.annotation.Nullable + public String getUser() { + return user; + } + + + public void setUser(String user) { + this.user = user; + } + + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + EMMuteGroupMemberResource muteGroupMemberResource = (EMMuteGroupMemberResource) o; + return Objects.equals(this.result, muteGroupMemberResource.result) && + Objects.equals(this.expire, muteGroupMemberResource.expire) && + Objects.equals(this.user, muteGroupMemberResource.user); + } + + @Override + public int hashCode() { + return Objects.hash(result, expire, user); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class EMMuteGroupMemberResource {\n"); + sb.append(" result: ").append(toIndentedString(result)).append("\n"); + sb.append(" expire: ").append(toIndentedString(expire)).append("\n"); + sb.append(" user: ").append(toIndentedString(user)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("result"); + openapiFields.add("expire"); + openapiFields.add("user"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to EMMuteGroupMemberResource + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!EMMuteGroupMemberResource.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format("The required field(s) %s in EMMuteGroupMemberResource is not found in the empty JSON string", EMMuteGroupMemberResource.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!EMMuteGroupMemberResource.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `EMMuteGroupMemberResource` properties. JSON: %s", entry.getKey(), jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + if ((jsonObj.get("user") != null && !jsonObj.get("user").isJsonNull()) && !jsonObj.get("user").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `user` to be a primitive type in the JSON string but got `%s`", jsonObj.get("user").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!EMMuteGroupMemberResource.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'EMMuteGroupMemberResource' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(EMMuteGroupMemberResource.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, EMMuteGroupMemberResource value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public EMMuteGroupMemberResource read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + return thisAdapter.fromJsonTree(jsonElement); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of EMMuteGroupMemberResource given an JSON string + * + * @param jsonString JSON string + * @return An instance of EMMuteGroupMemberResource + * @throws IOException if the JSON string is invalid with respect to EMMuteGroupMemberResource + */ + public static EMMuteGroupMemberResource fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, EMMuteGroupMemberResource.class); + } + + /** + * Convert an instance of EMMuteGroupMemberResource to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/com/easemob/im/api/model/EMMuteGroupMemberResult.java b/src/main/java/com/easemob/im/api/model/EMMuteGroupMemberResult.java new file mode 100644 index 000000000..60378cdf0 --- /dev/null +++ b/src/main/java/com/easemob/im/api/model/EMMuteGroupMemberResult.java @@ -0,0 +1,230 @@ +/* + * EMService + * Easemob Rest API + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.easemob.im.api.model; + +import java.util.Objects; +import com.easemob.im.api.model.EMMuteGroupMemberResource; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import com.easemob.im.JSON; + +/** + * EMMuteGroupMemberResult + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-01-25T14:51:53.998371+08:00[Asia/Shanghai]") +public class EMMuteGroupMemberResult { + public static final String SERIALIZED_NAME_DATA = "data"; + @SerializedName(SERIALIZED_NAME_DATA) + private List data; + + public EMMuteGroupMemberResult() { + } + + public EMMuteGroupMemberResult data(List data) { + + this.data = data; + return this; + } + + public EMMuteGroupMemberResult addDataItem(EMMuteGroupMemberResource dataItem) { + if (this.data == null) { + this.data = new ArrayList<>(); + } + this.data.add(dataItem); + return this; + } + + /** + * Get data + * @return data + **/ + @javax.annotation.Nullable + public List getData() { + return data; + } + + + public void setData(List data) { + this.data = data; + } + + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + EMMuteGroupMemberResult muteGroupMemberResult = (EMMuteGroupMemberResult) o; + return Objects.equals(this.data, muteGroupMemberResult.data); + } + + @Override + public int hashCode() { + return Objects.hash(data); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class EMMuteGroupMemberResult {\n"); + sb.append(" data: ").append(toIndentedString(data)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("data"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to EMMuteGroupMemberResult + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!EMMuteGroupMemberResult.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format("The required field(s) %s in EMMuteGroupMemberResult is not found in the empty JSON string", EMMuteGroupMemberResult.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!EMMuteGroupMemberResult.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `EMMuteGroupMemberResult` properties. JSON: %s", entry.getKey(), jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + if (jsonObj.get("data") != null && !jsonObj.get("data").isJsonNull()) { + JsonArray jsonArraydata = jsonObj.getAsJsonArray("data"); + if (jsonArraydata != null) { + // ensure the json data is an array + if (!jsonObj.get("data").isJsonArray()) { + throw new IllegalArgumentException(String.format("Expected the field `data` to be an array in the JSON string but got `%s`", jsonObj.get("data").toString())); + } + + // validate the optional field `data` (array) + for (int i = 0; i < jsonArraydata.size(); i++) { + EMMuteGroupMemberResource.validateJsonElement(jsonArraydata.get(i)); + }; + } + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!EMMuteGroupMemberResult.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'EMMuteGroupMemberResult' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(EMMuteGroupMemberResult.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, EMMuteGroupMemberResult value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public EMMuteGroupMemberResult read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + return thisAdapter.fromJsonTree(jsonElement); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of EMMuteGroupMemberResult given an JSON string + * + * @param jsonString JSON string + * @return An instance of EMMuteGroupMemberResult + * @throws IOException if the JSON string is invalid with respect to EMMuteGroupMemberResult + */ + public static EMMuteGroupMemberResult fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, EMMuteGroupMemberResult.class); + } + + /** + * Convert an instance of EMMuteGroupMemberResult to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/com/easemob/im/api/model/EMMuteRoomMember.java b/src/main/java/com/easemob/im/api/model/EMMuteRoomMember.java new file mode 100644 index 000000000..ef10f8237 --- /dev/null +++ b/src/main/java/com/easemob/im/api/model/EMMuteRoomMember.java @@ -0,0 +1,248 @@ +/* + * EMService + * Easemob Rest API + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.easemob.im.api.model; + +import java.util.Objects; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.math.BigDecimal; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import com.easemob.im.JSON; + +/** + * EMMuteRoomMember + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-01-25T14:51:53.998371+08:00[Asia/Shanghai]") +public class EMMuteRoomMember { + public static final String SERIALIZED_NAME_MUTE_DURATION = "mute_duration"; + @SerializedName(SERIALIZED_NAME_MUTE_DURATION) + private BigDecimal muteDuration; + + public static final String SERIALIZED_NAME_USERNAMES = "usernames"; + @SerializedName(SERIALIZED_NAME_USERNAMES) + private List usernames; + + public EMMuteRoomMember() { + } + + public EMMuteRoomMember muteDuration(BigDecimal muteDuration) { + + this.muteDuration = muteDuration; + return this; + } + + /** + * 禁言时长,从当前时间开始计算。单位为毫秒。-1 表示永久禁言 + * @return muteDuration + **/ + @javax.annotation.Nullable + public BigDecimal getMuteDuration() { + return muteDuration; + } + + + public void setMuteDuration(BigDecimal muteDuration) { + this.muteDuration = muteDuration; + } + + + public EMMuteRoomMember usernames(List usernames) { + + this.usernames = usernames; + return this; + } + + public EMMuteRoomMember addUsernamesItem(String usernamesItem) { + if (this.usernames == null) { + this.usernames = new ArrayList<>(); + } + this.usernames.add(usernamesItem); + return this; + } + + /** + * 要被禁言的用户 ID,一次最多可传 60 个 + * @return usernames + **/ + @javax.annotation.Nullable + public List getUsernames() { + return usernames; + } + + + public void setUsernames(List usernames) { + this.usernames = usernames; + } + + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + EMMuteRoomMember muteRoomMember = (EMMuteRoomMember) o; + return Objects.equals(this.muteDuration, muteRoomMember.muteDuration) && + Objects.equals(this.usernames, muteRoomMember.usernames); + } + + @Override + public int hashCode() { + return Objects.hash(muteDuration, usernames); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class EMMuteRoomMember {\n"); + sb.append(" muteDuration: ").append(toIndentedString(muteDuration)).append("\n"); + sb.append(" usernames: ").append(toIndentedString(usernames)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("mute_duration"); + openapiFields.add("usernames"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to EMMuteRoomMember + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!EMMuteRoomMember.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format("The required field(s) %s in EMMuteRoomMember is not found in the empty JSON string", EMMuteRoomMember.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!EMMuteRoomMember.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `EMMuteRoomMember` properties. JSON: %s", entry.getKey(), jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // ensure the optional json data is an array if present + if (jsonObj.get("usernames") != null && !jsonObj.get("usernames").isJsonNull() && !jsonObj.get("usernames").isJsonArray()) { + throw new IllegalArgumentException(String.format("Expected the field `usernames` to be an array in the JSON string but got `%s`", jsonObj.get("usernames").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!EMMuteRoomMember.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'EMMuteRoomMember' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(EMMuteRoomMember.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, EMMuteRoomMember value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public EMMuteRoomMember read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + return thisAdapter.fromJsonTree(jsonElement); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of EMMuteRoomMember given an JSON string + * + * @param jsonString JSON string + * @return An instance of EMMuteRoomMember + * @throws IOException if the JSON string is invalid with respect to EMMuteRoomMember + */ + public static EMMuteRoomMember fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, EMMuteRoomMember.class); + } + + /** + * Convert an instance of EMMuteRoomMember to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/com/easemob/im/api/model/EMMuteRoomMemberResource.java b/src/main/java/com/easemob/im/api/model/EMMuteRoomMemberResource.java new file mode 100644 index 000000000..fba7ae016 --- /dev/null +++ b/src/main/java/com/easemob/im/api/model/EMMuteRoomMemberResource.java @@ -0,0 +1,265 @@ +/* + * EMService + * Easemob Rest API + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.easemob.im.api.model; + +import java.util.Objects; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.math.BigDecimal; +import java.util.Arrays; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import com.easemob.im.JSON; + +/** + * EMMuteRoomMemberResource + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-01-25T14:51:53.998371+08:00[Asia/Shanghai]") +public class EMMuteRoomMemberResource { + public static final String SERIALIZED_NAME_RESULT = "result"; + @SerializedName(SERIALIZED_NAME_RESULT) + private Boolean result; + + public static final String SERIALIZED_NAME_EXPIRE = "expire"; + @SerializedName(SERIALIZED_NAME_EXPIRE) + private BigDecimal expire; + + public static final String SERIALIZED_NAME_USER = "user"; + @SerializedName(SERIALIZED_NAME_USER) + private String user; + + public EMMuteRoomMemberResource() { + } + + public EMMuteRoomMemberResource result(Boolean result) { + + this.result = result; + return this; + } + + /** + * 是否成功禁言用户: - true:是; - false:否 + * @return result + **/ + @javax.annotation.Nullable + public Boolean getResult() { + return result; + } + + + public void setResult(Boolean result) { + this.result = result; + } + + + public EMMuteRoomMemberResource expire(BigDecimal expire) { + + this.expire = expire; + return this; + } + + /** + * 禁言到期时间,Unix 时间戳,单位为毫秒 + * @return expire + **/ + @javax.annotation.Nullable + public BigDecimal getExpire() { + return expire; + } + + + public void setExpire(BigDecimal expire) { + this.expire = expire; + } + + + public EMMuteRoomMemberResource user(String user) { + + this.user = user; + return this; + } + + /** + * 被禁言的用户 ID + * @return user + **/ + @javax.annotation.Nullable + public String getUser() { + return user; + } + + + public void setUser(String user) { + this.user = user; + } + + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + EMMuteRoomMemberResource muteRoomMemberResource = (EMMuteRoomMemberResource) o; + return Objects.equals(this.result, muteRoomMemberResource.result) && + Objects.equals(this.expire, muteRoomMemberResource.expire) && + Objects.equals(this.user, muteRoomMemberResource.user); + } + + @Override + public int hashCode() { + return Objects.hash(result, expire, user); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class EMMuteRoomMemberResource {\n"); + sb.append(" result: ").append(toIndentedString(result)).append("\n"); + sb.append(" expire: ").append(toIndentedString(expire)).append("\n"); + sb.append(" user: ").append(toIndentedString(user)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("result"); + openapiFields.add("expire"); + openapiFields.add("user"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to EMMuteRoomMemberResource + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!EMMuteRoomMemberResource.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format("The required field(s) %s in EMMuteRoomMemberResource is not found in the empty JSON string", EMMuteRoomMemberResource.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!EMMuteRoomMemberResource.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `EMMuteRoomMemberResource` properties. JSON: %s", entry.getKey(), jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + if ((jsonObj.get("user") != null && !jsonObj.get("user").isJsonNull()) && !jsonObj.get("user").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `user` to be a primitive type in the JSON string but got `%s`", jsonObj.get("user").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!EMMuteRoomMemberResource.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'EMMuteRoomMemberResource' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(EMMuteRoomMemberResource.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, EMMuteRoomMemberResource value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public EMMuteRoomMemberResource read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + return thisAdapter.fromJsonTree(jsonElement); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of EMMuteRoomMemberResource given an JSON string + * + * @param jsonString JSON string + * @return An instance of EMMuteRoomMemberResource + * @throws IOException if the JSON string is invalid with respect to EMMuteRoomMemberResource + */ + public static EMMuteRoomMemberResource fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, EMMuteRoomMemberResource.class); + } + + /** + * Convert an instance of EMMuteRoomMemberResource to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/com/easemob/im/api/model/EMMuteRoomMemberResult.java b/src/main/java/com/easemob/im/api/model/EMMuteRoomMemberResult.java new file mode 100644 index 000000000..c67f32d14 --- /dev/null +++ b/src/main/java/com/easemob/im/api/model/EMMuteRoomMemberResult.java @@ -0,0 +1,230 @@ +/* + * EMService + * Easemob Rest API + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.easemob.im.api.model; + +import java.util.Objects; +import com.easemob.im.api.model.EMMuteRoomMemberResource; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import com.easemob.im.JSON; + +/** + * EMMuteRoomMemberResult + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-01-25T14:51:53.998371+08:00[Asia/Shanghai]") +public class EMMuteRoomMemberResult { + public static final String SERIALIZED_NAME_DATA = "data"; + @SerializedName(SERIALIZED_NAME_DATA) + private List data; + + public EMMuteRoomMemberResult() { + } + + public EMMuteRoomMemberResult data(List data) { + + this.data = data; + return this; + } + + public EMMuteRoomMemberResult addDataItem(EMMuteRoomMemberResource dataItem) { + if (this.data == null) { + this.data = new ArrayList<>(); + } + this.data.add(dataItem); + return this; + } + + /** + * Get data + * @return data + **/ + @javax.annotation.Nullable + public List getData() { + return data; + } + + + public void setData(List data) { + this.data = data; + } + + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + EMMuteRoomMemberResult muteRoomMemberResult = (EMMuteRoomMemberResult) o; + return Objects.equals(this.data, muteRoomMemberResult.data); + } + + @Override + public int hashCode() { + return Objects.hash(data); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class EMMuteRoomMemberResult {\n"); + sb.append(" data: ").append(toIndentedString(data)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("data"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to EMMuteRoomMemberResult + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!EMMuteRoomMemberResult.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format("The required field(s) %s in EMMuteRoomMemberResult is not found in the empty JSON string", EMMuteRoomMemberResult.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!EMMuteRoomMemberResult.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `EMMuteRoomMemberResult` properties. JSON: %s", entry.getKey(), jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + if (jsonObj.get("data") != null && !jsonObj.get("data").isJsonNull()) { + JsonArray jsonArraydata = jsonObj.getAsJsonArray("data"); + if (jsonArraydata != null) { + // ensure the json data is an array + if (!jsonObj.get("data").isJsonArray()) { + throw new IllegalArgumentException(String.format("Expected the field `data` to be an array in the JSON string but got `%s`", jsonObj.get("data").toString())); + } + + // validate the optional field `data` (array) + for (int i = 0; i < jsonArraydata.size(); i++) { + EMMuteRoomMemberResource.validateJsonElement(jsonArraydata.get(i)); + }; + } + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!EMMuteRoomMemberResult.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'EMMuteRoomMemberResult' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(EMMuteRoomMemberResult.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, EMMuteRoomMemberResult value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public EMMuteRoomMemberResult read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + return thisAdapter.fromJsonTree(jsonElement); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of EMMuteRoomMemberResult given an JSON string + * + * @param jsonString JSON string + * @return An instance of EMMuteRoomMemberResult + * @throws IOException if the JSON string is invalid with respect to EMMuteRoomMemberResult + */ + public static EMMuteRoomMemberResult fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, EMMuteRoomMemberResult.class); + } + + /** + * Convert an instance of EMMuteRoomMemberResult to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/com/easemob/im/api/model/EMOneWayDeleteConversation.java b/src/main/java/com/easemob/im/api/model/EMOneWayDeleteConversation.java new file mode 100644 index 000000000..069130856 --- /dev/null +++ b/src/main/java/com/easemob/im/api/model/EMOneWayDeleteConversation.java @@ -0,0 +1,277 @@ +/* + * EMService + * Easemob Rest API + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.easemob.im.api.model; + +import java.util.Objects; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.Arrays; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import com.easemob.im.JSON; + +/** + * EMOneWayDeleteConversation + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-01-25T14:51:53.998371+08:00[Asia/Shanghai]") +public class EMOneWayDeleteConversation { + public static final String SERIALIZED_NAME_CHANNEL = "channel"; + @SerializedName(SERIALIZED_NAME_CHANNEL) + private String channel; + + public static final String SERIALIZED_NAME_TYPE = "type"; + @SerializedName(SERIALIZED_NAME_TYPE) + private String type; + + public static final String SERIALIZED_NAME_DELETE_ROAM = "delete_roam"; + @SerializedName(SERIALIZED_NAME_DELETE_ROAM) + private Boolean deleteRoam; + + public EMOneWayDeleteConversation() { + } + + public EMOneWayDeleteConversation channel(String channel) { + + this.channel = channel; + return this; + } + + /** + * 要删除的会话 ID。该参数的值取决于会话类型 type 的值 - type 为 chat,即单聊时,会话 ID 为对端用户 ID; - type 为 groupchat,即群聊时,会话 ID 为群组 ID + * @return channel + **/ + @javax.annotation.Nonnull + public String getChannel() { + return channel; + } + + + public void setChannel(String channel) { + this.channel = channel; + } + + + public EMOneWayDeleteConversation type(String type) { + + this.type = type; + return this; + } + + /** + * 会话类型。 - chat:单聊会话; - groupchat:群聊会话 + * @return type + **/ + @javax.annotation.Nonnull + public String getType() { + return type; + } + + + public void setType(String type) { + this.type = type; + } + + + public EMOneWayDeleteConversation deleteRoam(Boolean deleteRoam) { + + this.deleteRoam = deleteRoam; + return this; + } + + /** + * 是否删除该会话在服务端的漫游消息。 - true:是。若删除了该会话的服务端消息,则用户无法从服务器拉取该会话的漫游消息。 - false:否。用户仍可以从服务器拉取该会话的漫游消息 + * @return deleteRoam + **/ + @javax.annotation.Nonnull + public Boolean getDeleteRoam() { + return deleteRoam; + } + + + public void setDeleteRoam(Boolean deleteRoam) { + this.deleteRoam = deleteRoam; + } + + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + EMOneWayDeleteConversation oneWayDeleteConversation = (EMOneWayDeleteConversation) o; + return Objects.equals(this.channel, oneWayDeleteConversation.channel) && + Objects.equals(this.type, oneWayDeleteConversation.type) && + Objects.equals(this.deleteRoam, oneWayDeleteConversation.deleteRoam); + } + + @Override + public int hashCode() { + return Objects.hash(channel, type, deleteRoam); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class EMOneWayDeleteConversation {\n"); + sb.append(" channel: ").append(toIndentedString(channel)).append("\n"); + sb.append(" type: ").append(toIndentedString(type)).append("\n"); + sb.append(" deleteRoam: ").append(toIndentedString(deleteRoam)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("channel"); + openapiFields.add("type"); + openapiFields.add("delete_roam"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + openapiRequiredFields.add("channel"); + openapiRequiredFields.add("type"); + openapiRequiredFields.add("delete_roam"); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to EMOneWayDeleteConversation + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!EMOneWayDeleteConversation.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format("The required field(s) %s in EMOneWayDeleteConversation is not found in the empty JSON string", EMOneWayDeleteConversation.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!EMOneWayDeleteConversation.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `EMOneWayDeleteConversation` properties. JSON: %s", entry.getKey(), jsonElement.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : EMOneWayDeleteConversation.openapiRequiredFields) { + if (jsonElement.getAsJsonObject().get(requiredField) == null) { + throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + if (!jsonObj.get("channel").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `channel` to be a primitive type in the JSON string but got `%s`", jsonObj.get("channel").toString())); + } + if (!jsonObj.get("type").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `type` to be a primitive type in the JSON string but got `%s`", jsonObj.get("type").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!EMOneWayDeleteConversation.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'EMOneWayDeleteConversation' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(EMOneWayDeleteConversation.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, EMOneWayDeleteConversation value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public EMOneWayDeleteConversation read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + return thisAdapter.fromJsonTree(jsonElement); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of EMOneWayDeleteConversation given an JSON string + * + * @param jsonString JSON string + * @return An instance of EMOneWayDeleteConversation + * @throws IOException if the JSON string is invalid with respect to EMOneWayDeleteConversation + */ + public static EMOneWayDeleteConversation fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, EMOneWayDeleteConversation.class); + } + + /** + * Convert an instance of EMOneWayDeleteConversation to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/com/easemob/im/api/model/EMOneWayDeleteConversationResource.java b/src/main/java/com/easemob/im/api/model/EMOneWayDeleteConversationResource.java new file mode 100644 index 000000000..55e19dd60 --- /dev/null +++ b/src/main/java/com/easemob/im/api/model/EMOneWayDeleteConversationResource.java @@ -0,0 +1,208 @@ +/* + * EMService + * Easemob Rest API + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.easemob.im.api.model; + +import java.util.Objects; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.Arrays; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import com.easemob.im.JSON; + +/** + * EMOneWayDeleteConversationResource + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-01-25T14:51:53.998371+08:00[Asia/Shanghai]") +public class EMOneWayDeleteConversationResource { + public static final String SERIALIZED_NAME_RESULT = "result"; + @SerializedName(SERIALIZED_NAME_RESULT) + private String result; + + public EMOneWayDeleteConversationResource() { + } + + public EMOneWayDeleteConversationResource result(String result) { + + this.result = result; + return this; + } + + /** + * Get result + * @return result + **/ + @javax.annotation.Nullable + public String getResult() { + return result; + } + + + public void setResult(String result) { + this.result = result; + } + + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + EMOneWayDeleteConversationResource oneWayDeleteConversationResource = (EMOneWayDeleteConversationResource) o; + return Objects.equals(this.result, oneWayDeleteConversationResource.result); + } + + @Override + public int hashCode() { + return Objects.hash(result); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class EMOneWayDeleteConversationResource {\n"); + sb.append(" result: ").append(toIndentedString(result)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("result"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to EMOneWayDeleteConversationResource + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!EMOneWayDeleteConversationResource.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format("The required field(s) %s in EMOneWayDeleteConversationResource is not found in the empty JSON string", EMOneWayDeleteConversationResource.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!EMOneWayDeleteConversationResource.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `EMOneWayDeleteConversationResource` properties. JSON: %s", entry.getKey(), jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + if ((jsonObj.get("result") != null && !jsonObj.get("result").isJsonNull()) && !jsonObj.get("result").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `result` to be a primitive type in the JSON string but got `%s`", jsonObj.get("result").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!EMOneWayDeleteConversationResource.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'EMOneWayDeleteConversationResource' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(EMOneWayDeleteConversationResource.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, EMOneWayDeleteConversationResource value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public EMOneWayDeleteConversationResource read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + return thisAdapter.fromJsonTree(jsonElement); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of EMOneWayDeleteConversationResource given an JSON string + * + * @param jsonString JSON string + * @return An instance of EMOneWayDeleteConversationResource + * @throws IOException if the JSON string is invalid with respect to EMOneWayDeleteConversationResource + */ + public static EMOneWayDeleteConversationResource fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, EMOneWayDeleteConversationResource.class); + } + + /** + * Convert an instance of EMOneWayDeleteConversationResource to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/com/easemob/im/api/model/EMOneWayDeleteConversationResult.java b/src/main/java/com/easemob/im/api/model/EMOneWayDeleteConversationResult.java new file mode 100644 index 000000000..89c2d6725 --- /dev/null +++ b/src/main/java/com/easemob/im/api/model/EMOneWayDeleteConversationResult.java @@ -0,0 +1,210 @@ +/* + * EMService + * Easemob Rest API + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.easemob.im.api.model; + +import java.util.Objects; +import com.easemob.im.api.model.EMOneWayDeleteConversationResource; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.Arrays; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import com.easemob.im.JSON; + +/** + * EMOneWayDeleteConversationResult + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-01-25T14:51:53.998371+08:00[Asia/Shanghai]") +public class EMOneWayDeleteConversationResult { + public static final String SERIALIZED_NAME_DATA = "data"; + @SerializedName(SERIALIZED_NAME_DATA) + private EMOneWayDeleteConversationResource data; + + public EMOneWayDeleteConversationResult() { + } + + public EMOneWayDeleteConversationResult data(EMOneWayDeleteConversationResource data) { + + this.data = data; + return this; + } + + /** + * Get data + * @return data + **/ + @javax.annotation.Nullable + public EMOneWayDeleteConversationResource getData() { + return data; + } + + + public void setData(EMOneWayDeleteConversationResource data) { + this.data = data; + } + + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + EMOneWayDeleteConversationResult oneWayDeleteConversationResult = (EMOneWayDeleteConversationResult) o; + return Objects.equals(this.data, oneWayDeleteConversationResult.data); + } + + @Override + public int hashCode() { + return Objects.hash(data); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class EMOneWayDeleteConversationResult {\n"); + sb.append(" data: ").append(toIndentedString(data)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("data"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to EMOneWayDeleteConversationResult + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!EMOneWayDeleteConversationResult.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format("The required field(s) %s in EMOneWayDeleteConversationResult is not found in the empty JSON string", EMOneWayDeleteConversationResult.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!EMOneWayDeleteConversationResult.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `EMOneWayDeleteConversationResult` properties. JSON: %s", entry.getKey(), jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // validate the optional field `data` + if (jsonObj.get("data") != null && !jsonObj.get("data").isJsonNull()) { + EMOneWayDeleteConversationResource.validateJsonElement(jsonObj.get("data")); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!EMOneWayDeleteConversationResult.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'EMOneWayDeleteConversationResult' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(EMOneWayDeleteConversationResult.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, EMOneWayDeleteConversationResult value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public EMOneWayDeleteConversationResult read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + return thisAdapter.fromJsonTree(jsonElement); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of EMOneWayDeleteConversationResult given an JSON string + * + * @param jsonString JSON string + * @return An instance of EMOneWayDeleteConversationResult + * @throws IOException if the JSON string is invalid with respect to EMOneWayDeleteConversationResult + */ + public static EMOneWayDeleteConversationResult fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, EMOneWayDeleteConversationResult.class); + } + + /** + * Convert an instance of EMOneWayDeleteConversationResult to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/com/easemob/im/api/model/EMRecallMessage.java b/src/main/java/com/easemob/im/api/model/EMRecallMessage.java new file mode 100644 index 000000000..3ceb20fd4 --- /dev/null +++ b/src/main/java/com/easemob/im/api/model/EMRecallMessage.java @@ -0,0 +1,340 @@ +/* + * EMService + * Easemob Rest API + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.easemob.im.api.model; + +import java.util.Objects; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.Arrays; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import com.easemob.im.JSON; + +/** + * EMRecallMessage + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-01-25T14:51:53.998371+08:00[Asia/Shanghai]") +public class EMRecallMessage { + public static final String SERIALIZED_NAME_MSG_ID = "msg_id"; + @SerializedName(SERIALIZED_NAME_MSG_ID) + private String msgId; + + public static final String SERIALIZED_NAME_TO = "to"; + @SerializedName(SERIALIZED_NAME_TO) + private String to; + + public static final String SERIALIZED_NAME_CHAT_TYPE = "chat_type"; + @SerializedName(SERIALIZED_NAME_CHAT_TYPE) + private String chatType; + + public static final String SERIALIZED_NAME_FROM = "from"; + @SerializedName(SERIALIZED_NAME_FROM) + private String from; + + public static final String SERIALIZED_NAME_FORCE = "force"; + @SerializedName(SERIALIZED_NAME_FORCE) + private Boolean force; + + public EMRecallMessage() { + } + + public EMRecallMessage msgId(String msgId) { + + this.msgId = msgId; + return this; + } + + /** + * 要撤回消息的消息 ID。由于每次只能撤销一条消息,因此只能传入一个消息 ID + * @return msgId + **/ + @javax.annotation.Nonnull + public String getMsgId() { + return msgId; + } + + + public void setMsgId(String msgId) { + this.msgId = msgId; + } + + + public EMRecallMessage to(String to) { + + this.to = to; + return this; + } + + /** + * 要撤回消息的接收方。 - 单聊为接收方用户 ID; - 群聊为群组 ID; - 聊天室聊天为聊天室 ID。 若不传入该参数,请求失败 + * @return to + **/ + @javax.annotation.Nonnull + public String getTo() { + return to; + } + + + public void setTo(String to) { + this.to = to; + } + + + public EMRecallMessage chatType(String chatType) { + + this.chatType = chatType; + return this; + } + + /** + * 要撤回消息的会话类型: - chat:单聊; - groupchat:群聊 ; - chatroom:聊天室 + * @return chatType + **/ + @javax.annotation.Nonnull + public String getChatType() { + return chatType; + } + + + public void setChatType(String chatType) { + this.chatType = chatType; + } + + + public EMRecallMessage from(String from) { + + this.from = from; + return this; + } + + /** + * 消息撤回方的用户 ID。若不传该参数,默认为 admin + * @return from + **/ + @javax.annotation.Nullable + public String getFrom() { + return from; + } + + + public void setFrom(String from) { + this.from = from; + } + + + public EMRecallMessage force(Boolean force) { + + this.force = force; + return this; + } + + /** + * 是否支持撤回超过服务器存储时长的消息。 - true:是。这种情况下,你可以撤回在撤回时长内的消息,也可以撤回超过服务器存储时长的消息。对于后者,该接口会撤回接收方在本地保存的消息。若消息发送的时间介于你的撤回时长和服务器存储时长之间,则撤回失败。例如,如果消息的撤回时长为 2 分钟,在服务器上的存储时长为 7 天,你可以撤回 2 分钟以内发送的消息或发送时间超过 7 天的消息;若消息发送了 3 分钟,则撤回失败。 - false:否,不支持撤回超过服务器存储时长的消息。如果你采用默认的 2 分钟撤回时长或联系了商务设置了撤回时长,服务器只能撤回指定时长内发送的消息,超过该时长的消息无法撤回。例如,你设置的撤回时长为 3 分钟,若消息发送了 4 分钟,则撤回失败 + * @return force + **/ + @javax.annotation.Nonnull + public Boolean getForce() { + return force; + } + + + public void setForce(Boolean force) { + this.force = force; + } + + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + EMRecallMessage recallMessage = (EMRecallMessage) o; + return Objects.equals(this.msgId, recallMessage.msgId) && + Objects.equals(this.to, recallMessage.to) && + Objects.equals(this.chatType, recallMessage.chatType) && + Objects.equals(this.from, recallMessage.from) && + Objects.equals(this.force, recallMessage.force); + } + + @Override + public int hashCode() { + return Objects.hash(msgId, to, chatType, from, force); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class EMRecallMessage {\n"); + sb.append(" msgId: ").append(toIndentedString(msgId)).append("\n"); + sb.append(" to: ").append(toIndentedString(to)).append("\n"); + sb.append(" chatType: ").append(toIndentedString(chatType)).append("\n"); + sb.append(" from: ").append(toIndentedString(from)).append("\n"); + sb.append(" force: ").append(toIndentedString(force)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("msg_id"); + openapiFields.add("to"); + openapiFields.add("chat_type"); + openapiFields.add("from"); + openapiFields.add("force"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + openapiRequiredFields.add("msg_id"); + openapiRequiredFields.add("to"); + openapiRequiredFields.add("chat_type"); + openapiRequiredFields.add("force"); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to EMRecallMessage + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!EMRecallMessage.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format("The required field(s) %s in EMRecallMessage is not found in the empty JSON string", EMRecallMessage.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!EMRecallMessage.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `EMRecallMessage` properties. JSON: %s", entry.getKey(), jsonElement.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : EMRecallMessage.openapiRequiredFields) { + if (jsonElement.getAsJsonObject().get(requiredField) == null) { + throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + if (!jsonObj.get("msg_id").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `msg_id` to be a primitive type in the JSON string but got `%s`", jsonObj.get("msg_id").toString())); + } + if (!jsonObj.get("to").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `to` to be a primitive type in the JSON string but got `%s`", jsonObj.get("to").toString())); + } + if (!jsonObj.get("chat_type").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `chat_type` to be a primitive type in the JSON string but got `%s`", jsonObj.get("chat_type").toString())); + } + if ((jsonObj.get("from") != null && !jsonObj.get("from").isJsonNull()) && !jsonObj.get("from").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `from` to be a primitive type in the JSON string but got `%s`", jsonObj.get("from").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!EMRecallMessage.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'EMRecallMessage' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(EMRecallMessage.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, EMRecallMessage value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public EMRecallMessage read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + return thisAdapter.fromJsonTree(jsonElement); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of EMRecallMessage given an JSON string + * + * @param jsonString JSON string + * @return An instance of EMRecallMessage + * @throws IOException if the JSON string is invalid with respect to EMRecallMessage + */ + public static EMRecallMessage fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, EMRecallMessage.class); + } + + /** + * Convert an instance of EMRecallMessage to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/com/easemob/im/api/model/EMRecallMessageResource.java b/src/main/java/com/easemob/im/api/model/EMRecallMessageResource.java new file mode 100644 index 000000000..c98c817ea --- /dev/null +++ b/src/main/java/com/easemob/im/api/model/EMRecallMessageResource.java @@ -0,0 +1,208 @@ +/* + * EMService + * Easemob Rest API + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.easemob.im.api.model; + +import java.util.Objects; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.Arrays; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import com.easemob.im.JSON; + +/** + * EMRecallMessageResource + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-01-25T14:51:53.998371+08:00[Asia/Shanghai]") +public class EMRecallMessageResource { + public static final String SERIALIZED_NAME_RECALLED = "recalled"; + @SerializedName(SERIALIZED_NAME_RECALLED) + private String recalled; + + public EMRecallMessageResource() { + } + + public EMRecallMessageResource recalled(String recalled) { + + this.recalled = recalled; + return this; + } + + /** + * Get recalled + * @return recalled + **/ + @javax.annotation.Nullable + public String getRecalled() { + return recalled; + } + + + public void setRecalled(String recalled) { + this.recalled = recalled; + } + + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + EMRecallMessageResource recallMessageResource = (EMRecallMessageResource) o; + return Objects.equals(this.recalled, recallMessageResource.recalled); + } + + @Override + public int hashCode() { + return Objects.hash(recalled); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class EMRecallMessageResource {\n"); + sb.append(" recalled: ").append(toIndentedString(recalled)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("recalled"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to EMRecallMessageResource + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!EMRecallMessageResource.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format("The required field(s) %s in EMRecallMessageResource is not found in the empty JSON string", EMRecallMessageResource.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!EMRecallMessageResource.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `EMRecallMessageResource` properties. JSON: %s", entry.getKey(), jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + if ((jsonObj.get("recalled") != null && !jsonObj.get("recalled").isJsonNull()) && !jsonObj.get("recalled").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `recalled` to be a primitive type in the JSON string but got `%s`", jsonObj.get("recalled").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!EMRecallMessageResource.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'EMRecallMessageResource' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(EMRecallMessageResource.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, EMRecallMessageResource value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public EMRecallMessageResource read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + return thisAdapter.fromJsonTree(jsonElement); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of EMRecallMessageResource given an JSON string + * + * @param jsonString JSON string + * @return An instance of EMRecallMessageResource + * @throws IOException if the JSON string is invalid with respect to EMRecallMessageResource + */ + public static EMRecallMessageResource fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, EMRecallMessageResource.class); + } + + /** + * Convert an instance of EMRecallMessageResource to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/com/easemob/im/api/model/EMRecallMessageResult.java b/src/main/java/com/easemob/im/api/model/EMRecallMessageResult.java new file mode 100644 index 000000000..52c711bcd --- /dev/null +++ b/src/main/java/com/easemob/im/api/model/EMRecallMessageResult.java @@ -0,0 +1,210 @@ +/* + * EMService + * Easemob Rest API + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.easemob.im.api.model; + +import java.util.Objects; +import com.easemob.im.api.model.EMRecallMessageResource; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.Arrays; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import com.easemob.im.JSON; + +/** + * EMRecallMessageResult + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-01-25T14:51:53.998371+08:00[Asia/Shanghai]") +public class EMRecallMessageResult { + public static final String SERIALIZED_NAME_DATA = "data"; + @SerializedName(SERIALIZED_NAME_DATA) + private EMRecallMessageResource data; + + public EMRecallMessageResult() { + } + + public EMRecallMessageResult data(EMRecallMessageResource data) { + + this.data = data; + return this; + } + + /** + * Get data + * @return data + **/ + @javax.annotation.Nullable + public EMRecallMessageResource getData() { + return data; + } + + + public void setData(EMRecallMessageResource data) { + this.data = data; + } + + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + EMRecallMessageResult recallMessageResult = (EMRecallMessageResult) o; + return Objects.equals(this.data, recallMessageResult.data); + } + + @Override + public int hashCode() { + return Objects.hash(data); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class EMRecallMessageResult {\n"); + sb.append(" data: ").append(toIndentedString(data)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("data"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to EMRecallMessageResult + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!EMRecallMessageResult.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format("The required field(s) %s in EMRecallMessageResult is not found in the empty JSON string", EMRecallMessageResult.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!EMRecallMessageResult.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `EMRecallMessageResult` properties. JSON: %s", entry.getKey(), jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // validate the optional field `data` + if (jsonObj.get("data") != null && !jsonObj.get("data").isJsonNull()) { + EMRecallMessageResource.validateJsonElement(jsonObj.get("data")); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!EMRecallMessageResult.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'EMRecallMessageResult' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(EMRecallMessageResult.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, EMRecallMessageResult value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public EMRecallMessageResult read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + return thisAdapter.fromJsonTree(jsonElement); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of EMRecallMessageResult given an JSON string + * + * @param jsonString JSON string + * @return An instance of EMRecallMessageResult + * @throws IOException if the JSON string is invalid with respect to EMRecallMessageResult + */ + public static EMRecallMessageResult fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, EMRecallMessageResult.class); + } + + /** + * Convert an instance of EMRecallMessageResult to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/com/easemob/im/api/model/EMRemoveContactResult.java b/src/main/java/com/easemob/im/api/model/EMRemoveContactResult.java new file mode 100644 index 000000000..f8b29ed2b --- /dev/null +++ b/src/main/java/com/easemob/im/api/model/EMRemoveContactResult.java @@ -0,0 +1,230 @@ +/* + * EMService + * Easemob Rest API + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.easemob.im.api.model; + +import java.util.Objects; +import com.easemob.im.api.model.EMUserResource; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import com.easemob.im.JSON; + +/** + * EMRemoveContactResult + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-01-25T14:51:53.998371+08:00[Asia/Shanghai]") +public class EMRemoveContactResult { + public static final String SERIALIZED_NAME_ENTITIES = "entities"; + @SerializedName(SERIALIZED_NAME_ENTITIES) + private List entities; + + public EMRemoveContactResult() { + } + + public EMRemoveContactResult entities(List entities) { + + this.entities = entities; + return this; + } + + public EMRemoveContactResult addEntitiesItem(EMUserResource entitiesItem) { + if (this.entities == null) { + this.entities = new ArrayList<>(); + } + this.entities.add(entitiesItem); + return this; + } + + /** + * Get entities + * @return entities + **/ + @javax.annotation.Nullable + public List getEntities() { + return entities; + } + + + public void setEntities(List entities) { + this.entities = entities; + } + + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + EMRemoveContactResult removeContactResult = (EMRemoveContactResult) o; + return Objects.equals(this.entities, removeContactResult.entities); + } + + @Override + public int hashCode() { + return Objects.hash(entities); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class EMRemoveContactResult {\n"); + sb.append(" entities: ").append(toIndentedString(entities)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("entities"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to EMRemoveContactResult + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!EMRemoveContactResult.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format("The required field(s) %s in EMRemoveContactResult is not found in the empty JSON string", EMRemoveContactResult.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!EMRemoveContactResult.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `EMRemoveContactResult` properties. JSON: %s", entry.getKey(), jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + if (jsonObj.get("entities") != null && !jsonObj.get("entities").isJsonNull()) { + JsonArray jsonArrayentities = jsonObj.getAsJsonArray("entities"); + if (jsonArrayentities != null) { + // ensure the json data is an array + if (!jsonObj.get("entities").isJsonArray()) { + throw new IllegalArgumentException(String.format("Expected the field `entities` to be an array in the JSON string but got `%s`", jsonObj.get("entities").toString())); + } + + // validate the optional field `entities` (array) + for (int i = 0; i < jsonArrayentities.size(); i++) { + EMUserResource.validateJsonElement(jsonArrayentities.get(i)); + }; + } + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!EMRemoveContactResult.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'EMRemoveContactResult' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(EMRemoveContactResult.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, EMRemoveContactResult value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public EMRemoveContactResult read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + return thisAdapter.fromJsonTree(jsonElement); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of EMRemoveContactResult given an JSON string + * + * @param jsonString JSON string + * @return An instance of EMRemoveContactResult + * @throws IOException if the JSON string is invalid with respect to EMRemoveContactResult + */ + public static EMRemoveContactResult fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, EMRemoveContactResult.class); + } + + /** + * Convert an instance of EMRemoveContactResult to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/com/easemob/im/api/model/EMRemoveGroupAdminResource.java b/src/main/java/com/easemob/im/api/model/EMRemoveGroupAdminResource.java new file mode 100644 index 000000000..ad5654503 --- /dev/null +++ b/src/main/java/com/easemob/im/api/model/EMRemoveGroupAdminResource.java @@ -0,0 +1,208 @@ +/* + * EMService + * Easemob Rest API + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.easemob.im.api.model; + +import java.util.Objects; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.Arrays; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import com.easemob.im.JSON; + +/** + * EMRemoveGroupAdminResource + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-01-25T14:51:53.998371+08:00[Asia/Shanghai]") +public class EMRemoveGroupAdminResource { + public static final String SERIALIZED_NAME_RESULT = "result"; + @SerializedName(SERIALIZED_NAME_RESULT) + private String result; + + public EMRemoveGroupAdminResource() { + } + + public EMRemoveGroupAdminResource result(String result) { + + this.result = result; + return this; + } + + /** + * Get result + * @return result + **/ + @javax.annotation.Nullable + public String getResult() { + return result; + } + + + public void setResult(String result) { + this.result = result; + } + + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + EMRemoveGroupAdminResource removeGroupAdminResource = (EMRemoveGroupAdminResource) o; + return Objects.equals(this.result, removeGroupAdminResource.result); + } + + @Override + public int hashCode() { + return Objects.hash(result); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class EMRemoveGroupAdminResource {\n"); + sb.append(" result: ").append(toIndentedString(result)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("result"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to EMRemoveGroupAdminResource + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!EMRemoveGroupAdminResource.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format("The required field(s) %s in EMRemoveGroupAdminResource is not found in the empty JSON string", EMRemoveGroupAdminResource.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!EMRemoveGroupAdminResource.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `EMRemoveGroupAdminResource` properties. JSON: %s", entry.getKey(), jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + if ((jsonObj.get("result") != null && !jsonObj.get("result").isJsonNull()) && !jsonObj.get("result").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `result` to be a primitive type in the JSON string but got `%s`", jsonObj.get("result").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!EMRemoveGroupAdminResource.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'EMRemoveGroupAdminResource' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(EMRemoveGroupAdminResource.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, EMRemoveGroupAdminResource value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public EMRemoveGroupAdminResource read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + return thisAdapter.fromJsonTree(jsonElement); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of EMRemoveGroupAdminResource given an JSON string + * + * @param jsonString JSON string + * @return An instance of EMRemoveGroupAdminResource + * @throws IOException if the JSON string is invalid with respect to EMRemoveGroupAdminResource + */ + public static EMRemoveGroupAdminResource fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, EMRemoveGroupAdminResource.class); + } + + /** + * Convert an instance of EMRemoveGroupAdminResource to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/com/easemob/im/api/model/EMRemoveGroupAdminResult.java b/src/main/java/com/easemob/im/api/model/EMRemoveGroupAdminResult.java new file mode 100644 index 000000000..573343d85 --- /dev/null +++ b/src/main/java/com/easemob/im/api/model/EMRemoveGroupAdminResult.java @@ -0,0 +1,210 @@ +/* + * EMService + * Easemob Rest API + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.easemob.im.api.model; + +import java.util.Objects; +import com.easemob.im.api.model.EMRemoveGroupAdminResource; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.Arrays; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import com.easemob.im.JSON; + +/** + * EMRemoveGroupAdminResult + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-01-25T14:51:53.998371+08:00[Asia/Shanghai]") +public class EMRemoveGroupAdminResult { + public static final String SERIALIZED_NAME_DATA = "data"; + @SerializedName(SERIALIZED_NAME_DATA) + private EMRemoveGroupAdminResource data; + + public EMRemoveGroupAdminResult() { + } + + public EMRemoveGroupAdminResult data(EMRemoveGroupAdminResource data) { + + this.data = data; + return this; + } + + /** + * Get data + * @return data + **/ + @javax.annotation.Nullable + public EMRemoveGroupAdminResource getData() { + return data; + } + + + public void setData(EMRemoveGroupAdminResource data) { + this.data = data; + } + + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + EMRemoveGroupAdminResult removeGroupAdminResult = (EMRemoveGroupAdminResult) o; + return Objects.equals(this.data, removeGroupAdminResult.data); + } + + @Override + public int hashCode() { + return Objects.hash(data); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class EMRemoveGroupAdminResult {\n"); + sb.append(" data: ").append(toIndentedString(data)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("data"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to EMRemoveGroupAdminResult + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!EMRemoveGroupAdminResult.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format("The required field(s) %s in EMRemoveGroupAdminResult is not found in the empty JSON string", EMRemoveGroupAdminResult.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!EMRemoveGroupAdminResult.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `EMRemoveGroupAdminResult` properties. JSON: %s", entry.getKey(), jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // validate the optional field `data` + if (jsonObj.get("data") != null && !jsonObj.get("data").isJsonNull()) { + EMRemoveGroupAdminResource.validateJsonElement(jsonObj.get("data")); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!EMRemoveGroupAdminResult.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'EMRemoveGroupAdminResult' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(EMRemoveGroupAdminResult.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, EMRemoveGroupAdminResult value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public EMRemoveGroupAdminResult read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + return thisAdapter.fromJsonTree(jsonElement); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of EMRemoveGroupAdminResult given an JSON string + * + * @param jsonString JSON string + * @return An instance of EMRemoveGroupAdminResult + * @throws IOException if the JSON string is invalid with respect to EMRemoveGroupAdminResult + */ + public static EMRemoveGroupAdminResult fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, EMRemoveGroupAdminResult.class); + } + + /** + * Convert an instance of EMRemoveGroupAdminResult to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/com/easemob/im/api/model/EMRemoveMultipleUsersFromThread.java b/src/main/java/com/easemob/im/api/model/EMRemoveMultipleUsersFromThread.java new file mode 100644 index 000000000..8431e8284 --- /dev/null +++ b/src/main/java/com/easemob/im/api/model/EMRemoveMultipleUsersFromThread.java @@ -0,0 +1,219 @@ +/* + * EMService + * Easemob Rest API + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.easemob.im.api.model; + +import java.util.Objects; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import com.easemob.im.JSON; + +/** + * EMRemoveMultipleUsersFromThread + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-01-25T14:51:53.998371+08:00[Asia/Shanghai]") +public class EMRemoveMultipleUsersFromThread { + public static final String SERIALIZED_NAME_USERNAMES = "usernames"; + @SerializedName(SERIALIZED_NAME_USERNAMES) + private List usernames; + + public EMRemoveMultipleUsersFromThread() { + } + + public EMRemoveMultipleUsersFromThread usernames(List usernames) { + + this.usernames = usernames; + return this; + } + + public EMRemoveMultipleUsersFromThread addUsernamesItem(String usernamesItem) { + if (this.usernames == null) { + this.usernames = new ArrayList<>(); + } + this.usernames.add(usernamesItem); + return this; + } + + /** + * 批量踢出子区的用户 ID 列表。每次最多可踢出 10 个子区成员 + * @return usernames + **/ + @javax.annotation.Nullable + public List getUsernames() { + return usernames; + } + + + public void setUsernames(List usernames) { + this.usernames = usernames; + } + + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + EMRemoveMultipleUsersFromThread removeMultipleUsersFromThread = (EMRemoveMultipleUsersFromThread) o; + return Objects.equals(this.usernames, removeMultipleUsersFromThread.usernames); + } + + @Override + public int hashCode() { + return Objects.hash(usernames); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class EMRemoveMultipleUsersFromThread {\n"); + sb.append(" usernames: ").append(toIndentedString(usernames)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("usernames"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to EMRemoveMultipleUsersFromThread + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!EMRemoveMultipleUsersFromThread.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format("The required field(s) %s in EMRemoveMultipleUsersFromThread is not found in the empty JSON string", EMRemoveMultipleUsersFromThread.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!EMRemoveMultipleUsersFromThread.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `EMRemoveMultipleUsersFromThread` properties. JSON: %s", entry.getKey(), jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // ensure the optional json data is an array if present + if (jsonObj.get("usernames") != null && !jsonObj.get("usernames").isJsonNull() && !jsonObj.get("usernames").isJsonArray()) { + throw new IllegalArgumentException(String.format("Expected the field `usernames` to be an array in the JSON string but got `%s`", jsonObj.get("usernames").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!EMRemoveMultipleUsersFromThread.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'EMRemoveMultipleUsersFromThread' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(EMRemoveMultipleUsersFromThread.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, EMRemoveMultipleUsersFromThread value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public EMRemoveMultipleUsersFromThread read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + return thisAdapter.fromJsonTree(jsonElement); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of EMRemoveMultipleUsersFromThread given an JSON string + * + * @param jsonString JSON string + * @return An instance of EMRemoveMultipleUsersFromThread + * @throws IOException if the JSON string is invalid with respect to EMRemoveMultipleUsersFromThread + */ + public static EMRemoveMultipleUsersFromThread fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, EMRemoveMultipleUsersFromThread.class); + } + + /** + * Convert an instance of EMRemoveMultipleUsersFromThread to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/com/easemob/im/api/model/EMRemoveMultipleUsersFromThreadResult.java b/src/main/java/com/easemob/im/api/model/EMRemoveMultipleUsersFromThreadResult.java new file mode 100644 index 000000000..0b3581e2c --- /dev/null +++ b/src/main/java/com/easemob/im/api/model/EMRemoveMultipleUsersFromThreadResult.java @@ -0,0 +1,230 @@ +/* + * EMService + * Easemob Rest API + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.easemob.im.api.model; + +import java.util.Objects; +import com.easemob.im.api.model.EMRemoveThreadUsersResource; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import com.easemob.im.JSON; + +/** + * EMRemoveMultipleUsersFromThreadResult + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-01-25T14:51:53.998371+08:00[Asia/Shanghai]") +public class EMRemoveMultipleUsersFromThreadResult { + public static final String SERIALIZED_NAME_ENTITIES = "entities"; + @SerializedName(SERIALIZED_NAME_ENTITIES) + private List entities; + + public EMRemoveMultipleUsersFromThreadResult() { + } + + public EMRemoveMultipleUsersFromThreadResult entities(List entities) { + + this.entities = entities; + return this; + } + + public EMRemoveMultipleUsersFromThreadResult addEntitiesItem(EMRemoveThreadUsersResource entitiesItem) { + if (this.entities == null) { + this.entities = new ArrayList<>(); + } + this.entities.add(entitiesItem); + return this; + } + + /** + * Get entities + * @return entities + **/ + @javax.annotation.Nullable + public List getEntities() { + return entities; + } + + + public void setEntities(List entities) { + this.entities = entities; + } + + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + EMRemoveMultipleUsersFromThreadResult removeMultipleUsersFromThreadResult = (EMRemoveMultipleUsersFromThreadResult) o; + return Objects.equals(this.entities, removeMultipleUsersFromThreadResult.entities); + } + + @Override + public int hashCode() { + return Objects.hash(entities); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class EMRemoveMultipleUsersFromThreadResult {\n"); + sb.append(" entities: ").append(toIndentedString(entities)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("entities"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to EMRemoveMultipleUsersFromThreadResult + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!EMRemoveMultipleUsersFromThreadResult.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format("The required field(s) %s in EMRemoveMultipleUsersFromThreadResult is not found in the empty JSON string", EMRemoveMultipleUsersFromThreadResult.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!EMRemoveMultipleUsersFromThreadResult.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `EMRemoveMultipleUsersFromThreadResult` properties. JSON: %s", entry.getKey(), jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + if (jsonObj.get("entities") != null && !jsonObj.get("entities").isJsonNull()) { + JsonArray jsonArrayentities = jsonObj.getAsJsonArray("entities"); + if (jsonArrayentities != null) { + // ensure the json data is an array + if (!jsonObj.get("entities").isJsonArray()) { + throw new IllegalArgumentException(String.format("Expected the field `entities` to be an array in the JSON string but got `%s`", jsonObj.get("entities").toString())); + } + + // validate the optional field `entities` (array) + for (int i = 0; i < jsonArrayentities.size(); i++) { + EMRemoveThreadUsersResource.validateJsonElement(jsonArrayentities.get(i)); + }; + } + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!EMRemoveMultipleUsersFromThreadResult.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'EMRemoveMultipleUsersFromThreadResult' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(EMRemoveMultipleUsersFromThreadResult.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, EMRemoveMultipleUsersFromThreadResult value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public EMRemoveMultipleUsersFromThreadResult read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + return thisAdapter.fromJsonTree(jsonElement); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of EMRemoveMultipleUsersFromThreadResult given an JSON string + * + * @param jsonString JSON string + * @return An instance of EMRemoveMultipleUsersFromThreadResult + * @throws IOException if the JSON string is invalid with respect to EMRemoveMultipleUsersFromThreadResult + */ + public static EMRemoveMultipleUsersFromThreadResult fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, EMRemoveMultipleUsersFromThreadResult.class); + } + + /** + * Convert an instance of EMRemoveMultipleUsersFromThreadResult to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/com/easemob/im/api/model/EMRemoveRoomAdminResource.java b/src/main/java/com/easemob/im/api/model/EMRemoveRoomAdminResource.java new file mode 100644 index 000000000..fdb5967ea --- /dev/null +++ b/src/main/java/com/easemob/im/api/model/EMRemoveRoomAdminResource.java @@ -0,0 +1,208 @@ +/* + * EMService + * Easemob Rest API + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.easemob.im.api.model; + +import java.util.Objects; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.Arrays; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import com.easemob.im.JSON; + +/** + * EMRemoveRoomAdminResource + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-01-25T14:51:53.998371+08:00[Asia/Shanghai]") +public class EMRemoveRoomAdminResource { + public static final String SERIALIZED_NAME_RESULT = "result"; + @SerializedName(SERIALIZED_NAME_RESULT) + private String result; + + public EMRemoveRoomAdminResource() { + } + + public EMRemoveRoomAdminResource result(String result) { + + this.result = result; + return this; + } + + /** + * Get result + * @return result + **/ + @javax.annotation.Nullable + public String getResult() { + return result; + } + + + public void setResult(String result) { + this.result = result; + } + + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + EMRemoveRoomAdminResource removeRoomAdminResource = (EMRemoveRoomAdminResource) o; + return Objects.equals(this.result, removeRoomAdminResource.result); + } + + @Override + public int hashCode() { + return Objects.hash(result); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class EMRemoveRoomAdminResource {\n"); + sb.append(" result: ").append(toIndentedString(result)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("result"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to EMRemoveRoomAdminResource + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!EMRemoveRoomAdminResource.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format("The required field(s) %s in EMRemoveRoomAdminResource is not found in the empty JSON string", EMRemoveRoomAdminResource.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!EMRemoveRoomAdminResource.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `EMRemoveRoomAdminResource` properties. JSON: %s", entry.getKey(), jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + if ((jsonObj.get("result") != null && !jsonObj.get("result").isJsonNull()) && !jsonObj.get("result").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `result` to be a primitive type in the JSON string but got `%s`", jsonObj.get("result").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!EMRemoveRoomAdminResource.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'EMRemoveRoomAdminResource' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(EMRemoveRoomAdminResource.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, EMRemoveRoomAdminResource value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public EMRemoveRoomAdminResource read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + return thisAdapter.fromJsonTree(jsonElement); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of EMRemoveRoomAdminResource given an JSON string + * + * @param jsonString JSON string + * @return An instance of EMRemoveRoomAdminResource + * @throws IOException if the JSON string is invalid with respect to EMRemoveRoomAdminResource + */ + public static EMRemoveRoomAdminResource fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, EMRemoveRoomAdminResource.class); + } + + /** + * Convert an instance of EMRemoveRoomAdminResource to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/com/easemob/im/api/model/EMRemoveRoomAdminResult.java b/src/main/java/com/easemob/im/api/model/EMRemoveRoomAdminResult.java new file mode 100644 index 000000000..3fa399244 --- /dev/null +++ b/src/main/java/com/easemob/im/api/model/EMRemoveRoomAdminResult.java @@ -0,0 +1,210 @@ +/* + * EMService + * Easemob Rest API + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.easemob.im.api.model; + +import java.util.Objects; +import com.easemob.im.api.model.EMRemoveRoomAdminResource; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.Arrays; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import com.easemob.im.JSON; + +/** + * EMRemoveRoomAdminResult + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-01-25T14:51:53.998371+08:00[Asia/Shanghai]") +public class EMRemoveRoomAdminResult { + public static final String SERIALIZED_NAME_DATA = "data"; + @SerializedName(SERIALIZED_NAME_DATA) + private EMRemoveRoomAdminResource data; + + public EMRemoveRoomAdminResult() { + } + + public EMRemoveRoomAdminResult data(EMRemoveRoomAdminResource data) { + + this.data = data; + return this; + } + + /** + * Get data + * @return data + **/ + @javax.annotation.Nullable + public EMRemoveRoomAdminResource getData() { + return data; + } + + + public void setData(EMRemoveRoomAdminResource data) { + this.data = data; + } + + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + EMRemoveRoomAdminResult removeRoomAdminResult = (EMRemoveRoomAdminResult) o; + return Objects.equals(this.data, removeRoomAdminResult.data); + } + + @Override + public int hashCode() { + return Objects.hash(data); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class EMRemoveRoomAdminResult {\n"); + sb.append(" data: ").append(toIndentedString(data)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("data"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to EMRemoveRoomAdminResult + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!EMRemoveRoomAdminResult.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format("The required field(s) %s in EMRemoveRoomAdminResult is not found in the empty JSON string", EMRemoveRoomAdminResult.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!EMRemoveRoomAdminResult.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `EMRemoveRoomAdminResult` properties. JSON: %s", entry.getKey(), jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // validate the optional field `data` + if (jsonObj.get("data") != null && !jsonObj.get("data").isJsonNull()) { + EMRemoveRoomAdminResource.validateJsonElement(jsonObj.get("data")); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!EMRemoveRoomAdminResult.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'EMRemoveRoomAdminResult' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(EMRemoveRoomAdminResult.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, EMRemoveRoomAdminResult value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public EMRemoveRoomAdminResult read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + return thisAdapter.fromJsonTree(jsonElement); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of EMRemoveRoomAdminResult given an JSON string + * + * @param jsonString JSON string + * @return An instance of EMRemoveRoomAdminResult + * @throws IOException if the JSON string is invalid with respect to EMRemoveRoomAdminResult + */ + public static EMRemoveRoomAdminResult fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, EMRemoveRoomAdminResult.class); + } + + /** + * Convert an instance of EMRemoveRoomAdminResult to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/com/easemob/im/api/model/EMRemoveRoomSuperAdminResource.java b/src/main/java/com/easemob/im/api/model/EMRemoveRoomSuperAdminResource.java new file mode 100644 index 000000000..2912935cb --- /dev/null +++ b/src/main/java/com/easemob/im/api/model/EMRemoveRoomSuperAdminResource.java @@ -0,0 +1,208 @@ +/* + * EMService + * Easemob Rest API + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.easemob.im.api.model; + +import java.util.Objects; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.Arrays; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import com.easemob.im.JSON; + +/** + * EMRemoveRoomSuperAdminResource + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-01-25T14:51:53.998371+08:00[Asia/Shanghai]") +public class EMRemoveRoomSuperAdminResource { + public static final String SERIALIZED_NAME_RESOURCE = "resource"; + @SerializedName(SERIALIZED_NAME_RESOURCE) + private String resource; + + public EMRemoveRoomSuperAdminResource() { + } + + public EMRemoveRoomSuperAdminResource resource(String resource) { + + this.resource = resource; + return this; + } + + /** + * Get resource + * @return resource + **/ + @javax.annotation.Nullable + public String getResource() { + return resource; + } + + + public void setResource(String resource) { + this.resource = resource; + } + + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + EMRemoveRoomSuperAdminResource removeRoomSuperAdminResource = (EMRemoveRoomSuperAdminResource) o; + return Objects.equals(this.resource, removeRoomSuperAdminResource.resource); + } + + @Override + public int hashCode() { + return Objects.hash(resource); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class EMRemoveRoomSuperAdminResource {\n"); + sb.append(" resource: ").append(toIndentedString(resource)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("resource"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to EMRemoveRoomSuperAdminResource + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!EMRemoveRoomSuperAdminResource.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format("The required field(s) %s in EMRemoveRoomSuperAdminResource is not found in the empty JSON string", EMRemoveRoomSuperAdminResource.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!EMRemoveRoomSuperAdminResource.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `EMRemoveRoomSuperAdminResource` properties. JSON: %s", entry.getKey(), jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + if ((jsonObj.get("resource") != null && !jsonObj.get("resource").isJsonNull()) && !jsonObj.get("resource").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `resource` to be a primitive type in the JSON string but got `%s`", jsonObj.get("resource").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!EMRemoveRoomSuperAdminResource.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'EMRemoveRoomSuperAdminResource' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(EMRemoveRoomSuperAdminResource.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, EMRemoveRoomSuperAdminResource value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public EMRemoveRoomSuperAdminResource read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + return thisAdapter.fromJsonTree(jsonElement); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of EMRemoveRoomSuperAdminResource given an JSON string + * + * @param jsonString JSON string + * @return An instance of EMRemoveRoomSuperAdminResource + * @throws IOException if the JSON string is invalid with respect to EMRemoveRoomSuperAdminResource + */ + public static EMRemoveRoomSuperAdminResource fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, EMRemoveRoomSuperAdminResource.class); + } + + /** + * Convert an instance of EMRemoveRoomSuperAdminResource to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/com/easemob/im/api/model/EMRemoveRoomSuperAdminResult.java b/src/main/java/com/easemob/im/api/model/EMRemoveRoomSuperAdminResult.java new file mode 100644 index 000000000..7286b124f --- /dev/null +++ b/src/main/java/com/easemob/im/api/model/EMRemoveRoomSuperAdminResult.java @@ -0,0 +1,210 @@ +/* + * EMService + * Easemob Rest API + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.easemob.im.api.model; + +import java.util.Objects; +import com.easemob.im.api.model.EMRemoveRoomSuperAdminResource; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.Arrays; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import com.easemob.im.JSON; + +/** + * EMRemoveRoomSuperAdminResult + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-01-25T14:51:53.998371+08:00[Asia/Shanghai]") +public class EMRemoveRoomSuperAdminResult { + public static final String SERIALIZED_NAME_DATA = "data"; + @SerializedName(SERIALIZED_NAME_DATA) + private EMRemoveRoomSuperAdminResource data; + + public EMRemoveRoomSuperAdminResult() { + } + + public EMRemoveRoomSuperAdminResult data(EMRemoveRoomSuperAdminResource data) { + + this.data = data; + return this; + } + + /** + * Get data + * @return data + **/ + @javax.annotation.Nullable + public EMRemoveRoomSuperAdminResource getData() { + return data; + } + + + public void setData(EMRemoveRoomSuperAdminResource data) { + this.data = data; + } + + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + EMRemoveRoomSuperAdminResult removeRoomSuperAdminResult = (EMRemoveRoomSuperAdminResult) o; + return Objects.equals(this.data, removeRoomSuperAdminResult.data); + } + + @Override + public int hashCode() { + return Objects.hash(data); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class EMRemoveRoomSuperAdminResult {\n"); + sb.append(" data: ").append(toIndentedString(data)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("data"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to EMRemoveRoomSuperAdminResult + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!EMRemoveRoomSuperAdminResult.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format("The required field(s) %s in EMRemoveRoomSuperAdminResult is not found in the empty JSON string", EMRemoveRoomSuperAdminResult.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!EMRemoveRoomSuperAdminResult.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `EMRemoveRoomSuperAdminResult` properties. JSON: %s", entry.getKey(), jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // validate the optional field `data` + if (jsonObj.get("data") != null && !jsonObj.get("data").isJsonNull()) { + EMRemoveRoomSuperAdminResource.validateJsonElement(jsonObj.get("data")); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!EMRemoveRoomSuperAdminResult.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'EMRemoveRoomSuperAdminResult' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(EMRemoveRoomSuperAdminResult.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, EMRemoveRoomSuperAdminResult value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public EMRemoveRoomSuperAdminResult read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + return thisAdapter.fromJsonTree(jsonElement); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of EMRemoveRoomSuperAdminResult given an JSON string + * + * @param jsonString JSON string + * @return An instance of EMRemoveRoomSuperAdminResult + * @throws IOException if the JSON string is invalid with respect to EMRemoveRoomSuperAdminResult + */ + public static EMRemoveRoomSuperAdminResult fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, EMRemoveRoomSuperAdminResult.class); + } + + /** + * Convert an instance of EMRemoveRoomSuperAdminResult to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/com/easemob/im/api/model/EMRemoveThreadUsersResource.java b/src/main/java/com/easemob/im/api/model/EMRemoveThreadUsersResource.java new file mode 100644 index 000000000..6357e1937 --- /dev/null +++ b/src/main/java/com/easemob/im/api/model/EMRemoveThreadUsersResource.java @@ -0,0 +1,236 @@ +/* + * EMService + * Easemob Rest API + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.easemob.im.api.model; + +import java.util.Objects; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.Arrays; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import com.easemob.im.JSON; + +/** + * EMRemoveThreadUsersResource + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-01-25T14:51:53.998371+08:00[Asia/Shanghai]") +public class EMRemoveThreadUsersResource { + public static final String SERIALIZED_NAME_RESULT = "result"; + @SerializedName(SERIALIZED_NAME_RESULT) + private Boolean result; + + public static final String SERIALIZED_NAME_USER = "user"; + @SerializedName(SERIALIZED_NAME_USER) + private String user; + + public EMRemoveThreadUsersResource() { + } + + public EMRemoveThreadUsersResource result(Boolean result) { + + this.result = result; + return this; + } + + /** + * 操作结果。 - true:成功; - false:失败 + * @return result + **/ + @javax.annotation.Nullable + public Boolean getResult() { + return result; + } + + + public void setResult(Boolean result) { + this.result = result; + } + + + public EMRemoveThreadUsersResource user(String user) { + + this.user = user; + return this; + } + + /** + * 被踢出子区的用户 ID + * @return user + **/ + @javax.annotation.Nullable + public String getUser() { + return user; + } + + + public void setUser(String user) { + this.user = user; + } + + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + EMRemoveThreadUsersResource removeThreadUsersResource = (EMRemoveThreadUsersResource) o; + return Objects.equals(this.result, removeThreadUsersResource.result) && + Objects.equals(this.user, removeThreadUsersResource.user); + } + + @Override + public int hashCode() { + return Objects.hash(result, user); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class EMRemoveThreadUsersResource {\n"); + sb.append(" result: ").append(toIndentedString(result)).append("\n"); + sb.append(" user: ").append(toIndentedString(user)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("result"); + openapiFields.add("user"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to EMRemoveThreadUsersResource + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!EMRemoveThreadUsersResource.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format("The required field(s) %s in EMRemoveThreadUsersResource is not found in the empty JSON string", EMRemoveThreadUsersResource.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!EMRemoveThreadUsersResource.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `EMRemoveThreadUsersResource` properties. JSON: %s", entry.getKey(), jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + if ((jsonObj.get("user") != null && !jsonObj.get("user").isJsonNull()) && !jsonObj.get("user").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `user` to be a primitive type in the JSON string but got `%s`", jsonObj.get("user").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!EMRemoveThreadUsersResource.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'EMRemoveThreadUsersResource' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(EMRemoveThreadUsersResource.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, EMRemoveThreadUsersResource value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public EMRemoveThreadUsersResource read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + return thisAdapter.fromJsonTree(jsonElement); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of EMRemoveThreadUsersResource given an JSON string + * + * @param jsonString JSON string + * @return An instance of EMRemoveThreadUsersResource + * @throws IOException if the JSON string is invalid with respect to EMRemoveThreadUsersResource + */ + public static EMRemoveThreadUsersResource fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, EMRemoveThreadUsersResource.class); + } + + /** + * Convert an instance of EMRemoveThreadUsersResource to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/com/easemob/im/api/model/EMRemoveUserFromBlockListResult.java b/src/main/java/com/easemob/im/api/model/EMRemoveUserFromBlockListResult.java new file mode 100644 index 000000000..6c0a08a07 --- /dev/null +++ b/src/main/java/com/easemob/im/api/model/EMRemoveUserFromBlockListResult.java @@ -0,0 +1,230 @@ +/* + * EMService + * Easemob Rest API + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.easemob.im.api.model; + +import java.util.Objects; +import com.easemob.im.api.model.EMUserResource; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import com.easemob.im.JSON; + +/** + * EMRemoveUserFromBlockListResult + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-01-25T14:51:53.998371+08:00[Asia/Shanghai]") +public class EMRemoveUserFromBlockListResult { + public static final String SERIALIZED_NAME_ENTITIES = "entities"; + @SerializedName(SERIALIZED_NAME_ENTITIES) + private List entities; + + public EMRemoveUserFromBlockListResult() { + } + + public EMRemoveUserFromBlockListResult entities(List entities) { + + this.entities = entities; + return this; + } + + public EMRemoveUserFromBlockListResult addEntitiesItem(EMUserResource entitiesItem) { + if (this.entities == null) { + this.entities = new ArrayList<>(); + } + this.entities.add(entitiesItem); + return this; + } + + /** + * Get entities + * @return entities + **/ + @javax.annotation.Nullable + public List getEntities() { + return entities; + } + + + public void setEntities(List entities) { + this.entities = entities; + } + + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + EMRemoveUserFromBlockListResult removeUserFromBlockListResult = (EMRemoveUserFromBlockListResult) o; + return Objects.equals(this.entities, removeUserFromBlockListResult.entities); + } + + @Override + public int hashCode() { + return Objects.hash(entities); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class EMRemoveUserFromBlockListResult {\n"); + sb.append(" entities: ").append(toIndentedString(entities)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("entities"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to EMRemoveUserFromBlockListResult + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!EMRemoveUserFromBlockListResult.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format("The required field(s) %s in EMRemoveUserFromBlockListResult is not found in the empty JSON string", EMRemoveUserFromBlockListResult.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!EMRemoveUserFromBlockListResult.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `EMRemoveUserFromBlockListResult` properties. JSON: %s", entry.getKey(), jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + if (jsonObj.get("entities") != null && !jsonObj.get("entities").isJsonNull()) { + JsonArray jsonArrayentities = jsonObj.getAsJsonArray("entities"); + if (jsonArrayentities != null) { + // ensure the json data is an array + if (!jsonObj.get("entities").isJsonArray()) { + throw new IllegalArgumentException(String.format("Expected the field `entities` to be an array in the JSON string but got `%s`", jsonObj.get("entities").toString())); + } + + // validate the optional field `entities` (array) + for (int i = 0; i < jsonArrayentities.size(); i++) { + EMUserResource.validateJsonElement(jsonArrayentities.get(i)); + }; + } + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!EMRemoveUserFromBlockListResult.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'EMRemoveUserFromBlockListResult' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(EMRemoveUserFromBlockListResult.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, EMRemoveUserFromBlockListResult value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public EMRemoveUserFromBlockListResult read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + return thisAdapter.fromJsonTree(jsonElement); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of EMRemoveUserFromBlockListResult given an JSON string + * + * @param jsonString JSON string + * @return An instance of EMRemoveUserFromBlockListResult + * @throws IOException if the JSON string is invalid with respect to EMRemoveUserFromBlockListResult + */ + public static EMRemoveUserFromBlockListResult fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, EMRemoveUserFromBlockListResult.class); + } + + /** + * Convert an instance of EMRemoveUserFromBlockListResult to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/com/easemob/im/api/model/EMRemoveUserFromGroupBlockListResource.java b/src/main/java/com/easemob/im/api/model/EMRemoveUserFromGroupBlockListResource.java new file mode 100644 index 000000000..126e5465b --- /dev/null +++ b/src/main/java/com/easemob/im/api/model/EMRemoveUserFromGroupBlockListResource.java @@ -0,0 +1,205 @@ +/* + * EMService + * Easemob Rest API + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.easemob.im.api.model; + +import java.util.Objects; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.Arrays; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import com.easemob.im.JSON; + +/** + * EMRemoveUserFromGroupBlockListResource + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-01-25T14:51:53.998371+08:00[Asia/Shanghai]") +public class EMRemoveUserFromGroupBlockListResource { + public static final String SERIALIZED_NAME_RESULT = "result"; + @SerializedName(SERIALIZED_NAME_RESULT) + private Boolean result; + + public EMRemoveUserFromGroupBlockListResource() { + } + + public EMRemoveUserFromGroupBlockListResource result(Boolean result) { + + this.result = result; + return this; + } + + /** + * Get result + * @return result + **/ + @javax.annotation.Nullable + public Boolean getResult() { + return result; + } + + + public void setResult(Boolean result) { + this.result = result; + } + + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + EMRemoveUserFromGroupBlockListResource removeUserFromGroupBlockListResource = (EMRemoveUserFromGroupBlockListResource) o; + return Objects.equals(this.result, removeUserFromGroupBlockListResource.result); + } + + @Override + public int hashCode() { + return Objects.hash(result); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class EMRemoveUserFromGroupBlockListResource {\n"); + sb.append(" result: ").append(toIndentedString(result)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("result"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to EMRemoveUserFromGroupBlockListResource + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!EMRemoveUserFromGroupBlockListResource.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format("The required field(s) %s in EMRemoveUserFromGroupBlockListResource is not found in the empty JSON string", EMRemoveUserFromGroupBlockListResource.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!EMRemoveUserFromGroupBlockListResource.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `EMRemoveUserFromGroupBlockListResource` properties. JSON: %s", entry.getKey(), jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!EMRemoveUserFromGroupBlockListResource.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'EMRemoveUserFromGroupBlockListResource' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(EMRemoveUserFromGroupBlockListResource.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, EMRemoveUserFromGroupBlockListResource value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public EMRemoveUserFromGroupBlockListResource read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + return thisAdapter.fromJsonTree(jsonElement); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of EMRemoveUserFromGroupBlockListResource given an JSON string + * + * @param jsonString JSON string + * @return An instance of EMRemoveUserFromGroupBlockListResource + * @throws IOException if the JSON string is invalid with respect to EMRemoveUserFromGroupBlockListResource + */ + public static EMRemoveUserFromGroupBlockListResource fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, EMRemoveUserFromGroupBlockListResource.class); + } + + /** + * Convert an instance of EMRemoveUserFromGroupBlockListResource to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/com/easemob/im/api/model/EMRemoveUserFromGroupBlockListResult.java b/src/main/java/com/easemob/im/api/model/EMRemoveUserFromGroupBlockListResult.java new file mode 100644 index 000000000..6de5e9259 --- /dev/null +++ b/src/main/java/com/easemob/im/api/model/EMRemoveUserFromGroupBlockListResult.java @@ -0,0 +1,210 @@ +/* + * EMService + * Easemob Rest API + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.easemob.im.api.model; + +import java.util.Objects; +import com.easemob.im.api.model.EMRemoveUserFromGroupBlockListResource; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.Arrays; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import com.easemob.im.JSON; + +/** + * EMRemoveUserFromGroupBlockListResult + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-01-25T14:51:53.998371+08:00[Asia/Shanghai]") +public class EMRemoveUserFromGroupBlockListResult { + public static final String SERIALIZED_NAME_DATA = "data"; + @SerializedName(SERIALIZED_NAME_DATA) + private EMRemoveUserFromGroupBlockListResource data; + + public EMRemoveUserFromGroupBlockListResult() { + } + + public EMRemoveUserFromGroupBlockListResult data(EMRemoveUserFromGroupBlockListResource data) { + + this.data = data; + return this; + } + + /** + * Get data + * @return data + **/ + @javax.annotation.Nullable + public EMRemoveUserFromGroupBlockListResource getData() { + return data; + } + + + public void setData(EMRemoveUserFromGroupBlockListResource data) { + this.data = data; + } + + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + EMRemoveUserFromGroupBlockListResult removeUserFromGroupBlockListResult = (EMRemoveUserFromGroupBlockListResult) o; + return Objects.equals(this.data, removeUserFromGroupBlockListResult.data); + } + + @Override + public int hashCode() { + return Objects.hash(data); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class EMRemoveUserFromGroupBlockListResult {\n"); + sb.append(" data: ").append(toIndentedString(data)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("data"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to EMRemoveUserFromGroupBlockListResult + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!EMRemoveUserFromGroupBlockListResult.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format("The required field(s) %s in EMRemoveUserFromGroupBlockListResult is not found in the empty JSON string", EMRemoveUserFromGroupBlockListResult.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!EMRemoveUserFromGroupBlockListResult.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `EMRemoveUserFromGroupBlockListResult` properties. JSON: %s", entry.getKey(), jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // validate the optional field `data` + if (jsonObj.get("data") != null && !jsonObj.get("data").isJsonNull()) { + EMRemoveUserFromGroupBlockListResource.validateJsonElement(jsonObj.get("data")); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!EMRemoveUserFromGroupBlockListResult.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'EMRemoveUserFromGroupBlockListResult' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(EMRemoveUserFromGroupBlockListResult.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, EMRemoveUserFromGroupBlockListResult value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public EMRemoveUserFromGroupBlockListResult read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + return thisAdapter.fromJsonTree(jsonElement); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of EMRemoveUserFromGroupBlockListResult given an JSON string + * + * @param jsonString JSON string + * @return An instance of EMRemoveUserFromGroupBlockListResult + * @throws IOException if the JSON string is invalid with respect to EMRemoveUserFromGroupBlockListResult + */ + public static EMRemoveUserFromGroupBlockListResult fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, EMRemoveUserFromGroupBlockListResult.class); + } + + /** + * Convert an instance of EMRemoveUserFromGroupBlockListResult to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/com/easemob/im/api/model/EMRemoveUserFromGroupWhiteListResult.java b/src/main/java/com/easemob/im/api/model/EMRemoveUserFromGroupWhiteListResult.java new file mode 100644 index 000000000..d8583fe3a --- /dev/null +++ b/src/main/java/com/easemob/im/api/model/EMRemoveUserFromGroupWhiteListResult.java @@ -0,0 +1,205 @@ +/* + * EMService + * Easemob Rest API + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.easemob.im.api.model; + +import java.util.Objects; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.Arrays; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import com.easemob.im.JSON; + +/** + * EMRemoveUserFromGroupWhiteListResult + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-01-25T14:51:53.998371+08:00[Asia/Shanghai]") +public class EMRemoveUserFromGroupWhiteListResult { + public static final String SERIALIZED_NAME_DATA = "data"; + @SerializedName(SERIALIZED_NAME_DATA) + private Object data; + + public EMRemoveUserFromGroupWhiteListResult() { + } + + public EMRemoveUserFromGroupWhiteListResult data(Object data) { + + this.data = data; + return this; + } + + /** + * Get data + * @return data + **/ + @javax.annotation.Nullable + public Object getData() { + return data; + } + + + public void setData(Object data) { + this.data = data; + } + + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + EMRemoveUserFromGroupWhiteListResult removeUserFromGroupWhiteListResult = (EMRemoveUserFromGroupWhiteListResult) o; + return Objects.equals(this.data, removeUserFromGroupWhiteListResult.data); + } + + @Override + public int hashCode() { + return Objects.hash(data); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class EMRemoveUserFromGroupWhiteListResult {\n"); + sb.append(" data: ").append(toIndentedString(data)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("data"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to EMRemoveUserFromGroupWhiteListResult + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!EMRemoveUserFromGroupWhiteListResult.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format("The required field(s) %s in EMRemoveUserFromGroupWhiteListResult is not found in the empty JSON string", EMRemoveUserFromGroupWhiteListResult.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!EMRemoveUserFromGroupWhiteListResult.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `EMRemoveUserFromGroupWhiteListResult` properties. JSON: %s", entry.getKey(), jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!EMRemoveUserFromGroupWhiteListResult.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'EMRemoveUserFromGroupWhiteListResult' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(EMRemoveUserFromGroupWhiteListResult.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, EMRemoveUserFromGroupWhiteListResult value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public EMRemoveUserFromGroupWhiteListResult read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + return thisAdapter.fromJsonTree(jsonElement); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of EMRemoveUserFromGroupWhiteListResult given an JSON string + * + * @param jsonString JSON string + * @return An instance of EMRemoveUserFromGroupWhiteListResult + * @throws IOException if the JSON string is invalid with respect to EMRemoveUserFromGroupWhiteListResult + */ + public static EMRemoveUserFromGroupWhiteListResult fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, EMRemoveUserFromGroupWhiteListResult.class); + } + + /** + * Convert an instance of EMRemoveUserFromGroupWhiteListResult to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/com/easemob/im/api/model/EMRemoveUserFromRoomBlockListResource.java b/src/main/java/com/easemob/im/api/model/EMRemoveUserFromRoomBlockListResource.java new file mode 100644 index 000000000..f016987cd --- /dev/null +++ b/src/main/java/com/easemob/im/api/model/EMRemoveUserFromRoomBlockListResource.java @@ -0,0 +1,205 @@ +/* + * EMService + * Easemob Rest API + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.easemob.im.api.model; + +import java.util.Objects; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.Arrays; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import com.easemob.im.JSON; + +/** + * EMRemoveUserFromRoomBlockListResource + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-01-25T14:51:53.998371+08:00[Asia/Shanghai]") +public class EMRemoveUserFromRoomBlockListResource { + public static final String SERIALIZED_NAME_RESULT = "result"; + @SerializedName(SERIALIZED_NAME_RESULT) + private Boolean result; + + public EMRemoveUserFromRoomBlockListResource() { + } + + public EMRemoveUserFromRoomBlockListResource result(Boolean result) { + + this.result = result; + return this; + } + + /** + * Get result + * @return result + **/ + @javax.annotation.Nullable + public Boolean getResult() { + return result; + } + + + public void setResult(Boolean result) { + this.result = result; + } + + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + EMRemoveUserFromRoomBlockListResource removeUserFromRoomBlockListResource = (EMRemoveUserFromRoomBlockListResource) o; + return Objects.equals(this.result, removeUserFromRoomBlockListResource.result); + } + + @Override + public int hashCode() { + return Objects.hash(result); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class EMRemoveUserFromRoomBlockListResource {\n"); + sb.append(" result: ").append(toIndentedString(result)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("result"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to EMRemoveUserFromRoomBlockListResource + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!EMRemoveUserFromRoomBlockListResource.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format("The required field(s) %s in EMRemoveUserFromRoomBlockListResource is not found in the empty JSON string", EMRemoveUserFromRoomBlockListResource.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!EMRemoveUserFromRoomBlockListResource.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `EMRemoveUserFromRoomBlockListResource` properties. JSON: %s", entry.getKey(), jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!EMRemoveUserFromRoomBlockListResource.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'EMRemoveUserFromRoomBlockListResource' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(EMRemoveUserFromRoomBlockListResource.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, EMRemoveUserFromRoomBlockListResource value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public EMRemoveUserFromRoomBlockListResource read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + return thisAdapter.fromJsonTree(jsonElement); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of EMRemoveUserFromRoomBlockListResource given an JSON string + * + * @param jsonString JSON string + * @return An instance of EMRemoveUserFromRoomBlockListResource + * @throws IOException if the JSON string is invalid with respect to EMRemoveUserFromRoomBlockListResource + */ + public static EMRemoveUserFromRoomBlockListResource fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, EMRemoveUserFromRoomBlockListResource.class); + } + + /** + * Convert an instance of EMRemoveUserFromRoomBlockListResource to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/com/easemob/im/api/model/EMRemoveUserFromRoomBlockListResult.java b/src/main/java/com/easemob/im/api/model/EMRemoveUserFromRoomBlockListResult.java new file mode 100644 index 000000000..dd288eb4c --- /dev/null +++ b/src/main/java/com/easemob/im/api/model/EMRemoveUserFromRoomBlockListResult.java @@ -0,0 +1,210 @@ +/* + * EMService + * Easemob Rest API + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.easemob.im.api.model; + +import java.util.Objects; +import com.easemob.im.api.model.EMRemoveUserFromRoomBlockListResource; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.Arrays; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import com.easemob.im.JSON; + +/** + * EMRemoveUserFromRoomBlockListResult + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-01-25T14:51:53.998371+08:00[Asia/Shanghai]") +public class EMRemoveUserFromRoomBlockListResult { + public static final String SERIALIZED_NAME_DATA = "data"; + @SerializedName(SERIALIZED_NAME_DATA) + private EMRemoveUserFromRoomBlockListResource data; + + public EMRemoveUserFromRoomBlockListResult() { + } + + public EMRemoveUserFromRoomBlockListResult data(EMRemoveUserFromRoomBlockListResource data) { + + this.data = data; + return this; + } + + /** + * Get data + * @return data + **/ + @javax.annotation.Nullable + public EMRemoveUserFromRoomBlockListResource getData() { + return data; + } + + + public void setData(EMRemoveUserFromRoomBlockListResource data) { + this.data = data; + } + + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + EMRemoveUserFromRoomBlockListResult removeUserFromRoomBlockListResult = (EMRemoveUserFromRoomBlockListResult) o; + return Objects.equals(this.data, removeUserFromRoomBlockListResult.data); + } + + @Override + public int hashCode() { + return Objects.hash(data); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class EMRemoveUserFromRoomBlockListResult {\n"); + sb.append(" data: ").append(toIndentedString(data)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("data"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to EMRemoveUserFromRoomBlockListResult + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!EMRemoveUserFromRoomBlockListResult.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format("The required field(s) %s in EMRemoveUserFromRoomBlockListResult is not found in the empty JSON string", EMRemoveUserFromRoomBlockListResult.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!EMRemoveUserFromRoomBlockListResult.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `EMRemoveUserFromRoomBlockListResult` properties. JSON: %s", entry.getKey(), jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // validate the optional field `data` + if (jsonObj.get("data") != null && !jsonObj.get("data").isJsonNull()) { + EMRemoveUserFromRoomBlockListResource.validateJsonElement(jsonObj.get("data")); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!EMRemoveUserFromRoomBlockListResult.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'EMRemoveUserFromRoomBlockListResult' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(EMRemoveUserFromRoomBlockListResult.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, EMRemoveUserFromRoomBlockListResult value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public EMRemoveUserFromRoomBlockListResult read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + return thisAdapter.fromJsonTree(jsonElement); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of EMRemoveUserFromRoomBlockListResult given an JSON string + * + * @param jsonString JSON string + * @return An instance of EMRemoveUserFromRoomBlockListResult + * @throws IOException if the JSON string is invalid with respect to EMRemoveUserFromRoomBlockListResult + */ + public static EMRemoveUserFromRoomBlockListResult fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, EMRemoveUserFromRoomBlockListResult.class); + } + + /** + * Convert an instance of EMRemoveUserFromRoomBlockListResult to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/com/easemob/im/api/model/EMRemoveUserFromRoomResource.java b/src/main/java/com/easemob/im/api/model/EMRemoveUserFromRoomResource.java new file mode 100644 index 000000000..aeabc47b9 --- /dev/null +++ b/src/main/java/com/easemob/im/api/model/EMRemoveUserFromRoomResource.java @@ -0,0 +1,205 @@ +/* + * EMService + * Easemob Rest API + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.easemob.im.api.model; + +import java.util.Objects; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.Arrays; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import com.easemob.im.JSON; + +/** + * EMRemoveUserFromRoomResource + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-01-25T14:51:53.998371+08:00[Asia/Shanghai]") +public class EMRemoveUserFromRoomResource { + public static final String SERIALIZED_NAME_RESULT = "result"; + @SerializedName(SERIALIZED_NAME_RESULT) + private Boolean result; + + public EMRemoveUserFromRoomResource() { + } + + public EMRemoveUserFromRoomResource result(Boolean result) { + + this.result = result; + return this; + } + + /** + * Get result + * @return result + **/ + @javax.annotation.Nullable + public Boolean getResult() { + return result; + } + + + public void setResult(Boolean result) { + this.result = result; + } + + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + EMRemoveUserFromRoomResource removeUserFromRoomResource = (EMRemoveUserFromRoomResource) o; + return Objects.equals(this.result, removeUserFromRoomResource.result); + } + + @Override + public int hashCode() { + return Objects.hash(result); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class EMRemoveUserFromRoomResource {\n"); + sb.append(" result: ").append(toIndentedString(result)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("result"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to EMRemoveUserFromRoomResource + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!EMRemoveUserFromRoomResource.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format("The required field(s) %s in EMRemoveUserFromRoomResource is not found in the empty JSON string", EMRemoveUserFromRoomResource.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!EMRemoveUserFromRoomResource.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `EMRemoveUserFromRoomResource` properties. JSON: %s", entry.getKey(), jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!EMRemoveUserFromRoomResource.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'EMRemoveUserFromRoomResource' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(EMRemoveUserFromRoomResource.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, EMRemoveUserFromRoomResource value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public EMRemoveUserFromRoomResource read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + return thisAdapter.fromJsonTree(jsonElement); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of EMRemoveUserFromRoomResource given an JSON string + * + * @param jsonString JSON string + * @return An instance of EMRemoveUserFromRoomResource + * @throws IOException if the JSON string is invalid with respect to EMRemoveUserFromRoomResource + */ + public static EMRemoveUserFromRoomResource fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, EMRemoveUserFromRoomResource.class); + } + + /** + * Convert an instance of EMRemoveUserFromRoomResource to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/com/easemob/im/api/model/EMRemoveUserFromRoomResult.java b/src/main/java/com/easemob/im/api/model/EMRemoveUserFromRoomResult.java new file mode 100644 index 000000000..ddc809ad6 --- /dev/null +++ b/src/main/java/com/easemob/im/api/model/EMRemoveUserFromRoomResult.java @@ -0,0 +1,210 @@ +/* + * EMService + * Easemob Rest API + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.easemob.im.api.model; + +import java.util.Objects; +import com.easemob.im.api.model.EMRemoveUserFromRoomResource; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.Arrays; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import com.easemob.im.JSON; + +/** + * EMRemoveUserFromRoomResult + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-01-25T14:51:53.998371+08:00[Asia/Shanghai]") +public class EMRemoveUserFromRoomResult { + public static final String SERIALIZED_NAME_DATA = "data"; + @SerializedName(SERIALIZED_NAME_DATA) + private EMRemoveUserFromRoomResource data; + + public EMRemoveUserFromRoomResult() { + } + + public EMRemoveUserFromRoomResult data(EMRemoveUserFromRoomResource data) { + + this.data = data; + return this; + } + + /** + * Get data + * @return data + **/ + @javax.annotation.Nullable + public EMRemoveUserFromRoomResource getData() { + return data; + } + + + public void setData(EMRemoveUserFromRoomResource data) { + this.data = data; + } + + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + EMRemoveUserFromRoomResult removeUserFromRoomResult = (EMRemoveUserFromRoomResult) o; + return Objects.equals(this.data, removeUserFromRoomResult.data); + } + + @Override + public int hashCode() { + return Objects.hash(data); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class EMRemoveUserFromRoomResult {\n"); + sb.append(" data: ").append(toIndentedString(data)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("data"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to EMRemoveUserFromRoomResult + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!EMRemoveUserFromRoomResult.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format("The required field(s) %s in EMRemoveUserFromRoomResult is not found in the empty JSON string", EMRemoveUserFromRoomResult.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!EMRemoveUserFromRoomResult.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `EMRemoveUserFromRoomResult` properties. JSON: %s", entry.getKey(), jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // validate the optional field `data` + if (jsonObj.get("data") != null && !jsonObj.get("data").isJsonNull()) { + EMRemoveUserFromRoomResource.validateJsonElement(jsonObj.get("data")); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!EMRemoveUserFromRoomResult.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'EMRemoveUserFromRoomResult' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(EMRemoveUserFromRoomResult.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, EMRemoveUserFromRoomResult value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public EMRemoveUserFromRoomResult read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + return thisAdapter.fromJsonTree(jsonElement); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of EMRemoveUserFromRoomResult given an JSON string + * + * @param jsonString JSON string + * @return An instance of EMRemoveUserFromRoomResult + * @throws IOException if the JSON string is invalid with respect to EMRemoveUserFromRoomResult + */ + public static EMRemoveUserFromRoomResult fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, EMRemoveUserFromRoomResult.class); + } + + /** + * Convert an instance of EMRemoveUserFromRoomResult to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/com/easemob/im/api/model/EMRemoveUserFromRoomWhiteListResult.java b/src/main/java/com/easemob/im/api/model/EMRemoveUserFromRoomWhiteListResult.java new file mode 100644 index 000000000..f5d6c67e9 --- /dev/null +++ b/src/main/java/com/easemob/im/api/model/EMRemoveUserFromRoomWhiteListResult.java @@ -0,0 +1,210 @@ +/* + * EMService + * Easemob Rest API + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.easemob.im.api.model; + +import java.util.Objects; +import com.easemob.im.api.model.EMAddUserToRoomWhiteListResource; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.Arrays; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import com.easemob.im.JSON; + +/** + * EMRemoveUserFromRoomWhiteListResult + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-01-25T14:51:53.998371+08:00[Asia/Shanghai]") +public class EMRemoveUserFromRoomWhiteListResult { + public static final String SERIALIZED_NAME_DATA = "data"; + @SerializedName(SERIALIZED_NAME_DATA) + private EMAddUserToRoomWhiteListResource data; + + public EMRemoveUserFromRoomWhiteListResult() { + } + + public EMRemoveUserFromRoomWhiteListResult data(EMAddUserToRoomWhiteListResource data) { + + this.data = data; + return this; + } + + /** + * Get data + * @return data + **/ + @javax.annotation.Nullable + public EMAddUserToRoomWhiteListResource getData() { + return data; + } + + + public void setData(EMAddUserToRoomWhiteListResource data) { + this.data = data; + } + + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + EMRemoveUserFromRoomWhiteListResult removeUserFromRoomWhiteListResult = (EMRemoveUserFromRoomWhiteListResult) o; + return Objects.equals(this.data, removeUserFromRoomWhiteListResult.data); + } + + @Override + public int hashCode() { + return Objects.hash(data); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class EMRemoveUserFromRoomWhiteListResult {\n"); + sb.append(" data: ").append(toIndentedString(data)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("data"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to EMRemoveUserFromRoomWhiteListResult + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!EMRemoveUserFromRoomWhiteListResult.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format("The required field(s) %s in EMRemoveUserFromRoomWhiteListResult is not found in the empty JSON string", EMRemoveUserFromRoomWhiteListResult.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!EMRemoveUserFromRoomWhiteListResult.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `EMRemoveUserFromRoomWhiteListResult` properties. JSON: %s", entry.getKey(), jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // validate the optional field `data` + if (jsonObj.get("data") != null && !jsonObj.get("data").isJsonNull()) { + EMAddUserToRoomWhiteListResource.validateJsonElement(jsonObj.get("data")); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!EMRemoveUserFromRoomWhiteListResult.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'EMRemoveUserFromRoomWhiteListResult' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(EMRemoveUserFromRoomWhiteListResult.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, EMRemoveUserFromRoomWhiteListResult value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public EMRemoveUserFromRoomWhiteListResult read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + return thisAdapter.fromJsonTree(jsonElement); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of EMRemoveUserFromRoomWhiteListResult given an JSON string + * + * @param jsonString JSON string + * @return An instance of EMRemoveUserFromRoomWhiteListResult + * @throws IOException if the JSON string is invalid with respect to EMRemoveUserFromRoomWhiteListResult + */ + public static EMRemoveUserFromRoomWhiteListResult fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, EMRemoveUserFromRoomWhiteListResult.class); + } + + /** + * Convert an instance of EMRemoveUserFromRoomWhiteListResult to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/com/easemob/im/api/model/EMRemoveUserToGroupResource.java b/src/main/java/com/easemob/im/api/model/EMRemoveUserToGroupResource.java new file mode 100644 index 000000000..1efe55bb8 --- /dev/null +++ b/src/main/java/com/easemob/im/api/model/EMRemoveUserToGroupResource.java @@ -0,0 +1,205 @@ +/* + * EMService + * Easemob Rest API + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.easemob.im.api.model; + +import java.util.Objects; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.Arrays; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import com.easemob.im.JSON; + +/** + * EMRemoveUserToGroupResource + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-01-25T14:51:53.998371+08:00[Asia/Shanghai]") +public class EMRemoveUserToGroupResource { + public static final String SERIALIZED_NAME_RESULT = "result"; + @SerializedName(SERIALIZED_NAME_RESULT) + private Boolean result; + + public EMRemoveUserToGroupResource() { + } + + public EMRemoveUserToGroupResource result(Boolean result) { + + this.result = result; + return this; + } + + /** + * Get result + * @return result + **/ + @javax.annotation.Nullable + public Boolean getResult() { + return result; + } + + + public void setResult(Boolean result) { + this.result = result; + } + + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + EMRemoveUserToGroupResource removeUserToGroupResource = (EMRemoveUserToGroupResource) o; + return Objects.equals(this.result, removeUserToGroupResource.result); + } + + @Override + public int hashCode() { + return Objects.hash(result); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class EMRemoveUserToGroupResource {\n"); + sb.append(" result: ").append(toIndentedString(result)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("result"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to EMRemoveUserToGroupResource + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!EMRemoveUserToGroupResource.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format("The required field(s) %s in EMRemoveUserToGroupResource is not found in the empty JSON string", EMRemoveUserToGroupResource.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!EMRemoveUserToGroupResource.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `EMRemoveUserToGroupResource` properties. JSON: %s", entry.getKey(), jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!EMRemoveUserToGroupResource.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'EMRemoveUserToGroupResource' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(EMRemoveUserToGroupResource.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, EMRemoveUserToGroupResource value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public EMRemoveUserToGroupResource read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + return thisAdapter.fromJsonTree(jsonElement); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of EMRemoveUserToGroupResource given an JSON string + * + * @param jsonString JSON string + * @return An instance of EMRemoveUserToGroupResource + * @throws IOException if the JSON string is invalid with respect to EMRemoveUserToGroupResource + */ + public static EMRemoveUserToGroupResource fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, EMRemoveUserToGroupResource.class); + } + + /** + * Convert an instance of EMRemoveUserToGroupResource to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/com/easemob/im/api/model/EMRemoveUserToGroupResult.java b/src/main/java/com/easemob/im/api/model/EMRemoveUserToGroupResult.java new file mode 100644 index 000000000..f2ba2f9f9 --- /dev/null +++ b/src/main/java/com/easemob/im/api/model/EMRemoveUserToGroupResult.java @@ -0,0 +1,210 @@ +/* + * EMService + * Easemob Rest API + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.easemob.im.api.model; + +import java.util.Objects; +import com.easemob.im.api.model.EMRemoveUserToGroupResource; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.Arrays; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import com.easemob.im.JSON; + +/** + * EMRemoveUserToGroupResult + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-01-25T14:51:53.998371+08:00[Asia/Shanghai]") +public class EMRemoveUserToGroupResult { + public static final String SERIALIZED_NAME_DATA = "data"; + @SerializedName(SERIALIZED_NAME_DATA) + private EMRemoveUserToGroupResource data; + + public EMRemoveUserToGroupResult() { + } + + public EMRemoveUserToGroupResult data(EMRemoveUserToGroupResource data) { + + this.data = data; + return this; + } + + /** + * Get data + * @return data + **/ + @javax.annotation.Nullable + public EMRemoveUserToGroupResource getData() { + return data; + } + + + public void setData(EMRemoveUserToGroupResource data) { + this.data = data; + } + + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + EMRemoveUserToGroupResult removeUserToGroupResult = (EMRemoveUserToGroupResult) o; + return Objects.equals(this.data, removeUserToGroupResult.data); + } + + @Override + public int hashCode() { + return Objects.hash(data); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class EMRemoveUserToGroupResult {\n"); + sb.append(" data: ").append(toIndentedString(data)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("data"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to EMRemoveUserToGroupResult + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!EMRemoveUserToGroupResult.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format("The required field(s) %s in EMRemoveUserToGroupResult is not found in the empty JSON string", EMRemoveUserToGroupResult.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!EMRemoveUserToGroupResult.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `EMRemoveUserToGroupResult` properties. JSON: %s", entry.getKey(), jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // validate the optional field `data` + if (jsonObj.get("data") != null && !jsonObj.get("data").isJsonNull()) { + EMRemoveUserToGroupResource.validateJsonElement(jsonObj.get("data")); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!EMRemoveUserToGroupResult.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'EMRemoveUserToGroupResult' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(EMRemoveUserToGroupResult.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, EMRemoveUserToGroupResult value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public EMRemoveUserToGroupResult read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + return thisAdapter.fromJsonTree(jsonElement); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of EMRemoveUserToGroupResult given an JSON string + * + * @param jsonString JSON string + * @return An instance of EMRemoveUserToGroupResult + * @throws IOException if the JSON string is invalid with respect to EMRemoveUserToGroupResult + */ + public static EMRemoveUserToGroupResult fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, EMRemoveUserToGroupResult.class); + } + + /** + * Convert an instance of EMRemoveUserToGroupResult to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/com/easemob/im/api/model/EMRoomBlockListResource.java b/src/main/java/com/easemob/im/api/model/EMRoomBlockListResource.java new file mode 100644 index 000000000..a2155efb8 --- /dev/null +++ b/src/main/java/com/easemob/im/api/model/EMRoomBlockListResource.java @@ -0,0 +1,267 @@ +/* + * EMService + * Easemob Rest API + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.easemob.im.api.model; + +import java.util.Objects; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.Arrays; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import com.easemob.im.JSON; + +/** + * EMRoomBlockListResource + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-01-25T14:51:53.998371+08:00[Asia/Shanghai]") +public class EMRoomBlockListResource { + public static final String SERIALIZED_NAME_RESULT = "result"; + @SerializedName(SERIALIZED_NAME_RESULT) + private Boolean result; + + public static final String SERIALIZED_NAME_REASON = "reason"; + @SerializedName(SERIALIZED_NAME_REASON) + private String reason; + + public static final String SERIALIZED_NAME_USER = "user"; + @SerializedName(SERIALIZED_NAME_USER) + private String user; + + public EMRoomBlockListResource() { + } + + public EMRoomBlockListResource result(Boolean result) { + + this.result = result; + return this; + } + + /** + * 是否成功批量添加用户至聊天室黑名单: - true:是; - false:否 + * @return result + **/ + @javax.annotation.Nullable + public Boolean getResult() { + return result; + } + + + public void setResult(Boolean result) { + this.result = result; + } + + + public EMRoomBlockListResource reason(String reason) { + + this.reason = reason; + return this; + } + + /** + * 添加失败的原因 + * @return reason + **/ + @javax.annotation.Nullable + public String getReason() { + return reason; + } + + + public void setReason(String reason) { + this.reason = reason; + } + + + public EMRoomBlockListResource user(String user) { + + this.user = user; + return this; + } + + /** + * 添加的用户 ID + * @return user + **/ + @javax.annotation.Nullable + public String getUser() { + return user; + } + + + public void setUser(String user) { + this.user = user; + } + + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + EMRoomBlockListResource roomBlockListResource = (EMRoomBlockListResource) o; + return Objects.equals(this.result, roomBlockListResource.result) && + Objects.equals(this.reason, roomBlockListResource.reason) && + Objects.equals(this.user, roomBlockListResource.user); + } + + @Override + public int hashCode() { + return Objects.hash(result, reason, user); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class EMRoomBlockListResource {\n"); + sb.append(" result: ").append(toIndentedString(result)).append("\n"); + sb.append(" reason: ").append(toIndentedString(reason)).append("\n"); + sb.append(" user: ").append(toIndentedString(user)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("result"); + openapiFields.add("reason"); + openapiFields.add("user"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to EMRoomBlockListResource + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!EMRoomBlockListResource.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format("The required field(s) %s in EMRoomBlockListResource is not found in the empty JSON string", EMRoomBlockListResource.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!EMRoomBlockListResource.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `EMRoomBlockListResource` properties. JSON: %s", entry.getKey(), jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + if ((jsonObj.get("reason") != null && !jsonObj.get("reason").isJsonNull()) && !jsonObj.get("reason").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `reason` to be a primitive type in the JSON string but got `%s`", jsonObj.get("reason").toString())); + } + if ((jsonObj.get("user") != null && !jsonObj.get("user").isJsonNull()) && !jsonObj.get("user").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `user` to be a primitive type in the JSON string but got `%s`", jsonObj.get("user").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!EMRoomBlockListResource.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'EMRoomBlockListResource' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(EMRoomBlockListResource.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, EMRoomBlockListResource value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public EMRoomBlockListResource read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + return thisAdapter.fromJsonTree(jsonElement); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of EMRoomBlockListResource given an JSON string + * + * @param jsonString JSON string + * @return An instance of EMRoomBlockListResource + * @throws IOException if the JSON string is invalid with respect to EMRoomBlockListResource + */ + public static EMRoomBlockListResource fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, EMRoomBlockListResource.class); + } + + /** + * Convert an instance of EMRoomBlockListResource to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/com/easemob/im/api/model/EMRoomMuteMemberResource.java b/src/main/java/com/easemob/im/api/model/EMRoomMuteMemberResource.java new file mode 100644 index 000000000..ae52d209e --- /dev/null +++ b/src/main/java/com/easemob/im/api/model/EMRoomMuteMemberResource.java @@ -0,0 +1,237 @@ +/* + * EMService + * Easemob Rest API + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.easemob.im.api.model; + +import java.util.Objects; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.math.BigDecimal; +import java.util.Arrays; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import com.easemob.im.JSON; + +/** + * EMRoomMuteMemberResource + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-01-25T14:51:53.998371+08:00[Asia/Shanghai]") +public class EMRoomMuteMemberResource { + public static final String SERIALIZED_NAME_EXPIRE = "expire"; + @SerializedName(SERIALIZED_NAME_EXPIRE) + private BigDecimal expire; + + public static final String SERIALIZED_NAME_USER = "user"; + @SerializedName(SERIALIZED_NAME_USER) + private String user; + + public EMRoomMuteMemberResource() { + } + + public EMRoomMuteMemberResource expire(BigDecimal expire) { + + this.expire = expire; + return this; + } + + /** + * 禁言到期的 Unix 时间戳,单位为毫秒 + * @return expire + **/ + @javax.annotation.Nullable + public BigDecimal getExpire() { + return expire; + } + + + public void setExpire(BigDecimal expire) { + this.expire = expire; + } + + + public EMRoomMuteMemberResource user(String user) { + + this.user = user; + return this; + } + + /** + * 被禁言的用户 ID + * @return user + **/ + @javax.annotation.Nullable + public String getUser() { + return user; + } + + + public void setUser(String user) { + this.user = user; + } + + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + EMRoomMuteMemberResource roomMuteMemberResource = (EMRoomMuteMemberResource) o; + return Objects.equals(this.expire, roomMuteMemberResource.expire) && + Objects.equals(this.user, roomMuteMemberResource.user); + } + + @Override + public int hashCode() { + return Objects.hash(expire, user); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class EMRoomMuteMemberResource {\n"); + sb.append(" expire: ").append(toIndentedString(expire)).append("\n"); + sb.append(" user: ").append(toIndentedString(user)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("expire"); + openapiFields.add("user"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to EMRoomMuteMemberResource + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!EMRoomMuteMemberResource.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format("The required field(s) %s in EMRoomMuteMemberResource is not found in the empty JSON string", EMRoomMuteMemberResource.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!EMRoomMuteMemberResource.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `EMRoomMuteMemberResource` properties. JSON: %s", entry.getKey(), jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + if ((jsonObj.get("user") != null && !jsonObj.get("user").isJsonNull()) && !jsonObj.get("user").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `user` to be a primitive type in the JSON string but got `%s`", jsonObj.get("user").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!EMRoomMuteMemberResource.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'EMRoomMuteMemberResource' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(EMRoomMuteMemberResource.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, EMRoomMuteMemberResource value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public EMRoomMuteMemberResource read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + return thisAdapter.fromJsonTree(jsonElement); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of EMRoomMuteMemberResource given an JSON string + * + * @param jsonString JSON string + * @return An instance of EMRoomMuteMemberResource + * @throws IOException if the JSON string is invalid with respect to EMRoomMuteMemberResource + */ + public static EMRoomMuteMemberResource fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, EMRoomMuteMemberResource.class); + } + + /** + * Convert an instance of EMRoomMuteMemberResource to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/com/easemob/im/api/model/EMRoomWhiteListResource.java b/src/main/java/com/easemob/im/api/model/EMRoomWhiteListResource.java new file mode 100644 index 000000000..386930a8d --- /dev/null +++ b/src/main/java/com/easemob/im/api/model/EMRoomWhiteListResource.java @@ -0,0 +1,267 @@ +/* + * EMService + * Easemob Rest API + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.easemob.im.api.model; + +import java.util.Objects; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.Arrays; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import com.easemob.im.JSON; + +/** + * EMRoomWhiteListResource + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-01-25T14:51:53.998371+08:00[Asia/Shanghai]") +public class EMRoomWhiteListResource { + public static final String SERIALIZED_NAME_RESULT = "result"; + @SerializedName(SERIALIZED_NAME_RESULT) + private Boolean result; + + public static final String SERIALIZED_NAME_REASON = "reason"; + @SerializedName(SERIALIZED_NAME_REASON) + private String reason; + + public static final String SERIALIZED_NAME_USER = "user"; + @SerializedName(SERIALIZED_NAME_USER) + private String user; + + public EMRoomWhiteListResource() { + } + + public EMRoomWhiteListResource result(Boolean result) { + + this.result = result; + return this; + } + + /** + * 是否成功将用户批量添加至聊天室白名单: - true:是; - false:否 + * @return result + **/ + @javax.annotation.Nullable + public Boolean getResult() { + return result; + } + + + public void setResult(Boolean result) { + this.result = result; + } + + + public EMRoomWhiteListResource reason(String reason) { + + this.reason = reason; + return this; + } + + /** + * 添加失败的原因 + * @return reason + **/ + @javax.annotation.Nullable + public String getReason() { + return reason; + } + + + public void setReason(String reason) { + this.reason = reason; + } + + + public EMRoomWhiteListResource user(String user) { + + this.user = user; + return this; + } + + /** + * 添加的用户 ID + * @return user + **/ + @javax.annotation.Nullable + public String getUser() { + return user; + } + + + public void setUser(String user) { + this.user = user; + } + + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + EMRoomWhiteListResource roomWhiteListResource = (EMRoomWhiteListResource) o; + return Objects.equals(this.result, roomWhiteListResource.result) && + Objects.equals(this.reason, roomWhiteListResource.reason) && + Objects.equals(this.user, roomWhiteListResource.user); + } + + @Override + public int hashCode() { + return Objects.hash(result, reason, user); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class EMRoomWhiteListResource {\n"); + sb.append(" result: ").append(toIndentedString(result)).append("\n"); + sb.append(" reason: ").append(toIndentedString(reason)).append("\n"); + sb.append(" user: ").append(toIndentedString(user)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("result"); + openapiFields.add("reason"); + openapiFields.add("user"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to EMRoomWhiteListResource + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!EMRoomWhiteListResource.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format("The required field(s) %s in EMRoomWhiteListResource is not found in the empty JSON string", EMRoomWhiteListResource.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!EMRoomWhiteListResource.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `EMRoomWhiteListResource` properties. JSON: %s", entry.getKey(), jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + if ((jsonObj.get("reason") != null && !jsonObj.get("reason").isJsonNull()) && !jsonObj.get("reason").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `reason` to be a primitive type in the JSON string but got `%s`", jsonObj.get("reason").toString())); + } + if ((jsonObj.get("user") != null && !jsonObj.get("user").isJsonNull()) && !jsonObj.get("user").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `user` to be a primitive type in the JSON string but got `%s`", jsonObj.get("user").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!EMRoomWhiteListResource.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'EMRoomWhiteListResource' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(EMRoomWhiteListResource.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, EMRoomWhiteListResource value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public EMRoomWhiteListResource read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + return thisAdapter.fromJsonTree(jsonElement); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of EMRoomWhiteListResource given an JSON string + * + * @param jsonString JSON string + * @return An instance of EMRoomWhiteListResource + * @throws IOException if the JSON string is invalid with respect to EMRoomWhiteListResource + */ + public static EMRoomWhiteListResource fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, EMRoomWhiteListResource.class); + } + + /** + * Convert an instance of EMRoomWhiteListResource to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/com/easemob/im/api/model/EMSendMessageResult.java b/src/main/java/com/easemob/im/api/model/EMSendMessageResult.java new file mode 100644 index 000000000..132137f18 --- /dev/null +++ b/src/main/java/com/easemob/im/api/model/EMSendMessageResult.java @@ -0,0 +1,205 @@ +/* + * EMService + * Easemob Rest API + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.easemob.im.api.model; + +import java.util.Objects; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.Arrays; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import com.easemob.im.JSON; + +/** + * EMSendMessageResult + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-01-25T14:51:53.998371+08:00[Asia/Shanghai]") +public class EMSendMessageResult { + public static final String SERIALIZED_NAME_DATA = "data"; + @SerializedName(SERIALIZED_NAME_DATA) + private Object data; + + public EMSendMessageResult() { + } + + public EMSendMessageResult data(Object data) { + + this.data = data; + return this; + } + + /** + * Get data + * @return data + **/ + @javax.annotation.Nullable + public Object getData() { + return data; + } + + + public void setData(Object data) { + this.data = data; + } + + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + EMSendMessageResult sendMessageResult = (EMSendMessageResult) o; + return Objects.equals(this.data, sendMessageResult.data); + } + + @Override + public int hashCode() { + return Objects.hash(data); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class EMSendMessageResult {\n"); + sb.append(" data: ").append(toIndentedString(data)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("data"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to EMSendMessageResult + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!EMSendMessageResult.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format("The required field(s) %s in EMSendMessageResult is not found in the empty JSON string", EMSendMessageResult.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!EMSendMessageResult.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `EMSendMessageResult` properties. JSON: %s", entry.getKey(), jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!EMSendMessageResult.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'EMSendMessageResult' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(EMSendMessageResult.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, EMSendMessageResult value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public EMSendMessageResult read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + return thisAdapter.fromJsonTree(jsonElement); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of EMSendMessageResult given an JSON string + * + * @param jsonString JSON string + * @return An instance of EMSendMessageResult + * @throws IOException if the JSON string is invalid with respect to EMSendMessageResult + */ + public static EMSendMessageResult fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, EMSendMessageResult.class); + } + + /** + * Convert an instance of EMSendMessageResult to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/com/easemob/im/api/model/EMSetContactNote.java b/src/main/java/com/easemob/im/api/model/EMSetContactNote.java new file mode 100644 index 000000000..e62d33d90 --- /dev/null +++ b/src/main/java/com/easemob/im/api/model/EMSetContactNote.java @@ -0,0 +1,208 @@ +/* + * EMService + * Easemob Rest API + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.easemob.im.api.model; + +import java.util.Objects; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.Arrays; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import com.easemob.im.JSON; + +/** + * EMSetContactNote + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-01-25T14:51:53.998371+08:00[Asia/Shanghai]") +public class EMSetContactNote { + public static final String SERIALIZED_NAME_REMARK = "remark"; + @SerializedName(SERIALIZED_NAME_REMARK) + private String remark; + + public EMSetContactNote() { + } + + public EMSetContactNote remark(String remark) { + + this.remark = remark; + return this; + } + + /** + * 好友备注。好友备注的长度不能超过 100 个字符 + * @return remark + **/ + @javax.annotation.Nullable + public String getRemark() { + return remark; + } + + + public void setRemark(String remark) { + this.remark = remark; + } + + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + EMSetContactNote setContactNote = (EMSetContactNote) o; + return Objects.equals(this.remark, setContactNote.remark); + } + + @Override + public int hashCode() { + return Objects.hash(remark); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class EMSetContactNote {\n"); + sb.append(" remark: ").append(toIndentedString(remark)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("remark"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to EMSetContactNote + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!EMSetContactNote.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format("The required field(s) %s in EMSetContactNote is not found in the empty JSON string", EMSetContactNote.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!EMSetContactNote.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `EMSetContactNote` properties. JSON: %s", entry.getKey(), jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + if ((jsonObj.get("remark") != null && !jsonObj.get("remark").isJsonNull()) && !jsonObj.get("remark").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `remark` to be a primitive type in the JSON string but got `%s`", jsonObj.get("remark").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!EMSetContactNote.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'EMSetContactNote' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(EMSetContactNote.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, EMSetContactNote value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public EMSetContactNote read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + return thisAdapter.fromJsonTree(jsonElement); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of EMSetContactNote given an JSON string + * + * @param jsonString JSON string + * @return An instance of EMSetContactNote + * @throws IOException if the JSON string is invalid with respect to EMSetContactNote + */ + public static EMSetContactNote fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, EMSetContactNote.class); + } + + /** + * Convert an instance of EMSetContactNote to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/com/easemob/im/api/model/EMSetContactNoteResult.java b/src/main/java/com/easemob/im/api/model/EMSetContactNoteResult.java new file mode 100644 index 000000000..1bc58d216 --- /dev/null +++ b/src/main/java/com/easemob/im/api/model/EMSetContactNoteResult.java @@ -0,0 +1,208 @@ +/* + * EMService + * Easemob Rest API + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.easemob.im.api.model; + +import java.util.Objects; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.Arrays; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import com.easemob.im.JSON; + +/** + * EMSetContactNoteResult + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-01-25T14:51:53.998371+08:00[Asia/Shanghai]") +public class EMSetContactNoteResult { + public static final String SERIALIZED_NAME_STATUS = "status"; + @SerializedName(SERIALIZED_NAME_STATUS) + private String status; + + public EMSetContactNoteResult() { + } + + public EMSetContactNoteResult status(String status) { + + this.status = status; + return this; + } + + /** + * Get status + * @return status + **/ + @javax.annotation.Nullable + public String getStatus() { + return status; + } + + + public void setStatus(String status) { + this.status = status; + } + + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + EMSetContactNoteResult setContactNoteResult = (EMSetContactNoteResult) o; + return Objects.equals(this.status, setContactNoteResult.status); + } + + @Override + public int hashCode() { + return Objects.hash(status); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class EMSetContactNoteResult {\n"); + sb.append(" status: ").append(toIndentedString(status)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("status"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to EMSetContactNoteResult + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!EMSetContactNoteResult.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format("The required field(s) %s in EMSetContactNoteResult is not found in the empty JSON string", EMSetContactNoteResult.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!EMSetContactNoteResult.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `EMSetContactNoteResult` properties. JSON: %s", entry.getKey(), jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + if ((jsonObj.get("status") != null && !jsonObj.get("status").isJsonNull()) && !jsonObj.get("status").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `status` to be a primitive type in the JSON string but got `%s`", jsonObj.get("status").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!EMSetContactNoteResult.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'EMSetContactNoteResult' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(EMSetContactNoteResult.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, EMSetContactNoteResult value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public EMSetContactNoteResult read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + return thisAdapter.fromJsonTree(jsonElement); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of EMSetContactNoteResult given an JSON string + * + * @param jsonString JSON string + * @return An instance of EMSetContactNoteResult + * @throws IOException if the JSON string is invalid with respect to EMSetContactNoteResult + */ + public static EMSetContactNoteResult fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, EMSetContactNoteResult.class); + } + + /** + * Convert an instance of EMSetContactNoteResult to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/com/easemob/im/api/model/EMSetRoomCustomAttributes.java b/src/main/java/com/easemob/im/api/model/EMSetRoomCustomAttributes.java new file mode 100644 index 000000000..41b6abe66 --- /dev/null +++ b/src/main/java/com/easemob/im/api/model/EMSetRoomCustomAttributes.java @@ -0,0 +1,236 @@ +/* + * EMService + * Easemob Rest API + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.easemob.im.api.model; + +import java.util.Objects; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.Arrays; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import com.easemob.im.JSON; + +/** + * EMSetRoomCustomAttributes + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-01-24T18:15:02.198321+08:00[Asia/Shanghai]") +public class EMSetRoomCustomAttributes { + public static final String SERIALIZED_NAME_META_DATA = "metaData"; + @SerializedName(SERIALIZED_NAME_META_DATA) + private Object metaData; + + public static final String SERIALIZED_NAME_AUTO_DELETE = "autoDelete"; + @SerializedName(SERIALIZED_NAME_AUTO_DELETE) + private String autoDelete; + + public EMSetRoomCustomAttributes() { + } + + public EMSetRoomCustomAttributes metaData(Object metaData) { + + this.metaData = metaData; + return this; + } + + /** + * 聊天室的自定义属性,存储为键值对(key-value)集合,即 Map<String,String>。该集合中最多可包含 10 个键值对,在每个键值对中,key 为属性名称,最多可包含 128 个字符;value 为属性值,不能超过 4096 个字符。每个聊天室最多可有 100 个自定义属性,每个应用的聊天室自定义属性总大小为 10 GB。 key 支持以下字符集: - 26 个小写英文字母 a-z; - 26 个大写英文字母 A-Z; - 10 个数字 0-9; - “_”, “-”, “.” + * @return metaData + **/ + @javax.annotation.Nullable + public Object getMetaData() { + return metaData; + } + + + public void setMetaData(Object metaData) { + this.metaData = metaData; + } + + + public EMSetRoomCustomAttributes autoDelete(String autoDelete) { + + this.autoDelete = autoDelete; + return this; + } + + /** + * 当前成员退出聊天室时是否自动删除该自定义属性。 -(默认)'DELETE':是; - 'NO_DELETE':否 + * @return autoDelete + **/ + @javax.annotation.Nullable + public String getAutoDelete() { + return autoDelete; + } + + + public void setAutoDelete(String autoDelete) { + this.autoDelete = autoDelete; + } + + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + EMSetRoomCustomAttributes setRoomCustomAttributes = (EMSetRoomCustomAttributes) o; + return Objects.equals(this.metaData, setRoomCustomAttributes.metaData) && + Objects.equals(this.autoDelete, setRoomCustomAttributes.autoDelete); + } + + @Override + public int hashCode() { + return Objects.hash(metaData, autoDelete); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class EMSetRoomCustomAttributes {\n"); + sb.append(" metaData: ").append(toIndentedString(metaData)).append("\n"); + sb.append(" autoDelete: ").append(toIndentedString(autoDelete)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("metaData"); + openapiFields.add("autoDelete"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to EMSetRoomCustomAttributes + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!EMSetRoomCustomAttributes.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format("The required field(s) %s in EMSetRoomCustomAttributes is not found in the empty JSON string", EMSetRoomCustomAttributes.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!EMSetRoomCustomAttributes.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `EMSetRoomCustomAttributes` properties. JSON: %s", entry.getKey(), jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + if ((jsonObj.get("autoDelete") != null && !jsonObj.get("autoDelete").isJsonNull()) && !jsonObj.get("autoDelete").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `autoDelete` to be a primitive type in the JSON string but got `%s`", jsonObj.get("autoDelete").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!EMSetRoomCustomAttributes.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'EMSetRoomCustomAttributes' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(EMSetRoomCustomAttributes.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, EMSetRoomCustomAttributes value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public EMSetRoomCustomAttributes read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + return thisAdapter.fromJsonTree(jsonElement); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of EMSetRoomCustomAttributes given an JSON string + * + * @param jsonString JSON string + * @return An instance of EMSetRoomCustomAttributes + * @throws IOException if the JSON string is invalid with respect to EMSetRoomCustomAttributes + */ + public static EMSetRoomCustomAttributes fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, EMSetRoomCustomAttributes.class); + } + + /** + * Convert an instance of EMSetRoomCustomAttributes to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/com/easemob/im/api/model/EMSetRoomCustomAttributesResource.java b/src/main/java/com/easemob/im/api/model/EMSetRoomCustomAttributesResource.java new file mode 100644 index 000000000..af5db9217 --- /dev/null +++ b/src/main/java/com/easemob/im/api/model/EMSetRoomCustomAttributesResource.java @@ -0,0 +1,247 @@ +/* + * EMService + * Easemob Rest API + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.easemob.im.api.model; + +import java.util.Objects; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import com.easemob.im.JSON; + +/** + * EMSetRoomCustomAttributesResource + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-01-25T14:51:53.998371+08:00[Asia/Shanghai]") +public class EMSetRoomCustomAttributesResource { + public static final String SERIALIZED_NAME_SUCCESS_KEYS = "successKeys"; + @SerializedName(SERIALIZED_NAME_SUCCESS_KEYS) + private List successKeys; + + public static final String SERIALIZED_NAME_ERROR_KEYS = "errorKeys"; + @SerializedName(SERIALIZED_NAME_ERROR_KEYS) + private Object errorKeys; + + public EMSetRoomCustomAttributesResource() { + } + + public EMSetRoomCustomAttributesResource successKeys(List successKeys) { + + this.successKeys = successKeys; + return this; + } + + public EMSetRoomCustomAttributesResource addSuccessKeysItem(String successKeysItem) { + if (this.successKeys == null) { + this.successKeys = new ArrayList<>(); + } + this.successKeys.add(successKeysItem); + return this; + } + + /** + * Get successKeys + * @return successKeys + **/ + @javax.annotation.Nullable + public List getSuccessKeys() { + return successKeys; + } + + + public void setSuccessKeys(List successKeys) { + this.successKeys = successKeys; + } + + + public EMSetRoomCustomAttributesResource errorKeys(Object errorKeys) { + + this.errorKeys = errorKeys; + return this; + } + + /** + * Get errorKeys + * @return errorKeys + **/ + @javax.annotation.Nullable + public Object getErrorKeys() { + return errorKeys; + } + + + public void setErrorKeys(Object errorKeys) { + this.errorKeys = errorKeys; + } + + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + EMSetRoomCustomAttributesResource setRoomCustomAttributesResource = (EMSetRoomCustomAttributesResource) o; + return Objects.equals(this.successKeys, setRoomCustomAttributesResource.successKeys) && + Objects.equals(this.errorKeys, setRoomCustomAttributesResource.errorKeys); + } + + @Override + public int hashCode() { + return Objects.hash(successKeys, errorKeys); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class EMSetRoomCustomAttributesResource {\n"); + sb.append(" successKeys: ").append(toIndentedString(successKeys)).append("\n"); + sb.append(" errorKeys: ").append(toIndentedString(errorKeys)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("successKeys"); + openapiFields.add("errorKeys"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to EMSetRoomCustomAttributesResource + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!EMSetRoomCustomAttributesResource.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format("The required field(s) %s in EMSetRoomCustomAttributesResource is not found in the empty JSON string", EMSetRoomCustomAttributesResource.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!EMSetRoomCustomAttributesResource.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `EMSetRoomCustomAttributesResource` properties. JSON: %s", entry.getKey(), jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // ensure the optional json data is an array if present + if (jsonObj.get("successKeys") != null && !jsonObj.get("successKeys").isJsonNull() && !jsonObj.get("successKeys").isJsonArray()) { + throw new IllegalArgumentException(String.format("Expected the field `successKeys` to be an array in the JSON string but got `%s`", jsonObj.get("successKeys").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!EMSetRoomCustomAttributesResource.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'EMSetRoomCustomAttributesResource' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(EMSetRoomCustomAttributesResource.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, EMSetRoomCustomAttributesResource value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public EMSetRoomCustomAttributesResource read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + return thisAdapter.fromJsonTree(jsonElement); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of EMSetRoomCustomAttributesResource given an JSON string + * + * @param jsonString JSON string + * @return An instance of EMSetRoomCustomAttributesResource + * @throws IOException if the JSON string is invalid with respect to EMSetRoomCustomAttributesResource + */ + public static EMSetRoomCustomAttributesResource fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, EMSetRoomCustomAttributesResource.class); + } + + /** + * Convert an instance of EMSetRoomCustomAttributesResource to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/com/easemob/im/api/model/EMSetRoomCustomAttributesResult.java b/src/main/java/com/easemob/im/api/model/EMSetRoomCustomAttributesResult.java new file mode 100644 index 000000000..4ca1ac36a --- /dev/null +++ b/src/main/java/com/easemob/im/api/model/EMSetRoomCustomAttributesResult.java @@ -0,0 +1,210 @@ +/* + * EMService + * Easemob Rest API + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.easemob.im.api.model; + +import java.util.Objects; +import com.easemob.im.api.model.EMSetRoomCustomAttributesResource; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.Arrays; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import com.easemob.im.JSON; + +/** + * EMSetRoomCustomAttributesResult + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-01-25T14:51:53.998371+08:00[Asia/Shanghai]") +public class EMSetRoomCustomAttributesResult { + public static final String SERIALIZED_NAME_DATA = "data"; + @SerializedName(SERIALIZED_NAME_DATA) + private EMSetRoomCustomAttributesResource data; + + public EMSetRoomCustomAttributesResult() { + } + + public EMSetRoomCustomAttributesResult data(EMSetRoomCustomAttributesResource data) { + + this.data = data; + return this; + } + + /** + * Get data + * @return data + **/ + @javax.annotation.Nullable + public EMSetRoomCustomAttributesResource getData() { + return data; + } + + + public void setData(EMSetRoomCustomAttributesResource data) { + this.data = data; + } + + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + EMSetRoomCustomAttributesResult setRoomCustomAttributesResult = (EMSetRoomCustomAttributesResult) o; + return Objects.equals(this.data, setRoomCustomAttributesResult.data); + } + + @Override + public int hashCode() { + return Objects.hash(data); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class EMSetRoomCustomAttributesResult {\n"); + sb.append(" data: ").append(toIndentedString(data)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("data"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to EMSetRoomCustomAttributesResult + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!EMSetRoomCustomAttributesResult.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format("The required field(s) %s in EMSetRoomCustomAttributesResult is not found in the empty JSON string", EMSetRoomCustomAttributesResult.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!EMSetRoomCustomAttributesResult.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `EMSetRoomCustomAttributesResult` properties. JSON: %s", entry.getKey(), jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // validate the optional field `data` + if (jsonObj.get("data") != null && !jsonObj.get("data").isJsonNull()) { + EMSetRoomCustomAttributesResource.validateJsonElement(jsonObj.get("data")); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!EMSetRoomCustomAttributesResult.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'EMSetRoomCustomAttributesResult' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(EMSetRoomCustomAttributesResult.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, EMSetRoomCustomAttributesResult value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public EMSetRoomCustomAttributesResult read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + return thisAdapter.fromJsonTree(jsonElement); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of EMSetRoomCustomAttributesResult given an JSON string + * + * @param jsonString JSON string + * @return An instance of EMSetRoomCustomAttributesResult + * @throws IOException if the JSON string is invalid with respect to EMSetRoomCustomAttributesResult + */ + public static EMSetRoomCustomAttributesResult fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, EMSetRoomCustomAttributesResult.class); + } + + /** + * Convert an instance of EMSetRoomCustomAttributesResult to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/com/easemob/im/api/model/EMSetUserGlobalMute.java b/src/main/java/com/easemob/im/api/model/EMSetUserGlobalMute.java new file mode 100644 index 000000000..14aebe8ad --- /dev/null +++ b/src/main/java/com/easemob/im/api/model/EMSetUserGlobalMute.java @@ -0,0 +1,292 @@ +/* + * EMService + * Easemob Rest API + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.easemob.im.api.model; + +import java.util.Objects; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.Arrays; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import com.easemob.im.JSON; + +/** + * EMSetUserGlobalMute + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-01-25T14:51:53.998371+08:00[Asia/Shanghai]") +public class EMSetUserGlobalMute { + public static final String SERIALIZED_NAME_USERNAME = "username"; + @SerializedName(SERIALIZED_NAME_USERNAME) + private String username; + + public static final String SERIALIZED_NAME_CHAT = "chat"; + @SerializedName(SERIALIZED_NAME_CHAT) + private Integer chat; + + public static final String SERIALIZED_NAME_GROUPCHAT = "groupchat"; + @SerializedName(SERIALIZED_NAME_GROUPCHAT) + private Integer groupchat; + + public static final String SERIALIZED_NAME_CHATROOM = "chatroom"; + @SerializedName(SERIALIZED_NAME_CHATROOM) + private Integer chatroom; + + public EMSetUserGlobalMute() { + } + + public EMSetUserGlobalMute username(String username) { + + this.username = username; + return this; + } + + /** + * 设置全局禁言的用户 ID + * @return username + **/ + @javax.annotation.Nullable + public String getUsername() { + return username; + } + + + public void setUsername(String username) { + this.username = username; + } + + + public EMSetUserGlobalMute chat(Integer chat) { + + this.chat = chat; + return this; + } + + /** + * 单聊禁言时长,单位为秒,最大值为 2147483647。 - > 0:该用户 ID 的单聊禁言时长。 - 0:取消该用户的单聊禁言。 - -1:该用户被设置永久单聊禁言。 - 其他负值无效。 + * @return chat + **/ + @javax.annotation.Nullable + public Integer getChat() { + return chat; + } + + + public void setChat(Integer chat) { + this.chat = chat; + } + + + public EMSetUserGlobalMute groupchat(Integer groupchat) { + + this.groupchat = groupchat; + return this; + } + + /** + * 群组禁言时长,单位为秒,规则同单聊禁言 + * @return groupchat + **/ + @javax.annotation.Nullable + public Integer getGroupchat() { + return groupchat; + } + + + public void setGroupchat(Integer groupchat) { + this.groupchat = groupchat; + } + + + public EMSetUserGlobalMute chatroom(Integer chatroom) { + + this.chatroom = chatroom; + return this; + } + + /** + * 聊天室禁言时长,单位为秒,规则同单聊禁言 + * @return chatroom + **/ + @javax.annotation.Nullable + public Integer getChatroom() { + return chatroom; + } + + + public void setChatroom(Integer chatroom) { + this.chatroom = chatroom; + } + + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + EMSetUserGlobalMute setUserGlobalMute = (EMSetUserGlobalMute) o; + return Objects.equals(this.username, setUserGlobalMute.username) && + Objects.equals(this.chat, setUserGlobalMute.chat) && + Objects.equals(this.groupchat, setUserGlobalMute.groupchat) && + Objects.equals(this.chatroom, setUserGlobalMute.chatroom); + } + + @Override + public int hashCode() { + return Objects.hash(username, chat, groupchat, chatroom); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class EMSetUserGlobalMute {\n"); + sb.append(" username: ").append(toIndentedString(username)).append("\n"); + sb.append(" chat: ").append(toIndentedString(chat)).append("\n"); + sb.append(" groupchat: ").append(toIndentedString(groupchat)).append("\n"); + sb.append(" chatroom: ").append(toIndentedString(chatroom)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("username"); + openapiFields.add("chat"); + openapiFields.add("groupchat"); + openapiFields.add("chatroom"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to EMSetUserGlobalMute + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!EMSetUserGlobalMute.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format("The required field(s) %s in EMSetUserGlobalMute is not found in the empty JSON string", EMSetUserGlobalMute.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!EMSetUserGlobalMute.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `EMSetUserGlobalMute` properties. JSON: %s", entry.getKey(), jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + if ((jsonObj.get("username") != null && !jsonObj.get("username").isJsonNull()) && !jsonObj.get("username").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `username` to be a primitive type in the JSON string but got `%s`", jsonObj.get("username").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!EMSetUserGlobalMute.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'EMSetUserGlobalMute' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(EMSetUserGlobalMute.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, EMSetUserGlobalMute value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public EMSetUserGlobalMute read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + return thisAdapter.fromJsonTree(jsonElement); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of EMSetUserGlobalMute given an JSON string + * + * @param jsonString JSON string + * @return An instance of EMSetUserGlobalMute + * @throws IOException if the JSON string is invalid with respect to EMSetUserGlobalMute + */ + public static EMSetUserGlobalMute fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, EMSetUserGlobalMute.class); + } + + /** + * Convert an instance of EMSetUserGlobalMute to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/com/easemob/im/api/model/EMSetUserGlobalMuteResource.java b/src/main/java/com/easemob/im/api/model/EMSetUserGlobalMuteResource.java new file mode 100644 index 000000000..94c20d516 --- /dev/null +++ b/src/main/java/com/easemob/im/api/model/EMSetUserGlobalMuteResource.java @@ -0,0 +1,208 @@ +/* + * EMService + * Easemob Rest API + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.easemob.im.api.model; + +import java.util.Objects; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.Arrays; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import com.easemob.im.JSON; + +/** + * EMSetUserGlobalMuteResource + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-01-25T14:51:53.998371+08:00[Asia/Shanghai]") +public class EMSetUserGlobalMuteResource { + public static final String SERIALIZED_NAME_RESULT = "result"; + @SerializedName(SERIALIZED_NAME_RESULT) + private String result; + + public EMSetUserGlobalMuteResource() { + } + + public EMSetUserGlobalMuteResource result(String result) { + + this.result = result; + return this; + } + + /** + * Get result + * @return result + **/ + @javax.annotation.Nullable + public String getResult() { + return result; + } + + + public void setResult(String result) { + this.result = result; + } + + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + EMSetUserGlobalMuteResource setUserGlobalMuteResource = (EMSetUserGlobalMuteResource) o; + return Objects.equals(this.result, setUserGlobalMuteResource.result); + } + + @Override + public int hashCode() { + return Objects.hash(result); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class EMSetUserGlobalMuteResource {\n"); + sb.append(" result: ").append(toIndentedString(result)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("result"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to EMSetUserGlobalMuteResource + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!EMSetUserGlobalMuteResource.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format("The required field(s) %s in EMSetUserGlobalMuteResource is not found in the empty JSON string", EMSetUserGlobalMuteResource.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!EMSetUserGlobalMuteResource.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `EMSetUserGlobalMuteResource` properties. JSON: %s", entry.getKey(), jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + if ((jsonObj.get("result") != null && !jsonObj.get("result").isJsonNull()) && !jsonObj.get("result").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `result` to be a primitive type in the JSON string but got `%s`", jsonObj.get("result").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!EMSetUserGlobalMuteResource.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'EMSetUserGlobalMuteResource' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(EMSetUserGlobalMuteResource.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, EMSetUserGlobalMuteResource value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public EMSetUserGlobalMuteResource read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + return thisAdapter.fromJsonTree(jsonElement); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of EMSetUserGlobalMuteResource given an JSON string + * + * @param jsonString JSON string + * @return An instance of EMSetUserGlobalMuteResource + * @throws IOException if the JSON string is invalid with respect to EMSetUserGlobalMuteResource + */ + public static EMSetUserGlobalMuteResource fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, EMSetUserGlobalMuteResource.class); + } + + /** + * Convert an instance of EMSetUserGlobalMuteResource to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/com/easemob/im/api/model/EMSetUserGlobalMuteResult.java b/src/main/java/com/easemob/im/api/model/EMSetUserGlobalMuteResult.java new file mode 100644 index 000000000..6e39115a3 --- /dev/null +++ b/src/main/java/com/easemob/im/api/model/EMSetUserGlobalMuteResult.java @@ -0,0 +1,210 @@ +/* + * EMService + * Easemob Rest API + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.easemob.im.api.model; + +import java.util.Objects; +import com.easemob.im.api.model.EMSetUserGlobalMuteResource; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.Arrays; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import com.easemob.im.JSON; + +/** + * EMSetUserGlobalMuteResult + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-01-25T14:51:53.998371+08:00[Asia/Shanghai]") +public class EMSetUserGlobalMuteResult { + public static final String SERIALIZED_NAME_DATA = "data"; + @SerializedName(SERIALIZED_NAME_DATA) + private EMSetUserGlobalMuteResource data; + + public EMSetUserGlobalMuteResult() { + } + + public EMSetUserGlobalMuteResult data(EMSetUserGlobalMuteResource data) { + + this.data = data; + return this; + } + + /** + * Get data + * @return data + **/ + @javax.annotation.Nullable + public EMSetUserGlobalMuteResource getData() { + return data; + } + + + public void setData(EMSetUserGlobalMuteResource data) { + this.data = data; + } + + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + EMSetUserGlobalMuteResult setUserGlobalMuteResult = (EMSetUserGlobalMuteResult) o; + return Objects.equals(this.data, setUserGlobalMuteResult.data); + } + + @Override + public int hashCode() { + return Objects.hash(data); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class EMSetUserGlobalMuteResult {\n"); + sb.append(" data: ").append(toIndentedString(data)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("data"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to EMSetUserGlobalMuteResult + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!EMSetUserGlobalMuteResult.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format("The required field(s) %s in EMSetUserGlobalMuteResult is not found in the empty JSON string", EMSetUserGlobalMuteResult.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!EMSetUserGlobalMuteResult.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `EMSetUserGlobalMuteResult` properties. JSON: %s", entry.getKey(), jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // validate the optional field `data` + if (jsonObj.get("data") != null && !jsonObj.get("data").isJsonNull()) { + EMSetUserGlobalMuteResource.validateJsonElement(jsonObj.get("data")); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!EMSetUserGlobalMuteResult.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'EMSetUserGlobalMuteResult' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(EMSetUserGlobalMuteResult.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, EMSetUserGlobalMuteResult value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public EMSetUserGlobalMuteResult read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + return thisAdapter.fromJsonTree(jsonElement); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of EMSetUserGlobalMuteResult given an JSON string + * + * @param jsonString JSON string + * @return An instance of EMSetUserGlobalMuteResult + * @throws IOException if the JSON string is invalid with respect to EMSetUserGlobalMuteResult + */ + public static EMSetUserGlobalMuteResult fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, EMSetUserGlobalMuteResult.class); + } + + /** + * Convert an instance of EMSetUserGlobalMuteResult to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/com/easemob/im/api/model/EMSetUserMetadataResult.java b/src/main/java/com/easemob/im/api/model/EMSetUserMetadataResult.java new file mode 100644 index 000000000..ef55df9d2 --- /dev/null +++ b/src/main/java/com/easemob/im/api/model/EMSetUserMetadataResult.java @@ -0,0 +1,205 @@ +/* + * EMService + * Easemob Rest API + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.easemob.im.api.model; + +import java.util.Objects; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.Arrays; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import com.easemob.im.JSON; + +/** + * EMSetUserMetadataResult + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-01-25T14:51:53.998371+08:00[Asia/Shanghai]") +public class EMSetUserMetadataResult { + public static final String SERIALIZED_NAME_DATA = "data"; + @SerializedName(SERIALIZED_NAME_DATA) + private Object data; + + public EMSetUserMetadataResult() { + } + + public EMSetUserMetadataResult data(Object data) { + + this.data = data; + return this; + } + + /** + * Get data + * @return data + **/ + @javax.annotation.Nullable + public Object getData() { + return data; + } + + + public void setData(Object data) { + this.data = data; + } + + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + EMSetUserMetadataResult setUserMetadataResult = (EMSetUserMetadataResult) o; + return Objects.equals(this.data, setUserMetadataResult.data); + } + + @Override + public int hashCode() { + return Objects.hash(data); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class EMSetUserMetadataResult {\n"); + sb.append(" data: ").append(toIndentedString(data)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("data"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to EMSetUserMetadataResult + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!EMSetUserMetadataResult.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format("The required field(s) %s in EMSetUserMetadataResult is not found in the empty JSON string", EMSetUserMetadataResult.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!EMSetUserMetadataResult.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `EMSetUserMetadataResult` properties. JSON: %s", entry.getKey(), jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!EMSetUserMetadataResult.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'EMSetUserMetadataResult' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(EMSetUserMetadataResult.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, EMSetUserMetadataResult value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public EMSetUserMetadataResult read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + return thisAdapter.fromJsonTree(jsonElement); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of EMSetUserMetadataResult given an JSON string + * + * @param jsonString JSON string + * @return An instance of EMSetUserMetadataResult + * @throws IOException if the JSON string is invalid with respect to EMSetUserMetadataResult + */ + public static EMSetUserMetadataResult fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, EMSetUserMetadataResult.class); + } + + /** + * Convert an instance of EMSetUserMetadataResult to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/com/easemob/im/api/model/EMThreadResource.java b/src/main/java/com/easemob/im/api/model/EMThreadResource.java new file mode 100644 index 000000000..6695e438a --- /dev/null +++ b/src/main/java/com/easemob/im/api/model/EMThreadResource.java @@ -0,0 +1,361 @@ +/* + * EMService + * Easemob Rest API + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.easemob.im.api.model; + +import java.util.Objects; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.math.BigDecimal; +import java.util.Arrays; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import com.easemob.im.JSON; + +/** + * EMThreadResource + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-01-25T14:51:53.998371+08:00[Asia/Shanghai]") +public class EMThreadResource { + public static final String SERIALIZED_NAME_NAME = "name"; + @SerializedName(SERIALIZED_NAME_NAME) + private String name; + + public static final String SERIALIZED_NAME_OWNER = "owner"; + @SerializedName(SERIALIZED_NAME_OWNER) + private String owner; + + public static final String SERIALIZED_NAME_ID = "id"; + @SerializedName(SERIALIZED_NAME_ID) + private String id; + + public static final String SERIALIZED_NAME_MSG_ID = "msgId"; + @SerializedName(SERIALIZED_NAME_MSG_ID) + private String msgId; + + public static final String SERIALIZED_NAME_GROUP_ID = "groupId"; + @SerializedName(SERIALIZED_NAME_GROUP_ID) + private String groupId; + + public static final String SERIALIZED_NAME_CREATED = "created"; + @SerializedName(SERIALIZED_NAME_CREATED) + private BigDecimal created; + + public EMThreadResource() { + } + + public EMThreadResource name(String name) { + + this.name = name; + return this; + } + + /** + * 子区名称 + * @return name + **/ + @javax.annotation.Nullable + public String getName() { + return name; + } + + + public void setName(String name) { + this.name = name; + } + + + public EMThreadResource owner(String owner) { + + this.owner = owner; + return this; + } + + /** + * 子区创建者的用户 ID + * @return owner + **/ + @javax.annotation.Nullable + public String getOwner() { + return owner; + } + + + public void setOwner(String owner) { + this.owner = owner; + } + + + public EMThreadResource id(String id) { + + this.id = id; + return this; + } + + /** + * 子区 ID + * @return id + **/ + @javax.annotation.Nullable + public String getId() { + return id; + } + + + public void setId(String id) { + this.id = id; + } + + + public EMThreadResource msgId(String msgId) { + + this.msgId = msgId; + return this; + } + + /** + * 子区的父消息 ID + * @return msgId + **/ + @javax.annotation.Nullable + public String getMsgId() { + return msgId; + } + + + public void setMsgId(String msgId) { + this.msgId = msgId; + } + + + public EMThreadResource groupId(String groupId) { + + this.groupId = groupId; + return this; + } + + /** + * 子区所属群组 ID + * @return groupId + **/ + @javax.annotation.Nullable + public String getGroupId() { + return groupId; + } + + + public void setGroupId(String groupId) { + this.groupId = groupId; + } + + + public EMThreadResource created(BigDecimal created) { + + this.created = created; + return this; + } + + /** + * 子区创建时间,Unix 时间戳 + * @return created + **/ + @javax.annotation.Nullable + public BigDecimal getCreated() { + return created; + } + + + public void setCreated(BigDecimal created) { + this.created = created; + } + + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + EMThreadResource threadResource = (EMThreadResource) o; + return Objects.equals(this.name, threadResource.name) && + Objects.equals(this.owner, threadResource.owner) && + Objects.equals(this.id, threadResource.id) && + Objects.equals(this.msgId, threadResource.msgId) && + Objects.equals(this.groupId, threadResource.groupId) && + Objects.equals(this.created, threadResource.created); + } + + @Override + public int hashCode() { + return Objects.hash(name, owner, id, msgId, groupId, created); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class EMThreadResource {\n"); + sb.append(" name: ").append(toIndentedString(name)).append("\n"); + sb.append(" owner: ").append(toIndentedString(owner)).append("\n"); + sb.append(" id: ").append(toIndentedString(id)).append("\n"); + sb.append(" msgId: ").append(toIndentedString(msgId)).append("\n"); + sb.append(" groupId: ").append(toIndentedString(groupId)).append("\n"); + sb.append(" created: ").append(toIndentedString(created)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("name"); + openapiFields.add("owner"); + openapiFields.add("id"); + openapiFields.add("msgId"); + openapiFields.add("groupId"); + openapiFields.add("created"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to EMThreadResource + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!EMThreadResource.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format("The required field(s) %s in EMThreadResource is not found in the empty JSON string", EMThreadResource.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!EMThreadResource.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `EMThreadResource` properties. JSON: %s", entry.getKey(), jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + if ((jsonObj.get("name") != null && !jsonObj.get("name").isJsonNull()) && !jsonObj.get("name").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("name").toString())); + } + if ((jsonObj.get("owner") != null && !jsonObj.get("owner").isJsonNull()) && !jsonObj.get("owner").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `owner` to be a primitive type in the JSON string but got `%s`", jsonObj.get("owner").toString())); + } + if ((jsonObj.get("id") != null && !jsonObj.get("id").isJsonNull()) && !jsonObj.get("id").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `id` to be a primitive type in the JSON string but got `%s`", jsonObj.get("id").toString())); + } + if ((jsonObj.get("msgId") != null && !jsonObj.get("msgId").isJsonNull()) && !jsonObj.get("msgId").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `msgId` to be a primitive type in the JSON string but got `%s`", jsonObj.get("msgId").toString())); + } + if ((jsonObj.get("groupId") != null && !jsonObj.get("groupId").isJsonNull()) && !jsonObj.get("groupId").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `groupId` to be a primitive type in the JSON string but got `%s`", jsonObj.get("groupId").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!EMThreadResource.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'EMThreadResource' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(EMThreadResource.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, EMThreadResource value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public EMThreadResource read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + return thisAdapter.fromJsonTree(jsonElement); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of EMThreadResource given an JSON string + * + * @param jsonString JSON string + * @return An instance of EMThreadResource + * @throws IOException if the JSON string is invalid with respect to EMThreadResource + */ + public static EMThreadResource fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, EMThreadResource.class); + } + + /** + * Convert an instance of EMThreadResource to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/com/easemob/im/api/model/EMUnmuteAllGroupMembersResource.java b/src/main/java/com/easemob/im/api/model/EMUnmuteAllGroupMembersResource.java new file mode 100644 index 000000000..b9f861db5 --- /dev/null +++ b/src/main/java/com/easemob/im/api/model/EMUnmuteAllGroupMembersResource.java @@ -0,0 +1,205 @@ +/* + * EMService + * Easemob Rest API + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.easemob.im.api.model; + +import java.util.Objects; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.Arrays; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import com.easemob.im.JSON; + +/** + * EMUnmuteAllGroupMembersResource + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-01-25T14:51:53.998371+08:00[Asia/Shanghai]") +public class EMUnmuteAllGroupMembersResource { + public static final String SERIALIZED_NAME_MUTE = "mute"; + @SerializedName(SERIALIZED_NAME_MUTE) + private Boolean mute; + + public EMUnmuteAllGroupMembersResource() { + } + + public EMUnmuteAllGroupMembersResource mute(Boolean mute) { + + this.mute = mute; + return this; + } + + /** + * Get mute + * @return mute + **/ + @javax.annotation.Nullable + public Boolean getMute() { + return mute; + } + + + public void setMute(Boolean mute) { + this.mute = mute; + } + + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + EMUnmuteAllGroupMembersResource unmuteAllGroupMembersResource = (EMUnmuteAllGroupMembersResource) o; + return Objects.equals(this.mute, unmuteAllGroupMembersResource.mute); + } + + @Override + public int hashCode() { + return Objects.hash(mute); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class EMUnmuteAllGroupMembersResource {\n"); + sb.append(" mute: ").append(toIndentedString(mute)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("mute"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to EMUnmuteAllGroupMembersResource + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!EMUnmuteAllGroupMembersResource.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format("The required field(s) %s in EMUnmuteAllGroupMembersResource is not found in the empty JSON string", EMUnmuteAllGroupMembersResource.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!EMUnmuteAllGroupMembersResource.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `EMUnmuteAllGroupMembersResource` properties. JSON: %s", entry.getKey(), jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!EMUnmuteAllGroupMembersResource.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'EMUnmuteAllGroupMembersResource' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(EMUnmuteAllGroupMembersResource.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, EMUnmuteAllGroupMembersResource value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public EMUnmuteAllGroupMembersResource read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + return thisAdapter.fromJsonTree(jsonElement); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of EMUnmuteAllGroupMembersResource given an JSON string + * + * @param jsonString JSON string + * @return An instance of EMUnmuteAllGroupMembersResource + * @throws IOException if the JSON string is invalid with respect to EMUnmuteAllGroupMembersResource + */ + public static EMUnmuteAllGroupMembersResource fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, EMUnmuteAllGroupMembersResource.class); + } + + /** + * Convert an instance of EMUnmuteAllGroupMembersResource to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/com/easemob/im/api/model/EMUnmuteAllGroupMembersResult.java b/src/main/java/com/easemob/im/api/model/EMUnmuteAllGroupMembersResult.java new file mode 100644 index 000000000..24c971287 --- /dev/null +++ b/src/main/java/com/easemob/im/api/model/EMUnmuteAllGroupMembersResult.java @@ -0,0 +1,210 @@ +/* + * EMService + * Easemob Rest API + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.easemob.im.api.model; + +import java.util.Objects; +import com.easemob.im.api.model.EMUnmuteAllGroupMembersResource; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.Arrays; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import com.easemob.im.JSON; + +/** + * EMUnmuteAllGroupMembersResult + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-01-25T14:51:53.998371+08:00[Asia/Shanghai]") +public class EMUnmuteAllGroupMembersResult { + public static final String SERIALIZED_NAME_DATA = "data"; + @SerializedName(SERIALIZED_NAME_DATA) + private EMUnmuteAllGroupMembersResource data; + + public EMUnmuteAllGroupMembersResult() { + } + + public EMUnmuteAllGroupMembersResult data(EMUnmuteAllGroupMembersResource data) { + + this.data = data; + return this; + } + + /** + * Get data + * @return data + **/ + @javax.annotation.Nullable + public EMUnmuteAllGroupMembersResource getData() { + return data; + } + + + public void setData(EMUnmuteAllGroupMembersResource data) { + this.data = data; + } + + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + EMUnmuteAllGroupMembersResult unmuteAllGroupMembersResult = (EMUnmuteAllGroupMembersResult) o; + return Objects.equals(this.data, unmuteAllGroupMembersResult.data); + } + + @Override + public int hashCode() { + return Objects.hash(data); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class EMUnmuteAllGroupMembersResult {\n"); + sb.append(" data: ").append(toIndentedString(data)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("data"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to EMUnmuteAllGroupMembersResult + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!EMUnmuteAllGroupMembersResult.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format("The required field(s) %s in EMUnmuteAllGroupMembersResult is not found in the empty JSON string", EMUnmuteAllGroupMembersResult.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!EMUnmuteAllGroupMembersResult.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `EMUnmuteAllGroupMembersResult` properties. JSON: %s", entry.getKey(), jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // validate the optional field `data` + if (jsonObj.get("data") != null && !jsonObj.get("data").isJsonNull()) { + EMUnmuteAllGroupMembersResource.validateJsonElement(jsonObj.get("data")); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!EMUnmuteAllGroupMembersResult.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'EMUnmuteAllGroupMembersResult' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(EMUnmuteAllGroupMembersResult.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, EMUnmuteAllGroupMembersResult value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public EMUnmuteAllGroupMembersResult read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + return thisAdapter.fromJsonTree(jsonElement); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of EMUnmuteAllGroupMembersResult given an JSON string + * + * @param jsonString JSON string + * @return An instance of EMUnmuteAllGroupMembersResult + * @throws IOException if the JSON string is invalid with respect to EMUnmuteAllGroupMembersResult + */ + public static EMUnmuteAllGroupMembersResult fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, EMUnmuteAllGroupMembersResult.class); + } + + /** + * Convert an instance of EMUnmuteAllGroupMembersResult to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/com/easemob/im/api/model/EMUnmuteAllRoomMemberResource.java b/src/main/java/com/easemob/im/api/model/EMUnmuteAllRoomMemberResource.java new file mode 100644 index 000000000..824c15cb2 --- /dev/null +++ b/src/main/java/com/easemob/im/api/model/EMUnmuteAllRoomMemberResource.java @@ -0,0 +1,205 @@ +/* + * EMService + * Easemob Rest API + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.easemob.im.api.model; + +import java.util.Objects; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.Arrays; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import com.easemob.im.JSON; + +/** + * EMUnmuteAllRoomMemberResource + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-01-25T14:51:53.998371+08:00[Asia/Shanghai]") +public class EMUnmuteAllRoomMemberResource { + public static final String SERIALIZED_NAME_MUTE = "mute"; + @SerializedName(SERIALIZED_NAME_MUTE) + private Boolean mute; + + public EMUnmuteAllRoomMemberResource() { + } + + public EMUnmuteAllRoomMemberResource mute(Boolean mute) { + + this.mute = mute; + return this; + } + + /** + * Get mute + * @return mute + **/ + @javax.annotation.Nullable + public Boolean getMute() { + return mute; + } + + + public void setMute(Boolean mute) { + this.mute = mute; + } + + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + EMUnmuteAllRoomMemberResource unmuteAllRoomMemberResource = (EMUnmuteAllRoomMemberResource) o; + return Objects.equals(this.mute, unmuteAllRoomMemberResource.mute); + } + + @Override + public int hashCode() { + return Objects.hash(mute); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class EMUnmuteAllRoomMemberResource {\n"); + sb.append(" mute: ").append(toIndentedString(mute)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("mute"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to EMUnmuteAllRoomMemberResource + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!EMUnmuteAllRoomMemberResource.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format("The required field(s) %s in EMUnmuteAllRoomMemberResource is not found in the empty JSON string", EMUnmuteAllRoomMemberResource.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!EMUnmuteAllRoomMemberResource.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `EMUnmuteAllRoomMemberResource` properties. JSON: %s", entry.getKey(), jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!EMUnmuteAllRoomMemberResource.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'EMUnmuteAllRoomMemberResource' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(EMUnmuteAllRoomMemberResource.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, EMUnmuteAllRoomMemberResource value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public EMUnmuteAllRoomMemberResource read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + return thisAdapter.fromJsonTree(jsonElement); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of EMUnmuteAllRoomMemberResource given an JSON string + * + * @param jsonString JSON string + * @return An instance of EMUnmuteAllRoomMemberResource + * @throws IOException if the JSON string is invalid with respect to EMUnmuteAllRoomMemberResource + */ + public static EMUnmuteAllRoomMemberResource fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, EMUnmuteAllRoomMemberResource.class); + } + + /** + * Convert an instance of EMUnmuteAllRoomMemberResource to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/com/easemob/im/api/model/EMUnmuteAllRoomMemberResult.java b/src/main/java/com/easemob/im/api/model/EMUnmuteAllRoomMemberResult.java new file mode 100644 index 000000000..85d1b8e6d --- /dev/null +++ b/src/main/java/com/easemob/im/api/model/EMUnmuteAllRoomMemberResult.java @@ -0,0 +1,210 @@ +/* + * EMService + * Easemob Rest API + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.easemob.im.api.model; + +import java.util.Objects; +import com.easemob.im.api.model.EMUnmuteAllRoomMemberResource; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.Arrays; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import com.easemob.im.JSON; + +/** + * EMUnmuteAllRoomMemberResult + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-01-25T14:51:53.998371+08:00[Asia/Shanghai]") +public class EMUnmuteAllRoomMemberResult { + public static final String SERIALIZED_NAME_DATA = "data"; + @SerializedName(SERIALIZED_NAME_DATA) + private EMUnmuteAllRoomMemberResource data; + + public EMUnmuteAllRoomMemberResult() { + } + + public EMUnmuteAllRoomMemberResult data(EMUnmuteAllRoomMemberResource data) { + + this.data = data; + return this; + } + + /** + * Get data + * @return data + **/ + @javax.annotation.Nullable + public EMUnmuteAllRoomMemberResource getData() { + return data; + } + + + public void setData(EMUnmuteAllRoomMemberResource data) { + this.data = data; + } + + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + EMUnmuteAllRoomMemberResult unmuteAllRoomMemberResult = (EMUnmuteAllRoomMemberResult) o; + return Objects.equals(this.data, unmuteAllRoomMemberResult.data); + } + + @Override + public int hashCode() { + return Objects.hash(data); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class EMUnmuteAllRoomMemberResult {\n"); + sb.append(" data: ").append(toIndentedString(data)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("data"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to EMUnmuteAllRoomMemberResult + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!EMUnmuteAllRoomMemberResult.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format("The required field(s) %s in EMUnmuteAllRoomMemberResult is not found in the empty JSON string", EMUnmuteAllRoomMemberResult.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!EMUnmuteAllRoomMemberResult.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `EMUnmuteAllRoomMemberResult` properties. JSON: %s", entry.getKey(), jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // validate the optional field `data` + if (jsonObj.get("data") != null && !jsonObj.get("data").isJsonNull()) { + EMUnmuteAllRoomMemberResource.validateJsonElement(jsonObj.get("data")); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!EMUnmuteAllRoomMemberResult.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'EMUnmuteAllRoomMemberResult' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(EMUnmuteAllRoomMemberResult.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, EMUnmuteAllRoomMemberResult value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public EMUnmuteAllRoomMemberResult read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + return thisAdapter.fromJsonTree(jsonElement); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of EMUnmuteAllRoomMemberResult given an JSON string + * + * @param jsonString JSON string + * @return An instance of EMUnmuteAllRoomMemberResult + * @throws IOException if the JSON string is invalid with respect to EMUnmuteAllRoomMemberResult + */ + public static EMUnmuteAllRoomMemberResult fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, EMUnmuteAllRoomMemberResult.class); + } + + /** + * Convert an instance of EMUnmuteAllRoomMemberResult to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/com/easemob/im/api/model/EMUnmuteRoomMemberResource.java b/src/main/java/com/easemob/im/api/model/EMUnmuteRoomMemberResource.java new file mode 100644 index 000000000..894307663 --- /dev/null +++ b/src/main/java/com/easemob/im/api/model/EMUnmuteRoomMemberResource.java @@ -0,0 +1,236 @@ +/* + * EMService + * Easemob Rest API + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.easemob.im.api.model; + +import java.util.Objects; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.Arrays; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import com.easemob.im.JSON; + +/** + * EMUnmuteRoomMemberResource + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-01-25T14:51:53.998371+08:00[Asia/Shanghai]") +public class EMUnmuteRoomMemberResource { + public static final String SERIALIZED_NAME_RESULT = "result"; + @SerializedName(SERIALIZED_NAME_RESULT) + private Boolean result; + + public static final String SERIALIZED_NAME_USER = "user"; + @SerializedName(SERIALIZED_NAME_USER) + private String user; + + public EMUnmuteRoomMemberResource() { + } + + public EMUnmuteRoomMemberResource result(Boolean result) { + + this.result = result; + return this; + } + + /** + * 是否成功将指定用户移出禁言列表: - true:是; - false:否 + * @return result + **/ + @javax.annotation.Nullable + public Boolean getResult() { + return result; + } + + + public void setResult(Boolean result) { + this.result = result; + } + + + public EMUnmuteRoomMemberResource user(String user) { + + this.user = user; + return this; + } + + /** + * 被解除禁言的聊天室成员的用户 ID + * @return user + **/ + @javax.annotation.Nullable + public String getUser() { + return user; + } + + + public void setUser(String user) { + this.user = user; + } + + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + EMUnmuteRoomMemberResource unmuteRoomMemberResource = (EMUnmuteRoomMemberResource) o; + return Objects.equals(this.result, unmuteRoomMemberResource.result) && + Objects.equals(this.user, unmuteRoomMemberResource.user); + } + + @Override + public int hashCode() { + return Objects.hash(result, user); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class EMUnmuteRoomMemberResource {\n"); + sb.append(" result: ").append(toIndentedString(result)).append("\n"); + sb.append(" user: ").append(toIndentedString(user)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("result"); + openapiFields.add("user"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to EMUnmuteRoomMemberResource + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!EMUnmuteRoomMemberResource.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format("The required field(s) %s in EMUnmuteRoomMemberResource is not found in the empty JSON string", EMUnmuteRoomMemberResource.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!EMUnmuteRoomMemberResource.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `EMUnmuteRoomMemberResource` properties. JSON: %s", entry.getKey(), jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + if ((jsonObj.get("user") != null && !jsonObj.get("user").isJsonNull()) && !jsonObj.get("user").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `user` to be a primitive type in the JSON string but got `%s`", jsonObj.get("user").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!EMUnmuteRoomMemberResource.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'EMUnmuteRoomMemberResource' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(EMUnmuteRoomMemberResource.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, EMUnmuteRoomMemberResource value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public EMUnmuteRoomMemberResource read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + return thisAdapter.fromJsonTree(jsonElement); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of EMUnmuteRoomMemberResource given an JSON string + * + * @param jsonString JSON string + * @return An instance of EMUnmuteRoomMemberResource + * @throws IOException if the JSON string is invalid with respect to EMUnmuteRoomMemberResource + */ + public static EMUnmuteRoomMemberResource fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, EMUnmuteRoomMemberResource.class); + } + + /** + * Convert an instance of EMUnmuteRoomMemberResource to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/com/easemob/im/api/model/EMUnmuteRoomMemberResult.java b/src/main/java/com/easemob/im/api/model/EMUnmuteRoomMemberResult.java new file mode 100644 index 000000000..03f58d994 --- /dev/null +++ b/src/main/java/com/easemob/im/api/model/EMUnmuteRoomMemberResult.java @@ -0,0 +1,230 @@ +/* + * EMService + * Easemob Rest API + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.easemob.im.api.model; + +import java.util.Objects; +import com.easemob.im.api.model.EMUnmuteRoomMemberResource; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import com.easemob.im.JSON; + +/** + * EMUnmuteRoomMemberResult + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-01-25T14:51:53.998371+08:00[Asia/Shanghai]") +public class EMUnmuteRoomMemberResult { + public static final String SERIALIZED_NAME_DATA = "data"; + @SerializedName(SERIALIZED_NAME_DATA) + private List data; + + public EMUnmuteRoomMemberResult() { + } + + public EMUnmuteRoomMemberResult data(List data) { + + this.data = data; + return this; + } + + public EMUnmuteRoomMemberResult addDataItem(EMUnmuteRoomMemberResource dataItem) { + if (this.data == null) { + this.data = new ArrayList<>(); + } + this.data.add(dataItem); + return this; + } + + /** + * Get data + * @return data + **/ + @javax.annotation.Nullable + public List getData() { + return data; + } + + + public void setData(List data) { + this.data = data; + } + + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + EMUnmuteRoomMemberResult unmuteRoomMemberResult = (EMUnmuteRoomMemberResult) o; + return Objects.equals(this.data, unmuteRoomMemberResult.data); + } + + @Override + public int hashCode() { + return Objects.hash(data); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class EMUnmuteRoomMemberResult {\n"); + sb.append(" data: ").append(toIndentedString(data)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("data"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to EMUnmuteRoomMemberResult + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!EMUnmuteRoomMemberResult.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format("The required field(s) %s in EMUnmuteRoomMemberResult is not found in the empty JSON string", EMUnmuteRoomMemberResult.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!EMUnmuteRoomMemberResult.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `EMUnmuteRoomMemberResult` properties. JSON: %s", entry.getKey(), jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + if (jsonObj.get("data") != null && !jsonObj.get("data").isJsonNull()) { + JsonArray jsonArraydata = jsonObj.getAsJsonArray("data"); + if (jsonArraydata != null) { + // ensure the json data is an array + if (!jsonObj.get("data").isJsonArray()) { + throw new IllegalArgumentException(String.format("Expected the field `data` to be an array in the JSON string but got `%s`", jsonObj.get("data").toString())); + } + + // validate the optional field `data` (array) + for (int i = 0; i < jsonArraydata.size(); i++) { + EMUnmuteRoomMemberResource.validateJsonElement(jsonArraydata.get(i)); + }; + } + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!EMUnmuteRoomMemberResult.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'EMUnmuteRoomMemberResult' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(EMUnmuteRoomMemberResult.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, EMUnmuteRoomMemberResult value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public EMUnmuteRoomMemberResult read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + return thisAdapter.fromJsonTree(jsonElement); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of EMUnmuteRoomMemberResult given an JSON string + * + * @param jsonString JSON string + * @return An instance of EMUnmuteRoomMemberResult + * @throws IOException if the JSON string is invalid with respect to EMUnmuteRoomMemberResult + */ + public static EMUnmuteRoomMemberResult fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, EMUnmuteRoomMemberResult.class); + } + + /** + * Convert an instance of EMUnmuteRoomMemberResult to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/com/easemob/im/api/model/EMUploadChatFileResource.java b/src/main/java/com/easemob/im/api/model/EMUploadChatFileResource.java new file mode 100644 index 000000000..75727217c --- /dev/null +++ b/src/main/java/com/easemob/im/api/model/EMUploadChatFileResource.java @@ -0,0 +1,270 @@ +/* + * EMService + * Easemob Rest API + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.easemob.im.api.model; + +import java.util.Objects; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.Arrays; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import com.easemob.im.JSON; + +/** + * EMUploadChatFileResource + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-01-25T14:51:53.998371+08:00[Asia/Shanghai]") +public class EMUploadChatFileResource { + public static final String SERIALIZED_NAME_UUID = "uuid"; + @SerializedName(SERIALIZED_NAME_UUID) + private String uuid; + + public static final String SERIALIZED_NAME_TYPE = "type"; + @SerializedName(SERIALIZED_NAME_TYPE) + private String type; + + public static final String SERIALIZED_NAME_SHARE_SECRET = "share-secret"; + @SerializedName(SERIALIZED_NAME_SHARE_SECRET) + private String shareSecret; + + public EMUploadChatFileResource() { + } + + public EMUploadChatFileResource uuid(String uuid) { + + this.uuid = uuid; + return this; + } + + /** + * 文件 ID,即时通讯服务分配给该文件的唯一标识符。该参数在发送消息时需用到 + * @return uuid + **/ + @javax.annotation.Nullable + public String getUuid() { + return uuid; + } + + + public void setUuid(String uuid) { + this.uuid = uuid; + } + + + public EMUploadChatFileResource type(String type) { + + this.type = type; + return this; + } + + /** + * 文件类型,为固定值 chatfile + * @return type + **/ + @javax.annotation.Nullable + public String getType() { + return type; + } + + + public void setType(String type) { + this.type = type; + } + + + public EMUploadChatFileResource shareSecret(String shareSecret) { + + this.shareSecret = shareSecret; + return this; + } + + /** + * 文件访问密钥。你需要自行保存 share-secret,以便 下载文件时使用 + * @return shareSecret + **/ + @javax.annotation.Nullable + public String getShareSecret() { + return shareSecret; + } + + + public void setShareSecret(String shareSecret) { + this.shareSecret = shareSecret; + } + + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + EMUploadChatFileResource uploadChatFileResource = (EMUploadChatFileResource) o; + return Objects.equals(this.uuid, uploadChatFileResource.uuid) && + Objects.equals(this.type, uploadChatFileResource.type) && + Objects.equals(this.shareSecret, uploadChatFileResource.shareSecret); + } + + @Override + public int hashCode() { + return Objects.hash(uuid, type, shareSecret); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class EMUploadChatFileResource {\n"); + sb.append(" uuid: ").append(toIndentedString(uuid)).append("\n"); + sb.append(" type: ").append(toIndentedString(type)).append("\n"); + sb.append(" shareSecret: ").append(toIndentedString(shareSecret)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("uuid"); + openapiFields.add("type"); + openapiFields.add("share-secret"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to EMUploadChatFileResource + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!EMUploadChatFileResource.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format("The required field(s) %s in EMUploadChatFileResource is not found in the empty JSON string", EMUploadChatFileResource.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!EMUploadChatFileResource.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `EMUploadChatFileResource` properties. JSON: %s", entry.getKey(), jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + if ((jsonObj.get("uuid") != null && !jsonObj.get("uuid").isJsonNull()) && !jsonObj.get("uuid").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `uuid` to be a primitive type in the JSON string but got `%s`", jsonObj.get("uuid").toString())); + } + if ((jsonObj.get("type") != null && !jsonObj.get("type").isJsonNull()) && !jsonObj.get("type").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `type` to be a primitive type in the JSON string but got `%s`", jsonObj.get("type").toString())); + } + if ((jsonObj.get("share-secret") != null && !jsonObj.get("share-secret").isJsonNull()) && !jsonObj.get("share-secret").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `share-secret` to be a primitive type in the JSON string but got `%s`", jsonObj.get("share-secret").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!EMUploadChatFileResource.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'EMUploadChatFileResource' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(EMUploadChatFileResource.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, EMUploadChatFileResource value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public EMUploadChatFileResource read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + return thisAdapter.fromJsonTree(jsonElement); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of EMUploadChatFileResource given an JSON string + * + * @param jsonString JSON string + * @return An instance of EMUploadChatFileResource + * @throws IOException if the JSON string is invalid with respect to EMUploadChatFileResource + */ + public static EMUploadChatFileResource fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, EMUploadChatFileResource.class); + } + + /** + * Convert an instance of EMUploadChatFileResource to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/com/easemob/im/api/model/EMUploadChatFileResult.java b/src/main/java/com/easemob/im/api/model/EMUploadChatFileResult.java new file mode 100644 index 000000000..2d9b76751 --- /dev/null +++ b/src/main/java/com/easemob/im/api/model/EMUploadChatFileResult.java @@ -0,0 +1,230 @@ +/* + * EMService + * Easemob Rest API + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.easemob.im.api.model; + +import java.util.Objects; +import com.easemob.im.api.model.EMUploadChatFileResource; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import com.easemob.im.JSON; + +/** + * EMUploadChatFileResult + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-01-25T14:51:53.998371+08:00[Asia/Shanghai]") +public class EMUploadChatFileResult { + public static final String SERIALIZED_NAME_ENTITIES = "entities"; + @SerializedName(SERIALIZED_NAME_ENTITIES) + private List entities; + + public EMUploadChatFileResult() { + } + + public EMUploadChatFileResult entities(List entities) { + + this.entities = entities; + return this; + } + + public EMUploadChatFileResult addEntitiesItem(EMUploadChatFileResource entitiesItem) { + if (this.entities == null) { + this.entities = new ArrayList<>(); + } + this.entities.add(entitiesItem); + return this; + } + + /** + * Get entities + * @return entities + **/ + @javax.annotation.Nullable + public List getEntities() { + return entities; + } + + + public void setEntities(List entities) { + this.entities = entities; + } + + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + EMUploadChatFileResult uploadChatFileResult = (EMUploadChatFileResult) o; + return Objects.equals(this.entities, uploadChatFileResult.entities); + } + + @Override + public int hashCode() { + return Objects.hash(entities); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class EMUploadChatFileResult {\n"); + sb.append(" entities: ").append(toIndentedString(entities)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("entities"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to EMUploadChatFileResult + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!EMUploadChatFileResult.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format("The required field(s) %s in EMUploadChatFileResult is not found in the empty JSON string", EMUploadChatFileResult.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!EMUploadChatFileResult.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `EMUploadChatFileResult` properties. JSON: %s", entry.getKey(), jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + if (jsonObj.get("entities") != null && !jsonObj.get("entities").isJsonNull()) { + JsonArray jsonArrayentities = jsonObj.getAsJsonArray("entities"); + if (jsonArrayentities != null) { + // ensure the json data is an array + if (!jsonObj.get("entities").isJsonArray()) { + throw new IllegalArgumentException(String.format("Expected the field `entities` to be an array in the JSON string but got `%s`", jsonObj.get("entities").toString())); + } + + // validate the optional field `entities` (array) + for (int i = 0; i < jsonArrayentities.size(); i++) { + EMUploadChatFileResource.validateJsonElement(jsonArrayentities.get(i)); + }; + } + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!EMUploadChatFileResult.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'EMUploadChatFileResult' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(EMUploadChatFileResult.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, EMUploadChatFileResult value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public EMUploadChatFileResult read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + return thisAdapter.fromJsonTree(jsonElement); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of EMUploadChatFileResult given an JSON string + * + * @param jsonString JSON string + * @return An instance of EMUploadChatFileResult + * @throws IOException if the JSON string is invalid with respect to EMUploadChatFileResult + */ + public static EMUploadChatFileResult fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, EMUploadChatFileResult.class); + } + + /** + * Convert an instance of EMUploadChatFileResult to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/com/easemob/im/api/model/EMUploadGroupShareFileResult.java b/src/main/java/com/easemob/im/api/model/EMUploadGroupShareFileResult.java new file mode 100644 index 000000000..9b475432d --- /dev/null +++ b/src/main/java/com/easemob/im/api/model/EMUploadGroupShareFileResult.java @@ -0,0 +1,210 @@ +/* + * EMService + * Easemob Rest API + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.easemob.im.api.model; + +import java.util.Objects; +import com.easemob.im.api.model.EMGroupShareFileResource; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.Arrays; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import com.easemob.im.JSON; + +/** + * EMUploadGroupShareFileResult + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-01-25T14:51:53.998371+08:00[Asia/Shanghai]") +public class EMUploadGroupShareFileResult { + public static final String SERIALIZED_NAME_DATA = "data"; + @SerializedName(SERIALIZED_NAME_DATA) + private EMGroupShareFileResource data; + + public EMUploadGroupShareFileResult() { + } + + public EMUploadGroupShareFileResult data(EMGroupShareFileResource data) { + + this.data = data; + return this; + } + + /** + * Get data + * @return data + **/ + @javax.annotation.Nullable + public EMGroupShareFileResource getData() { + return data; + } + + + public void setData(EMGroupShareFileResource data) { + this.data = data; + } + + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + EMUploadGroupShareFileResult uploadGroupShareFileResult = (EMUploadGroupShareFileResult) o; + return Objects.equals(this.data, uploadGroupShareFileResult.data); + } + + @Override + public int hashCode() { + return Objects.hash(data); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class EMUploadGroupShareFileResult {\n"); + sb.append(" data: ").append(toIndentedString(data)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("data"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to EMUploadGroupShareFileResult + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!EMUploadGroupShareFileResult.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format("The required field(s) %s in EMUploadGroupShareFileResult is not found in the empty JSON string", EMUploadGroupShareFileResult.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!EMUploadGroupShareFileResult.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `EMUploadGroupShareFileResult` properties. JSON: %s", entry.getKey(), jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // validate the optional field `data` + if (jsonObj.get("data") != null && !jsonObj.get("data").isJsonNull()) { + EMGroupShareFileResource.validateJsonElement(jsonObj.get("data")); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!EMUploadGroupShareFileResult.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'EMUploadGroupShareFileResult' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(EMUploadGroupShareFileResult.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, EMUploadGroupShareFileResult value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public EMUploadGroupShareFileResult read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + return thisAdapter.fromJsonTree(jsonElement); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of EMUploadGroupShareFileResult given an JSON string + * + * @param jsonString JSON string + * @return An instance of EMUploadGroupShareFileResult + * @throws IOException if the JSON string is invalid with respect to EMUploadGroupShareFileResult + */ + public static EMUploadGroupShareFileResult fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, EMUploadGroupShareFileResult.class); + } + + /** + * Convert an instance of EMUploadGroupShareFileResult to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/com/easemob/im/api/model/EMUserDeactivateResult.java b/src/main/java/com/easemob/im/api/model/EMUserDeactivateResult.java new file mode 100644 index 000000000..e66724290 --- /dev/null +++ b/src/main/java/com/easemob/im/api/model/EMUserDeactivateResult.java @@ -0,0 +1,230 @@ +/* + * EMService + * Easemob Rest API + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.easemob.im.api.model; + +import java.util.Objects; +import com.easemob.im.api.model.EMUserResource; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import com.easemob.im.JSON; + +/** + * EMUserDeactivateResult + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-01-25T14:51:53.998371+08:00[Asia/Shanghai]") +public class EMUserDeactivateResult { + public static final String SERIALIZED_NAME_ENTITIES = "entities"; + @SerializedName(SERIALIZED_NAME_ENTITIES) + private List entities; + + public EMUserDeactivateResult() { + } + + public EMUserDeactivateResult entities(List entities) { + + this.entities = entities; + return this; + } + + public EMUserDeactivateResult addEntitiesItem(EMUserResource entitiesItem) { + if (this.entities == null) { + this.entities = new ArrayList<>(); + } + this.entities.add(entitiesItem); + return this; + } + + /** + * Get entities + * @return entities + **/ + @javax.annotation.Nullable + public List getEntities() { + return entities; + } + + + public void setEntities(List entities) { + this.entities = entities; + } + + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + EMUserDeactivateResult userDeactivateResult = (EMUserDeactivateResult) o; + return Objects.equals(this.entities, userDeactivateResult.entities); + } + + @Override + public int hashCode() { + return Objects.hash(entities); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class EMUserDeactivateResult {\n"); + sb.append(" entities: ").append(toIndentedString(entities)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("entities"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to EMUserDeactivateResult + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!EMUserDeactivateResult.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format("The required field(s) %s in EMUserDeactivateResult is not found in the empty JSON string", EMUserDeactivateResult.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!EMUserDeactivateResult.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `EMUserDeactivateResult` properties. JSON: %s", entry.getKey(), jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + if (jsonObj.get("entities") != null && !jsonObj.get("entities").isJsonNull()) { + JsonArray jsonArrayentities = jsonObj.getAsJsonArray("entities"); + if (jsonArrayentities != null) { + // ensure the json data is an array + if (!jsonObj.get("entities").isJsonArray()) { + throw new IllegalArgumentException(String.format("Expected the field `entities` to be an array in the JSON string but got `%s`", jsonObj.get("entities").toString())); + } + + // validate the optional field `entities` (array) + for (int i = 0; i < jsonArrayentities.size(); i++) { + EMUserResource.validateJsonElement(jsonArrayentities.get(i)); + }; + } + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!EMUserDeactivateResult.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'EMUserDeactivateResult' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(EMUserDeactivateResult.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, EMUserDeactivateResult value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public EMUserDeactivateResult read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + return thisAdapter.fromJsonTree(jsonElement); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of EMUserDeactivateResult given an JSON string + * + * @param jsonString JSON string + * @return An instance of EMUserDeactivateResult + * @throws IOException if the JSON string is invalid with respect to EMUserDeactivateResult + */ + public static EMUserDeactivateResult fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, EMUserDeactivateResult.class); + } + + /** + * Convert an instance of EMUserDeactivateResult to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/com/easemob/im/api/model/EMUserGlobalMuteResource.java b/src/main/java/com/easemob/im/api/model/EMUserGlobalMuteResource.java new file mode 100644 index 000000000..7f336c11d --- /dev/null +++ b/src/main/java/com/easemob/im/api/model/EMUserGlobalMuteResource.java @@ -0,0 +1,320 @@ +/* + * EMService + * Easemob Rest API + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.easemob.im.api.model; + +import java.util.Objects; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.Arrays; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import com.easemob.im.JSON; + +/** + * EMUserGlobalMuteResource + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-01-25T14:51:53.998371+08:00[Asia/Shanghai]") +public class EMUserGlobalMuteResource { + public static final String SERIALIZED_NAME_USERID = "userid"; + @SerializedName(SERIALIZED_NAME_USERID) + private String userid; + + public static final String SERIALIZED_NAME_CHAT = "chat"; + @SerializedName(SERIALIZED_NAME_CHAT) + private Integer chat; + + public static final String SERIALIZED_NAME_GROUPCHAT = "groupchat"; + @SerializedName(SERIALIZED_NAME_GROUPCHAT) + private Integer groupchat; + + public static final String SERIALIZED_NAME_CHATROOM = "chatroom"; + @SerializedName(SERIALIZED_NAME_CHATROOM) + private Integer chatroom; + + public static final String SERIALIZED_NAME_UNIXTIME = "unixtime"; + @SerializedName(SERIALIZED_NAME_UNIXTIME) + private Integer unixtime; + + public EMUserGlobalMuteResource() { + } + + public EMUserGlobalMuteResource userid(String userid) { + + this.userid = userid; + return this; + } + + /** + * 设置禁言的用户 ID + * @return userid + **/ + @javax.annotation.Nullable + public String getUserid() { + return userid; + } + + + public void setUserid(String userid) { + this.userid = userid; + } + + + public EMUserGlobalMuteResource chat(Integer chat) { + + this.chat = chat; + return this; + } + + /** + * 单聊剩余禁言时间,单位为秒。最大值为 2147483647。 - > 0:该用户 ID 剩余的单聊禁言时长。 - 0:该用户的单聊消息禁言已取消。 - -1:该用户被设置永久单聊消息禁言。 + * @return chat + **/ + @javax.annotation.Nullable + public Integer getChat() { + return chat; + } + + + public void setChat(Integer chat) { + this.chat = chat; + } + + + public EMUserGlobalMuteResource groupchat(Integer groupchat) { + + this.groupchat = groupchat; + return this; + } + + /** + * 群组消息剩余禁言时长,单位为秒,规则同单聊禁言 + * @return groupchat + **/ + @javax.annotation.Nullable + public Integer getGroupchat() { + return groupchat; + } + + + public void setGroupchat(Integer groupchat) { + this.groupchat = groupchat; + } + + + public EMUserGlobalMuteResource chatroom(Integer chatroom) { + + this.chatroom = chatroom; + return this; + } + + /** + * 聊天室消息剩余禁言时长,单位为秒,规则同单聊禁言 + * @return chatroom + **/ + @javax.annotation.Nullable + public Integer getChatroom() { + return chatroom; + } + + + public void setChatroom(Integer chatroom) { + this.chatroom = chatroom; + } + + + public EMUserGlobalMuteResource unixtime(Integer unixtime) { + + this.unixtime = unixtime; + return this; + } + + /** + * 当前操作的 Unix 时间戳 + * @return unixtime + **/ + @javax.annotation.Nullable + public Integer getUnixtime() { + return unixtime; + } + + + public void setUnixtime(Integer unixtime) { + this.unixtime = unixtime; + } + + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + EMUserGlobalMuteResource userGlobalMuteResource = (EMUserGlobalMuteResource) o; + return Objects.equals(this.userid, userGlobalMuteResource.userid) && + Objects.equals(this.chat, userGlobalMuteResource.chat) && + Objects.equals(this.groupchat, userGlobalMuteResource.groupchat) && + Objects.equals(this.chatroom, userGlobalMuteResource.chatroom) && + Objects.equals(this.unixtime, userGlobalMuteResource.unixtime); + } + + @Override + public int hashCode() { + return Objects.hash(userid, chat, groupchat, chatroom, unixtime); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class EMUserGlobalMuteResource {\n"); + sb.append(" userid: ").append(toIndentedString(userid)).append("\n"); + sb.append(" chat: ").append(toIndentedString(chat)).append("\n"); + sb.append(" groupchat: ").append(toIndentedString(groupchat)).append("\n"); + sb.append(" chatroom: ").append(toIndentedString(chatroom)).append("\n"); + sb.append(" unixtime: ").append(toIndentedString(unixtime)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("userid"); + openapiFields.add("chat"); + openapiFields.add("groupchat"); + openapiFields.add("chatroom"); + openapiFields.add("unixtime"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to EMUserGlobalMuteResource + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!EMUserGlobalMuteResource.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format("The required field(s) %s in EMUserGlobalMuteResource is not found in the empty JSON string", EMUserGlobalMuteResource.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!EMUserGlobalMuteResource.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `EMUserGlobalMuteResource` properties. JSON: %s", entry.getKey(), jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + if ((jsonObj.get("userid") != null && !jsonObj.get("userid").isJsonNull()) && !jsonObj.get("userid").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `userid` to be a primitive type in the JSON string but got `%s`", jsonObj.get("userid").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!EMUserGlobalMuteResource.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'EMUserGlobalMuteResource' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(EMUserGlobalMuteResource.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, EMUserGlobalMuteResource value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public EMUserGlobalMuteResource read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + return thisAdapter.fromJsonTree(jsonElement); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of EMUserGlobalMuteResource given an JSON string + * + * @param jsonString JSON string + * @return An instance of EMUserGlobalMuteResource + * @throws IOException if the JSON string is invalid with respect to EMUserGlobalMuteResource + */ + public static EMUserGlobalMuteResource fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, EMUserGlobalMuteResource.class); + } + + /** + * Convert an instance of EMUserGlobalMuteResource to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/com/easemob/im/api/model/EMUserJoinedGroupResource.java b/src/main/java/com/easemob/im/api/model/EMUserJoinedGroupResource.java new file mode 100644 index 000000000..b2b253d51 --- /dev/null +++ b/src/main/java/com/easemob/im/api/model/EMUserJoinedGroupResource.java @@ -0,0 +1,470 @@ +/* + * EMService + * Easemob Rest API + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.easemob.im.api.model; + +import java.util.Objects; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.math.BigDecimal; +import java.util.Arrays; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import com.easemob.im.JSON; + +/** + * EMUserJoinedGroupResource + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-01-25T14:51:53.998371+08:00[Asia/Shanghai]") +public class EMUserJoinedGroupResource { + public static final String SERIALIZED_NAME_ID = "id"; + @SerializedName(SERIALIZED_NAME_ID) + private String id; + + public static final String SERIALIZED_NAME_NAME = "name"; + @SerializedName(SERIALIZED_NAME_NAME) + private String name; + + public static final String SERIALIZED_NAME_OWNER = "owner"; + @SerializedName(SERIALIZED_NAME_OWNER) + private String owner; + + public static final String SERIALIZED_NAME_DESCRIPTION = "description"; + @SerializedName(SERIALIZED_NAME_DESCRIPTION) + private String description; + + public static final String SERIALIZED_NAME_DISABLED = "disabled"; + @SerializedName(SERIALIZED_NAME_DISABLED) + private Boolean disabled; + + public static final String SERIALIZED_NAME_PUBLIC = "public"; + @SerializedName(SERIALIZED_NAME_PUBLIC) + private Boolean _public; + + public static final String SERIALIZED_NAME_ALLOWINVITES = "allowinvites"; + @SerializedName(SERIALIZED_NAME_ALLOWINVITES) + private Boolean allowinvites; + + public static final String SERIALIZED_NAME_MEMBERSONLY = "membersonly"; + @SerializedName(SERIALIZED_NAME_MEMBERSONLY) + private Boolean membersonly; + + public static final String SERIALIZED_NAME_MAXUSERS = "maxusers"; + @SerializedName(SERIALIZED_NAME_MAXUSERS) + private Integer maxusers; + + public static final String SERIALIZED_NAME_CREATED = "created"; + @SerializedName(SERIALIZED_NAME_CREATED) + private BigDecimal created; + + public EMUserJoinedGroupResource() { + } + + public EMUserJoinedGroupResource id(String id) { + + this.id = id; + return this; + } + + /** + * 群组 ID + * @return id + **/ + @javax.annotation.Nullable + public String getId() { + return id; + } + + + public void setId(String id) { + this.id = id; + } + + + public EMUserJoinedGroupResource name(String name) { + + this.name = name; + return this; + } + + /** + * 群组名称 + * @return name + **/ + @javax.annotation.Nullable + public String getName() { + return name; + } + + + public void setName(String name) { + this.name = name; + } + + + public EMUserJoinedGroupResource owner(String owner) { + + this.owner = owner; + return this; + } + + /** + * 群主的用户 ID + * @return owner + **/ + @javax.annotation.Nullable + public String getOwner() { + return owner; + } + + + public void setOwner(String owner) { + this.owner = owner; + } + + + public EMUserJoinedGroupResource description(String description) { + + this.description = description; + return this; + } + + /** + * 群组描述 + * @return description + **/ + @javax.annotation.Nullable + public String getDescription() { + return description; + } + + + public void setDescription(String description) { + this.description = description; + } + + + public EMUserJoinedGroupResource disabled(Boolean disabled) { + + this.disabled = disabled; + return this; + } + + /** + * 群组是否被禁用: - true:禁用。禁用后不能对群组进行任何修改。 - false:未禁用 + * @return disabled + **/ + @javax.annotation.Nullable + public Boolean getDisabled() { + return disabled; + } + + + public void setDisabled(Boolean disabled) { + this.disabled = disabled; + } + + + public EMUserJoinedGroupResource _public(Boolean _public) { + + this._public = _public; + return this; + } + + /** + * 是否是公开群: - true:公开群。公开群可以被搜索到,用户可以申请加入公开群。 - false:私有群。私有群无法被搜索到,需要群主或群管理员邀请,用户才可以加入 + * @return _public + **/ + @javax.annotation.Nullable + public Boolean getPublic() { + return _public; + } + + + public void setPublic(Boolean _public) { + this._public = _public; + } + + + public EMUserJoinedGroupResource allowinvites(Boolean allowinvites) { + + this.allowinvites = allowinvites; + return this; + } + + /** + * 是否允许普通群成员邀请用户加入群组: - true:普通群成员可拉人入群; - false:只有群主或者管理员才可以拉人入群 + * @return allowinvites + **/ + @javax.annotation.Nullable + public Boolean getAllowinvites() { + return allowinvites; + } + + + public void setAllowinvites(Boolean allowinvites) { + this.allowinvites = allowinvites; + } + + + public EMUserJoinedGroupResource membersonly(Boolean membersonly) { + + this.membersonly = membersonly; + return this; + } + + /** + * 用户申请入群是否需要群主或者群管理员审批。 - true:需要; - false:不需要,用户直接进群 + * @return membersonly + **/ + @javax.annotation.Nullable + public Boolean getMembersonly() { + return membersonly; + } + + + public void setMembersonly(Boolean membersonly) { + this.membersonly = membersonly; + } + + + public EMUserJoinedGroupResource maxusers(Integer maxusers) { + + this.maxusers = maxusers; + return this; + } + + /** + * 群组最大成员数(包括群主) + * @return maxusers + **/ + @javax.annotation.Nullable + public Integer getMaxusers() { + return maxusers; + } + + + public void setMaxusers(Integer maxusers) { + this.maxusers = maxusers; + } + + + public EMUserJoinedGroupResource created(BigDecimal created) { + + this.created = created; + return this; + } + + /** + * 群组创建的时间戳,单位为毫秒 + * @return created + **/ + @javax.annotation.Nullable + public BigDecimal getCreated() { + return created; + } + + + public void setCreated(BigDecimal created) { + this.created = created; + } + + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + EMUserJoinedGroupResource userJoinedGroupResource = (EMUserJoinedGroupResource) o; + return Objects.equals(this.id, userJoinedGroupResource.id) && + Objects.equals(this.name, userJoinedGroupResource.name) && + Objects.equals(this.owner, userJoinedGroupResource.owner) && + Objects.equals(this.description, userJoinedGroupResource.description) && + Objects.equals(this.disabled, userJoinedGroupResource.disabled) && + Objects.equals(this._public, userJoinedGroupResource._public) && + Objects.equals(this.allowinvites, userJoinedGroupResource.allowinvites) && + Objects.equals(this.membersonly, userJoinedGroupResource.membersonly) && + Objects.equals(this.maxusers, userJoinedGroupResource.maxusers) && + Objects.equals(this.created, userJoinedGroupResource.created); + } + + @Override + public int hashCode() { + return Objects.hash(id, name, owner, description, disabled, _public, allowinvites, membersonly, maxusers, created); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class EMUserJoinedGroupResource {\n"); + sb.append(" id: ").append(toIndentedString(id)).append("\n"); + sb.append(" name: ").append(toIndentedString(name)).append("\n"); + sb.append(" owner: ").append(toIndentedString(owner)).append("\n"); + sb.append(" description: ").append(toIndentedString(description)).append("\n"); + sb.append(" disabled: ").append(toIndentedString(disabled)).append("\n"); + sb.append(" _public: ").append(toIndentedString(_public)).append("\n"); + sb.append(" allowinvites: ").append(toIndentedString(allowinvites)).append("\n"); + sb.append(" membersonly: ").append(toIndentedString(membersonly)).append("\n"); + sb.append(" maxusers: ").append(toIndentedString(maxusers)).append("\n"); + sb.append(" created: ").append(toIndentedString(created)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("id"); + openapiFields.add("name"); + openapiFields.add("owner"); + openapiFields.add("description"); + openapiFields.add("disabled"); + openapiFields.add("public"); + openapiFields.add("allowinvites"); + openapiFields.add("membersonly"); + openapiFields.add("maxusers"); + openapiFields.add("created"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to EMUserJoinedGroupResource + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!EMUserJoinedGroupResource.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format("The required field(s) %s in EMUserJoinedGroupResource is not found in the empty JSON string", EMUserJoinedGroupResource.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!EMUserJoinedGroupResource.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `EMUserJoinedGroupResource` properties. JSON: %s", entry.getKey(), jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + if ((jsonObj.get("id") != null && !jsonObj.get("id").isJsonNull()) && !jsonObj.get("id").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `id` to be a primitive type in the JSON string but got `%s`", jsonObj.get("id").toString())); + } + if ((jsonObj.get("name") != null && !jsonObj.get("name").isJsonNull()) && !jsonObj.get("name").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("name").toString())); + } + if ((jsonObj.get("owner") != null && !jsonObj.get("owner").isJsonNull()) && !jsonObj.get("owner").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `owner` to be a primitive type in the JSON string but got `%s`", jsonObj.get("owner").toString())); + } + if ((jsonObj.get("description") != null && !jsonObj.get("description").isJsonNull()) && !jsonObj.get("description").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `description` to be a primitive type in the JSON string but got `%s`", jsonObj.get("description").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!EMUserJoinedGroupResource.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'EMUserJoinedGroupResource' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(EMUserJoinedGroupResource.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, EMUserJoinedGroupResource value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public EMUserJoinedGroupResource read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + return thisAdapter.fromJsonTree(jsonElement); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of EMUserJoinedGroupResource given an JSON string + * + * @param jsonString JSON string + * @return An instance of EMUserJoinedGroupResource + * @throws IOException if the JSON string is invalid with respect to EMUserJoinedGroupResource + */ + public static EMUserJoinedGroupResource fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, EMUserJoinedGroupResource.class); + } + + /** + * Convert an instance of EMUserJoinedGroupResource to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/com/easemob/im/api/model/EMUserResource.java b/src/main/java/com/easemob/im/api/model/EMUserResource.java new file mode 100644 index 000000000..b49c8e609 --- /dev/null +++ b/src/main/java/com/easemob/im/api/model/EMUserResource.java @@ -0,0 +1,296 @@ +/* + * EMService + * Easemob Rest API + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.easemob.im.api.model; + +import java.util.Objects; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.math.BigDecimal; +import java.util.Arrays; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import com.easemob.im.JSON; + +/** + * EMUserResource + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-01-25T14:51:53.998371+08:00[Asia/Shanghai]") +public class EMUserResource { + public static final String SERIALIZED_NAME_USERNAME = "username"; + @SerializedName(SERIALIZED_NAME_USERNAME) + private String username; + + public static final String SERIALIZED_NAME_UUID = "uuid"; + @SerializedName(SERIALIZED_NAME_UUID) + private String uuid; + + public static final String SERIALIZED_NAME_ACTIVATED = "activated"; + @SerializedName(SERIALIZED_NAME_ACTIVATED) + private Boolean activated; + + public static final String SERIALIZED_NAME_CREATED = "created"; + @SerializedName(SERIALIZED_NAME_CREATED) + private BigDecimal created; + + public EMUserResource() { + } + + public EMUserResource username(String username) { + + this.username = username; + return this; + } + + /** + * 用户 ID + * @return username + **/ + @javax.annotation.Nullable + public String getUsername() { + return username; + } + + + public void setUsername(String username) { + this.username = username; + } + + + public EMUserResource uuid(String uuid) { + + this.uuid = uuid; + return this; + } + + /** + * 用户 ID 的 uuid + * @return uuid + **/ + @javax.annotation.Nullable + public String getUuid() { + return uuid; + } + + + public void setUuid(String uuid) { + this.uuid = uuid; + } + + + public EMUserResource activated(Boolean activated) { + + this.activated = activated; + return this; + } + + /** + * 用户是否被封禁 + * @return activated + **/ + @javax.annotation.Nullable + public Boolean getActivated() { + return activated; + } + + + public void setActivated(Boolean activated) { + this.activated = activated; + } + + + public EMUserResource created(BigDecimal created) { + + this.created = created; + return this; + } + + /** + * 用户创建的时间 + * @return created + **/ + @javax.annotation.Nullable + public BigDecimal getCreated() { + return created; + } + + + public void setCreated(BigDecimal created) { + this.created = created; + } + + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + EMUserResource userResource = (EMUserResource) o; + return Objects.equals(this.username, userResource.username) && + Objects.equals(this.uuid, userResource.uuid) && + Objects.equals(this.activated, userResource.activated) && + Objects.equals(this.created, userResource.created); + } + + @Override + public int hashCode() { + return Objects.hash(username, uuid, activated, created); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class EMUserResource {\n"); + sb.append(" username: ").append(toIndentedString(username)).append("\n"); + sb.append(" uuid: ").append(toIndentedString(uuid)).append("\n"); + sb.append(" activated: ").append(toIndentedString(activated)).append("\n"); + sb.append(" created: ").append(toIndentedString(created)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("username"); + openapiFields.add("uuid"); + openapiFields.add("activated"); + openapiFields.add("created"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to EMUserResource + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!EMUserResource.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format("The required field(s) %s in EMUserResource is not found in the empty JSON string", EMUserResource.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!EMUserResource.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `EMUserResource` properties. JSON: %s", entry.getKey(), jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + if ((jsonObj.get("username") != null && !jsonObj.get("username").isJsonNull()) && !jsonObj.get("username").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `username` to be a primitive type in the JSON string but got `%s`", jsonObj.get("username").toString())); + } + if ((jsonObj.get("uuid") != null && !jsonObj.get("uuid").isJsonNull()) && !jsonObj.get("uuid").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `uuid` to be a primitive type in the JSON string but got `%s`", jsonObj.get("uuid").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!EMUserResource.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'EMUserResource' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(EMUserResource.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, EMUserResource value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public EMUserResource read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + return thisAdapter.fromJsonTree(jsonElement); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of EMUserResource given an JSON string + * + * @param jsonString JSON string + * @return An instance of EMUserResource + * @throws IOException if the JSON string is invalid with respect to EMUserResource + */ + public static EMUserResource fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, EMUserResource.class); + } + + /** + * Convert an instance of EMUserResource to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/com/easemob/im/auth/ApiKeyAuth.java b/src/main/java/com/easemob/im/auth/ApiKeyAuth.java new file mode 100644 index 000000000..0a2fbcb13 --- /dev/null +++ b/src/main/java/com/easemob/im/auth/ApiKeyAuth.java @@ -0,0 +1,80 @@ +/* + * EMService + * Easemob Rest API + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.easemob.im.auth; + +import com.easemob.im.ApiException; +import com.easemob.im.Pair; + +import java.net.URI; +import java.util.Map; +import java.util.List; + +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-01-25T14:51:53.998371+08:00[Asia/Shanghai]") +public class ApiKeyAuth implements Authentication { + private final String location; + private final String paramName; + + private String apiKey; + private String apiKeyPrefix; + + public ApiKeyAuth(String location, String paramName) { + this.location = location; + this.paramName = paramName; + } + + public String getLocation() { + return location; + } + + public String getParamName() { + return paramName; + } + + public String getApiKey() { + return apiKey; + } + + public void setApiKey(String apiKey) { + this.apiKey = apiKey; + } + + public String getApiKeyPrefix() { + return apiKeyPrefix; + } + + public void setApiKeyPrefix(String apiKeyPrefix) { + this.apiKeyPrefix = apiKeyPrefix; + } + + @Override + public void applyToParams(List queryParams, Map headerParams, Map cookieParams, + String payload, String method, URI uri) throws ApiException { + if (apiKey == null) { + return; + } + String value; + if (apiKeyPrefix != null) { + value = apiKeyPrefix + " " + apiKey; + } else { + value = apiKey; + } + if ("query".equals(location)) { + queryParams.add(new Pair(paramName, value)); + } else if ("header".equals(location)) { + headerParams.put(paramName, value); + } else if ("cookie".equals(location)) { + cookieParams.put(paramName, value); + } + } +} diff --git a/src/main/java/com/easemob/im/auth/Authentication.java b/src/main/java/com/easemob/im/auth/Authentication.java new file mode 100644 index 000000000..13b3ca6c2 --- /dev/null +++ b/src/main/java/com/easemob/im/auth/Authentication.java @@ -0,0 +1,36 @@ +/* + * EMService + * Easemob Rest API + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.easemob.im.auth; + +import com.easemob.im.Pair; +import com.easemob.im.ApiException; + +import java.net.URI; +import java.util.Map; +import java.util.List; + +public interface Authentication { + /** + * Apply authentication settings to header and query params. + * + * @param queryParams List of query parameters + * @param headerParams Map of header parameters + * @param cookieParams Map of cookie parameters + * @param payload HTTP request body + * @param method HTTP method + * @param uri URI + * @throws ApiException if failed to update the parameters + */ + void applyToParams(List queryParams, Map headerParams, Map cookieParams, String payload, String method, URI uri) throws ApiException; +} diff --git a/src/main/java/com/easemob/im/auth/HttpBasicAuth.java b/src/main/java/com/easemob/im/auth/HttpBasicAuth.java new file mode 100644 index 000000000..7750c3b8b --- /dev/null +++ b/src/main/java/com/easemob/im/auth/HttpBasicAuth.java @@ -0,0 +1,57 @@ +/* + * EMService + * Easemob Rest API + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.easemob.im.auth; + +import com.easemob.im.Pair; +import com.easemob.im.ApiException; + +import okhttp3.Credentials; + +import java.net.URI; +import java.util.Map; +import java.util.List; + +import java.io.UnsupportedEncodingException; + +public class HttpBasicAuth implements Authentication { + private String username; + private String password; + + public String getUsername() { + return username; + } + + public void setUsername(String username) { + this.username = username; + } + + public String getPassword() { + return password; + } + + public void setPassword(String password) { + this.password = password; + } + + @Override + public void applyToParams(List queryParams, Map headerParams, Map cookieParams, + String payload, String method, URI uri) throws ApiException { + if (username == null && password == null) { + return; + } + headerParams.put("Authorization", Credentials.basic( + username == null ? "" : username, + password == null ? "" : password)); + } +} diff --git a/src/main/java/com/easemob/im/auth/HttpBearerAuth.java b/src/main/java/com/easemob/im/auth/HttpBearerAuth.java new file mode 100644 index 000000000..c4054dc32 --- /dev/null +++ b/src/main/java/com/easemob/im/auth/HttpBearerAuth.java @@ -0,0 +1,63 @@ +/* + * EMService + * Easemob Rest API + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.easemob.im.auth; + +import com.easemob.im.ApiException; +import com.easemob.im.Pair; + +import java.net.URI; +import java.util.Map; +import java.util.List; + +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-01-25T14:51:53.998371+08:00[Asia/Shanghai]") +public class HttpBearerAuth implements Authentication { + private final String scheme; + private String bearerToken; + + public HttpBearerAuth(String scheme) { + this.scheme = scheme; + } + + /** + * Gets the token, which together with the scheme, will be sent as the value of the Authorization header. + * + * @return The bearer token + */ + public String getBearerToken() { + return bearerToken; + } + + /** + * Sets the token, which together with the scheme, will be sent as the value of the Authorization header. + * + * @param bearerToken The bearer token to send in the Authorization header + */ + public void setBearerToken(String bearerToken) { + this.bearerToken = bearerToken; + } + + @Override + public void applyToParams(List queryParams, Map headerParams, Map cookieParams, + String payload, String method, URI uri) throws ApiException { + if (bearerToken == null) { + return; + } + + headerParams.put("Authorization", (scheme != null ? upperCaseBearer(scheme) + " " : "") + bearerToken); + } + + private static String upperCaseBearer(String scheme) { + return ("bearer".equalsIgnoreCase(scheme)) ? "Bearer" : scheme; + } +} diff --git a/src/test/java/com/easemob/im/api/AbstractTest.java b/src/test/java/com/easemob/im/api/AbstractTest.java new file mode 100644 index 000000000..1141bdeea --- /dev/null +++ b/src/test/java/com/easemob/im/api/AbstractTest.java @@ -0,0 +1,30 @@ +package com.easemob.im.api; + +import com.easemob.im.ApiClient; +import com.easemob.im.ApiException; +import com.easemob.im.Configuration; + +import java.time.Instant; +import java.util.concurrent.ThreadLocalRandom; + +public abstract class AbstractTest { + static { + try { + Configuration.setDefaultApiClient(ApiClient.builder() + .setBasePath(System.getenv("IM_BASE_URI")) + .setAppKey(System.getenv("IM_APPKEY")) + .setClientId(System.getenv("IM_CLIENT_ID")) + .setClientSecret(System.getenv("IM_CLIENT_SECRET")) + .build()); + } catch (ApiException e) { + throw new RuntimeException(e); + } + } + + protected static String randomUserName() { + return String.format("user-%d-%d", + ThreadLocalRandom.current().nextInt(100000000), + Instant.now().toEpochMilli() + ); + } +} diff --git a/src/test/java/com/easemob/im/api/BlockApiTest.java b/src/test/java/com/easemob/im/api/BlockApiTest.java new file mode 100644 index 000000000..5f6ec69b3 --- /dev/null +++ b/src/test/java/com/easemob/im/api/BlockApiTest.java @@ -0,0 +1,205 @@ +/* + * EMService + * Easemob Rest API + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.easemob.im.api; + +import com.easemob.im.ApiException; +import com.easemob.im.api.model.*; +import org.junit.jupiter.api.Test; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +import static org.junit.jupiter.api.Assertions.*; + +/** + * API tests for BlockApi + */ +public class BlockApiTest extends AbstractTest { + + private final UserApi userApi = new UserApi(); + + private final BlockApi api = new BlockApi(); + + public BlockApiTest() { + } + + /** + * 添加用户至黑名单 + *

+ * 将一个或多个用户添加用户到黑名单。用户被加入黑名单后,无法向你发送消息,也无法发送好友申请。用户可以将任何其他用户添加到黑名单列表,无论该用户是否是好友。好友被加入黑名单后仍在好友列表上显示。每个用户的黑名单人数上限为 500。文档介绍:https://docs-im-beta.easemob.com/document/server-side/user_relationship.html#%E6%B7%BB%E5%8A%A0%E7%94%A8%E6%88%B7%E8%87%B3%E9%BB%91%E5%90%8D%E5%8D%95 + * + * @throws ApiException if the Api call fails + */ + @Test + public void addUserToBlockListTest() throws ApiException { + String username1 = randomUserName(); + String username2 = randomUserName(); + String username3 = randomUserName(); + String password = "123456"; + + List emCreateUserList = new ArrayList<>(); + EMCreateUser createUser1 = new EMCreateUser(); + createUser1.setUsername(username1); + createUser1.setPassword(password); + + EMCreateUser createUser2 = new EMCreateUser(); + createUser2.setUsername(username2); + createUser2.setPassword(password); + + EMCreateUser createUser3 = new EMCreateUser(); + createUser3.setUsername(username3); + createUser3.setPassword(password); + + emCreateUserList.add(createUser1); + emCreateUserList.add(createUser2); + emCreateUserList.add(createUser3); + + assertDoesNotThrow(() -> userApi.createUsers(emCreateUserList)); + + EMAddUserToBlockList addUserToBlockList = new EMAddUserToBlockList(); + addUserToBlockList.setUsernames(Arrays.asList(username2, username3)); + EMAddUserToBlockListResult addUserToBlockListResult = + assertDoesNotThrow(() -> api.addUserToBlockList(username1, addUserToBlockList)); + assertNotNull(addUserToBlockListResult); + assertNotNull(addUserToBlockListResult.getData()); + assertEquals(2, addUserToBlockListResult.getData().size()); + + assertDoesNotThrow(() -> userApi.deleteUser(username1)); + assertDoesNotThrow(() -> userApi.deleteUser(username2)); + assertDoesNotThrow(() -> userApi.deleteUser(username3)); + } + + /** + * 获取黑名单列表 + *

+ * 获取指定用户的好友列表。文档介绍:https://docs-im-beta.easemob.com/document/server-side/user_relationship.html#%E8%8E%B7%E5%8F%96%E5%A5%BD%E5%8F%8B%E5%88%97%E8%A1%A8 + * + * @throws ApiException if the Api call fails + */ + @Test + public void getBlockListTest() throws ApiException { + String username1 = randomUserName(); + String username2 = randomUserName(); + String username3 = randomUserName(); + String password = "123456"; + + List emCreateUserList = new ArrayList<>(); + EMCreateUser createUser1 = new EMCreateUser(); + createUser1.setUsername(username1); + createUser1.setPassword(password); + + EMCreateUser createUser2 = new EMCreateUser(); + createUser2.setUsername(username2); + createUser2.setPassword(password); + + EMCreateUser createUser3 = new EMCreateUser(); + createUser3.setUsername(username3); + createUser3.setPassword(password); + + emCreateUserList.add(createUser1); + emCreateUserList.add(createUser2); + emCreateUserList.add(createUser3); + + assertDoesNotThrow(() -> userApi.createUsers(emCreateUserList)); + + EMAddUserToBlockList addUserToBlockList = new EMAddUserToBlockList(); + addUserToBlockList.setUsernames(Arrays.asList(username2, username3)); + EMAddUserToBlockListResult addUserToBlockListResult = + assertDoesNotThrow(() -> api.addUserToBlockList(username1, addUserToBlockList)); + assertNotNull(addUserToBlockListResult); + assertNotNull(addUserToBlockListResult.getData()); + assertEquals(2, addUserToBlockListResult.getData().size()); + + EMGetBlockListResult getBlockListResult = + assertDoesNotThrow(() -> api.getBlockList(username1, 1, null)); + assertNotNull(getBlockListResult); + assertNotNull(getBlockListResult.getData()); + assertEquals(1, getBlockListResult.getData().size()); + assertNotNull(getBlockListResult.getCursor()); + + EMGetBlockListResult getBlockListNextResult = assertDoesNotThrow( + () -> api.getBlockList(username1, 1, getBlockListResult.getCursor())); + assertEquals(1, getBlockListResult.getData().size()); + + assertDoesNotThrow(() -> userApi.deleteUser(username1)); + assertDoesNotThrow(() -> userApi.deleteUser(username2)); + assertDoesNotThrow(() -> userApi.deleteUser(username3)); + } + + /** + * 从黑名单中移除用户 + *

+ * 从用户的黑名单中移除用户: 将好友从黑名单中移除后,恢复好友关系,可以正常收发消息; 将非好友从黑名单中移除后,恢复到未添加好友的状态。文档介绍:https://docs-im-beta.easemob.com/document/server-side/user_relationship.html#%E4%BB%8E%E9%BB%91%E5%90%8D%E5%8D%95%E4%B8%AD%E7%A7%BB%E9%99%A4%E7%94%A8%E6%88%B7 + * + * @throws ApiException if the Api call fails + */ + @Test + public void removeUserFromBlockListTest() throws ApiException { + String username1 = randomUserName(); + String username2 = randomUserName(); + String username3 = randomUserName(); + String password = "123456"; + + List emCreateUserList = new ArrayList<>(); + EMCreateUser createUser1 = new EMCreateUser(); + createUser1.setUsername(username1); + createUser1.setPassword(password); + + EMCreateUser createUser2 = new EMCreateUser(); + createUser2.setUsername(username2); + createUser2.setPassword(password); + + EMCreateUser createUser3 = new EMCreateUser(); + createUser3.setUsername(username3); + createUser3.setPassword(password); + + emCreateUserList.add(createUser1); + emCreateUserList.add(createUser2); + emCreateUserList.add(createUser3); + + assertDoesNotThrow(() -> userApi.createUsers(emCreateUserList)); + + EMAddUserToBlockList addUserToBlockList = new EMAddUserToBlockList(); + addUserToBlockList.setUsernames(Arrays.asList(username2, username3)); + EMAddUserToBlockListResult addUserToBlockListResult = + assertDoesNotThrow(() -> api.addUserToBlockList(username1, addUserToBlockList)); + assertNotNull(addUserToBlockListResult); + assertNotNull(addUserToBlockListResult.getData()); + assertEquals(2, addUserToBlockListResult.getData().size()); + + EMGetBlockListResult getBlockListResult = + assertDoesNotThrow(() -> api.getBlockList(username1, 2, null)); + assertNotNull(getBlockListResult); + assertNotNull(getBlockListResult.getData()); + assertEquals(2, getBlockListResult.getData().size()); + + EMRemoveUserFromBlockListResult removeUserFromBlockListResult = + assertDoesNotThrow(() -> api.removeUserFromBlockList(username1, username2)); + assertNotNull(removeUserFromBlockListResult); + assertNotNull(removeUserFromBlockListResult.getEntities()); + assertEquals(username2, removeUserFromBlockListResult.getEntities().get(0).getUsername()); + + EMGetBlockListResult getBlockListResult1 = + assertDoesNotThrow(() -> api.getBlockList(username1, 2, null)); + assertNotNull(getBlockListResult1); + assertNotNull(getBlockListResult1.getData()); + assertEquals(1, getBlockListResult1.getData().size()); + + assertDoesNotThrow(() -> userApi.deleteUser(username1)); + assertDoesNotThrow(() -> userApi.deleteUser(username2)); + assertDoesNotThrow(() -> userApi.deleteUser(username3)); + } + +} diff --git a/src/test/java/com/easemob/im/api/ChatFileApiTest.java b/src/test/java/com/easemob/im/api/ChatFileApiTest.java new file mode 100644 index 000000000..28da64c99 --- /dev/null +++ b/src/test/java/com/easemob/im/api/ChatFileApiTest.java @@ -0,0 +1,81 @@ +/* + * EMService + * Easemob Rest API + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.easemob.im.api; + +import com.easemob.im.ApiException; +import com.easemob.im.api.model.EMUploadChatFileResult; +import org.junit.jupiter.api.Test; +import org.junit.platform.commons.util.ClassLoaderUtils; + +import java.io.File; +import java.util.Objects; + +import static org.junit.jupiter.api.Assertions.*; + +/** + * API tests for ChatFileApi + */ +public class ChatFileApiTest extends AbstractTest { + + private final ChatFileApi api = new ChatFileApi(); + + public ChatFileApiTest() { + } + + /** + * 下载文件/下载缩略图 + * + * 可利用该方法下载图片、语音、视频或其他类型的文件。文档介绍:https://docs-im-beta.easemob.com/document/server-side/message_download.html#%E4%B8%8B%E8%BD%BD%E6%96%87%E4%BB%B6 + * + * @throws ApiException if the Api call fails + */ + @Test + public void downloadChatFileTest() throws ApiException { + File _file = new File(Objects.requireNonNull( + ClassLoaderUtils.getDefaultClassLoader().getResource("upload/blue.png")).getPath()); + Boolean restrictAccess = true; + + EMUploadChatFileResult uploadChatFileResult = assertDoesNotThrow(() -> api.uploadChatFile(restrictAccess, _file)); + assertNotNull(uploadChatFileResult); + assertNotNull(uploadChatFileResult.getEntities()); + assertNotNull(uploadChatFileResult.getEntities().get(0)); + + String fileUuid = uploadChatFileResult.getEntities().get(0).getUuid(); + String shareSecret = uploadChatFileResult.getEntities().get(0).getShareSecret(); + File file = assertDoesNotThrow(() -> api.downloadChatFile(fileUuid, shareSecret, false)); + assertNotNull(file); + assertTrue(file.delete()); + } + + /** + * 上传文件 + * + * 对于附件类型的消息,如图片、语音、视频或其他类型文件,发送消息前需上传文件。文档介绍:https://docs-im-beta.easemob.com/document/server-side/message_download.html#%E4%B8%8A%E4%BC%A0%E6%96%87%E4%BB%B6 + * + * @throws ApiException if the Api call fails + */ + @Test + public void uploadChatFileTest() throws ApiException { + File _file = new File(Objects.requireNonNull( + ClassLoaderUtils.getDefaultClassLoader().getResource("upload/blue.png")).getPath()); + Boolean restrictAccess = false; + + EMUploadChatFileResult uploadChatFileResult = assertDoesNotThrow(() -> api.uploadChatFile(restrictAccess, _file)); + assertNotNull(uploadChatFileResult); + assertNotNull(uploadChatFileResult.getEntities()); + assertNotNull(uploadChatFileResult.getEntities().get(0)); + assertNotNull(uploadChatFileResult.getEntities().get(0).getUuid()); + } + +} diff --git a/src/test/java/com/easemob/im/api/ContactApiTest.java b/src/test/java/com/easemob/im/api/ContactApiTest.java new file mode 100644 index 000000000..6bea0fbf8 --- /dev/null +++ b/src/test/java/com/easemob/im/api/ContactApiTest.java @@ -0,0 +1,213 @@ +/* + * EMService + * Easemob Rest API + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.easemob.im.api; + +import com.easemob.im.ApiException; +import com.easemob.im.api.model.*; +import org.junit.jupiter.api.Test; + +import java.util.ArrayList; +import java.util.List; + +import static org.junit.jupiter.api.Assertions.*; + +/** + * API tests for ContactApi + */ +public class ContactApiTest extends AbstractTest { + + private final ContactApi api = new ContactApi(); + + private final UserApi userApi = new UserApi(); + + public ContactApiTest() { + } + + /** + * 添加好友 + * + * 添加好友,好友必须是和当前用户在一个 App Key 下的用户。对于免费版即时通讯服务,单个 App Key 下的每个用户的好友数量上限为 1000,不同服务版本的 App Key 的该数量上限不同。文档介绍:https://docs-im-beta.easemob.com/document/server-side/user_relationship.html#%E6%B7%BB%E5%8A%A0%E5%A5%BD%E5%8F%8B + * + * @throws ApiException if the Api call fails + */ + @Test + public void addContactTest() throws ApiException { + String username1 = randomUserName(); + String username2 = randomUserName(); + String password = "123456"; + + List emCreateUserList = new ArrayList<>(); + EMCreateUser createUser1 = new EMCreateUser(); + createUser1.setUsername(username1); + createUser1.setPassword(password); + + EMCreateUser createUser2 = new EMCreateUser(); + createUser2.setUsername(username2); + createUser2.setPassword(password); + + emCreateUserList.add(createUser1); + emCreateUserList.add(createUser2); + + assertDoesNotThrow(() -> userApi.createUsers(emCreateUserList)); + + EMAddContactResult response = api.addContact(username1, username2); + assertNotNull(response); + assertNotNull(response.getEntities()); + assertNotNull(response.getEntities().get(0)); + assertEquals(username2, response.getEntities().get(0).getUsername()); + + assertDoesNotThrow(() -> userApi.deleteUser(username1)); + assertDoesNotThrow(() -> userApi.deleteUser(username2)); + } + + /** + * 获取好友列表 + * + * 获取指定用户的好友列表。文档介绍:https://docs-im-beta.easemob.com/document/server-side/user_relationship.html#%E8%8E%B7%E5%8F%96%E5%A5%BD%E5%8F%8B%E5%88%97%E8%A1%A8 + * + * @throws ApiException if the Api call fails + */ + @Test + public void getContactListTest() throws ApiException { + String username1 = randomUserName(); + String username2 = randomUserName(); + String username3 = randomUserName(); + String password = "123456"; + + List emCreateUserList = new ArrayList<>(); + EMCreateUser createUser1 = new EMCreateUser(); + createUser1.setUsername(username1); + createUser1.setPassword(password); + + EMCreateUser createUser2 = new EMCreateUser(); + createUser2.setUsername(username2); + createUser2.setPassword(password); + + EMCreateUser createUser3 = new EMCreateUser(); + createUser3.setUsername(username3); + createUser3.setPassword(password); + + emCreateUserList.add(createUser1); + emCreateUserList.add(createUser2); + emCreateUserList.add(createUser3); + + assertDoesNotThrow(() -> userApi.createUsers(emCreateUserList)); + + EMAddContactResult addContactResult = assertDoesNotThrow(() -> api.addContact(username1, username2)); + assertNotNull(addContactResult); + assertNotNull(addContactResult.getEntities()); + assertNotNull(addContactResult.getEntities().get(0)); + assertEquals(username2, addContactResult.getEntities().get(0).getUsername()); + + assertDoesNotThrow(() -> api.addContact(username1, username3)); + + EMGetContactListResult getContactListResult = assertDoesNotThrow(() -> api.getContactList(username1, 2, null, true)); + assertNotNull(getContactListResult); + assertNotNull(getContactListResult.getData()); + assertNotNull(getContactListResult.getData().getContacts()); + assertEquals(2, getContactListResult.getData().getContacts().size()); + + assertDoesNotThrow(() -> userApi.deleteUser(username1)); + assertDoesNotThrow(() -> userApi.deleteUser(username2)); + assertDoesNotThrow(() -> userApi.deleteUser(username3)); + } + + /** + * 移除好友 + * + * 从用户的好友列表中移除一个用户。文档介绍:https://docs-im-beta.easemob.com/document/server-side/user_relationship.html#%E7%A7%BB%E9%99%A4%E5%A5%BD%E5%8F%8B + * + * @throws ApiException if the Api call fails + */ + @Test + public void removeContactTest() throws ApiException { + String username1 = randomUserName(); + String username2 = randomUserName(); + String password = "123456"; + + List emCreateUserList = new ArrayList<>(); + EMCreateUser createUser1 = new EMCreateUser(); + createUser1.setUsername(username1); + createUser1.setPassword(password); + + EMCreateUser createUser2 = new EMCreateUser(); + createUser2.setUsername(username2); + createUser2.setPassword(password); + + emCreateUserList.add(createUser1); + emCreateUserList.add(createUser2); + + assertDoesNotThrow(() -> userApi.createUsers(emCreateUserList)); + + EMAddContactResult addContactResult = assertDoesNotThrow(() -> api.addContact(username1, username2)); + assertNotNull(addContactResult); + assertNotNull(addContactResult.getEntities()); + assertNotNull(addContactResult.getEntities().get(0)); + assertEquals(username2, addContactResult.getEntities().get(0).getUsername()); + + EMRemoveContactResult removeContactResult = assertDoesNotThrow(() -> api.removeContact(username1, username2)); + assertNotNull(removeContactResult); + assertNotNull(removeContactResult.getEntities()); + assertNotNull(removeContactResult.getEntities().get(0)); + assertEquals(username2, removeContactResult.getEntities().get(0).getUsername()); + + assertDoesNotThrow(() -> userApi.deleteUser(username1)); + assertDoesNotThrow(() -> userApi.deleteUser(username2)); + } + + /** + * 设置好友备注 + * + * 你可以调用该接口设置你在当前 app 下的好友的备注,即你和要设置备注的好友需在同一个 App Key 下。对于免费版即时通讯服务,单个 App Key 下的每个用户的好友数量上限为 100,不同服务套餐包的 App Key 的该数量上限不同。文档介绍:https://docs-im-beta.easemob.com/document/server-side/user_relationship.html#%E8%AE%BE%E7%BD%AE%E5%A5%BD%E5%8F%8B%E5%A4%87%E6%B3%A8 + * + * @throws ApiException if the Api call fails + */ + @Test + public void setContactNoteTest() throws ApiException { + String username1 = randomUserName(); + String username2 = randomUserName(); + String password = "123456"; + + List emCreateUserList = new ArrayList<>(); + EMCreateUser createUser1 = new EMCreateUser(); + createUser1.setUsername(username1); + createUser1.setPassword(password); + + EMCreateUser createUser2 = new EMCreateUser(); + createUser2.setUsername(username2); + createUser2.setPassword(password); + + emCreateUserList.add(createUser1); + emCreateUserList.add(createUser2); + + assertDoesNotThrow(() -> userApi.createUsers(emCreateUserList)); + + EMAddContactResult addContactResult = assertDoesNotThrow(() -> api.addContact(username1, username2)); + assertNotNull(addContactResult); + assertNotNull(addContactResult.getEntities()); + assertNotNull(addContactResult.getEntities().get(0)); + assertEquals(username2, addContactResult.getEntities().get(0).getUsername()); + + EMSetContactNote contactNote = new EMSetContactNote(); + contactNote.setRemark("tom"); + EMSetContactNoteResult setContactNoteResult = assertDoesNotThrow(() -> api.setContactNote(username1, username2, contactNote)); + assertNotNull(setContactNoteResult); + assertNotNull(setContactNoteResult.getStatus()); + assertEquals("ok", setContactNoteResult.getStatus()); + + assertDoesNotThrow(() -> userApi.deleteUser(username1)); + assertDoesNotThrow(() -> userApi.deleteUser(username2)); + } + +} diff --git a/src/test/java/com/easemob/im/api/GroupApiTest.java b/src/test/java/com/easemob/im/api/GroupApiTest.java new file mode 100644 index 000000000..e68405150 --- /dev/null +++ b/src/test/java/com/easemob/im/api/GroupApiTest.java @@ -0,0 +1,2090 @@ +/* + * EMService + * Easemob Rest API + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.easemob.im.api; + +import com.easemob.im.ApiException; +import com.easemob.im.api.model.*; +import org.junit.jupiter.api.Test; +import org.junit.platform.commons.util.ClassLoaderUtils; + +import java.io.File; +import java.math.BigDecimal; +import java.util.*; + +import static org.junit.jupiter.api.Assertions.*; + +/** + * API tests for GroupApi + */ +public class GroupApiTest extends AbstractTest { + + private final UserApi userApi = new UserApi(); + + private final GroupApi api = new GroupApi(); + + public GroupApiTest() { + } + + /** + * 添加群管理员 + *

+ * 将一个普通群成员设为为群管理员。群管理员有管理黑名单、禁言等权限。最多可以添加 99 个群管理员。文档介绍:https://docs-im-beta.easemob.com/document/server-side/group.html#%E6%B7%BB%E5%8A%A0%E7%BE%A4%E7%AE%A1%E7%90%86%E5%91%98 + * + * @throws ApiException if the Api call fails + */ + @Test + public void addGroupAdminTest() throws ApiException { + String username1 = randomUserName(); + String username2 = randomUserName(); + String password = "123456"; + + List emCreateUserList = new ArrayList<>(); + EMCreateUser createUser1 = new EMCreateUser(); + createUser1.setUsername(username1); + createUser1.setPassword(password); + + EMCreateUser createUser2 = new EMCreateUser(); + createUser2.setUsername(username2); + createUser2.setPassword(password); + + emCreateUserList.add(createUser1); + emCreateUserList.add(createUser2); + + assertDoesNotThrow(() -> userApi.createUsers(emCreateUserList)); + + EMCreateGroup createGroup = new EMCreateGroup(); + createGroup.setOwner(username1); + createGroup.setGroupname("test-group"); + createGroup.setDescription("元梦之星"); + createGroup.setMaxusers(200); + createGroup.setMembers(Arrays.asList(username2)); + createGroup.setPublic(true); + + EMCreateGroupResult createGroupResult = + assertDoesNotThrow(() -> api.createGroup(createGroup)); + assertNotNull(createGroupResult); + assertNotNull(createGroupResult.getData()); + assertNotNull(createGroupResult.getData().getGroupid()); + + String groupId = createGroupResult.getData().getGroupid(); + EMAddGroupAdmin addGroupAdmin = new EMAddGroupAdmin(); + addGroupAdmin.newadmin(username2); + EMAddGroupAdminResult addGroupAdminResult = + assertDoesNotThrow(() -> api.addGroupAdmin(groupId, addGroupAdmin)); + assertNotNull(addGroupAdminResult); + assertNotNull(addGroupAdminResult.getData()); + assertNotNull(addGroupAdminResult.getData().getResult()); + assertEquals("success", addGroupAdminResult.getData().getResult()); + + assertDoesNotThrow(() -> userApi.deleteUser(username1)); + assertDoesNotThrow(() -> userApi.deleteUser(username2)); + try { + api.deleteGroup(groupId); + } catch (ApiException ignored) { + } + } + + /** + * 批量添加群组成员 + *

+ * 一次为群组添加多个成员,每次最多可以添加 60 位成员。如果所有用户均已是群成员,添加失败,返回错误。文档介绍:https://docs-im-beta.easemob.com/document/server-side/group.html#%E6%89%B9%E9%87%8F%E6%B7%BB%E5%8A%A0%E7%BE%A4%E7%BB%84%E6%88%90%E5%91%98 + * + * @throws ApiException if the Api call fails + */ + @Test + public void addMultipleUserToGroupTest() throws ApiException { + String username1 = randomUserName(); + String username2 = randomUserName(); + String username3 = randomUserName(); + String password = "123456"; + + List emCreateUserList = new ArrayList<>(); + EMCreateUser createUser1 = new EMCreateUser(); + createUser1.setUsername(username1); + createUser1.setPassword(password); + + EMCreateUser createUser2 = new EMCreateUser(); + createUser2.setUsername(username2); + createUser2.setPassword(password); + + EMCreateUser createUser3 = new EMCreateUser(); + createUser3.setUsername(username3); + createUser3.setPassword(password); + + emCreateUserList.add(createUser1); + emCreateUserList.add(createUser2); + emCreateUserList.add(createUser3); + + assertDoesNotThrow(() -> userApi.createUsers(emCreateUserList)); + + EMCreateGroup createGroup = new EMCreateGroup(); + createGroup.setOwner(username1); + createGroup.setGroupname("test-group"); + createGroup.setDescription("元梦之星"); + createGroup.setMaxusers(200); + createGroup.setMembers(Arrays.asList(username2)); + createGroup.setPublic(true); + + EMCreateGroupResult createGroupResult = + assertDoesNotThrow(() -> api.createGroup(createGroup)); + assertNotNull(createGroupResult); + assertNotNull(createGroupResult.getData()); + assertNotNull(createGroupResult.getData().getGroupid()); + + String groupId = createGroupResult.getData().getGroupid(); + EMAddMultipleUserToGroup emAddMultipleUserToGroup = new EMAddMultipleUserToGroup(); + emAddMultipleUserToGroup.setUsernames(Arrays.asList(username3)); + EMAddMultipleUserToGroupResult addMultipleUserToGroup = + api.addMultipleUserToGroup(groupId, emAddMultipleUserToGroup); + assertNotNull(addMultipleUserToGroup); + assertNotNull(addMultipleUserToGroup.getData()); + assertNotNull(addMultipleUserToGroup.getData().getNewmembers()); + assertEquals(1, addMultipleUserToGroup.getData().getNewmembers().size()); + + assertDoesNotThrow(() -> userApi.deleteUser(username1)); + assertDoesNotThrow(() -> userApi.deleteUser(username2)); + assertDoesNotThrow(() -> userApi.deleteUser(username3)); + try { + api.deleteGroup(groupId); + } catch (ApiException ignored) { + } + } + + /** + * 批量添加用户至群组黑名单 + *

+ * 将多个用户添加至群组黑名单,一次最多可以添加 60 个用户。群主无法被加入群组的黑名单。用户进入群组黑名单后会收到加入黑名单的回调。黑名单上的用户无法查看该群组的信息,也收不到该群组的消息。文档介绍:https://docs-im-beta.easemob.com/document/server-side/group.html#%E6%89%B9%E9%87%8F%E6%B7%BB%E5%8A%A0%E7%94%A8%E6%88%B7%E8%87%B3%E7%BE%A4%E7%BB%84%E9%BB%91%E5%90%8D%E5%8D%95 + * + * @throws ApiException if the Api call fails + */ + @Test + public void addMultipleUserToGroupBlockListTest() throws ApiException { + String username1 = randomUserName(); + String username2 = randomUserName(); + String password = "123456"; + + List emCreateUserList = new ArrayList<>(); + EMCreateUser createUser1 = new EMCreateUser(); + createUser1.setUsername(username1); + createUser1.setPassword(password); + + EMCreateUser createUser2 = new EMCreateUser(); + createUser2.setUsername(username2); + createUser2.setPassword(password); + + emCreateUserList.add(createUser1); + emCreateUserList.add(createUser2); + + assertDoesNotThrow(() -> userApi.createUsers(emCreateUserList)); + + EMCreateGroup createGroup = new EMCreateGroup(); + createGroup.setOwner(username1); + createGroup.setGroupname("test-group"); + createGroup.setDescription("元梦之星"); + createGroup.setMaxusers(200); + createGroup.setMembers(Arrays.asList(username2)); + createGroup.setPublic(true); + + EMCreateGroupResult createGroupResult = + assertDoesNotThrow(() -> api.createGroup(createGroup)); + assertNotNull(createGroupResult); + assertNotNull(createGroupResult.getData()); + assertNotNull(createGroupResult.getData().getGroupid()); + + String groupId = createGroupResult.getData().getGroupid(); + EMAddMultipleUserToGroupBlockList emAddMultipleUserToGroupBlockList = + new EMAddMultipleUserToGroupBlockList(); + emAddMultipleUserToGroupBlockList.setUsernames(Arrays.asList(username2)); + EMAddMultipleUserToGroupBlockListResult addMultipleUserToGroupBlockListResult = + assertDoesNotThrow(() -> api.addMultipleUserToGroupBlockList(groupId, + emAddMultipleUserToGroupBlockList)); + assertNotNull(addMultipleUserToGroupBlockListResult); + assertNotNull(addMultipleUserToGroupBlockListResult.getData()); + + assertDoesNotThrow(() -> userApi.deleteUser(username1)); + assertDoesNotThrow(() -> userApi.deleteUser(username2)); + try { + api.deleteGroup(groupId); + } catch (ApiException ignored) { + } + } + + /** + * 批量添加用户至群组白名单 + *

+ * 添加多个用户至群组白名单。你一次最多可添加 60 个用户。用户添加至白名单后在群组全员禁言时仍可以在群组中发送消息。文档介绍:https://docs-im-beta.easemob.com/document/server-side/group.html#%E6%89%B9%E9%87%8F%E6%B7%BB%E5%8A%A0%E7%94%A8%E6%88%B7%E8%87%B3%E7%BE%A4%E7%BB%84%E7%99%BD%E5%90%8D%E5%8D%95 + * + * @throws ApiException if the Api call fails + */ + @Test + public void addMultipleUserToGroupWhiteListTest() throws ApiException { + String username1 = randomUserName(); + String username2 = randomUserName(); + String password = "123456"; + + List emCreateUserList = new ArrayList<>(); + EMCreateUser createUser1 = new EMCreateUser(); + createUser1.setUsername(username1); + createUser1.setPassword(password); + + EMCreateUser createUser2 = new EMCreateUser(); + createUser2.setUsername(username2); + createUser2.setPassword(password); + + emCreateUserList.add(createUser1); + emCreateUserList.add(createUser2); + + assertDoesNotThrow(() -> userApi.createUsers(emCreateUserList)); + + EMCreateGroup createGroup = new EMCreateGroup(); + createGroup.setOwner(username1); + createGroup.setGroupname("test-group"); + createGroup.setDescription("元梦之星"); + createGroup.setMaxusers(200); + createGroup.setMembers(Arrays.asList(username2)); + createGroup.setPublic(true); + + EMCreateGroupResult createGroupResult = + assertDoesNotThrow(() -> api.createGroup(createGroup)); + assertNotNull(createGroupResult); + assertNotNull(createGroupResult.getData()); + assertNotNull(createGroupResult.getData().getGroupid()); + + String groupId = createGroupResult.getData().getGroupid(); + EMAddMultipleUserToGroupWhiteList emAddMultipleUserToGroupWhiteList = + new EMAddMultipleUserToGroupWhiteList(); + emAddMultipleUserToGroupWhiteList.setUsernames(Arrays.asList(username2)); + EMAddMultipleUserToGroupWhiteListResult addMultipleUserToGroupWhiteListResult = + assertDoesNotThrow(() -> api.addMultipleUserToGroupWhiteList(groupId, + emAddMultipleUserToGroupWhiteList)); + assertNotNull(addMultipleUserToGroupWhiteListResult); + assertNotNull(addMultipleUserToGroupWhiteListResult.getData()); + + assertDoesNotThrow(() -> userApi.deleteUser(username1)); + assertDoesNotThrow(() -> userApi.deleteUser(username2)); + try { + api.deleteGroup(groupId); + } catch (ApiException ignored) { + } + } + + /** + * 添加单个群组成员 + *

+ * 每次添加一个群成员。若添加的用户已是群成员,则添加失败,返回错误。文档介绍:https://docs-im-beta.easemob.com/document/server-side/group.html#%E6%B7%BB%E5%8A%A0%E5%8D%95%E4%B8%AA%E7%BE%A4%E7%BB%84%E6%88%90%E5%91%98 + * + * @throws ApiException if the Api call fails + */ + @Test + public void addUserToGroupTest() throws ApiException { + String username1 = randomUserName(); + String username2 = randomUserName(); + String username3 = randomUserName(); + String password = "123456"; + + List emCreateUserList = new ArrayList<>(); + EMCreateUser createUser1 = new EMCreateUser(); + createUser1.setUsername(username1); + createUser1.setPassword(password); + + EMCreateUser createUser2 = new EMCreateUser(); + createUser2.setUsername(username2); + createUser2.setPassword(password); + + EMCreateUser createUser3 = new EMCreateUser(); + createUser3.setUsername(username3); + createUser3.setPassword(password); + + emCreateUserList.add(createUser1); + emCreateUserList.add(createUser2); + emCreateUserList.add(createUser3); + + assertDoesNotThrow(() -> userApi.createUsers(emCreateUserList)); + + EMCreateGroup createGroup = new EMCreateGroup(); + createGroup.setOwner(username1); + createGroup.setGroupname("test-group"); + createGroup.setDescription("元梦之星"); + createGroup.setMaxusers(200); + createGroup.setMembers(Arrays.asList(username2)); + createGroup.setPublic(true); + + EMCreateGroupResult createGroupResult = + assertDoesNotThrow(() -> api.createGroup(createGroup)); + assertNotNull(createGroupResult); + assertNotNull(createGroupResult.getData()); + assertNotNull(createGroupResult.getData().getGroupid()); + + String groupId = createGroupResult.getData().getGroupid(); + EMAddUserToGroupResult addUserToGroupResult = + assertDoesNotThrow(() -> api.addUserToGroup(groupId, username3)); + assertNotNull(addUserToGroupResult); + assertNotNull(addUserToGroupResult.getData()); + assertNotNull(addUserToGroupResult.getData().getResult()); + assertEquals(true, addUserToGroupResult.getData().getResult()); + + assertDoesNotThrow(() -> userApi.deleteUser(username1)); + assertDoesNotThrow(() -> userApi.deleteUser(username2)); + assertDoesNotThrow(() -> userApi.deleteUser(username3)); + try { + api.deleteGroup(groupId); + } catch (ApiException ignored) { + } + } + + /** + * 添加单个用户至群组黑名单 + *

+ * 将单个用户添加至群组黑名单。群主无法被加入群组的黑名单。用户进入群组黑名单后会收到加入黑名单的回调。之后,该用户无法查看该群组的信息,也收不到该群组的消息。文档介绍:https://docs-im-beta.easemob.com/document/server-side/group.html#%E6%B7%BB%E5%8A%A0%E5%8D%95%E4%B8%AA%E7%94%A8%E6%88%B7%E8%87%B3%E7%BE%A4%E7%BB%84%E9%BB%91%E5%90%8D%E5%8D%95 + * + * @throws ApiException if the Api call fails + */ + @Test + public void addUserToGroupBlockListTest() throws ApiException { + String username1 = randomUserName(); + String username2 = randomUserName(); + String password = "123456"; + + List emCreateUserList = new ArrayList<>(); + EMCreateUser createUser1 = new EMCreateUser(); + createUser1.setUsername(username1); + createUser1.setPassword(password); + + EMCreateUser createUser2 = new EMCreateUser(); + createUser2.setUsername(username2); + createUser2.setPassword(password); + + emCreateUserList.add(createUser1); + emCreateUserList.add(createUser2); + + assertDoesNotThrow(() -> userApi.createUsers(emCreateUserList)); + + EMCreateGroup createGroup = new EMCreateGroup(); + createGroup.setOwner(username1); + createGroup.setGroupname("test-group"); + createGroup.setDescription("元梦之星"); + createGroup.setMaxusers(200); + createGroup.setMembers(Arrays.asList(username2)); + createGroup.setPublic(true); + + EMCreateGroupResult createGroupResult = + assertDoesNotThrow(() -> api.createGroup(createGroup)); + assertNotNull(createGroupResult); + assertNotNull(createGroupResult.getData()); + assertNotNull(createGroupResult.getData().getGroupid()); + + String groupId = createGroupResult.getData().getGroupid(); + EMAddUserToGroupBlockListResult addUserToGroupBlockListResult = + assertDoesNotThrow(() -> api.addUserToGroupBlockList(groupId, username2)); + assertNotNull(addUserToGroupBlockListResult); + assertNotNull(addUserToGroupBlockListResult.getData()); + assertNotNull(addUserToGroupBlockListResult.getData().getResult()); + assertEquals(true, addUserToGroupBlockListResult.getData().getResult()); + + assertDoesNotThrow(() -> userApi.deleteUser(username1)); + assertDoesNotThrow(() -> userApi.deleteUser(username2)); + try { + api.deleteGroup(groupId); + } catch (ApiException ignored) { + } + } + + /** + * 添加单个用户至群组白名单 + *

+ * 将指定的单个用户添加至群组白名单。用户添加至群组白名单后,当群组全员被禁言时,仍可以在群组中发送消息。文档介绍:https://docs-im-beta.easemob.com/document/server-side/group.html#%E6%9F%A5%E8%AF%A2%E7%BE%A4%E7%BB%84%E7%99%BD%E5%90%8D%E5%8D%95 + * + * @throws ApiException if the Api call fails + */ + @Test + public void addUserToGroupWhiteListTest() throws ApiException { + String username1 = randomUserName(); + String username2 = randomUserName(); + String password = "123456"; + + List emCreateUserList = new ArrayList<>(); + EMCreateUser createUser1 = new EMCreateUser(); + createUser1.setUsername(username1); + createUser1.setPassword(password); + + EMCreateUser createUser2 = new EMCreateUser(); + createUser2.setUsername(username2); + createUser2.setPassword(password); + + emCreateUserList.add(createUser1); + emCreateUserList.add(createUser2); + + assertDoesNotThrow(() -> userApi.createUsers(emCreateUserList)); + + EMCreateGroup createGroup = new EMCreateGroup(); + createGroup.setOwner(username1); + createGroup.setGroupname("test-group"); + createGroup.setDescription("元梦之星"); + createGroup.setMaxusers(200); + createGroup.setMembers(Arrays.asList(username2)); + createGroup.setPublic(true); + + EMCreateGroupResult createGroupResult = + assertDoesNotThrow(() -> api.createGroup(createGroup)); + assertNotNull(createGroupResult); + assertNotNull(createGroupResult.getData()); + assertNotNull(createGroupResult.getData().getGroupid()); + + String groupId = createGroupResult.getData().getGroupid(); + EMAddUserToGroupWhiteListResult addUserToGroupWhiteListResult = + assertDoesNotThrow(() -> api.addUserToGroupWhiteList(groupId, username2)); + assertNotNull(addUserToGroupWhiteListResult); + assertNotNull(addUserToGroupWhiteListResult.getData()); + assertNotNull(addUserToGroupWhiteListResult.getData().getResult()); + assertEquals(true, addUserToGroupWhiteListResult.getData().getResult()); + + assertDoesNotThrow(() -> userApi.deleteUser(username1)); + assertDoesNotThrow(() -> userApi.deleteUser(username2)); + try { + api.deleteGroup(groupId); + } catch (ApiException ignored) { + } + } + + /** + * 查看指定用户是否已加入群组 + *

+ * 查看单个用户是否已加入了指定的群组。文档介绍:https://docs-im-beta.easemob.com/document/server-side/group.html#%E6%9F%A5%E7%9C%8B%E6%8C%87%E5%AE%9A%E7%94%A8%E6%88%B7%E6%98%AF%E5%90%A6%E5%B7%B2%E5%8A%A0%E5%85%A5%E7%BE%A4%E7%BB%84 + * + * @throws ApiException if the Api call fails + */ + @Test + public void checkUserJoinedGroupTest() throws ApiException { + String username1 = randomUserName(); + String username2 = randomUserName(); + String password = "123456"; + + List emCreateUserList = new ArrayList<>(); + EMCreateUser createUser1 = new EMCreateUser(); + createUser1.setUsername(username1); + createUser1.setPassword(password); + + EMCreateUser createUser2 = new EMCreateUser(); + createUser2.setUsername(username2); + createUser2.setPassword(password); + + emCreateUserList.add(createUser1); + emCreateUserList.add(createUser2); + + assertDoesNotThrow(() -> userApi.createUsers(emCreateUserList)); + + EMCreateGroup createGroup = new EMCreateGroup(); + createGroup.setOwner(username1); + createGroup.setGroupname("test-group"); + createGroup.setDescription("元梦之星"); + createGroup.setMaxusers(200); + createGroup.setMembers(Arrays.asList(username2)); + createGroup.setPublic(true); + + EMCreateGroupResult createGroupResult = + assertDoesNotThrow(() -> api.createGroup(createGroup)); + assertNotNull(createGroupResult); + assertNotNull(createGroupResult.getData()); + assertNotNull(createGroupResult.getData().getGroupid()); + + String groupId = createGroupResult.getData().getGroupid(); + EMCheckUserJoinedGroupResult checkUserJoinedGroupResult = + assertDoesNotThrow(() -> api.checkUserJoinedGroup(groupId, username2)); + assertNotNull(checkUserJoinedGroupResult); + assertNotNull(checkUserJoinedGroupResult.getData()); + assertEquals(true, checkUserJoinedGroupResult.getData()); + + assertDoesNotThrow(() -> userApi.deleteUser(username1)); + assertDoesNotThrow(() -> userApi.deleteUser(username2)); + try { + api.deleteGroup(groupId); + } catch (ApiException ignored) { + } + } + + /** + * 创建群组 + *

+ * 创建一个群组,并设置群组名称、群组描述、公开群/私有群属性、群成员最大人数(包括群主)、加入公开群是否需要批准、群主、群成员和群组扩展信息。文档介绍:https://docs-im-beta.easemob.com/document/server-side/group.html#%E5%88%9B%E5%BB%BA%E7%BE%A4%E7%BB%84 + * + * @throws ApiException if the Api call fails + */ + @Test + public void createGroupTest() throws ApiException { + String username1 = randomUserName(); + String username2 = randomUserName(); + String password = "123456"; + + List emCreateUserList = new ArrayList<>(); + EMCreateUser createUser1 = new EMCreateUser(); + createUser1.setUsername(username1); + createUser1.setPassword(password); + + EMCreateUser createUser2 = new EMCreateUser(); + createUser2.setUsername(username2); + createUser2.setPassword(password); + + emCreateUserList.add(createUser1); + emCreateUserList.add(createUser2); + + assertDoesNotThrow(() -> userApi.createUsers(emCreateUserList)); + + EMCreateGroup createGroup = new EMCreateGroup(); + createGroup.setOwner(username1); + createGroup.setGroupname("test-group"); + createGroup.setDescription("元梦之星"); + createGroup.setMaxusers(200); + createGroup.setMembers(Arrays.asList(username2)); + createGroup.setPublic(true); + + EMCreateGroupResult createGroupResult = + assertDoesNotThrow(() -> api.createGroup(createGroup)); + assertNotNull(createGroupResult); + assertNotNull(createGroupResult.getData()); + assertNotNull(createGroupResult.getData().getGroupid()); + + String groupId = createGroupResult.getData().getGroupid(); + + assertDoesNotThrow(() -> userApi.deleteUser(username1)); + assertDoesNotThrow(() -> userApi.deleteUser(username2)); + try { + api.deleteGroup(groupId); + } catch (ApiException ignored) { + } + } + + /** + * 删除群组 + *

+ * 删除指定的群组。删除群组时会同时删除群组下所有的子区(Thread)。文档介绍:https://docs-im-beta.easemob.com/document/server-side/group.html#%E5%88%A0%E9%99%A4%E7%BE%A4%E7%BB%84 + * + * @throws ApiException if the Api call fails + */ + @Test + public void deleteGroupTest() throws ApiException { + String username1 = randomUserName(); + String username2 = randomUserName(); + String password = "123456"; + + List emCreateUserList = new ArrayList<>(); + EMCreateUser createUser1 = new EMCreateUser(); + createUser1.setUsername(username1); + createUser1.setPassword(password); + + EMCreateUser createUser2 = new EMCreateUser(); + createUser2.setUsername(username2); + createUser2.setPassword(password); + + emCreateUserList.add(createUser1); + emCreateUserList.add(createUser2); + + assertDoesNotThrow(() -> userApi.createUsers(emCreateUserList)); + + EMCreateGroup createGroup = new EMCreateGroup(); + createGroup.setOwner(username1); + createGroup.setGroupname("test-group"); + createGroup.setDescription("元梦之星"); + createGroup.setMaxusers(200); + createGroup.setMembers(Arrays.asList(username2)); + createGroup.setPublic(true); + + EMCreateGroupResult createGroupResult = + assertDoesNotThrow(() -> api.createGroup(createGroup)); + assertNotNull(createGroupResult); + assertNotNull(createGroupResult.getData()); + assertNotNull(createGroupResult.getData().getGroupid()); + + String groupId = createGroupResult.getData().getGroupid(); + try { + EMDeleteGroupResult deleteGroupResult = api.deleteGroup(groupId); + assertNotNull(deleteGroupResult); + assertNotNull(deleteGroupResult.getData()); + assertNotNull(deleteGroupResult.getData().getSuccess()); + assertEquals(true, deleteGroupResult.getData().getSuccess()); + assertEquals(groupId, deleteGroupResult.getData().getGroupid()); + } catch (ApiException ignored) { + } + + assertDoesNotThrow(() -> userApi.deleteUser(username1)); + assertDoesNotThrow(() -> userApi.deleteUser(username2)); + + } + + /** + * 删除群组共享文件 + *

+ * 根据指定的群组 ID 与 文件 ID(file_id)删除群组共享文件,文件 ID 可从 获取群组共享文件 接口的响应中获取。文档介绍:https://docs-im-beta.easemob.com/document/server-side/group.html#%E5%88%A0%E9%99%A4%E7%BE%A4%E7%BB%84%E5%85%B1%E4%BA%AB%E6%96%87%E4%BB%B6 + * + * @throws ApiException if the Api call fails + */ + @Test + public void deleteGroupShareFileTest() throws ApiException { + String username1 = randomUserName(); + String username2 = randomUserName(); + String password = "123456"; + + List emCreateUserList = new ArrayList<>(); + EMCreateUser createUser1 = new EMCreateUser(); + createUser1.setUsername(username1); + createUser1.setPassword(password); + + EMCreateUser createUser2 = new EMCreateUser(); + createUser2.setUsername(username2); + createUser2.setPassword(password); + + emCreateUserList.add(createUser1); + emCreateUserList.add(createUser2); + + assertDoesNotThrow(() -> userApi.createUsers(emCreateUserList)); + + EMCreateGroup createGroup = new EMCreateGroup(); + createGroup.setOwner(username1); + createGroup.setGroupname("test-group"); + createGroup.setDescription("元梦之星"); + createGroup.setMaxusers(200); + createGroup.setMembers(Arrays.asList(username2)); + createGroup.setPublic(true); + + EMCreateGroupResult createGroupResult = + assertDoesNotThrow(() -> api.createGroup(createGroup)); + assertNotNull(createGroupResult); + assertNotNull(createGroupResult.getData()); + assertNotNull(createGroupResult.getData().getGroupid()); + + String groupId = createGroupResult.getData().getGroupid(); + + EMUploadGroupShareFileResult uploadGroupShareFileResult = assertDoesNotThrow( + () -> api.uploadGroupShareFile(groupId, new File(Objects.requireNonNull( + ClassLoaderUtils.getDefaultClassLoader().getResource("upload/blue.png")).getPath()))); + assertNotNull(uploadGroupShareFileResult); + assertNotNull(uploadGroupShareFileResult.getData()); + assertNotNull(uploadGroupShareFileResult.getData().getFileId()); + + String fileId = uploadGroupShareFileResult.getData().getFileId(); + + EMDeleteGroupShareFileResult deleteGroupShareFileResult = + assertDoesNotThrow(() -> api.deleteGroupShareFile(groupId, fileId)); + assertNotNull(deleteGroupShareFileResult); + assertNotNull(deleteGroupShareFileResult.getData()); + assertEquals(true, deleteGroupShareFileResult.getData().getResult()); + + assertDoesNotThrow(() -> userApi.deleteUser(username1)); + assertDoesNotThrow(() -> userApi.deleteUser(username2)); + try { + api.deleteGroup(groupId); + } catch (ApiException ignored) { + } + } + + /** + * 封禁群组 + *

+ * 封禁指定的群组。例如,群成员经常在群中发送违规消息,可以调用该 API 对该群进行封禁。群组被封禁后,群中任何成员均无法在群组以及该群组下的子区中发送和接收消息,也无法进行群组和子区管理操作。文档介绍:https://docs-im-beta.easemob.com/document/server-side/group.html#%E5%B0%81%E7%A6%81%E7%BE%A4%E7%BB%84 + * + * @throws ApiException if the Api call fails + */ + @Test + public void disableGroupTest() throws ApiException { + String username1 = randomUserName(); + String username2 = randomUserName(); + String password = "123456"; + + List emCreateUserList = new ArrayList<>(); + EMCreateUser createUser1 = new EMCreateUser(); + createUser1.setUsername(username1); + createUser1.setPassword(password); + + EMCreateUser createUser2 = new EMCreateUser(); + createUser2.setUsername(username2); + createUser2.setPassword(password); + + emCreateUserList.add(createUser1); + emCreateUserList.add(createUser2); + + assertDoesNotThrow(() -> userApi.createUsers(emCreateUserList)); + + EMCreateGroup createGroup = new EMCreateGroup(); + createGroup.setOwner(username1); + createGroup.setGroupname("test-group"); + createGroup.setDescription("元梦之星"); + createGroup.setMaxusers(200); + createGroup.setMembers(Arrays.asList(username2)); + createGroup.setPublic(true); + + EMCreateGroupResult createGroupResult = + assertDoesNotThrow(() -> api.createGroup(createGroup)); + assertNotNull(createGroupResult); + assertNotNull(createGroupResult.getData()); + assertNotNull(createGroupResult.getData().getGroupid()); + + String groupId = createGroupResult.getData().getGroupid(); + EMDisableGroupResult disableGroupResult = + assertDoesNotThrow(() -> api.disableGroup(groupId)); + assertNotNull(disableGroupResult); + assertNotNull(disableGroupResult.getData()); + assertEquals(true, disableGroupResult.getData().getDisabled()); + + assertDoesNotThrow(() -> userApi.deleteUser(username1)); + assertDoesNotThrow(() -> userApi.deleteUser(username2)); + try { + api.deleteGroup(groupId); + } catch (ApiException ignored) { + } + } + + /** + * 下载群组共享文件 + *

+ * 根据指定的群组 ID 与文件 ID(file_id)下载群组共享文件,文件 ID 可从 获取群组共享文件 接口的响应中获取。文档介绍:https://docs-im-beta.easemob.com/document/server-side/group.html#%E4%B8%8B%E8%BD%BD%E7%BE%A4%E7%BB%84%E5%85%B1%E4%BA%AB%E6%96%87%E4%BB%B6 + * + * @throws ApiException if the Api call fails + */ + @Test + public void downloadGroupShareFileTest() throws ApiException { + String username1 = randomUserName(); + String username2 = randomUserName(); + String password = "123456"; + + List emCreateUserList = new ArrayList<>(); + EMCreateUser createUser1 = new EMCreateUser(); + createUser1.setUsername(username1); + createUser1.setPassword(password); + + EMCreateUser createUser2 = new EMCreateUser(); + createUser2.setUsername(username2); + createUser2.setPassword(password); + + emCreateUserList.add(createUser1); + emCreateUserList.add(createUser2); + + assertDoesNotThrow(() -> userApi.createUsers(emCreateUserList)); + + EMCreateGroup createGroup = new EMCreateGroup(); + createGroup.setOwner(username1); + createGroup.setGroupname("test-group"); + createGroup.setDescription("元梦之星"); + createGroup.setMaxusers(200); + createGroup.setMembers(Arrays.asList(username2)); + createGroup.setPublic(true); + + EMCreateGroupResult createGroupResult = + assertDoesNotThrow(() -> api.createGroup(createGroup)); + assertNotNull(createGroupResult); + assertNotNull(createGroupResult.getData()); + assertNotNull(createGroupResult.getData().getGroupid()); + + String groupId = createGroupResult.getData().getGroupid(); + + EMUploadGroupShareFileResult uploadGroupShareFileResult = assertDoesNotThrow( + () -> api.uploadGroupShareFile(groupId, new File(Objects.requireNonNull( + ClassLoaderUtils.getDefaultClassLoader().getResource("upload/blue.png")).getPath()))); + assertNotNull(uploadGroupShareFileResult); + assertNotNull(uploadGroupShareFileResult.getData()); + assertNotNull(uploadGroupShareFileResult.getData().getFileId()); + + String fileId = uploadGroupShareFileResult.getData().getFileId(); + File file = assertDoesNotThrow(() -> api.downloadGroupShareFile(groupId, fileId)); + assertNotNull(file); + assertTrue(file.delete()); + + assertDoesNotThrow(() -> userApi.deleteUser(username1)); + assertDoesNotThrow(() -> userApi.deleteUser(username2)); + try { + api.deleteGroup(groupId); + } catch (ApiException ignored) { + } + } + + /** + * 封禁群组 + *

+ * 解除对指定群组的封禁。群组解禁后,群成员可以在该群组以及该群组下的子区中发送和接收消息并进行群组和子区管理相关操作。文档介绍:https://docs-im-beta.easemob.com/document/server-side/group.html#%E8%A7%A3%E7%A6%81%E7%BE%A4%E7%BB%84 + * + * @throws ApiException if the Api call fails + */ + @Test + public void enableGroupTest() throws ApiException { + String username1 = randomUserName(); + String username2 = randomUserName(); + String password = "123456"; + + List emCreateUserList = new ArrayList<>(); + EMCreateUser createUser1 = new EMCreateUser(); + createUser1.setUsername(username1); + createUser1.setPassword(password); + + EMCreateUser createUser2 = new EMCreateUser(); + createUser2.setUsername(username2); + createUser2.setPassword(password); + + emCreateUserList.add(createUser1); + emCreateUserList.add(createUser2); + + assertDoesNotThrow(() -> userApi.createUsers(emCreateUserList)); + + EMCreateGroup createGroup = new EMCreateGroup(); + createGroup.setOwner(username1); + createGroup.setGroupname("test-group"); + createGroup.setDescription("元梦之星"); + createGroup.setMaxusers(200); + createGroup.setMembers(Arrays.asList(username2)); + createGroup.setPublic(true); + + EMCreateGroupResult createGroupResult = + assertDoesNotThrow(() -> api.createGroup(createGroup)); + assertNotNull(createGroupResult); + assertNotNull(createGroupResult.getData()); + assertNotNull(createGroupResult.getData().getGroupid()); + + String groupId = createGroupResult.getData().getGroupid(); + EMEnableGroupResult enableGroupResult = assertDoesNotThrow(() -> api.enableGroup(groupId)); + assertNotNull(enableGroupResult); + assertNotNull(enableGroupResult.getData()); + assertEquals(false, enableGroupResult.getData().getDisabled()); + + assertDoesNotThrow(() -> userApi.deleteUser(username1)); + assertDoesNotThrow(() -> userApi.deleteUser(username2)); + try { + api.deleteGroup(groupId); + } catch (ApiException ignored) { + } + } + + /** + * 获取 App 中的群组 + *

+ * 分页获取应用下的群组的信息。文档介绍:https://docs-im-beta.easemob.com/document/server-side/group.html#%E8%8E%B7%E5%8F%96-app-%E4%B8%AD%E7%9A%84%E7%BE%A4%E7%BB%84 + * + * @throws ApiException if the Api call fails + */ + @Test + public void getAppGroupsTest() throws ApiException { + String username1 = randomUserName(); + String username2 = randomUserName(); + String password = "123456"; + + List emCreateUserList = new ArrayList<>(); + EMCreateUser createUser1 = new EMCreateUser(); + createUser1.setUsername(username1); + createUser1.setPassword(password); + + EMCreateUser createUser2 = new EMCreateUser(); + createUser2.setUsername(username2); + createUser2.setPassword(password); + + emCreateUserList.add(createUser1); + emCreateUserList.add(createUser2); + + assertDoesNotThrow(() -> userApi.createUsers(emCreateUserList)); + + EMCreateGroup createGroup = new EMCreateGroup(); + createGroup.setOwner(username1); + createGroup.setGroupname("test-group"); + createGroup.setDescription("元梦之星"); + createGroup.setMaxusers(200); + createGroup.setMembers(Arrays.asList(username2)); + createGroup.setPublic(true); + + EMCreateGroupResult createGroupResult = + assertDoesNotThrow(() -> api.createGroup(createGroup)); + assertNotNull(createGroupResult); + assertNotNull(createGroupResult.getData()); + assertNotNull(createGroupResult.getData().getGroupid()); + + String groupId = createGroupResult.getData().getGroupid(); + EMGetAppGroupsResult getAppGroupsResult = + assertDoesNotThrow(() -> api.getAppGroups(1, null)); + assertNotNull(getAppGroupsResult); + assertNotNull(getAppGroupsResult.getData()); + assertNotNull(getAppGroupsResult.getData()); + assertEquals(1, getAppGroupsResult.getData().size()); + assertNotNull(getAppGroupsResult.getCursor()); + + String cursor = getAppGroupsResult.getCursor(); + EMGetAppGroupsResult getAppGroupsNextResult = + assertDoesNotThrow(() -> api.getAppGroups(1, cursor)); + assertNotNull(getAppGroupsNextResult); + assertNotNull(getAppGroupsNextResult.getData()); + assertNotNull(getAppGroupsNextResult.getData()); + assertEquals(1, getAppGroupsNextResult.getData().size()); + + assertDoesNotThrow(() -> userApi.deleteUser(username1)); + assertDoesNotThrow(() -> userApi.deleteUser(username2)); + try { + api.deleteGroup(groupId); + } catch (ApiException ignored) { + } + } + + /** + * 获取群管理员列表 + *

+ * 获取群组管理员列表。文档介绍:https://docs-im-beta.easemob.com/document/server-side/group.html#%E8%8E%B7%E5%8F%96%E7%BE%A4%E7%AE%A1%E7%90%86%E5%91%98%E5%88%97%E8%A1%A8 + * + * @throws ApiException if the Api call fails + */ + @Test + public void getGroupAdminListTest() throws ApiException { + String username1 = randomUserName(); + String username2 = randomUserName(); + String password = "123456"; + + List emCreateUserList = new ArrayList<>(); + EMCreateUser createUser1 = new EMCreateUser(); + createUser1.setUsername(username1); + createUser1.setPassword(password); + + EMCreateUser createUser2 = new EMCreateUser(); + createUser2.setUsername(username2); + createUser2.setPassword(password); + + emCreateUserList.add(createUser1); + emCreateUserList.add(createUser2); + + assertDoesNotThrow(() -> userApi.createUsers(emCreateUserList)); + + EMCreateGroup createGroup = new EMCreateGroup(); + createGroup.setOwner(username1); + createGroup.setGroupname("test-group"); + createGroup.setDescription("元梦之星"); + createGroup.setMaxusers(200); + createGroup.setMembers(Arrays.asList(username2)); + createGroup.setPublic(true); + + EMCreateGroupResult createGroupResult = + assertDoesNotThrow(() -> api.createGroup(createGroup)); + assertNotNull(createGroupResult); + assertNotNull(createGroupResult.getData()); + assertNotNull(createGroupResult.getData().getGroupid()); + + String groupId = createGroupResult.getData().getGroupid(); + assertDoesNotThrow(() -> api.getGroupAdminList(groupId)); + + assertDoesNotThrow(() -> userApi.deleteUser(username1)); + assertDoesNotThrow(() -> userApi.deleteUser(username2)); + try { + api.deleteGroup(groupId); + } catch (ApiException ignored) { + } + } + + /** + * 获取群组公告 + *

+ * 获取指定群组 ID 的群组公告。文档介绍:https://docs-im-beta.easemob.com/document/server-side/group.html#%E8%8E%B7%E5%8F%96%E7%BE%A4%E7%BB%84%E5%85%AC%E5%91%8A + * + * @throws ApiException if the Api call fails + */ + @Test + public void getGroupAnnouncementTest() throws ApiException { + String username1 = randomUserName(); + String username2 = randomUserName(); + String password = "123456"; + + List emCreateUserList = new ArrayList<>(); + EMCreateUser createUser1 = new EMCreateUser(); + createUser1.setUsername(username1); + createUser1.setPassword(password); + + EMCreateUser createUser2 = new EMCreateUser(); + createUser2.setUsername(username2); + createUser2.setPassword(password); + + emCreateUserList.add(createUser1); + emCreateUserList.add(createUser2); + + assertDoesNotThrow(() -> userApi.createUsers(emCreateUserList)); + + EMCreateGroup createGroup = new EMCreateGroup(); + createGroup.setOwner(username1); + createGroup.setGroupname("test-group"); + createGroup.setDescription("元梦之星"); + createGroup.setMaxusers(200); + createGroup.setMembers(Arrays.asList(username2)); + createGroup.setPublic(true); + + EMCreateGroupResult createGroupResult = + assertDoesNotThrow(() -> api.createGroup(createGroup)); + assertNotNull(createGroupResult); + assertNotNull(createGroupResult.getData()); + assertNotNull(createGroupResult.getData().getGroupid()); + + String groupId = createGroupResult.getData().getGroupid(); + + EMModifyGroupAnnouncement modifyGroupAnnouncement = new EMModifyGroupAnnouncement(); + modifyGroupAnnouncement.setAnnouncement("new announcement"); + EMModifyGroupAnnouncementResult modifyGroupAnnouncementResult = assertDoesNotThrow( + () -> api.modifyGroupAnnouncement(groupId, modifyGroupAnnouncement)); + assertNotNull(modifyGroupAnnouncementResult); + assertNotNull(modifyGroupAnnouncementResult.getData()); + assertEquals(true, modifyGroupAnnouncementResult.getData().getResult()); + assertEquals(groupId, modifyGroupAnnouncementResult.getData().getId()); + + EMGetGroupAnnouncementResult getGroupAnnouncementResult = + assertDoesNotThrow(() -> api.getGroupAnnouncement(groupId)); + assertNotNull(getGroupAnnouncementResult); + assertNotNull(getGroupAnnouncementResult.getData()); + assertEquals("new announcement", getGroupAnnouncementResult.getData().getAnnouncement()); + + assertDoesNotThrow(() -> userApi.deleteUser(username1)); + assertDoesNotThrow(() -> userApi.deleteUser(username2)); + try { + api.deleteGroup(groupId); + } catch (ApiException ignored) { + } + } + + /** + * 查询群组黑名单 + *

+ * 查询一个群组黑名单中的用户列表。黑名单中的用户无法查看该群组的信息,也无法收到该群组的消息。文档介绍:https://docs-im-beta.easemob.com/document/server-side/group.html#%E6%9F%A5%E8%AF%A2%E7%BE%A4%E7%BB%84%E9%BB%91%E5%90%8D%E5%8D%95 + * + * @throws ApiException if the Api call fails + */ + @Test + public void getGroupBlockListTest() throws ApiException { + String username1 = randomUserName(); + String username2 = randomUserName(); + String password = "123456"; + + List emCreateUserList = new ArrayList<>(); + EMCreateUser createUser1 = new EMCreateUser(); + createUser1.setUsername(username1); + createUser1.setPassword(password); + + EMCreateUser createUser2 = new EMCreateUser(); + createUser2.setUsername(username2); + createUser2.setPassword(password); + + emCreateUserList.add(createUser1); + emCreateUserList.add(createUser2); + + assertDoesNotThrow(() -> userApi.createUsers(emCreateUserList)); + + EMCreateGroup createGroup = new EMCreateGroup(); + createGroup.setOwner(username1); + createGroup.setGroupname("test-group"); + createGroup.setDescription("元梦之星"); + createGroup.setMaxusers(200); + createGroup.setMembers(Arrays.asList(username2)); + createGroup.setPublic(true); + + EMCreateGroupResult createGroupResult = + assertDoesNotThrow(() -> api.createGroup(createGroup)); + assertNotNull(createGroupResult); + assertNotNull(createGroupResult.getData()); + assertNotNull(createGroupResult.getData().getGroupid()); + + String groupId = createGroupResult.getData().getGroupid(); + + assertDoesNotThrow(() -> api.addUserToGroupBlockList(groupId, username2)); + + EMGetGroupBlockListResult getGroupBlockListResult = + assertDoesNotThrow(() -> api.getGroupBlockList(groupId)); + assertNotNull(getGroupBlockListResult); + assertNotNull(getGroupBlockListResult.getData()); + assertEquals(1, getGroupBlockListResult.getData().size()); + + assertDoesNotThrow(() -> userApi.deleteUser(username1)); + assertDoesNotThrow(() -> userApi.deleteUser(username2)); + try { + api.deleteGroup(groupId); + } catch (ApiException ignored) { + } + } + + /** + * 获取群组详情 + *

+ * 可以获取一个或多个群组的详情,最多可获取 100 个群组的详情。当获取多个群组的详情时,返回所有存在的群组的详情;对于不存在的群组,返回 “group id doesn’t exist”。文档介绍:https://docs-im-beta.easemob.com/document/server-side/group.html#%E8%8E%B7%E5%8F%96%E7%BE%A4%E7%BB%84%E8%AF%A6%E6%83%85 + * + * @throws ApiException if the Api call fails + */ + @Test + public void getGroupInfoTest() throws ApiException { + String username1 = randomUserName(); + String username2 = randomUserName(); + String password = "123456"; + + List emCreateUserList = new ArrayList<>(); + EMCreateUser createUser1 = new EMCreateUser(); + createUser1.setUsername(username1); + createUser1.setPassword(password); + + EMCreateUser createUser2 = new EMCreateUser(); + createUser2.setUsername(username2); + createUser2.setPassword(password); + + emCreateUserList.add(createUser1); + emCreateUserList.add(createUser2); + + assertDoesNotThrow(() -> userApi.createUsers(emCreateUserList)); + + EMCreateGroup createGroup = new EMCreateGroup(); + createGroup.setOwner(username1); + createGroup.setGroupname("test-group"); + createGroup.setDescription("元梦之星"); + createGroup.setMaxusers(200); + createGroup.setMembers(Arrays.asList(username2)); + createGroup.setPublic(true); + + EMCreateGroupResult createGroupResult = + assertDoesNotThrow(() -> api.createGroup(createGroup)); + assertNotNull(createGroupResult); + assertNotNull(createGroupResult.getData()); + assertNotNull(createGroupResult.getData().getGroupid()); + + String groupId = createGroupResult.getData().getGroupid(); + + EMGetGroupInfoResult getGroupInfoResult = + assertDoesNotThrow(() -> api.getGroupInfo(groupId)); + assertNotNull(getGroupInfoResult); + assertNotNull(getGroupInfoResult.getData()); + assertEquals(1, getGroupInfoResult.getData().size()); + assertEquals("元梦之星", getGroupInfoResult.getData().get(0).getDescription()); + + assertDoesNotThrow(() -> userApi.deleteUser(username1)); + assertDoesNotThrow(() -> userApi.deleteUser(username2)); + try { + api.deleteGroup(groupId); + } catch (ApiException ignored) { + } + } + + /** + * 分页获取群成员列表 + *

+ * 可以分页获取群组成员列表。文档介绍:https://docs-im-beta.easemob.com/document/server-side/group.html#%E7%AE%A1%E7%90%86%E7%BE%A4%E7%BB%84%E6%88%90%E5%91%98 + * + * @throws ApiException if the Api call fails + */ + @Test + public void getGroupMemberListTest() throws ApiException { + String username1 = randomUserName(); + String username2 = randomUserName(); + String password = "123456"; + + List emCreateUserList = new ArrayList<>(); + EMCreateUser createUser1 = new EMCreateUser(); + createUser1.setUsername(username1); + createUser1.setPassword(password); + + EMCreateUser createUser2 = new EMCreateUser(); + createUser2.setUsername(username2); + createUser2.setPassword(password); + + emCreateUserList.add(createUser1); + emCreateUserList.add(createUser2); + + assertDoesNotThrow(() -> userApi.createUsers(emCreateUserList)); + + EMCreateGroup createGroup = new EMCreateGroup(); + createGroup.setOwner(username1); + createGroup.setGroupname("test-group"); + createGroup.setDescription("元梦之星"); + createGroup.setMaxusers(200); + createGroup.setMembers(Arrays.asList(username2)); + createGroup.setPublic(true); + + EMCreateGroupResult createGroupResult = + assertDoesNotThrow(() -> api.createGroup(createGroup)); + assertNotNull(createGroupResult); + assertNotNull(createGroupResult.getData()); + assertNotNull(createGroupResult.getData().getGroupid()); + + String groupId = createGroupResult.getData().getGroupid(); + + EMGetGroupMemberListResult getGroupMemberListResult = + assertDoesNotThrow(() -> api.getGroupMemberList(groupId, 1, 1)); + assertNotNull(getGroupMemberListResult); + assertNotNull(getGroupMemberListResult.getData()); + assertEquals(1, getGroupMemberListResult.getData().size()); + + EMGetGroupMemberListResult getGroupMemberListNextResult = + assertDoesNotThrow(() -> api.getGroupMemberList(groupId, 2, 1)); + assertNotNull(getGroupMemberListNextResult); + assertNotNull(getGroupMemberListNextResult.getData()); + assertEquals(1, getGroupMemberListNextResult.getData().size()); + + assertDoesNotThrow(() -> userApi.deleteUser(username1)); + assertDoesNotThrow(() -> userApi.deleteUser(username2)); + try { + api.deleteGroup(groupId); + } catch (ApiException ignored) { + } + } + + /** + * 获取禁言列表 + *

+ * 获取当前群组的禁言用户列表。文档介绍:https://docs-im-beta.easemob.com/document/server-side/group.html#%E8%8E%B7%E5%8F%96%E7%A6%81%E8%A8%80%E5%88%97%E8%A1%A8 + * + * @throws ApiException if the Api call fails + */ + @Test + public void getGroupMuteListTest() throws ApiException { + String username1 = randomUserName(); + String username2 = randomUserName(); + String password = "123456"; + + List emCreateUserList = new ArrayList<>(); + EMCreateUser createUser1 = new EMCreateUser(); + createUser1.setUsername(username1); + createUser1.setPassword(password); + + EMCreateUser createUser2 = new EMCreateUser(); + createUser2.setUsername(username2); + createUser2.setPassword(password); + + emCreateUserList.add(createUser1); + emCreateUserList.add(createUser2); + + assertDoesNotThrow(() -> userApi.createUsers(emCreateUserList)); + + EMCreateGroup createGroup = new EMCreateGroup(); + createGroup.setOwner(username1); + createGroup.setGroupname("test-group"); + createGroup.setDescription("元梦之星"); + createGroup.setMaxusers(200); + createGroup.setMembers(Arrays.asList(username2)); + createGroup.setPublic(true); + + EMCreateGroupResult createGroupResult = + assertDoesNotThrow(() -> api.createGroup(createGroup)); + assertNotNull(createGroupResult); + assertNotNull(createGroupResult.getData()); + assertNotNull(createGroupResult.getData().getGroupid()); + + String groupId = createGroupResult.getData().getGroupid(); + + EMMuteGroupMember muteGroupMember = new EMMuteGroupMember(); + muteGroupMember.setUsernames(Arrays.asList(username2)); + muteGroupMember.setMuteDuration(new BigDecimal(1000)); + EMMuteGroupMemberResult muteGroupMemberResult = + assertDoesNotThrow(() -> api.muteGroupMember(groupId, muteGroupMember)); + assertNotNull(muteGroupMemberResult); + assertNotNull(muteGroupMemberResult.getData()); + assertEquals(1, muteGroupMemberResult.getData().size()); + assertEquals(true, muteGroupMemberResult.getData().get(0).getResult()); + assertEquals(username2, muteGroupMemberResult.getData().get(0).getUser()); + + EMGetGroupMuteListResult getGroupMuteListResult = + assertDoesNotThrow(() -> api.getGroupMuteList(groupId)); + assertNotNull(getGroupMuteListResult); + assertNotNull(getGroupMuteListResult.getData()); + assertEquals(1, getGroupMuteListResult.getData().size()); + assertEquals(username2, getGroupMuteListResult.getData().get(0).getUser()); + + assertDoesNotThrow(() -> userApi.deleteUser(username1)); + assertDoesNotThrow(() -> userApi.deleteUser(username2)); + try { + api.deleteGroup(groupId); + } catch (ApiException ignored) { + } + } + + /** + * 获取群组共享文件 + *

+ * 可以分页获取指定群组 ID 的群组共享文件。获取文件后,你可以根据响应中返回的文件 ID(file_id)调用 下载群组共享文件 接口下载文件,或调用 删除群组共享文件 接口删除文件。文档介绍:https://docs-im-beta.easemob.com/document/server-side/group.html#%E8%8E%B7%E5%8F%96%E7%BE%A4%E7%BB%84%E5%85%B1%E4%BA%AB%E6%96%87%E4%BB%B6 + * + * @throws ApiException if the Api call fails + */ + @Test + public void getGroupShareFileTest() throws ApiException { + String username1 = randomUserName(); + String username2 = randomUserName(); + String password = "123456"; + + List emCreateUserList = new ArrayList<>(); + EMCreateUser createUser1 = new EMCreateUser(); + createUser1.setUsername(username1); + createUser1.setPassword(password); + + EMCreateUser createUser2 = new EMCreateUser(); + createUser2.setUsername(username2); + createUser2.setPassword(password); + + emCreateUserList.add(createUser1); + emCreateUserList.add(createUser2); + + assertDoesNotThrow(() -> userApi.createUsers(emCreateUserList)); + + EMCreateGroup createGroup = new EMCreateGroup(); + createGroup.setOwner(username1); + createGroup.setGroupname("test-group"); + createGroup.setDescription("元梦之星"); + createGroup.setMaxusers(200); + createGroup.setMembers(Arrays.asList(username2)); + createGroup.setPublic(true); + + EMCreateGroupResult createGroupResult = + assertDoesNotThrow(() -> api.createGroup(createGroup)); + assertNotNull(createGroupResult); + assertNotNull(createGroupResult.getData()); + assertNotNull(createGroupResult.getData().getGroupid()); + + String groupId = createGroupResult.getData().getGroupid(); + + EMUploadGroupShareFileResult uploadGroupShareFileResult = assertDoesNotThrow( + () -> api.uploadGroupShareFile(groupId, new File(Objects.requireNonNull( + ClassLoaderUtils.getDefaultClassLoader().getResource("upload/blue.png")).getPath()))); + assertNotNull(uploadGroupShareFileResult); + assertNotNull(uploadGroupShareFileResult.getData()); + assertNotNull(uploadGroupShareFileResult.getData().getFileId()); + + assertDoesNotThrow( + () -> api.uploadGroupShareFile(groupId, new File(Objects.requireNonNull( + ClassLoaderUtils.getDefaultClassLoader().getResource("upload/blue.png")).getPath()))); + + EMGetGroupShareFileResult getGroupShareFileResult = + assertDoesNotThrow(() -> api.getGroupShareFile(groupId, 1, 1)); + assertNotNull(getGroupShareFileResult); + assertNotNull(getGroupShareFileResult.getData()); + assertNotNull(getGroupShareFileResult.getData()); + assertEquals(1, getGroupShareFileResult.getData().size()); + + EMGetGroupShareFileResult getGroupShareFileNextResult = + assertDoesNotThrow(() -> api.getGroupShareFile(groupId, 2, 1)); + assertNotNull(getGroupShareFileNextResult); + assertNotNull(getGroupShareFileNextResult.getData()); + assertNotNull(getGroupShareFileNextResult.getData()); + assertEquals(1, getGroupShareFileNextResult.getData().size()); + + assertDoesNotThrow(() -> userApi.deleteUser(username1)); + assertDoesNotThrow(() -> userApi.deleteUser(username2)); + try { + api.deleteGroup(groupId); + } catch (ApiException ignored) { + } + } + + /** + * 查询群组白名单 + *

+ * 查询群组白名单中的用户列表。文档介绍:https://docs-im-beta.easemob.com/document/server-side/group.html#%E6%9F%A5%E8%AF%A2%E7%BE%A4%E7%BB%84%E7%99%BD%E5%90%8D%E5%8D%95 + * + * @throws ApiException if the Api call fails + */ + @Test + public void getGroupWhiteListTest() throws ApiException { + String username1 = randomUserName(); + String username2 = randomUserName(); + String password = "123456"; + + List emCreateUserList = new ArrayList<>(); + EMCreateUser createUser1 = new EMCreateUser(); + createUser1.setUsername(username1); + createUser1.setPassword(password); + + EMCreateUser createUser2 = new EMCreateUser(); + createUser2.setUsername(username2); + createUser2.setPassword(password); + + emCreateUserList.add(createUser1); + emCreateUserList.add(createUser2); + + assertDoesNotThrow(() -> userApi.createUsers(emCreateUserList)); + + EMCreateGroup createGroup = new EMCreateGroup(); + createGroup.setOwner(username1); + createGroup.setGroupname("test-group"); + createGroup.setDescription("元梦之星"); + createGroup.setMaxusers(200); + createGroup.setMembers(Arrays.asList(username2)); + createGroup.setPublic(true); + + EMCreateGroupResult createGroupResult = + assertDoesNotThrow(() -> api.createGroup(createGroup)); + assertNotNull(createGroupResult); + assertNotNull(createGroupResult.getData()); + assertNotNull(createGroupResult.getData().getGroupid()); + + String groupId = createGroupResult.getData().getGroupid(); + assertDoesNotThrow(() -> api.addUserToGroupWhiteList(groupId, username2)); + EMGetGroupWhiteListResult getGroupWhiteListResult = + assertDoesNotThrow(() -> api.getGroupWhiteList(groupId)); + assertNotNull(getGroupWhiteListResult); + assertNotNull(getGroupWhiteListResult.getData()); + assertEquals(2, getGroupWhiteListResult.getData().size()); + + assertDoesNotThrow(() -> userApi.deleteUser(username1)); + assertDoesNotThrow(() -> userApi.deleteUser(username2)); + try { + api.deleteGroup(groupId); + } catch (ApiException ignored) { + } + } + + /** + * 获取单个用户加入的所有群组 + *

+ * 根据用户 ID 分页获取指定用户加入的所有群组。文档介绍:https://docs-im-beta.easemob.com/document/server-side/group.html#%E8%8E%B7%E5%8F%96%E5%8D%95%E4%B8%AA%E7%94%A8%E6%88%B7%E5%8A%A0%E5%85%A5%E7%9A%84%E6%89%80%E6%9C%89%E7%BE%A4%E7%BB%84 + * + * @throws ApiException if the Api call fails + */ + @Test + public void getUserJoinedGroupsTest() throws ApiException { + String username1 = randomUserName(); + String username2 = randomUserName(); + String password = "123456"; + + List emCreateUserList = new ArrayList<>(); + EMCreateUser createUser1 = new EMCreateUser(); + createUser1.setUsername(username1); + createUser1.setPassword(password); + + EMCreateUser createUser2 = new EMCreateUser(); + createUser2.setUsername(username2); + createUser2.setPassword(password); + + emCreateUserList.add(createUser1); + emCreateUserList.add(createUser2); + + assertDoesNotThrow(() -> userApi.createUsers(emCreateUserList)); + + EMCreateGroup createGroup = new EMCreateGroup(); + createGroup.setOwner(username1); + createGroup.setGroupname("test-group"); + createGroup.setDescription("元梦之星"); + createGroup.setMaxusers(200); + createGroup.setMembers(Arrays.asList(username2)); + createGroup.setPublic(true); + + EMCreateGroupResult createGroupResult = + assertDoesNotThrow(() -> api.createGroup(createGroup)); + assertNotNull(createGroupResult); + assertNotNull(createGroupResult.getData()); + assertNotNull(createGroupResult.getData().getGroupid()); + + String groupId = createGroupResult.getData().getGroupid(); + EMGetUserJoinedGroupsResult getUserJoinedGroupsResult = + assertDoesNotThrow(() -> api.getUserJoinedGroups(username1, 0, 1)); + assertNotNull(getUserJoinedGroupsResult); + assertNotNull(getUserJoinedGroupsResult.getEntities()); + assertEquals(1, getUserJoinedGroupsResult.getEntities().size()); + + assertDoesNotThrow(() -> userApi.deleteUser(username1)); + assertDoesNotThrow(() -> userApi.deleteUser(username2)); + try { + api.deleteGroup(groupId); + } catch (ApiException ignored) { + } + } + + /** + * 修改群组信息 + *

+ * 修改指定的群组信息,可修改 groupname、description、maxusers、membersonly、allowinvites、invite_need_confirm、public 和 custom 属性。如果传入其他字段,或传入的字段不存在,则不能修改的字段会抛出异常。文档介绍:https://docs-im-beta.easemob.com/document/server-side/group.html#%E4%BF%AE%E6%94%B9%E7%BE%A4%E7%BB%84%E4%BF%A1%E6%81%AF + * + * @throws ApiException if the Api call fails + */ + @Test + public void modifyGroupTest() throws ApiException { + String username1 = randomUserName(); + String username2 = randomUserName(); + String password = "123456"; + + List emCreateUserList = new ArrayList<>(); + EMCreateUser createUser1 = new EMCreateUser(); + createUser1.setUsername(username1); + createUser1.setPassword(password); + + EMCreateUser createUser2 = new EMCreateUser(); + createUser2.setUsername(username2); + createUser2.setPassword(password); + + emCreateUserList.add(createUser1); + emCreateUserList.add(createUser2); + + assertDoesNotThrow(() -> userApi.createUsers(emCreateUserList)); + + EMCreateGroup createGroup = new EMCreateGroup(); + createGroup.setOwner(username1); + createGroup.setGroupname("test-group"); + createGroup.setDescription("元梦之星"); + createGroup.setMaxusers(200); + createGroup.setMembers(Arrays.asList(username2)); + createGroup.setPublic(true); + + EMCreateGroupResult createGroupResult = + assertDoesNotThrow(() -> api.createGroup(createGroup)); + assertNotNull(createGroupResult); + assertNotNull(createGroupResult.getData()); + assertNotNull(createGroupResult.getData().getGroupid()); + + String groupId = createGroupResult.getData().getGroupid(); + + EMModifyGroup modifyGroup = new EMModifyGroup(); + modifyGroup.setGroupname("元梦之星"); + modifyGroup.setMaxusers(500); + EMModifyGroupResult modifyGroupResult = + assertDoesNotThrow(() -> api.modifyGroup(groupId, modifyGroup)); + assertNotNull(modifyGroupResult); + assertNotNull(modifyGroupResult.getData()); + Map data = (Map) modifyGroupResult.getData(); + assertEquals(true, data.get("groupname")); + assertEquals(true, data.get("maxusers")); + + EMModifyGroup modifyGroupOwner = new EMModifyGroup(); + modifyGroupOwner.setNewowner(username2); + EMModifyGroupResult modifyGroupOwnerResult = + assertDoesNotThrow(() -> api.modifyGroup(groupId, modifyGroupOwner)); + assertNotNull(modifyGroupOwnerResult); + assertNotNull(modifyGroupOwnerResult.getData()); + Map modifyGroupOwnerData = (Map) modifyGroupOwnerResult.getData(); + assertEquals(true, modifyGroupOwnerData.get("newowner")); + + assertDoesNotThrow(() -> userApi.deleteUser(username1)); + assertDoesNotThrow(() -> userApi.deleteUser(username2)); + try { + api.deleteGroup(groupId); + } catch (ApiException ignored) { + } + } + + /** + * 修改群组公告 + *

+ * 修改指定群组 ID 的群组公告。群组公告不能超过 512 个字符。文档介绍:https://docs-im-beta.easemob.com/document/server-side/group.html#%E4%BF%AE%E6%94%B9%E7%BE%A4%E7%BB%84%E5%85%AC%E5%91%8A + * + * @throws ApiException if the Api call fails + */ + @Test + public void modifyGroupAnnouncementTest() throws ApiException { + String username1 = randomUserName(); + String username2 = randomUserName(); + String password = "123456"; + + List emCreateUserList = new ArrayList<>(); + EMCreateUser createUser1 = new EMCreateUser(); + createUser1.setUsername(username1); + createUser1.setPassword(password); + + EMCreateUser createUser2 = new EMCreateUser(); + createUser2.setUsername(username2); + createUser2.setPassword(password); + + emCreateUserList.add(createUser1); + emCreateUserList.add(createUser2); + + assertDoesNotThrow(() -> userApi.createUsers(emCreateUserList)); + + EMCreateGroup createGroup = new EMCreateGroup(); + createGroup.setOwner(username1); + createGroup.setGroupname("test-group"); + createGroup.setDescription("元梦之星"); + createGroup.setMaxusers(200); + createGroup.setMembers(Arrays.asList(username2)); + createGroup.setPublic(true); + + EMCreateGroupResult createGroupResult = + assertDoesNotThrow(() -> api.createGroup(createGroup)); + assertNotNull(createGroupResult); + assertNotNull(createGroupResult.getData()); + assertNotNull(createGroupResult.getData().getGroupid()); + + String groupId = createGroupResult.getData().getGroupid(); + EMModifyGroupAnnouncement modifyGroupAnnouncement = new EMModifyGroupAnnouncement(); + modifyGroupAnnouncement.setAnnouncement("new announcement"); + EMModifyGroupAnnouncementResult modifyGroupAnnouncementResult = assertDoesNotThrow( + () -> api.modifyGroupAnnouncement(groupId, modifyGroupAnnouncement)); + assertNotNull(modifyGroupAnnouncementResult); + assertNotNull(modifyGroupAnnouncementResult.getData()); + assertEquals(true, modifyGroupAnnouncementResult.getData().getResult()); + assertEquals(groupId, modifyGroupAnnouncementResult.getData().getId()); + + assertDoesNotThrow(() -> userApi.deleteUser(username1)); + assertDoesNotThrow(() -> userApi.deleteUser(username2)); + try { + api.deleteGroup(groupId); + } catch (ApiException ignored) { + } + } + + /** + * 禁言全体群成员 + *

+ * 对所有群组成员一键禁言,即将群组的所有成员加入禁言列表。设置群组全员禁言后,仅群组白名单中的用户可在群组以及该群组下的子区内发送消息。文档介绍:https://docs-im-beta.easemob.com/document/server-side/group.html#%E7%A6%81%E8%A8%80%E5%85%A8%E4%BD%93%E7%BE%A4%E6%88%90%E5%91%98 + * + * @throws ApiException if the Api call fails + */ + @Test + public void muteAllGroupMembersTest() throws ApiException { + String username1 = randomUserName(); + String username2 = randomUserName(); + String password = "123456"; + + List emCreateUserList = new ArrayList<>(); + EMCreateUser createUser1 = new EMCreateUser(); + createUser1.setUsername(username1); + createUser1.setPassword(password); + + EMCreateUser createUser2 = new EMCreateUser(); + createUser2.setUsername(username2); + createUser2.setPassword(password); + + emCreateUserList.add(createUser1); + emCreateUserList.add(createUser2); + + assertDoesNotThrow(() -> userApi.createUsers(emCreateUserList)); + + EMCreateGroup createGroup = new EMCreateGroup(); + createGroup.setOwner(username1); + createGroup.setGroupname("test-group"); + createGroup.setDescription("元梦之星"); + createGroup.setMaxusers(200); + createGroup.setMembers(Arrays.asList(username2)); + createGroup.setPublic(true); + + EMCreateGroupResult createGroupResult = + assertDoesNotThrow(() -> api.createGroup(createGroup)); + assertNotNull(createGroupResult); + assertNotNull(createGroupResult.getData()); + assertNotNull(createGroupResult.getData().getGroupid()); + + String groupId = createGroupResult.getData().getGroupid(); + EMMuteAllGroupMembersResult muteAllGroupMembersResult = + assertDoesNotThrow(() -> api.muteAllGroupMembers(groupId)); + assertNotNull(muteAllGroupMembersResult); + assertNotNull(muteAllGroupMembersResult.getData()); + assertEquals(true, muteAllGroupMembersResult.getData().getMute()); + + assertDoesNotThrow(() -> userApi.deleteUser(username1)); + assertDoesNotThrow(() -> userApi.deleteUser(username2)); + try { + api.deleteGroup(groupId); + } catch (ApiException ignored) { + } + } + + /** + * 禁言指定群成员 + *

+ * 对一个或多个群成员禁言。你一次最多可禁言 60 个群组成员。群成员被禁言后,将无法在群组中发送消息,也无法在该群组下的子区中发送消息。文档介绍:https://docs-im-beta.easemob.com/document/server-side/group.html#%E7%A6%81%E8%A8%80%E6%8C%87%E5%AE%9A%E7%BE%A4%E6%88%90%E5%91%98 + * + * @throws ApiException if the Api call fails + */ + @Test + public void muteGroupMemberTest() throws ApiException { + String username1 = randomUserName(); + String username2 = randomUserName(); + String password = "123456"; + + List emCreateUserList = new ArrayList<>(); + EMCreateUser createUser1 = new EMCreateUser(); + createUser1.setUsername(username1); + createUser1.setPassword(password); + + EMCreateUser createUser2 = new EMCreateUser(); + createUser2.setUsername(username2); + createUser2.setPassword(password); + + emCreateUserList.add(createUser1); + emCreateUserList.add(createUser2); + + assertDoesNotThrow(() -> userApi.createUsers(emCreateUserList)); + + EMCreateGroup createGroup = new EMCreateGroup(); + createGroup.setOwner(username1); + createGroup.setGroupname("test-group"); + createGroup.setDescription("元梦之星"); + createGroup.setMaxusers(200); + createGroup.setMembers(Arrays.asList(username2)); + createGroup.setPublic(true); + + EMCreateGroupResult createGroupResult = + assertDoesNotThrow(() -> api.createGroup(createGroup)); + assertNotNull(createGroupResult); + assertNotNull(createGroupResult.getData()); + assertNotNull(createGroupResult.getData().getGroupid()); + + String groupId = createGroupResult.getData().getGroupid(); + EMMuteGroupMember muteGroupMember = new EMMuteGroupMember(); + muteGroupMember.setMuteDuration(new BigDecimal(1000)); + muteGroupMember.setUsernames(Arrays.asList(username2)); + EMMuteGroupMemberResult muteGroupMemberResult = + assertDoesNotThrow(() -> api.muteGroupMember(groupId, muteGroupMember)); + assertNotNull(muteGroupMemberResult); + assertNotNull(muteGroupMemberResult.getData()); + assertEquals(true, muteGroupMemberResult.getData().get(0).getResult()); + assertEquals(username2, muteGroupMemberResult.getData().get(0).getUser()); + + assertDoesNotThrow(() -> userApi.deleteUser(username1)); + assertDoesNotThrow(() -> userApi.deleteUser(username2)); + try { + api.deleteGroup(groupId); + } catch (ApiException ignored) { + } + } + + /** + * 移除群管理员 + *

+ * 将用户的角色从群管理员降为群普通成员。文档介绍:https://docs-im-beta.easemob.com/document/server-side/group.html#%E7%A7%BB%E9%99%A4%E7%BE%A4%E7%AE%A1%E7%90%86%E5%91%98 + * + * @throws ApiException if the Api call fails + */ + @Test + public void removeGroupAdminTest() throws ApiException { + String username1 = randomUserName(); + String username2 = randomUserName(); + String password = "123456"; + + List emCreateUserList = new ArrayList<>(); + EMCreateUser createUser1 = new EMCreateUser(); + createUser1.setUsername(username1); + createUser1.setPassword(password); + + EMCreateUser createUser2 = new EMCreateUser(); + createUser2.setUsername(username2); + createUser2.setPassword(password); + + emCreateUserList.add(createUser1); + emCreateUserList.add(createUser2); + + assertDoesNotThrow(() -> userApi.createUsers(emCreateUserList)); + + EMCreateGroup createGroup = new EMCreateGroup(); + createGroup.setOwner(username1); + createGroup.setGroupname("test-group"); + createGroup.setDescription("元梦之星"); + createGroup.setMaxusers(200); + createGroup.setMembers(Arrays.asList(username2)); + createGroup.setPublic(true); + + EMCreateGroupResult createGroupResult = + assertDoesNotThrow(() -> api.createGroup(createGroup)); + assertNotNull(createGroupResult); + assertNotNull(createGroupResult.getData()); + assertNotNull(createGroupResult.getData().getGroupid()); + + String groupId = createGroupResult.getData().getGroupid(); + + EMAddGroupAdmin addGroupAdmin = new EMAddGroupAdmin(); + addGroupAdmin.newadmin(username2); + assertDoesNotThrow(() -> api.addGroupAdmin(groupId, addGroupAdmin)); + + EMRemoveGroupAdminResult removeGroupAdminResult = + assertDoesNotThrow(() -> api.removeGroupAdmin(groupId, username2)); + assertNotNull(removeGroupAdminResult); + assertNotNull(removeGroupAdminResult.getData()); + assertEquals("success", removeGroupAdminResult.getData().getResult()); + + assertDoesNotThrow(() -> userApi.deleteUser(username1)); + assertDoesNotThrow(() -> userApi.deleteUser(username2)); + try { + api.deleteGroup(groupId); + } catch (ApiException ignored) { + } + } + + /** + * 从群组黑名单移除单个用户 + *

+ * 将指定用户移出群组黑名单。对于群组黑名单中的用户,如果需要将其再次加入群组,需要先将其从群组黑名单中移除。文档介绍:https://docs-im-beta.easemob.com/document/server-side/group.html#%E4%BB%8E%E7%BE%A4%E7%BB%84%E9%BB%91%E5%90%8D%E5%8D%95%E7%A7%BB%E9%99%A4%E5%8D%95%E4%B8%AA%E7%94%A8%E6%88%B7 + * + * @throws ApiException if the Api call fails + */ + @Test + public void removeUserFromGroupBlockListTest() throws ApiException { + String username1 = randomUserName(); + String username2 = randomUserName(); + String password = "123456"; + + List emCreateUserList = new ArrayList<>(); + EMCreateUser createUser1 = new EMCreateUser(); + createUser1.setUsername(username1); + createUser1.setPassword(password); + + EMCreateUser createUser2 = new EMCreateUser(); + createUser2.setUsername(username2); + createUser2.setPassword(password); + + emCreateUserList.add(createUser1); + emCreateUserList.add(createUser2); + + assertDoesNotThrow(() -> userApi.createUsers(emCreateUserList)); + + EMCreateGroup createGroup = new EMCreateGroup(); + createGroup.setOwner(username1); + createGroup.setGroupname("test-group"); + createGroup.setDescription("元梦之星"); + createGroup.setMaxusers(200); + createGroup.setMembers(Arrays.asList(username2)); + createGroup.setPublic(true); + + EMCreateGroupResult createGroupResult = + assertDoesNotThrow(() -> api.createGroup(createGroup)); + assertNotNull(createGroupResult); + assertNotNull(createGroupResult.getData()); + assertNotNull(createGroupResult.getData().getGroupid()); + + String groupId = createGroupResult.getData().getGroupid(); + + assertDoesNotThrow(() -> api.addUserToGroupBlockList(groupId, username2)); + + EMRemoveUserFromGroupBlockListResult removeUserFromGroupBlockListResult = + assertDoesNotThrow(() -> api.removeUserFromGroupBlockList(groupId, username2)); + assertNotNull(removeUserFromGroupBlockListResult); + assertNotNull(removeUserFromGroupBlockListResult.getData()); + assertEquals(true, removeUserFromGroupBlockListResult.getData().getResult()); + + assertDoesNotThrow(() -> userApi.deleteUser(username1)); + assertDoesNotThrow(() -> userApi.deleteUser(username2)); + try { + api.deleteGroup(groupId); + } catch (ApiException ignored) { + } + } + + /** + * 从群组白名单移除用户 + *

+ * 将指定用户从群组白名单中移除。文档介绍:https://docs-im-beta.easemob.com/document/server-side/group.html#%E4%BB%8E%E7%BE%A4%E7%BB%84%E7%99%BD%E5%90%8D%E5%8D%95%E7%A7%BB%E9%99%A4%E7%94%A8%E6%88%B7 + * + * @throws ApiException if the Api call fails + */ + @Test + public void removeUserFromGroupWhiteListTest() throws ApiException { + String username1 = randomUserName(); + String username2 = randomUserName(); + String password = "123456"; + + List emCreateUserList = new ArrayList<>(); + EMCreateUser createUser1 = new EMCreateUser(); + createUser1.setUsername(username1); + createUser1.setPassword(password); + + EMCreateUser createUser2 = new EMCreateUser(); + createUser2.setUsername(username2); + createUser2.setPassword(password); + + emCreateUserList.add(createUser1); + emCreateUserList.add(createUser2); + + assertDoesNotThrow(() -> userApi.createUsers(emCreateUserList)); + + EMCreateGroup createGroup = new EMCreateGroup(); + createGroup.setOwner(username1); + createGroup.setGroupname("test-group"); + createGroup.setDescription("元梦之星"); + createGroup.setMaxusers(200); + createGroup.setMembers(Arrays.asList(username2)); + createGroup.setPublic(true); + + EMCreateGroupResult createGroupResult = + assertDoesNotThrow(() -> api.createGroup(createGroup)); + assertNotNull(createGroupResult); + assertNotNull(createGroupResult.getData()); + assertNotNull(createGroupResult.getData().getGroupid()); + + String groupId = createGroupResult.getData().getGroupid(); + + assertDoesNotThrow(() -> api.addUserToGroupWhiteList(groupId, username2)); + + EMRemoveUserFromGroupWhiteListResult removeUserFromGroupWhiteListResult = + assertDoesNotThrow(() -> api.removeUserFromGroupWhiteList(groupId, username2)); + assertNotNull(removeUserFromGroupWhiteListResult); + assertNotNull(removeUserFromGroupWhiteListResult.getData()); + + assertDoesNotThrow(() -> userApi.deleteUser(username1)); + assertDoesNotThrow(() -> userApi.deleteUser(username2)); + try { + api.deleteGroup(groupId); + } catch (ApiException ignored) { + } + } + + /** + * 移除单个群组成员 + *

+ * 从群中移除指定成员。如果被移除用户不是群成员,将移除失败,并返回错误。移除后,该成员也会被移除其在该群组中加入的子区。文档介绍:https://docs-im-beta.easemob.com/document/server-side/group.html#%E7%A7%BB%E9%99%A4%E5%8D%95%E4%B8%AA%E7%BE%A4%E7%BB%84%E6%88%90%E5%91%98 + * + * @throws ApiException if the Api call fails + */ + @Test + public void removeUserToGroupTest() throws ApiException { + String username1 = randomUserName(); + String username2 = randomUserName(); + String password = "123456"; + + List emCreateUserList = new ArrayList<>(); + EMCreateUser createUser1 = new EMCreateUser(); + createUser1.setUsername(username1); + createUser1.setPassword(password); + + EMCreateUser createUser2 = new EMCreateUser(); + createUser2.setUsername(username2); + createUser2.setPassword(password); + + emCreateUserList.add(createUser1); + emCreateUserList.add(createUser2); + + assertDoesNotThrow(() -> userApi.createUsers(emCreateUserList)); + + EMCreateGroup createGroup = new EMCreateGroup(); + createGroup.setOwner(username1); + createGroup.setGroupname("test-group"); + createGroup.setDescription("元梦之星"); + createGroup.setMaxusers(200); + createGroup.setMembers(Arrays.asList(username2)); + createGroup.setPublic(true); + + EMCreateGroupResult createGroupResult = + assertDoesNotThrow(() -> api.createGroup(createGroup)); + assertNotNull(createGroupResult); + assertNotNull(createGroupResult.getData()); + assertNotNull(createGroupResult.getData().getGroupid()); + + String groupId = createGroupResult.getData().getGroupid(); + + EMRemoveUserToGroupResult removeUserToGroupResult = + assertDoesNotThrow(() -> api.removeUserToGroup(groupId, username2)); + assertNotNull(removeUserToGroupResult); + assertNotNull(removeUserToGroupResult.getData()); + assertEquals(true, removeUserToGroupResult.getData().getResult()); + + assertDoesNotThrow(() -> userApi.deleteUser(username1)); + assertDoesNotThrow(() -> userApi.deleteUser(username2)); + try { + api.deleteGroup(groupId); + } catch (ApiException ignored) { + } + } + + /** + * 解除全员禁言 + *

+ * 一键取消对群组全体成员的禁言。解除禁言后,群成员可以在群组和该群组下的子区中正常发送消息。文档介绍:https://docs-im-beta.easemob.com/document/server-side/group.html#%E8%A7%A3%E9%99%A4%E5%85%A8%E5%91%98%E7%A6%81%E8%A8%80 + * + * @throws ApiException if the Api call fails + */ + @Test + public void unmuteAllGroupMembersTest() throws ApiException { + String username1 = randomUserName(); + String username2 = randomUserName(); + String password = "123456"; + + List emCreateUserList = new ArrayList<>(); + EMCreateUser createUser1 = new EMCreateUser(); + createUser1.setUsername(username1); + createUser1.setPassword(password); + + EMCreateUser createUser2 = new EMCreateUser(); + createUser2.setUsername(username2); + createUser2.setPassword(password); + + emCreateUserList.add(createUser1); + emCreateUserList.add(createUser2); + + assertDoesNotThrow(() -> userApi.createUsers(emCreateUserList)); + + EMCreateGroup createGroup = new EMCreateGroup(); + createGroup.setOwner(username1); + createGroup.setGroupname("test-group"); + createGroup.setDescription("元梦之星"); + createGroup.setMaxusers(200); + createGroup.setMembers(Arrays.asList(username2)); + createGroup.setPublic(true); + + EMCreateGroupResult createGroupResult = + assertDoesNotThrow(() -> api.createGroup(createGroup)); + assertNotNull(createGroupResult); + assertNotNull(createGroupResult.getData()); + assertNotNull(createGroupResult.getData().getGroupid()); + + String groupId = createGroupResult.getData().getGroupid(); + + assertDoesNotThrow(() -> api.addUserToGroupWhiteList(groupId, username2)); + + EMUnmuteAllGroupMembersResult unmuteAllGroupMembersResult = + assertDoesNotThrow(() -> api.unmuteAllGroupMembers(groupId)); + assertNotNull(unmuteAllGroupMembersResult); + assertNotNull(unmuteAllGroupMembersResult.getData()); + assertEquals(false, unmuteAllGroupMembersResult.getData().getMute()); + + assertDoesNotThrow(() -> userApi.deleteUser(username1)); + assertDoesNotThrow(() -> userApi.deleteUser(username2)); + try { + api.deleteGroup(groupId); + } catch (ApiException ignored) { + } + } + + /** + * 上传群组共享文件 + *

+ * 上传指定群组 ID 的群组共享文件。注意上传的文件大小不能超过 10 MB。分页获取指定群组 ID 的群组共享文件,然后可以根据响应中返回的文件 ID(file_id)调用 下载群组共享文件 接口下载该文件,或调用 删除群组共享文件 接口删除该文件。文档介绍:https://docs-im-beta.easemob.com/document/server-side/group.html#%E4%B8%8A%E4%BC%A0%E7%BE%A4%E7%BB%84%E5%85%B1%E4%BA%AB%E6%96%87%E4%BB%B6 + * + * @throws ApiException if the Api call fails + */ + @Test + public void uploadGroupShareFileTest() throws ApiException { + String username1 = randomUserName(); + String username2 = randomUserName(); + String password = "123456"; + + List emCreateUserList = new ArrayList<>(); + EMCreateUser createUser1 = new EMCreateUser(); + createUser1.setUsername(username1); + createUser1.setPassword(password); + + EMCreateUser createUser2 = new EMCreateUser(); + createUser2.setUsername(username2); + createUser2.setPassword(password); + + emCreateUserList.add(createUser1); + emCreateUserList.add(createUser2); + + assertDoesNotThrow(() -> userApi.createUsers(emCreateUserList)); + + EMCreateGroup createGroup = new EMCreateGroup(); + createGroup.setOwner(username1); + createGroup.setGroupname("test-group"); + createGroup.setDescription("元梦之星"); + createGroup.setMaxusers(200); + createGroup.setMembers(Arrays.asList(username2)); + createGroup.setPublic(true); + + EMCreateGroupResult createGroupResult = + assertDoesNotThrow(() -> api.createGroup(createGroup)); + assertNotNull(createGroupResult); + assertNotNull(createGroupResult.getData()); + assertNotNull(createGroupResult.getData().getGroupid()); + + String groupId = createGroupResult.getData().getGroupid(); + + assertDoesNotThrow(() -> api.addUserToGroupWhiteList(groupId, username2)); + + EMUploadGroupShareFileResult uploadGroupShareFileResult = assertDoesNotThrow( + () -> api.uploadGroupShareFile(groupId, new File(Objects.requireNonNull( + ClassLoaderUtils.getDefaultClassLoader().getResource("upload/blue.png")).getPath()))); + assertNotNull(uploadGroupShareFileResult); + assertNotNull(uploadGroupShareFileResult.getData()); + assertNotNull(uploadGroupShareFileResult.getData().getFileId()); + + String fileId = uploadGroupShareFileResult.getData().getFileId(); + + assertDoesNotThrow(() -> api.deleteGroupShareFile(groupId, fileId)); + + assertDoesNotThrow(() -> userApi.deleteUser(username1)); + assertDoesNotThrow(() -> userApi.deleteUser(username2)); + try { + api.deleteGroup(groupId); + } catch (ApiException ignored) { + } + } + +} diff --git a/src/test/java/com/easemob/im/api/HistoryMessageApiTest.java b/src/test/java/com/easemob/im/api/HistoryMessageApiTest.java new file mode 100644 index 000000000..3e86d8cf6 --- /dev/null +++ b/src/test/java/com/easemob/im/api/HistoryMessageApiTest.java @@ -0,0 +1,44 @@ +/* + * EMService + * Easemob Rest API + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.easemob.im.api; + +import com.easemob.im.ApiException; +import org.junit.jupiter.api.Test; + +import static org.junit.Assert.assertThrows; + +/** + * API tests for HistoryMessageApi + */ +public class HistoryMessageApiTest extends AbstractTest { + + private final HistoryMessageApi api = new HistoryMessageApi(); + + public HistoryMessageApiTest() { + } + + /** + * 获取历史消息记录 + * + * 你可以从服务端获取用户发送的历史消息的记录。单次请求获取从指定起始时间开始一小时内的发送的历史消息记录。查询历史消息记录时存在一定延时,无法实时获取。过期的历史消息记录无法获取。文档介绍:https://docs-im-beta.easemob.com/document/server-side/message_historical.html + * + * @throws ApiException if the Api call fails + */ + @Test + public void historyMessageTest() throws ApiException { + String time = "2024012415"; + assertThrows(ApiException.class, () -> api.historyMessage(time)); + } + +} diff --git a/src/test/java/com/easemob/im/api/MessageApiTest.java b/src/test/java/com/easemob/im/api/MessageApiTest.java new file mode 100644 index 000000000..a298e29d4 --- /dev/null +++ b/src/test/java/com/easemob/im/api/MessageApiTest.java @@ -0,0 +1,434 @@ +/* + * EMService + * Easemob Rest API + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.easemob.im.api; + +import com.easemob.im.ApiException; +import com.easemob.im.api.model.*; +import org.junit.jupiter.api.Test; + +import java.math.BigDecimal; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import java.util.Map; + +import static org.junit.jupiter.api.Assertions.*; + +/** + * API tests for MessageApi + */ +public class MessageApiTest extends AbstractTest { + + private final UserApi userApi = new UserApi(); + + private final MessageApi messageApi = new MessageApi(); + + private final GroupApi groupApi = new GroupApi(); + + private final RoomApi roomApi = new RoomApi(); + + public MessageApiTest() { + } + + /** + * 导入群聊消息 + * + * 你可以在数据迁移时导入群聊消息。每次调用该接口只能导入一条消息。文档介绍:https://docs-im-beta.easemob.com/document/server-side/message_import.html#%E5%AF%BC%E5%85%A5%E7%BE%A4%E8%81%8A%E6%B6%88%E6%81%AF + * + * @throws ApiException if the Api call fails + */ + @Test + public void importChatGroupMessageTest() throws ApiException { + String username1 = randomUserName(); + String username2 = randomUserName(); + String password = "123456"; + + List emCreateUserList = new ArrayList<>(); + EMCreateUser createUser1 = new EMCreateUser(); + createUser1.setUsername(username1); + createUser1.setPassword(password); + + EMCreateUser createUser2 = new EMCreateUser(); + createUser2.setUsername(username2); + createUser2.setPassword(password); + + emCreateUserList.add(createUser1); + emCreateUserList.add(createUser2); + + assertDoesNotThrow(() -> userApi.createUsers(emCreateUserList)); + + EMCreateGroup createGroup = new EMCreateGroup(); + createGroup.setOwner(username1); + createGroup.setGroupname("test-group"); + createGroup.setDescription("元梦之星"); + createGroup.setMaxusers(200); + createGroup.setMembers(Arrays.asList(username2)); + createGroup.setPublic(true); + + EMCreateGroupResult createGroupResult = + assertDoesNotThrow(() -> groupApi.createGroup(createGroup)); + assertNotNull(createGroupResult); + assertNotNull(createGroupResult.getData()); + assertNotNull(createGroupResult.getData().getGroupid()); + + String groupId = createGroupResult.getData().getGroupid(); + + EMImportChatGroupMessage emImportChatUserMessage = new EMImportChatGroupMessage(); + emImportChatUserMessage.setFrom(username1); + emImportChatUserMessage.setTarget(groupId); + emImportChatUserMessage.setType("txt"); + emImportChatUserMessage.setIsAckRead(true); + emImportChatUserMessage.setMsgTimestamp(new BigDecimal(System.currentTimeMillis())); + emImportChatUserMessage.needDownload(false); + emImportChatUserMessage.body(new EMMessageContent().msg("test message1")); + EMImportChatGroupMessageResult response = messageApi.importChatGroupMessage(emImportChatUserMessage); + assertNotNull(response.getData()); + assertNotNull(response.getData().getMsgId()); + + assertDoesNotThrow(() -> userApi.deleteUser(username1)); + assertDoesNotThrow(() -> userApi.deleteUser(username2)); + try { + groupApi.deleteGroup(groupId); + } catch (ApiException ignored) { + } + } + + /** + * 导入单聊消息 + * + * 你可以在数据迁移时导入单聊消息。每次调用该接口只能导入一条消息。文档介绍:https://docs-im-beta.easemob.com/document/server-side/message_import.html#%E5%AF%BC%E5%85%A5%E5%8D%95%E8%81%8A%E6%B6%88%E6%81%AF + * + * @throws ApiException if the Api call fails + */ + @Test + public void importChatUserMessageTest() throws ApiException { + String username1 = randomUserName(); + String username2 = randomUserName(); + String password = "123456"; + + List emCreateUserList = new ArrayList<>(); + EMCreateUser createUser1 = new EMCreateUser(); + createUser1.setUsername(username1); + createUser1.setPassword(password); + + EMCreateUser createUser2 = new EMCreateUser(); + createUser2.setUsername(username2); + createUser2.setPassword(password); + + emCreateUserList.add(createUser1); + emCreateUserList.add(createUser2); + + assertDoesNotThrow(() -> userApi.createUsers(emCreateUserList)); + + EMImportChatUserMessage emImportChatUserMessage = new EMImportChatUserMessage(); + emImportChatUserMessage.setFrom(username2); + emImportChatUserMessage.setTarget(username1); + emImportChatUserMessage.setType("txt"); + emImportChatUserMessage.setIsAckRead(true); + emImportChatUserMessage.setMsgTimestamp(new BigDecimal(System.currentTimeMillis())); + emImportChatUserMessage.needDownload(false); + emImportChatUserMessage.body(new EMMessageContent().msg("test message1")); + EMImportChatUserMessageResult response = messageApi.importChatUserMessage(emImportChatUserMessage); + assertNotNull(response.getData()); + assertNotNull(response.getData().getMsgId()); + + assertDoesNotThrow(() -> userApi.deleteUser(username1)); + assertDoesNotThrow(() -> userApi.deleteUser(username2)); + } + + /** + * 单向删除会话 + * + * 该方法使聊天用户能够从服务器中删除会话。删除会话后,该用户将从服务器获取不到该会话。该会话的其他参与聊天用户仍然可以从服务器获取会话内容。文档介绍:https://docs-im-beta.easemob.com/document/server-side/message_recall.html#%E5%8D%95%E5%90%91%E5%88%A0%E9%99%A4%E4%BC%9A%E8%AF%9D + * + * @throws ApiException if the Api call fails + */ + @Test + public void oneWayDeleteConversationTest() throws ApiException { + String username1 = randomUserName(); + String username2 = randomUserName(); + String password = "123456"; + + List emCreateUserList = new ArrayList<>(); + EMCreateUser createUser1 = new EMCreateUser(); + createUser1.setUsername(username1); + createUser1.setPassword(password); + + EMCreateUser createUser2 = new EMCreateUser(); + createUser2.setUsername(username2); + createUser2.setPassword(password); + + emCreateUserList.add(createUser1); + emCreateUserList.add(createUser2); + + assertDoesNotThrow(() -> userApi.createUsers(emCreateUserList)); + + EMCreateMessage emCreateMessage = new EMCreateMessage(); + emCreateMessage.setFrom(username1); + emCreateMessage.setTo(new ArrayList(){{add(username2);}}); + emCreateMessage.setType("txt"); + EMMessageContent messageContent = new EMMessageContent(); + messageContent.setMsg("test message"); + emCreateMessage.setBody(messageContent); + + EMSendMessageResult sendMessageResponse = messageApi.sendMessagesToUser(emCreateMessage); + assertNotNull(sendMessageResponse.getData()); + + EMOneWayDeleteConversation emOneWayDeleteConversation = new EMOneWayDeleteConversation(); + emOneWayDeleteConversation.setChannel(username2); + emOneWayDeleteConversation.setType("chat"); + emOneWayDeleteConversation.setDeleteRoam(true); + + EMOneWayDeleteConversationResult response = messageApi.oneWayDeleteConversation(username1, emOneWayDeleteConversation); + assertNotNull(response.getData()); + assertEquals("ok", response.getData().getResult()); + + EMOneWayDeleteConversation emOneWayDeleteConversation1 = new EMOneWayDeleteConversation(); + emOneWayDeleteConversation1.setChannel(username1); + emOneWayDeleteConversation1.setType("chat"); + emOneWayDeleteConversation1.setDeleteRoam(true); + EMOneWayDeleteConversationResult response1 = messageApi.oneWayDeleteConversation(username2, emOneWayDeleteConversation1); + assertNotNull(response1.getData()); + assertEquals("ok", response1.getData().getResult()); + + assertDoesNotThrow(() -> userApi.deleteUser(username1)); + assertDoesNotThrow(() -> userApi.deleteUser(username2)); + } + + /** + * 撤回消息 + * + * 发送方可以撤回一条发送成功的消息。默认情况下,发送方可撤回发出 2 分钟内的消息。文档介绍:https://docs-im-beta.easemob.com/document/server-side/message_recall.html#%E6%92%A4%E5%9B%9E%E6%B6%88%E6%81%AF + * + * @throws ApiException if the Api call fails + */ + @Test + public void recallMessageTest() throws ApiException { + String username1 = randomUserName(); + String username2 = randomUserName(); + String password = "123456"; + + List emCreateUserList = new ArrayList<>(); + EMCreateUser createUser1 = new EMCreateUser(); + createUser1.setUsername(username1); + createUser1.setPassword(password); + + EMCreateUser createUser2 = new EMCreateUser(); + createUser2.setUsername(username2); + createUser2.setPassword(password); + + emCreateUserList.add(createUser1); + emCreateUserList.add(createUser2); + + assertDoesNotThrow(() -> userApi.createUsers(emCreateUserList)); + + EMCreateMessage emCreateMessage = new EMCreateMessage(); + emCreateMessage.setFrom(username1); + emCreateMessage.setTo(new ArrayList(){{add(username2);}}); + emCreateMessage.setType("txt"); + EMMessageContent messageContent = new EMMessageContent(); + messageContent.setMsg("test message"); + emCreateMessage.setBody(messageContent); + + EMSendMessageResult sendMessageResponse = messageApi.sendMessagesToUser(emCreateMessage); + assertNotNull(sendMessageResponse.getData()); + Map data = (Map) sendMessageResponse.getData(); + String messageId = data.get(username2); + + EMRecallMessage emRecallMessage = new EMRecallMessage(); + emRecallMessage.setFrom(username1); + emRecallMessage.setMsgId(messageId); + emRecallMessage.setTo(username2); + emRecallMessage.setChatType("chat"); + emRecallMessage.setForce(true); + EMRecallMessageResult response = messageApi.recallMessage(emRecallMessage); + assertNotNull(response.getData()); + assertEquals("yes", response.getData().getRecalled()); + + assertDoesNotThrow(() -> userApi.deleteUser(username1)); + assertDoesNotThrow(() -> userApi.deleteUser(username2)); + } + + /** + * 发送群聊消息 + * + * 向群组发送消息。文档介绍:https://docs-im-beta.easemob.com/document/server-side/message_group.html + * + * @throws ApiException if the Api call fails + */ + @Test + public void sendMessagesToGroupTest() throws ApiException { + String username1 = randomUserName(); + String username2 = randomUserName(); + String password = "123456"; + + List emCreateUserList = new ArrayList<>(); + EMCreateUser createUser1 = new EMCreateUser(); + createUser1.setUsername(username1); + createUser1.setPassword(password); + + EMCreateUser createUser2 = new EMCreateUser(); + createUser2.setUsername(username2); + createUser2.setPassword(password); + + emCreateUserList.add(createUser1); + emCreateUserList.add(createUser2); + + assertDoesNotThrow(() -> userApi.createUsers(emCreateUserList)); + + EMCreateGroup createGroup = new EMCreateGroup(); + createGroup.setOwner(username1); + createGroup.setGroupname("test-group"); + createGroup.setDescription("元梦之星"); + createGroup.setMaxusers(200); + createGroup.setMembers(Arrays.asList(username2)); + createGroup.setPublic(true); + + EMCreateGroupResult createGroupResult = + assertDoesNotThrow(() -> groupApi.createGroup(createGroup)); + assertNotNull(createGroupResult); + assertNotNull(createGroupResult.getData()); + assertNotNull(createGroupResult.getData().getGroupid()); + + String groupId = createGroupResult.getData().getGroupid(); + + EMCreateMessage emCreateMessage = new EMCreateMessage(); + emCreateMessage.setFrom(username1); + emCreateMessage.setTo(new ArrayList(){{add(groupId);}}); + emCreateMessage.setType("txt"); + EMMessageContent messageContent = new EMMessageContent(); + messageContent.setMsg("test message"); + emCreateMessage.setBody(messageContent); + + EMSendMessageResult response = messageApi.sendMessagesToGroup(emCreateMessage); + assertNotNull(response.getData()); + Map data = (Map) response.getData(); + System.out.println("messageId : " + data.get(groupId)); + + assertDoesNotThrow(() -> userApi.deleteUser(username1)); + assertDoesNotThrow(() -> userApi.deleteUser(username2)); + try { + groupApi.deleteGroup(groupId); + } catch (ApiException ignored) { + } + } + + /** + * 发送聊天室消息 + * + * 向群组发送消息。文档介绍:https://docs-im-beta.easemob.com/document/server-side/message_chatroom.html + * + * @throws ApiException if the Api call fails + */ + @Test + public void sendMessagesToRoomTest() throws ApiException { + String username1 = randomUserName(); + String username2 = randomUserName(); + String password = "123456"; + + List emCreateUserList = new ArrayList<>(); + EMCreateUser createUser1 = new EMCreateUser(); + createUser1.setUsername(username1); + createUser1.setPassword(password); + + EMCreateUser createUser2 = new EMCreateUser(); + createUser2.setUsername(username2); + createUser2.setPassword(password); + + emCreateUserList.add(createUser1); + emCreateUserList.add(createUser2); + + assertDoesNotThrow(() -> userApi.createUsers(emCreateUserList)); + + EMCreateRoom createRoom = new EMCreateRoom(); + createRoom.setOwner(username1); + createRoom.setName("test-room"); + createRoom.setDescription("元梦之星"); + createRoom.setMaxusers(200); + createRoom.setMembers(Arrays.asList(username2)); + createRoom.setCustom("custom"); + + EMCreateRoomResult createRoomResult= assertDoesNotThrow(() -> roomApi.createRoom(createRoom)); + assertNotNull(createRoomResult); + assertNotNull(createRoomResult.getData()); + assertNotNull(createRoomResult.getData().getId()); + + String roomId = createRoomResult.getData().getId(); + + EMCreateMessage emCreateMessage = new EMCreateMessage(); + emCreateMessage.setFrom(username1); + emCreateMessage.setTo(new ArrayList(){{add(roomId);}}); + emCreateMessage.setType("txt"); + EMMessageContent messageContent = new EMMessageContent(); + messageContent.setMsg("test message"); + emCreateMessage.setBody(messageContent); + + EMSendMessageResult response = messageApi.sendMessagesToRoom(emCreateMessage); + assertNotNull(response.getData()); + Map data = (Map) response.getData(); + System.out.println("messageId : " + data.get(roomId)); + + assertDoesNotThrow(() -> userApi.deleteUser(username1)); + assertDoesNotThrow(() -> userApi.deleteUser(username2)); + try { + roomApi.deleteRoom(roomId); + } catch (ApiException ignored) { + } + } + + /** + * 发送单聊消息 + * + * 给用户发送消息。文档介绍:https://docs-im-beta.easemob.com/document/server-side/message_single.html + * + * @throws ApiException if the Api call fails + */ + @Test + public void sendMessagesToUserTest() throws ApiException { + String username1 = randomUserName(); + String username2 = randomUserName(); + String password = "123456"; + + List emCreateUserList = new ArrayList<>(); + EMCreateUser createUser1 = new EMCreateUser(); + createUser1.setUsername(username1); + createUser1.setPassword(password); + + EMCreateUser createUser2 = new EMCreateUser(); + createUser2.setUsername(username2); + createUser2.setPassword(password); + + emCreateUserList.add(createUser1); + emCreateUserList.add(createUser2); + + assertDoesNotThrow(() -> userApi.createUsers(emCreateUserList)); + + EMCreateMessage emCreateMessage = new EMCreateMessage(); + emCreateMessage.setFrom(username1); + emCreateMessage.setTo(new ArrayList(){{add(username2);}}); + emCreateMessage.setType("txt"); + EMMessageContent messageContent = new EMMessageContent(); + messageContent.setMsg("test message"); + emCreateMessage.setBody(messageContent); + + EMSendMessageResult response = messageApi.sendMessagesToUser(emCreateMessage); + assertNotNull(response.getData()); + Map data = (Map)response.getData(); + System.out.println("messageId : " + data.get(username2)); + + assertDoesNotThrow(() -> userApi.deleteUser(username1)); + assertDoesNotThrow(() -> userApi.deleteUser(username2)); + } + +} diff --git a/src/test/java/com/easemob/im/api/MetadataApiTest.java b/src/test/java/com/easemob/im/api/MetadataApiTest.java new file mode 100644 index 000000000..9fe82f896 --- /dev/null +++ b/src/test/java/com/easemob/im/api/MetadataApiTest.java @@ -0,0 +1,375 @@ +/* + * EMService + * Easemob Rest API + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.easemob.im.api; + +import com.easemob.im.ApiException; +import com.easemob.im.api.model.*; +import org.junit.jupiter.api.Test; + +import java.util.*; + +import static org.junit.jupiter.api.Assertions.*; + +/** + * API tests for MetadataApi + */ +public class MetadataApiTest extends AbstractTest { + + private final MetadataApi api = new MetadataApi(); + + private final UserApi userApi = new UserApi(); + + private final GroupApi groupApi = new GroupApi(); + + public MetadataApiTest() { + } + + /** + * 设置群成员自定义属性 + *

+ * 设置群成员自定义属性。群成员可设置自定义属性(key-value),例如在群组中的昵称和头像等。群主可修改所有群成员的自定义属性,其他群成员只能修改自己的自定义属性。文档介绍:https://docs-im-beta.easemob.com/document/server-side/group.html#%E8%AE%BE%E7%BD%AE%E7%BE%A4%E6%88%90%E5%91%98%E8%87%AA%E5%AE%9A%E4%B9%89%E5%B1%9E%E6%80%A7 + * + * @throws ApiException if the Api call fails + */ + @Test + public void customGroupMemberAttributeTest() throws ApiException { + String username1 = randomUserName(); + String username2 = randomUserName(); + String password = "123456"; + + List emCreateUserList = new ArrayList<>(); + EMCreateUser createUser1 = new EMCreateUser(); + createUser1.setUsername(username1); + createUser1.setPassword(password); + + EMCreateUser createUser2 = new EMCreateUser(); + createUser2.setUsername(username2); + createUser2.setPassword(password); + + emCreateUserList.add(createUser1); + emCreateUserList.add(createUser2); + + assertDoesNotThrow(() -> userApi.createUsers(emCreateUserList)); + + EMCreateGroup createGroup = new EMCreateGroup(); + createGroup.setOwner(username1); + createGroup.setGroupname("test-group"); + createGroup.setDescription("元梦之星"); + createGroup.setMaxusers(200); + createGroup.setMembers(Arrays.asList(username2)); + createGroup.setPublic(true); + + EMCreateGroupResult createGroupResult = + assertDoesNotThrow(() -> groupApi.createGroup(createGroup)); + assertNotNull(createGroupResult); + assertNotNull(createGroupResult.getData()); + assertNotNull(createGroupResult.getData().getGroupid()); + + String groupId = createGroupResult.getData().getGroupid(); + + Map metadata = new HashMap<>(); + metadata.put("key1", "value1"); + metadata.put("key2", "value2"); + + EMCustomGroupMemberAttribute customGroupMemberAttribute = new EMCustomGroupMemberAttribute(); + customGroupMemberAttribute.setMetaData(metadata); + + EMCustomGroupMemberAttributeResult customGroupMemberAttributeResult = assertDoesNotThrow( + () -> api.customGroupMemberAttribute(groupId, username2, customGroupMemberAttribute)); + assertNotNull(customGroupMemberAttributeResult); + assertNotNull(customGroupMemberAttributeResult.getData()); + assertEquals("value1", ((Map) customGroupMemberAttributeResult.getData()).get("key1")); + assertEquals("value2", ((Map) customGroupMemberAttributeResult.getData()).get("key2")); + + assertDoesNotThrow(() -> userApi.deleteUser(username1)); + assertDoesNotThrow(() -> userApi.deleteUser(username2)); + try { + groupApi.deleteGroup(groupId); + } catch (ApiException ignored) { + } + } + + /** + * 删除用户属性 + *

+ * 删除单个用户的所有属性。如果指定的用户或用户属性不存在(可能已删除),也视为删除成功。文档介绍:https://docs-im-beta.easemob.com/document/server-side/userprofile.html#%E5%88%A0%E9%99%A4%E7%94%A8%E6%88%B7%E5%B1%9E%E6%80%A7 + * + * @throws ApiException if the Api call fails + */ + @Test + public void deleteUserMetadataTest() throws ApiException { + String username = randomUserName(); + String password = "123456"; + + List emCreateUserList = new ArrayList<>(); + EMCreateUser createUser = new EMCreateUser(); + createUser.setUsername(username); + createUser.setPassword(password); + + emCreateUserList.add(createUser); + + assertDoesNotThrow(() -> userApi.createUsers(emCreateUserList)); + + Map metadata = new HashMap<>(); + metadata.put("nickname", "javk"); + metadata.put("age", "20"); + EMSetUserMetadataResult setUserMetadataResult = + assertDoesNotThrow(() -> api.setUserMetadata(username, metadata)); + assertNotNull(setUserMetadataResult); + assertNotNull(setUserMetadataResult.getData()); + + EMDeleteUserMetadataResult deleteUserMetadataResult = + assertDoesNotThrow(() -> api.deleteUserMetadata(username)); + assertNotNull(deleteUserMetadataResult); + assertNotNull(deleteUserMetadataResult.getData()); + assertEquals(true, deleteUserMetadataResult.getData()); + + assertDoesNotThrow(() -> userApi.deleteUser(username)); + } + + /** + * 获取单个群成员的所有自定义属性 + *

+ * 获取单个群成员的所有自定义属性。文档介绍:https://docs-im-beta.easemob.com/document/server-side/group.html#%E8%8E%B7%E5%8F%96%E5%8D%95%E4%B8%AA%E7%BE%A4%E6%88%90%E5%91%98%E7%9A%84%E6%89%80%E6%9C%89%E8%87%AA%E5%AE%9A%E4%B9%89%E5%B1%9E%E6%80%A7 + * + * @throws ApiException if the Api call fails + */ + @Test + public void getGroupMemberAllCustomAttributeTest() throws ApiException { + String username1 = randomUserName(); + String username2 = randomUserName(); + String password = "123456"; + + List emCreateUserList = new ArrayList<>(); + EMCreateUser createUser1 = new EMCreateUser(); + createUser1.setUsername(username1); + createUser1.setPassword(password); + + EMCreateUser createUser2 = new EMCreateUser(); + createUser2.setUsername(username2); + createUser2.setPassword(password); + + emCreateUserList.add(createUser1); + emCreateUserList.add(createUser2); + + assertDoesNotThrow(() -> userApi.createUsers(emCreateUserList)); + + EMCreateGroup createGroup = new EMCreateGroup(); + createGroup.setOwner(username1); + createGroup.setGroupname("test-group"); + createGroup.setDescription("元梦之星"); + createGroup.setMaxusers(200); + createGroup.setMembers(Arrays.asList(username2)); + createGroup.setPublic(true); + + EMCreateGroupResult createGroupResult = + assertDoesNotThrow(() -> groupApi.createGroup(createGroup)); + assertNotNull(createGroupResult); + assertNotNull(createGroupResult.getData()); + assertNotNull(createGroupResult.getData().getGroupid()); + + String groupId = createGroupResult.getData().getGroupid(); + + Map metadata = new HashMap<>(); + metadata.put("key1", "value1"); + metadata.put("key2", "value2"); + + EMCustomGroupMemberAttribute customGroupMemberAttribute = new EMCustomGroupMemberAttribute(); + customGroupMemberAttribute.setMetaData(metadata); + + EMCustomGroupMemberAttributeResult customGroupMemberAttributeResult = assertDoesNotThrow( + () -> api.customGroupMemberAttribute(groupId, username2, customGroupMemberAttribute)); + assertNotNull(customGroupMemberAttributeResult); + assertNotNull(customGroupMemberAttributeResult.getData()); + assertEquals("value1", ((Map) customGroupMemberAttributeResult.getData()).get("key1")); + assertEquals("value2", ((Map) customGroupMemberAttributeResult.getData()).get("key2")); + + EMGetGroupMemberAllCustomAttributeResult getGroupMemberAllCustomAttributeResult = assertDoesNotThrow( + () -> api.getGroupMemberAllCustomAttribute(groupId, username2)); + assertNotNull(getGroupMemberAllCustomAttributeResult); + assertNotNull(getGroupMemberAllCustomAttributeResult.getData()); + assertEquals("value1", + ((Map) getGroupMemberAllCustomAttributeResult.getData()).get("key1")); + assertEquals("value1", + ((Map) getGroupMemberAllCustomAttributeResult.getData()).get("key1")); + + assertDoesNotThrow(() -> userApi.deleteUser(username1)); + assertDoesNotThrow(() -> userApi.deleteUser(username2)); + try { + groupApi.deleteGroup(groupId); + } catch (ApiException ignored) { + } + } + + /** + * 根据属性 key 获取多个群成员的自定义属性 + *

+ * 根据指定的属性 key 获取多个群成员的自定义属性。每次最多可获取 10 个群成员的自定义属性。文档介绍:https://docs-im-beta.easemob.com/document/server-side/group.html#%E6%A0%B9%E6%8D%AE%E5%B1%9E%E6%80%A7-key-%E8%8E%B7%E5%8F%96%E5%A4%9A%E4%B8%AA%E7%BE%A4%E6%88%90%E5%91%98%E7%9A%84%E8%87%AA%E5%AE%9A%E4%B9%89%E5%B1%9E%E6%80%A7 + * + * @throws ApiException if the Api call fails + */ + @Test + public void getMultipleGroupMembersAttributesTest() throws ApiException { + String username1 = randomUserName(); + String username2 = randomUserName(); + String password = "123456"; + + List emCreateUserList = new ArrayList<>(); + EMCreateUser createUser1 = new EMCreateUser(); + createUser1.setUsername(username1); + createUser1.setPassword(password); + + EMCreateUser createUser2 = new EMCreateUser(); + createUser2.setUsername(username2); + createUser2.setPassword(password); + + emCreateUserList.add(createUser1); + emCreateUserList.add(createUser2); + + assertDoesNotThrow(() -> userApi.createUsers(emCreateUserList)); + + EMCreateGroup createGroup = new EMCreateGroup(); + createGroup.setOwner(username1); + createGroup.setGroupname("test-group"); + createGroup.setDescription("元梦之星"); + createGroup.setMaxusers(200); + createGroup.setMembers(Arrays.asList(username2)); + createGroup.setPublic(true); + + EMCreateGroupResult createGroupResult = + assertDoesNotThrow(() -> groupApi.createGroup(createGroup)); + assertNotNull(createGroupResult); + assertNotNull(createGroupResult.getData()); + assertNotNull(createGroupResult.getData().getGroupid()); + + String groupId = createGroupResult.getData().getGroupid(); + + Map metadata = new HashMap<>(); + metadata.put("key1", "value1"); + metadata.put("key2", "value2"); + + EMCustomGroupMemberAttribute customGroupMemberAttribute = new EMCustomGroupMemberAttribute(); + customGroupMemberAttribute.setMetaData(metadata); + + EMCustomGroupMemberAttributeResult customGroupMemberAttributeResult = assertDoesNotThrow( + () -> api.customGroupMemberAttribute(groupId, username2, customGroupMemberAttribute)); + assertNotNull(customGroupMemberAttributeResult); + assertNotNull(customGroupMemberAttributeResult.getData()); + assertEquals("value1", ((Map) customGroupMemberAttributeResult.getData()).get("key1")); + assertEquals("value2", ((Map) customGroupMemberAttributeResult.getData()).get("key2")); + + EMGetMultipleGroupMembersAttributes getMultipleGroupMembersAttributes = new EMGetMultipleGroupMembersAttributes(); + getMultipleGroupMembersAttributes.setTargets(Arrays.asList(username2)); + getMultipleGroupMembersAttributes.setProperties(Arrays.asList("key1")); + + EMGetMultipleGroupMembersAttributesResult response = assertDoesNotThrow(() -> api.getMultipleGroupMembersAttributes(groupId, + getMultipleGroupMembersAttributes)); + assertNotNull(response); + assertNotNull(response.getData()); + + assertDoesNotThrow(() -> userApi.deleteUser(username1)); + assertDoesNotThrow(() -> userApi.deleteUser(username2)); + try { + groupApi.deleteGroup(groupId); + } catch (ApiException ignored) { + } + } + + /** + * 获取用户属性 + *

+ * 获取单个用户的全部用户属性键值对。需要在请求中填写 {username},指定获取用户属性的用户 ID。如果指定的用户或用户属性不存在,返回空数据{}。文档介绍:https://docs-im-beta.easemob.com/document/server-side/userprofile.html#%E8%8E%B7%E5%8F%96%E7%94%A8%E6%88%B7%E5%B1%9E%E6%80%A7 + * + * @throws ApiException if the Api call fails + */ + @Test + public void getUserMetadataTest() throws ApiException { + String username1 = randomUserName(); + String password = "123456"; + + List emCreateUserList = new ArrayList<>(); + EMCreateUser createUser1 = new EMCreateUser(); + createUser1.setUsername(username1); + createUser1.setPassword(password); + + emCreateUserList.add(createUser1); + + assertDoesNotThrow(() -> userApi.createUsers(emCreateUserList)); + + Map metadata = new HashMap<>(); + metadata.put("nickname", "jack"); + metadata.put("age", "20"); + EMSetUserMetadataResult setUserMetadataResult = + assertDoesNotThrow(() -> api.setUserMetadata(username1, metadata)); + assertNotNull(setUserMetadataResult); + assertNotNull(setUserMetadataResult.getData()); + + EMGetUserMetadataResult getUserMetadataResult = + assertDoesNotThrow(() -> api.getUserMetadata(username1)); + assertNotNull(getUserMetadataResult); + Map result = (Map) getUserMetadataResult.getData(); + assertEquals("jack", result.get("nickname")); + assertEquals("20", result.get("age")); + + assertDoesNotThrow(() -> userApi.deleteUser(username1)); + } + + /** + * 获取 app 下用户属性总大小 + *

+ * 取该 app 下所有用户的属性数据大小,单位为字节。文档介绍:https://docs-im-beta.easemob.com/document/server-side/userprofile.html#%E8%8E%B7%E5%8F%96-app-%E4%B8%8B%E7%94%A8%E6%88%B7%E5%B1%9E%E6%80%A7%E6%80%BB%E5%A4%A7%E5%B0%8F + * + * @throws ApiException if the Api call fails + */ + @Test + public void getUserMetadataCapacityTest() throws ApiException { + EMGetUserMetadataCapacityResult response = + assertDoesNotThrow(() -> api.getUserMetadataCapacity()); + assertNotNull(response); + assertNotNull(response.getData()); + } + + /** + * 设置用户属性 + *

+ * 用户属性的内容为一个或多个纯文本键值对,默认单个用户的属性总长度不能超过 2 KB,默认单个 app 下所有用户的属性总长度不能超过 10 GB。利用该 API,每次只能设置一个用户的用户属性。文档介绍:https://docs-im-beta.easemob.com/document/server-side/userprofile.html#%E8%AE%BE%E7%BD%AE%E7%94%A8%E6%88%B7%E5%B1%9E%E6%80%A7 + * + * @throws ApiException if the Api call fails + */ + @Test + public void setUserMetadataTest() throws ApiException { + String username1 = randomUserName(); + String password = "123456"; + + List emCreateUserList = new ArrayList<>(); + EMCreateUser createUser1 = new EMCreateUser(); + createUser1.setUsername(username1); + createUser1.setPassword(password); + + emCreateUserList.add(createUser1); + + assertDoesNotThrow(() -> userApi.createUsers(emCreateUserList)); + + Map metadata = new HashMap<>(); + metadata.put("nickname", "javk"); + metadata.put("age", "20"); + EMSetUserMetadataResult setUserMetadataResult = + assertDoesNotThrow(() -> api.setUserMetadata(username1, metadata)); + assertNotNull(setUserMetadataResult); + assertNotNull(setUserMetadataResult.getData()); + + assertDoesNotThrow(() -> userApi.deleteUser(username1)); + } + +} diff --git a/src/test/java/com/easemob/im/api/RoomApiTest.java b/src/test/java/com/easemob/im/api/RoomApiTest.java new file mode 100644 index 000000000..5510bde89 --- /dev/null +++ b/src/test/java/com/easemob/im/api/RoomApiTest.java @@ -0,0 +1,2054 @@ +/* + * EMService + * Easemob Rest API + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.easemob.im.api; + +import com.easemob.im.ApiException; +import com.easemob.im.api.model.*; +import org.junit.jupiter.api.Test; + +import java.math.BigDecimal; +import java.util.*; + +import static org.junit.jupiter.api.Assertions.*; + +/** + * API tests for RoomApi + */ +public class RoomApiTest extends AbstractTest { + + private final UserApi userApi = new UserApi(); + + private final RoomApi api = new RoomApi(); + + public RoomApiTest() { + } + + /** + * 批量添加聊天室成员 + * + * 向聊天室添加多位用户,一次性最多可添加 60 位用户。文档介绍:https://docs-im-beta.easemob.com/document/server-side/chatroom.html#%E6%89%B9%E9%87%8F%E6%B7%BB%E5%8A%A0%E8%81%8A%E5%A4%A9%E5%AE%A4%E6%88%90%E5%91%98 + * + * @throws ApiException if the Api call fails + */ + @Test + public void addMultipleUserToRoomTest() throws ApiException { + String username1 = randomUserName(); + String username2 = randomUserName(); + String password = "123456"; + + List emCreateUserList = new ArrayList<>(); + EMCreateUser createUser1 = new EMCreateUser(); + createUser1.setUsername(username1); + createUser1.setPassword(password); + + EMCreateUser createUser2 = new EMCreateUser(); + createUser2.setUsername(username2); + createUser2.setPassword(password); + + emCreateUserList.add(createUser1); + emCreateUserList.add(createUser2); + + assertDoesNotThrow(() -> userApi.createUsers(emCreateUserList)); + + EMCreateRoom createRoom = new EMCreateRoom(); + createRoom.setOwner(username1); + createRoom.setName("test-room"); + createRoom.setDescription("元梦之星"); + createRoom.setMaxusers(200); + createRoom.setMembers(Arrays.asList(username2)); + createRoom.setCustom("custom"); + + EMCreateRoomResult createRoomResult= assertDoesNotThrow(() -> api.createRoom(createRoom)); + assertNotNull(createRoomResult); + assertNotNull(createRoomResult.getData()); + assertNotNull(createRoomResult.getData().getId()); + + String roomId = createRoomResult.getData().getId(); + + EMAddMultipleUserToRoom addMultipleUserToRoom = new EMAddMultipleUserToRoom(); + addMultipleUserToRoom.setUsernames(Arrays.asList(username2)); + assertDoesNotThrow(() -> api.addMultipleUserToRoom(roomId, addMultipleUserToRoom)); + + assertDoesNotThrow(() -> userApi.deleteUser(username1)); + assertDoesNotThrow(() -> userApi.deleteUser(username2)); + try {api.deleteRoom(roomId);} catch (ApiException ignored) {} + } + + /** + * 批量添加用户至聊天室黑名单 + * + * 将多个用户加入指定聊天室的黑名单。你一次最多可以添加 60 个用户至聊天室黑名单。聊天室所有者无法被加入聊天室的黑名单。用户进入聊天室黑名单后,无法查看和收发该聊天室的信息。文档介绍:https://docs-im-beta.easemob.com/document/server-side/chatroom.html#%E6%89%B9%E9%87%8F%E6%B7%BB%E5%8A%A0%E7%94%A8%E6%88%B7%E8%87%B3%E8%81%8A%E5%A4%A9%E5%AE%A4%E9%BB%91%E5%90%8D%E5%8D%95 + * + * @throws ApiException if the Api call fails + */ + @Test + public void addMultipleUserToRoomBlockListTest() throws ApiException { + String username1 = randomUserName(); + String username2 = randomUserName(); + String password = "123456"; + + List emCreateUserList = new ArrayList<>(); + EMCreateUser createUser1 = new EMCreateUser(); + createUser1.setUsername(username1); + createUser1.setPassword(password); + + EMCreateUser createUser2 = new EMCreateUser(); + createUser2.setUsername(username2); + createUser2.setPassword(password); + + emCreateUserList.add(createUser1); + emCreateUserList.add(createUser2); + + assertDoesNotThrow(() -> userApi.createUsers(emCreateUserList)); + + EMCreateRoom createRoom = new EMCreateRoom(); + createRoom.setOwner(username1); + createRoom.setName("test-room"); + createRoom.setDescription("元梦之星"); + createRoom.setMaxusers(200); + createRoom.setMembers(Arrays.asList(username2)); + createRoom.setCustom("custom"); + + EMCreateRoomResult createRoomResult= assertDoesNotThrow(() -> api.createRoom(createRoom)); + assertNotNull(createRoomResult); + assertNotNull(createRoomResult.getData()); + assertNotNull(createRoomResult.getData().getId()); + + String roomId = createRoomResult.getData().getId(); + + EMAddMultipleUserToRoomBlockList addMultipleUserToRoomBlockList = new EMAddMultipleUserToRoomBlockList(); + addMultipleUserToRoomBlockList.setUsernames(Arrays.asList(username2)); + + EMAddMultipleUserToRoomBlockListResult addMultipleUserToRoomBlockListResult = + assertDoesNotThrow(() -> api.addMultipleUserToRoomBlockList(roomId, + addMultipleUserToRoomBlockList)); + assertNotNull(addMultipleUserToRoomBlockListResult); + assertNotNull(addMultipleUserToRoomBlockListResult.getData()); + + assertDoesNotThrow(() -> userApi.deleteUser(username1)); + assertDoesNotThrow(() -> userApi.deleteUser(username2)); + try {api.deleteRoom(roomId);} catch (ApiException ignored) {} + } + + /** + * 批量添加用户至聊天室白名单 + * + * 添加多个用户至聊天室白名单。你一次最多可添加 60 个用户。用户添加至聊天室白名单后,在聊天室全员禁言时,仍可以在聊天室中发送消息。文档介绍:https://docs-im-beta.easemob.com/document/server-side/chatroom.html#%E6%89%B9%E9%87%8F%E6%B7%BB%E5%8A%A0%E7%94%A8%E6%88%B7%E8%87%B3%E8%81%8A%E5%A4%A9%E5%AE%A4%E7%99%BD%E5%90%8D%E5%8D%95 + * + * @throws ApiException if the Api call fails + */ + @Test + public void addMultipleUserToRoomWhiteListTest() throws ApiException { + String username1 = randomUserName(); + String username2 = randomUserName(); + String password = "123456"; + + List emCreateUserList = new ArrayList<>(); + EMCreateUser createUser1 = new EMCreateUser(); + createUser1.setUsername(username1); + createUser1.setPassword(password); + + EMCreateUser createUser2 = new EMCreateUser(); + createUser2.setUsername(username2); + createUser2.setPassword(password); + + emCreateUserList.add(createUser1); + emCreateUserList.add(createUser2); + + assertDoesNotThrow(() -> userApi.createUsers(emCreateUserList)); + + EMCreateRoom createRoom = new EMCreateRoom(); + createRoom.setOwner(username1); + createRoom.setName("test-room"); + createRoom.setDescription("元梦之星"); + createRoom.setMaxusers(200); + createRoom.setMembers(Arrays.asList(username2)); + createRoom.setCustom("custom"); + + EMCreateRoomResult createRoomResult= assertDoesNotThrow(() -> api.createRoom(createRoom)); + assertNotNull(createRoomResult); + assertNotNull(createRoomResult.getData()); + assertNotNull(createRoomResult.getData().getId()); + + String roomId = createRoomResult.getData().getId(); + + EMAddMultipleUserToRoomWhiteList addMultipleUserToRoomWhiteList = new EMAddMultipleUserToRoomWhiteList(); + addMultipleUserToRoomWhiteList.setUsernames(Arrays.asList(username2)); + + EMAddMultipleUserToRoomWhiteListResult addMultipleUserToRoomWhiteListResult = + assertDoesNotThrow(() -> api.addMultipleUserToRoomWhiteList(roomId, + addMultipleUserToRoomWhiteList)); + assertNotNull(addMultipleUserToRoomWhiteListResult); + assertNotNull(addMultipleUserToRoomWhiteListResult.getData()); + + assertDoesNotThrow(() -> userApi.deleteUser(username1)); + assertDoesNotThrow(() -> userApi.deleteUser(username2)); + try {api.deleteRoom(roomId);} catch (ApiException ignored) {} + } + + /** + * 添加聊天室管理员 + * + * 将一个聊天室成员设置为聊天室管理员。文档介绍:https://docs-im-beta.easemob.com/document/server-side/chatroom.html#%E6%B7%BB%E5%8A%A0%E8%81%8A%E5%A4%A9%E5%AE%A4%E7%AE%A1%E7%90%86%E5%91%98 + * + * @throws ApiException if the Api call fails + */ + @Test + public void addRoomAdminTest() throws ApiException { + String username1 = randomUserName(); + String username2 = randomUserName(); + String password = "123456"; + + List emCreateUserList = new ArrayList<>(); + EMCreateUser createUser1 = new EMCreateUser(); + createUser1.setUsername(username1); + createUser1.setPassword(password); + + EMCreateUser createUser2 = new EMCreateUser(); + createUser2.setUsername(username2); + createUser2.setPassword(password); + + emCreateUserList.add(createUser1); + emCreateUserList.add(createUser2); + + assertDoesNotThrow(() -> userApi.createUsers(emCreateUserList)); + + EMCreateRoom createRoom = new EMCreateRoom(); + createRoom.setOwner(username1); + createRoom.setName("test-room"); + createRoom.setDescription("元梦之星"); + createRoom.setMaxusers(200); + createRoom.setMembers(Arrays.asList(username2)); + createRoom.setCustom("custom"); + + EMCreateRoomResult createRoomResult= assertDoesNotThrow(() -> api.createRoom(createRoom)); + assertNotNull(createRoomResult); + assertNotNull(createRoomResult.getData()); + assertNotNull(createRoomResult.getData().getId()); + + String roomId = createRoomResult.getData().getId(); + + EMAddRoomAdmin addRoomAdmin = new EMAddRoomAdmin(); + addRoomAdmin.setNewadmin(username2); + + EMAddRoomAdminResult addRoomAdminResult = + assertDoesNotThrow(() -> api.addRoomAdmin(roomId, addRoomAdmin)); + assertNotNull(addRoomAdminResult); + assertNotNull(addRoomAdminResult.getData()); + assertEquals("success", addRoomAdminResult.getData().getResult()); + + assertDoesNotThrow(() -> userApi.deleteUser(username1)); + assertDoesNotThrow(() -> userApi.deleteUser(username2)); + try {api.deleteRoom(roomId);} catch (ApiException ignored) {} + } + + /** + * 添加超级管理员 + * + * 添加一个聊天室超级管理员。文档介绍:https://docs-im-beta.easemob.com/document/server-side/chatroom.html#%E6%B7%BB%E5%8A%A0%E8%B6%85%E7%BA%A7%E7%AE%A1%E7%90%86%E5%91%98 + * + * @throws ApiException if the Api call fails + */ + @Test + public void addRoomSuperAdminTest() throws ApiException { + String username = randomUserName(); + String password = "123456"; + + List emCreateUserList = new ArrayList<>(); + EMCreateUser createUser = new EMCreateUser(); + createUser.setUsername(username); + createUser.setPassword(password); + + emCreateUserList.add(createUser); + + assertDoesNotThrow(() -> userApi.createUsers(emCreateUserList)); + + EMAddRoomSuperAdmin addRoomSuperAdmin = new EMAddRoomSuperAdmin(); + addRoomSuperAdmin.setSuperadmin(username); + + EMAddRoomSuperAdminResult addRoomSuperAdminResult = + assertDoesNotThrow(() -> api.addRoomSuperAdmin(addRoomSuperAdmin)); + assertNotNull(addRoomSuperAdminResult); + assertNotNull(addRoomSuperAdminResult.getData()); + assertEquals("success", addRoomSuperAdminResult.getData().getResult()); + + assertDoesNotThrow(() -> userApi.deleteUser(username)); + } + + /** + * 添加单个聊天室成员 + * + * 向聊天室添加一个成员。如果待添加的用户在 app 中不存在或已经在聊天室中,则请求失败并返回错误码 400。文档介绍:https://docs-im-beta.easemob.com/document/server-side/chatroom.html#%E6%B7%BB%E5%8A%A0%E5%8D%95%E4%B8%AA%E8%81%8A%E5%A4%A9%E5%AE%A4%E6%88%90%E5%91%98 + * + * @throws ApiException if the Api call fails + */ + @Test + public void addUserToRoomTest() throws ApiException { + String username1 = randomUserName(); + String username2 = randomUserName(); + String password = "123456"; + + List emCreateUserList = new ArrayList<>(); + EMCreateUser createUser1 = new EMCreateUser(); + createUser1.setUsername(username1); + createUser1.setPassword(password); + + EMCreateUser createUser2 = new EMCreateUser(); + createUser2.setUsername(username2); + createUser2.setPassword(password); + + emCreateUserList.add(createUser1); + emCreateUserList.add(createUser2); + + assertDoesNotThrow(() -> userApi.createUsers(emCreateUserList)); + + EMCreateRoom createRoom = new EMCreateRoom(); + createRoom.setOwner(username1); + createRoom.setName("test-room"); + createRoom.setDescription("元梦之星"); + createRoom.setMaxusers(200); + createRoom.setMembers(Arrays.asList(username2)); + createRoom.setCustom("custom"); + + EMCreateRoomResult createRoomResult= assertDoesNotThrow(() -> api.createRoom(createRoom)); + assertNotNull(createRoomResult); + assertNotNull(createRoomResult.getData()); + assertNotNull(createRoomResult.getData().getId()); + + String roomId = createRoomResult.getData().getId(); + + EMAddUserToRoomResult addUserToRoomResult = + assertDoesNotThrow(() -> api.addUserToRoom(roomId, username2)); + assertNotNull(addUserToRoomResult); + assertNotNull(addUserToRoomResult.getData()); + assertEquals("success", addUserToRoomResult.getData().getResult()); + + assertDoesNotThrow(() -> userApi.deleteUser(username1)); + assertDoesNotThrow(() -> userApi.deleteUser(username2)); + try {api.deleteRoom(roomId);} catch (ApiException ignored) {} + } + + /** + * 添加单个用户至聊天室黑名单 + * + * 查询一个聊天室黑名单中的用户列表。黑名单中的用户无法查看或收到该聊天室的信息。文档介绍:https://docs-im-beta.easemob.com/document/server-side/chatroom.html#%E6%B7%BB%E5%8A%A0%E5%8D%95%E4%B8%AA%E7%94%A8%E6%88%B7%E8%87%B3%E8%81%8A%E5%A4%A9%E5%AE%A4%E9%BB%91%E5%90%8D%E5%8D%95 + * + * @throws ApiException if the Api call fails + */ + @Test + public void addUserToRoomBlockListTest() throws ApiException { + String username1 = randomUserName(); + String username2 = randomUserName(); + String password = "123456"; + + List emCreateUserList = new ArrayList<>(); + EMCreateUser createUser1 = new EMCreateUser(); + createUser1.setUsername(username1); + createUser1.setPassword(password); + + EMCreateUser createUser2 = new EMCreateUser(); + createUser2.setUsername(username2); + createUser2.setPassword(password); + + emCreateUserList.add(createUser1); + emCreateUserList.add(createUser2); + + assertDoesNotThrow(() -> userApi.createUsers(emCreateUserList)); + + EMCreateRoom createRoom = new EMCreateRoom(); + createRoom.setOwner(username1); + createRoom.setName("test-room"); + createRoom.setDescription("元梦之星"); + createRoom.setMaxusers(200); + createRoom.setMembers(Arrays.asList(username2)); + createRoom.setCustom("custom"); + + EMCreateRoomResult createRoomResult= assertDoesNotThrow(() -> api.createRoom(createRoom)); + assertNotNull(createRoomResult); + assertNotNull(createRoomResult.getData()); + assertNotNull(createRoomResult.getData().getId()); + + String roomId = createRoomResult.getData().getId(); + + EMAddUserToRoomBlockListResult addUserToRoomBlockListResult = + assertDoesNotThrow(() -> api.addUserToRoomBlockList(roomId, username2)); + assertNotNull(addUserToRoomBlockListResult); + assertNotNull(addUserToRoomBlockListResult.getData()); + assertEquals(true, addUserToRoomBlockListResult.getData().getResult()); + + assertDoesNotThrow(() -> userApi.deleteUser(username1)); + assertDoesNotThrow(() -> userApi.deleteUser(username2)); + try {api.deleteRoom(roomId);} catch (ApiException ignored) {} + } + + /** + * 添加单个用户至聊天室白名单 + * + * 将单个用户添加至聊天室白名单。用户添加至聊天室白名单后,当聊天室全员禁言时,仍可以在聊天室中发送消息。文档介绍:https://docs-im-beta.easemob.com/document/server-side/chatroom.html#%E6%B7%BB%E5%8A%A0%E5%8D%95%E4%B8%AA%E7%94%A8%E6%88%B7%E8%87%B3%E8%81%8A%E5%A4%A9%E5%AE%A4%E7%99%BD%E5%90%8D%E5%8D%95 + * + * @throws ApiException if the Api call fails + */ + @Test + public void addUserToRoomWhiteListTest() throws ApiException { + String username1 = randomUserName(); + String username2 = randomUserName(); + String password = "123456"; + + List emCreateUserList = new ArrayList<>(); + EMCreateUser createUser1 = new EMCreateUser(); + createUser1.setUsername(username1); + createUser1.setPassword(password); + + EMCreateUser createUser2 = new EMCreateUser(); + createUser2.setUsername(username2); + createUser2.setPassword(password); + + emCreateUserList.add(createUser1); + emCreateUserList.add(createUser2); + + assertDoesNotThrow(() -> userApi.createUsers(emCreateUserList)); + + EMCreateRoom createRoom = new EMCreateRoom(); + createRoom.setOwner(username1); + createRoom.setName("test-room"); + createRoom.setDescription("元梦之星"); + createRoom.setMaxusers(200); + createRoom.setMembers(Arrays.asList(username2)); + createRoom.setCustom("custom"); + + EMCreateRoomResult createRoomResult= assertDoesNotThrow(() -> api.createRoom(createRoom)); + assertNotNull(createRoomResult); + assertNotNull(createRoomResult.getData()); + assertNotNull(createRoomResult.getData().getId()); + + String roomId = createRoomResult.getData().getId(); + + EMAddUserToRoomWhiteListResult addUserToRoomWhiteListResult = + assertDoesNotThrow(() -> api.addUserToRoomWhiteList(roomId, username2)); + assertNotNull(addUserToRoomWhiteListResult); + assertNotNull(addUserToRoomWhiteListResult.getData()); + assertEquals(true, addUserToRoomWhiteListResult.getData().getResult()); + + assertDoesNotThrow(() -> userApi.deleteUser(username1)); + assertDoesNotThrow(() -> userApi.deleteUser(username2)); + try {api.deleteRoom(roomId);} catch (ApiException ignored) {} + } + + /** + * 创建聊天室 + * + * 创建一个聊天室,需设置聊天室名称、聊天室描述、聊天室成员最大人数(包括管理员)、聊天室管理员和普通成员以及聊天室扩展信息。文档介绍:https://docs-im-beta.easemob.com/document/server-side/chatroom.html#%E5%88%9B%E5%BB%BA%E8%81%8A%E5%A4%A9%E5%AE%A4 + * + * @throws ApiException if the Api call fails + */ + @Test + public void createRoomTest() { + String username1 = randomUserName(); + String username2 = randomUserName(); + String password = "123456"; + + List emCreateUserList = new ArrayList<>(); + EMCreateUser createUser1 = new EMCreateUser(); + createUser1.setUsername(username1); + createUser1.setPassword(password); + + EMCreateUser createUser2 = new EMCreateUser(); + createUser2.setUsername(username2); + createUser2.setPassword(password); + + emCreateUserList.add(createUser1); + emCreateUserList.add(createUser2); + + assertDoesNotThrow(() -> userApi.createUsers(emCreateUserList)); + + EMCreateRoom createRoom = new EMCreateRoom(); + createRoom.setOwner(username1); + createRoom.setName("test-room"); + createRoom.setDescription("元梦之星"); + createRoom.setMaxusers(200); + createRoom.setMembers(Arrays.asList(username2)); + createRoom.setCustom("custom"); + + EMCreateRoomResult createRoomResult= assertDoesNotThrow(() -> api.createRoom(createRoom)); + assertNotNull(createRoomResult); + assertNotNull(createRoomResult.getData()); + assertNotNull(createRoomResult.getData().getId()); + + String roomId = createRoomResult.getData().getId(); + + assertDoesNotThrow(() -> userApi.deleteUser(username1)); + assertDoesNotThrow(() -> userApi.deleteUser(username2)); + try {api.deleteRoom(roomId);} catch (ApiException ignored) {} + } + + /** + * 删除聊天室 + * + * 删除单个聊天室。如果要删除的聊天室不存在,会返回错误。文档介绍:https://docs-im-beta.easemob.com/document/server-side/chatroom.html#%E5%88%A0%E9%99%A4%E8%81%8A%E5%A4%A9%E5%AE%A4 + * + * @throws ApiException if the Api call fails + */ + @Test + public void deleteRoomTest() throws ApiException { + String username1 = randomUserName(); + String username2 = randomUserName(); + String password = "123456"; + + List emCreateUserList = new ArrayList<>(); + EMCreateUser createUser1 = new EMCreateUser(); + createUser1.setUsername(username1); + createUser1.setPassword(password); + + EMCreateUser createUser2 = new EMCreateUser(); + createUser2.setUsername(username2); + createUser2.setPassword(password); + + emCreateUserList.add(createUser1); + emCreateUserList.add(createUser2); + + assertDoesNotThrow(() -> userApi.createUsers(emCreateUserList)); + + EMCreateRoom createRoom = new EMCreateRoom(); + createRoom.setOwner(username1); + createRoom.setName("test-room"); + createRoom.setDescription("元梦之星"); + createRoom.setMaxusers(200); + createRoom.setMembers(Arrays.asList(username2)); + createRoom.setCustom("custom"); + + EMCreateRoomResult createRoomResult= assertDoesNotThrow(() -> api.createRoom(createRoom)); + assertNotNull(createRoomResult); + assertNotNull(createRoomResult.getData()); + assertNotNull(createRoomResult.getData().getId()); + + String roomId = createRoomResult.getData().getId(); + try { + EMDeleteRoomResult deleteRoomResult = api.deleteRoom(roomId); + assertNotNull(deleteRoomResult); + assertNotNull(deleteRoomResult.getData()); + assertEquals(true, deleteRoomResult.getData().getSuccess()); + + } catch (ApiException ignored) {} + + assertDoesNotThrow(() -> userApi.deleteUser(username1)); + assertDoesNotThrow(() -> userApi.deleteUser(username2)); + } + + /** + * 删除聊天室自定义属性 + * + * 用户删除其设置的聊天室自定义属性。该方法只能删除当前用户设置的聊天室自定义属性,不能删除其他成员设置的自定义属性。该方法每次最多可删除 10 个自定义属性。文档介绍:https://docs-im-beta.easemob.com/document/server-side/chatroom.html#%E5%88%A0%E9%99%A4%E8%81%8A%E5%A4%A9%E5%AE%A4%E8%87%AA%E5%AE%9A%E4%B9%89%E5%B1%9E%E6%80%A7 + * + * @throws ApiException if the Api call fails + */ + @Test + public void deleteRoomCustomAttributesTest() throws ApiException { + String username1 = randomUserName(); + String username2 = randomUserName(); + String password = "123456"; + + List emCreateUserList = new ArrayList<>(); + EMCreateUser createUser1 = new EMCreateUser(); + createUser1.setUsername(username1); + createUser1.setPassword(password); + + EMCreateUser createUser2 = new EMCreateUser(); + createUser2.setUsername(username2); + createUser2.setPassword(password); + + emCreateUserList.add(createUser1); + emCreateUserList.add(createUser2); + + assertDoesNotThrow(() -> userApi.createUsers(emCreateUserList)); + + EMCreateRoom createRoom = new EMCreateRoom(); + createRoom.setOwner(username1); + createRoom.setName("test-room"); + createRoom.setDescription("元梦之星"); + createRoom.setMaxusers(200); + createRoom.setMembers(Arrays.asList(username2)); + createRoom.setCustom("custom"); + + EMCreateRoomResult createRoomResult= assertDoesNotThrow(() -> api.createRoom(createRoom)); + assertNotNull(createRoomResult); + assertNotNull(createRoomResult.getData()); + assertNotNull(createRoomResult.getData().getId()); + + String roomId = createRoomResult.getData().getId(); + + Map metadata = new HashMap<>(); + metadata.put("key1", "value1"); + metadata.put("key2", "value2"); + + EMSetRoomCustomAttributes setRoomCustomAttributes = new EMSetRoomCustomAttributes(); + setRoomCustomAttributes.setAutoDelete("delete"); + setRoomCustomAttributes.setMetaData(metadata); + EMSetRoomCustomAttributesResult setRoomCustomAttributesResult = assertDoesNotThrow(() -> api.setRoomCustomAttributes(roomId, username2, setRoomCustomAttributes)); + assertNotNull(setRoomCustomAttributesResult); + assertNotNull(setRoomCustomAttributesResult.getData()); + assertNotNull(setRoomCustomAttributesResult.getData().getSuccessKeys()); + assertEquals(2, setRoomCustomAttributesResult.getData().getSuccessKeys().size()); + + EMDeleteRoomCustomAttributes deleteRoomCustomAttributes = new EMDeleteRoomCustomAttributes(); + deleteRoomCustomAttributes.setKeys(Arrays.asList("key1", "key2")); + + EMDeleteRoomCustomAttributesResult deleteRoomCustomAttributesResult = assertDoesNotThrow(() -> api.deleteRoomCustomAttributes(roomId, username2, deleteRoomCustomAttributes)); + assertNotNull(deleteRoomCustomAttributesResult); + assertNotNull(deleteRoomCustomAttributesResult.getData()); + assertNotNull(deleteRoomCustomAttributesResult.getData().getSuccessKeys()); + assertEquals(2, deleteRoomCustomAttributesResult.getData().getSuccessKeys().size()); + + assertDoesNotThrow(() -> userApi.deleteUser(username1)); + assertDoesNotThrow(() -> userApi.deleteUser(username2)); + try {api.deleteRoom(roomId);} catch (ApiException ignored) {} + } + + /** + * 强制删除聊天室自定义属性 + * + * 用户强制删除聊天室的自定义属性信息,即该方法除了会删除当前用户设置的聊天室自定义属性,还可以删除其他用户设置的自定义属性。该方法每次最多可删除 10 个自定义属性。文档介绍:https://docs-im-beta.easemob.com/document/server-side/chatroom.html#%E5%BC%BA%E5%88%B6%E5%88%A0%E9%99%A4%E8%81%8A%E5%A4%A9%E5%AE%A4%E8%87%AA%E5%AE%9A%E4%B9%89%E5%B1%9E%E6%80%A7 + * + * @throws ApiException if the Api call fails + */ + @Test + public void forceDeleteRoomCustomAttributesTest() throws ApiException { + String username1 = randomUserName(); + String username2 = randomUserName(); + String password = "123456"; + + List emCreateUserList = new ArrayList<>(); + EMCreateUser createUser1 = new EMCreateUser(); + createUser1.setUsername(username1); + createUser1.setPassword(password); + + EMCreateUser createUser2 = new EMCreateUser(); + createUser2.setUsername(username2); + createUser2.setPassword(password); + + emCreateUserList.add(createUser1); + emCreateUserList.add(createUser2); + + assertDoesNotThrow(() -> userApi.createUsers(emCreateUserList)); + + EMCreateRoom createRoom = new EMCreateRoom(); + createRoom.setOwner(username1); + createRoom.setName("test-room"); + createRoom.setDescription("元梦之星"); + createRoom.setMaxusers(200); + createRoom.setMembers(Arrays.asList(username2)); + createRoom.setCustom("custom"); + + EMCreateRoomResult createRoomResult= assertDoesNotThrow(() -> api.createRoom(createRoom)); + assertNotNull(createRoomResult); + assertNotNull(createRoomResult.getData()); + assertNotNull(createRoomResult.getData().getId()); + + String roomId = createRoomResult.getData().getId(); + + Map metadata = new HashMap<>(); + metadata.put("key1", "value1"); + metadata.put("key2", "value2"); + + EMSetRoomCustomAttributes setRoomCustomAttributes = new EMSetRoomCustomAttributes(); + setRoomCustomAttributes.setAutoDelete("delete"); + setRoomCustomAttributes.setMetaData(metadata); + + EMSetRoomCustomAttributesResult setRoomCustomAttributesResult = assertDoesNotThrow(() -> api.setRoomCustomAttributes(roomId, username2, setRoomCustomAttributes)); + assertNotNull(setRoomCustomAttributesResult); + assertNotNull(setRoomCustomAttributesResult.getData()); + assertNotNull(setRoomCustomAttributesResult.getData().getSuccessKeys()); + assertEquals(2, setRoomCustomAttributesResult.getData().getSuccessKeys().size()); + + EMForceDeleteRoomCustomAttributes forceDeleteRoomCustomAttributes = new EMForceDeleteRoomCustomAttributes(); + forceDeleteRoomCustomAttributes.setKeys(Arrays.asList("key1", "key2")); + + EMForceDeleteRoomCustomAttributesResult forceDeleteRoomCustomAttributesResult = assertDoesNotThrow(() -> api.forceDeleteRoomCustomAttributes(roomId, username2, forceDeleteRoomCustomAttributes)); + assertNotNull(forceDeleteRoomCustomAttributesResult); + assertNotNull(forceDeleteRoomCustomAttributesResult.getData()); + assertNotNull(forceDeleteRoomCustomAttributesResult.getData().getSuccessKeys()); + assertEquals(2, forceDeleteRoomCustomAttributesResult.getData().getSuccessKeys().size()); + + assertDoesNotThrow(() -> userApi.deleteUser(username1)); + assertDoesNotThrow(() -> userApi.deleteUser(username2)); + try {api.deleteRoom(roomId);} catch (ApiException ignored) {} + } + + /** + * 强制设置聊天室自定义属性 + * + * 用户强制设置指定聊天室的自定义属性信息,即该方法可覆盖其他用户设置的聊天室自定义属性。文档介绍:https://docs-im-beta.easemob.com/document/server-side/chatroom.html#%E5%BC%BA%E5%88%B6%E8%AE%BE%E7%BD%AE%E8%81%8A%E5%A4%A9%E5%AE%A4%E8%87%AA%E5%AE%9A%E4%B9%89%E5%B1%9E%E6%80%A7 + * + * @throws ApiException if the Api call fails + */ + @Test + public void forceSetRoomCustomAttributesTest() throws ApiException { + String username1 = randomUserName(); + String username2 = randomUserName(); + String password = "123456"; + + List emCreateUserList = new ArrayList<>(); + EMCreateUser createUser1 = new EMCreateUser(); + createUser1.setUsername(username1); + createUser1.setPassword(password); + + EMCreateUser createUser2 = new EMCreateUser(); + createUser2.setUsername(username2); + createUser2.setPassword(password); + + emCreateUserList.add(createUser1); + emCreateUserList.add(createUser2); + + assertDoesNotThrow(() -> userApi.createUsers(emCreateUserList)); + + EMCreateRoom createRoom = new EMCreateRoom(); + createRoom.setOwner(username1); + createRoom.setName("test-room"); + createRoom.setDescription("元梦之星"); + createRoom.setMaxusers(200); + createRoom.setMembers(Arrays.asList(username2)); + createRoom.setCustom("custom"); + + EMCreateRoomResult createRoomResult= assertDoesNotThrow(() -> api.createRoom(createRoom)); + assertNotNull(createRoomResult); + assertNotNull(createRoomResult.getData()); + assertNotNull(createRoomResult.getData().getId()); + + String roomId = createRoomResult.getData().getId(); + + Map metadata = new HashMap<>(); + metadata.put("key1", "value1"); + metadata.put("key2", "value2"); + + EMForceSetRoomCustomAttributes forceSetRoomCustomAttributes = new EMForceSetRoomCustomAttributes(); + forceSetRoomCustomAttributes.setAutoDelete("delete"); + forceSetRoomCustomAttributes.setMetaData(metadata); + + EMForceSetRoomCustomAttributesResult forceSetRoomCustomAttributesResult = assertDoesNotThrow(() -> api.forceSetRoomCustomAttributes(roomId, username2, forceSetRoomCustomAttributes)); + assertNotNull(forceSetRoomCustomAttributesResult); + assertNotNull(forceSetRoomCustomAttributesResult.getData()); + assertNotNull(forceSetRoomCustomAttributesResult.getData().getSuccessKeys()); + assertEquals(2, forceSetRoomCustomAttributesResult.getData().getSuccessKeys().size()); + + assertDoesNotThrow(() -> userApi.deleteUser(username1)); + assertDoesNotThrow(() -> userApi.deleteUser(username2)); + try {api.deleteRoom(roomId);} catch (ApiException ignored) {} + } + + /** + * 获取禁言列表 + * + * 获取当前聊天室的禁言用户列表。文档介绍:https://docs-im-beta.easemob.com/document/server-side/chatroom.html#%E8%8E%B7%E5%8F%96%E7%A6%81%E8%A8%80%E5%88%97%E8%A1%A8 + * + * @throws ApiException if the Api call fails + */ + @Test + public void getMuteRoomMemberListTest() throws ApiException { + String username1 = randomUserName(); + String username2 = randomUserName(); + String password = "123456"; + + List emCreateUserList = new ArrayList<>(); + EMCreateUser createUser1 = new EMCreateUser(); + createUser1.setUsername(username1); + createUser1.setPassword(password); + + EMCreateUser createUser2 = new EMCreateUser(); + createUser2.setUsername(username2); + createUser2.setPassword(password); + + emCreateUserList.add(createUser1); + emCreateUserList.add(createUser2); + + assertDoesNotThrow(() -> userApi.createUsers(emCreateUserList)); + + EMCreateRoom createRoom = new EMCreateRoom(); + createRoom.setOwner(username1); + createRoom.setName("test-room"); + createRoom.setDescription("元梦之星"); + createRoom.setMaxusers(200); + createRoom.setMembers(Arrays.asList(username2)); + createRoom.setCustom("custom"); + + EMCreateRoomResult createRoomResult= assertDoesNotThrow(() -> api.createRoom(createRoom)); + assertNotNull(createRoomResult); + assertNotNull(createRoomResult.getData()); + assertNotNull(createRoomResult.getData().getId()); + + String roomId = createRoomResult.getData().getId(); + + EMMuteRoomMember muteRoomMember = new EMMuteRoomMember(); + muteRoomMember.setUsernames(Arrays.asList(username2)); + muteRoomMember.setMuteDuration(new BigDecimal(1000)); + + EMMuteRoomMemberResult muteRoomMemberResult = assertDoesNotThrow(() -> api.muteRoomMember(roomId, muteRoomMember)); + assertNotNull(muteRoomMemberResult); + assertNotNull(muteRoomMemberResult.getData()); + assertEquals(1, muteRoomMemberResult.getData().size()); + assertEquals(true, muteRoomMemberResult.getData().get(0).getResult()); + + EMGetMuteRoomMemberListResult getMuteRoomMemberListResult = assertDoesNotThrow(() -> api.getMuteRoomMemberList(roomId)); + assertNotNull(getMuteRoomMemberListResult); + assertNotNull(getMuteRoomMemberListResult.getData()); + assertNotNull(getMuteRoomMemberListResult.getData()); + assertEquals(1, getMuteRoomMemberListResult.getData().size()); + assertEquals(username2, muteRoomMemberResult.getData().get(0).getUser()); + + assertDoesNotThrow(() -> userApi.deleteUser(username1)); + assertDoesNotThrow(() -> userApi.deleteUser(username2)); + try {api.deleteRoom(roomId);} catch (ApiException ignored) {} + } + + /** + * 获取聊天室管理员列表 + * + * 获取聊天室管理员列表的接口。文档介绍:https://docs-im-beta.easemob.com/document/server-side/chatroom.html#%E8%8E%B7%E5%8F%96%E8%81%8A%E5%A4%A9%E5%AE%A4%E7%AE%A1%E7%90%86%E5%91%98%E5%88%97%E8%A1%A8 + * + * @throws ApiException if the Api call fails + */ + @Test + public void getRoomAdminListTest() throws ApiException { + String username1 = randomUserName(); + String username2 = randomUserName(); + String password = "123456"; + + List emCreateUserList = new ArrayList<>(); + EMCreateUser createUser1 = new EMCreateUser(); + createUser1.setUsername(username1); + createUser1.setPassword(password); + + EMCreateUser createUser2 = new EMCreateUser(); + createUser2.setUsername(username2); + createUser2.setPassword(password); + + emCreateUserList.add(createUser1); + emCreateUserList.add(createUser2); + + assertDoesNotThrow(() -> userApi.createUsers(emCreateUserList)); + + EMCreateRoom createRoom = new EMCreateRoom(); + createRoom.setOwner(username1); + createRoom.setName("test-room"); + createRoom.setDescription("元梦之星"); + createRoom.setMaxusers(200); + createRoom.setMembers(Arrays.asList(username2)); + createRoom.setCustom("custom"); + + EMCreateRoomResult createRoomResult= assertDoesNotThrow(() -> api.createRoom(createRoom)); + assertNotNull(createRoomResult); + assertNotNull(createRoomResult.getData()); + assertNotNull(createRoomResult.getData().getId()); + + String roomId = createRoomResult.getData().getId(); + + EMAddRoomAdmin addRoomAdmin = new EMAddRoomAdmin(); + addRoomAdmin.setNewadmin(username2); + assertDoesNotThrow(() -> api.addRoomAdmin(roomId, addRoomAdmin)); + + EMGetRoomAdminListResult getRoomAdminListResult = assertDoesNotThrow(() -> api.getRoomAdminList(roomId)); + assertNotNull(getRoomAdminListResult); + assertNotNull(getRoomAdminListResult.getData()); + assertEquals(1, getRoomAdminListResult.getData().size()); + assertEquals(username2, getRoomAdminListResult.getData().get(0)); + + assertDoesNotThrow(() -> userApi.deleteUser(username1)); + assertDoesNotThrow(() -> userApi.deleteUser(username2)); + try {api.deleteRoom(roomId);} catch (ApiException ignored) {} + } + + /** + * 获取聊天室公告 + * + * 获取指定聊天室 ID 的聊天室公告。文档介绍:https://docs-im-beta.easemob.com/document/server-side/chatroom.html#%E8%8E%B7%E5%8F%96%E8%81%8A%E5%A4%A9%E5%AE%A4%E5%85%AC%E5%91%8A + * + * @throws ApiException if the Api call fails + */ + @Test + public void getRoomAnnouncementTest() throws ApiException { + String username1 = randomUserName(); + String username2 = randomUserName(); + String password = "123456"; + + List emCreateUserList = new ArrayList<>(); + EMCreateUser createUser1 = new EMCreateUser(); + createUser1.setUsername(username1); + createUser1.setPassword(password); + + EMCreateUser createUser2 = new EMCreateUser(); + createUser2.setUsername(username2); + createUser2.setPassword(password); + + emCreateUserList.add(createUser1); + emCreateUserList.add(createUser2); + + assertDoesNotThrow(() -> userApi.createUsers(emCreateUserList)); + + EMCreateRoom createRoom = new EMCreateRoom(); + createRoom.setOwner(username1); + createRoom.setName("test-room"); + createRoom.setDescription("元梦之星"); + createRoom.setMaxusers(200); + createRoom.setMembers(Arrays.asList(username2)); + createRoom.setCustom("custom"); + + EMCreateRoomResult createRoomResult= assertDoesNotThrow(() -> api.createRoom(createRoom)); + assertNotNull(createRoomResult); + assertNotNull(createRoomResult.getData()); + assertNotNull(createRoomResult.getData().getId()); + + String roomId = createRoomResult.getData().getId(); + + EMModifyRoomAnnouncement modifyRoomAnnouncement = new EMModifyRoomAnnouncement(); + modifyRoomAnnouncement.setAnnouncement("元梦之星"); + + EMModifyRoomAnnouncementResult modifyRoomAnnouncementResult = assertDoesNotThrow(() -> api.modifyRoomAnnouncement(roomId, modifyRoomAnnouncement)); + assertNotNull(modifyRoomAnnouncementResult); + assertNotNull(modifyRoomAnnouncementResult.getData()); + assertEquals(true, modifyRoomAnnouncementResult.getData().getResult()); + + EMGetRoomAnnouncementResult getRoomAnnouncementResult = assertDoesNotThrow(() -> api.getRoomAnnouncement(roomId)); + assertNotNull(getRoomAnnouncementResult); + assertNotNull(getRoomAnnouncementResult.getData()); + + assertDoesNotThrow(() -> userApi.deleteUser(username1)); + assertDoesNotThrow(() -> userApi.deleteUser(username2)); + try {api.deleteRoom(roomId);} catch (ApiException ignored) {} + } + + /** + * 查询聊天室黑名单 + * + * 查询一个聊天室黑名单中的用户列表。黑名单中的用户无法查看或收到该聊天室的信息。文档介绍:https://docs-im-beta.easemob.com/document/server-side/chatroom.html#%E6%9F%A5%E8%AF%A2%E8%81%8A%E5%A4%A9%E5%AE%A4%E9%BB%91%E5%90%8D%E5%8D%95 + * + * @throws ApiException if the Api call fails + */ + @Test + public void getRoomBlockListTest() throws ApiException { + String username1 = randomUserName(); + String username2 = randomUserName(); + String password = "123456"; + + List emCreateUserList = new ArrayList<>(); + EMCreateUser createUser1 = new EMCreateUser(); + createUser1.setUsername(username1); + createUser1.setPassword(password); + + EMCreateUser createUser2 = new EMCreateUser(); + createUser2.setUsername(username2); + createUser2.setPassword(password); + + emCreateUserList.add(createUser1); + emCreateUserList.add(createUser2); + + assertDoesNotThrow(() -> userApi.createUsers(emCreateUserList)); + + EMCreateRoom createRoom = new EMCreateRoom(); + createRoom.setOwner(username1); + createRoom.setName("test-room"); + createRoom.setDescription("元梦之星"); + createRoom.setMaxusers(200); + createRoom.setMembers(Arrays.asList(username2)); + createRoom.setCustom("custom"); + + EMCreateRoomResult createRoomResult= assertDoesNotThrow(() -> api.createRoom(createRoom)); + assertNotNull(createRoomResult); + assertNotNull(createRoomResult.getData()); + assertNotNull(createRoomResult.getData().getId()); + + String roomId = createRoomResult.getData().getId(); + + EMAddUserToRoomBlockListResult addUserToRoomBlockListResult = assertDoesNotThrow(() -> api.addUserToRoomBlockList(roomId, username2)); + assertNotNull(addUserToRoomBlockListResult); + assertNotNull(addUserToRoomBlockListResult.getData()); + assertEquals(true, addUserToRoomBlockListResult.getData().getResult()); + + EMGetRoomBlockListResult getRoomBlockListResult = assertDoesNotThrow(() -> api.getRoomBlockList(roomId)); + assertNotNull(getRoomBlockListResult); + assertNotNull(getRoomBlockListResult.getData()); + assertEquals(1, getRoomBlockListResult.getData().size()); + + assertDoesNotThrow(() -> userApi.deleteUser(username1)); + assertDoesNotThrow(() -> userApi.deleteUser(username2)); + try {api.deleteRoom(roomId);} catch (ApiException ignored) {} + } + + /** + * 获取聊天室自定义属性 + * + * 获取指定聊天室的自定义属性信息。文档介绍:https://docs-im-beta.easemob.com/document/server-side/chatroom.html#%E8%8E%B7%E5%8F%96%E8%81%8A%E5%A4%A9%E5%AE%A4%E8%87%AA%E5%AE%9A%E4%B9%89%E5%B1%9E%E6%80%A7 + * + * @throws ApiException if the Api call fails + */ + @Test + public void getRoomCustomAttributesTest() throws ApiException { + String username1 = randomUserName(); + String username2 = randomUserName(); + String password = "123456"; + + List emCreateUserList = new ArrayList<>(); + EMCreateUser createUser1 = new EMCreateUser(); + createUser1.setUsername(username1); + createUser1.setPassword(password); + + EMCreateUser createUser2 = new EMCreateUser(); + createUser2.setUsername(username2); + createUser2.setPassword(password); + + emCreateUserList.add(createUser1); + emCreateUserList.add(createUser2); + + assertDoesNotThrow(() -> userApi.createUsers(emCreateUserList)); + + EMCreateRoom createRoom = new EMCreateRoom(); + createRoom.setOwner(username1); + createRoom.setName("test-room"); + createRoom.setDescription("元梦之星"); + createRoom.setMaxusers(200); + createRoom.setMembers(Arrays.asList(username2)); + createRoom.setCustom("custom"); + + EMCreateRoomResult createRoomResult= assertDoesNotThrow(() -> api.createRoom(createRoom)); + assertNotNull(createRoomResult); + assertNotNull(createRoomResult.getData()); + assertNotNull(createRoomResult.getData().getId()); + + String roomId = createRoomResult.getData().getId(); + + Map metadata = new HashMap<>(); + metadata.put("key1", "value1"); + metadata.put("key2", "value2"); + + EMSetRoomCustomAttributes setRoomCustomAttributes = new EMSetRoomCustomAttributes(); + setRoomCustomAttributes.setAutoDelete("delete"); + setRoomCustomAttributes.setMetaData(metadata); + + EMSetRoomCustomAttributesResult setRoomCustomAttributesResult = assertDoesNotThrow(() -> api.setRoomCustomAttributes(roomId, username2, setRoomCustomAttributes)); + assertNotNull(setRoomCustomAttributesResult); + assertNotNull(setRoomCustomAttributesResult.getData()); + assertNotNull(setRoomCustomAttributesResult.getData().getSuccessKeys()); + assertEquals(2, setRoomCustomAttributesResult.getData().getSuccessKeys().size()); + + EMGetRoomCustomAttributes getRoomCustomAttributes = new EMGetRoomCustomAttributes(); + getRoomCustomAttributes.setKeys(Arrays.asList("key1", "key2")); + + EMGetRoomCustomAttributesResult getRoomCustomAttributesResult = assertDoesNotThrow(() -> api.getRoomCustomAttributes(roomId, getRoomCustomAttributes)); + assertNotNull(getRoomCustomAttributesResult); + assertNotNull(getRoomCustomAttributesResult.getData()); + assertEquals("value1", ((Map) getRoomCustomAttributesResult.getData()).get("key1")); + assertEquals("value2", ((Map) getRoomCustomAttributesResult.getData()).get("key2")); + + assertDoesNotThrow(() -> userApi.deleteUser(username1)); + assertDoesNotThrow(() -> userApi.deleteUser(username2)); + try {api.deleteRoom(roomId);} catch (ApiException ignored) {} + } + + /** + * 查询聊天室详情 + * + * 查询一个聊天室的详情。文档介绍:https://docs-im-beta.easemob.com/document/server-side/chatroom.html#%E6%9F%A5%E8%AF%A2%E8%81%8A%E5%A4%A9%E5%AE%A4%E8%AF%A6%E6%83%85 + * + * @throws ApiException if the Api call fails + */ + @Test + public void getRoomInfoTest() throws ApiException { + String username1 = randomUserName(); + String username2 = randomUserName(); + String password = "123456"; + + List emCreateUserList = new ArrayList<>(); + EMCreateUser createUser1 = new EMCreateUser(); + createUser1.setUsername(username1); + createUser1.setPassword(password); + + EMCreateUser createUser2 = new EMCreateUser(); + createUser2.setUsername(username2); + createUser2.setPassword(password); + + emCreateUserList.add(createUser1); + emCreateUserList.add(createUser2); + + assertDoesNotThrow(() -> userApi.createUsers(emCreateUserList)); + + EMCreateRoom createRoom = new EMCreateRoom(); + createRoom.setOwner(username1); + createRoom.setName("test-room"); + createRoom.setDescription("元梦之星"); + createRoom.setMaxusers(200); + createRoom.setMembers(Arrays.asList(username2)); + createRoom.setCustom("custom"); + + EMCreateRoomResult createRoomResult= assertDoesNotThrow(() -> api.createRoom(createRoom)); + assertNotNull(createRoomResult); + assertNotNull(createRoomResult.getData()); + assertNotNull(createRoomResult.getData().getId()); + + String roomId = createRoomResult.getData().getId(); + + EMGetRoomInfoResult getRoomInfoResult = assertDoesNotThrow(() -> api.getRoomInfo(roomId)); + assertNotNull(getRoomInfoResult); + assertNotNull(getRoomInfoResult.getData()); + assertNotNull(getRoomInfoResult.getData().get(0)); + assertEquals("元梦之星", getRoomInfoResult.getData().get(0).getDescription()); + + assertDoesNotThrow(() -> userApi.deleteUser(username1)); + assertDoesNotThrow(() -> userApi.deleteUser(username2)); + try {api.deleteRoom(roomId);} catch (ApiException ignored) {} + } + + /** + * 获取 app 中的聊天室 + * + * 分页获取应用下的聊天室列表和信息。文档介绍:https://docs-im-beta.easemob.com/document/server-side/chatroom.html#%E8%8E%B7%E5%8F%96-app-%E4%B8%AD%E7%9A%84%E8%81%8A%E5%A4%A9%E5%AE%A4 + * + * @throws ApiException if the Api call fails + */ + @Test + public void getRoomListTest() throws ApiException { + String username1 = randomUserName(); + String username2 = randomUserName(); + String password = "123456"; + + List emCreateUserList = new ArrayList<>(); + EMCreateUser createUser1 = new EMCreateUser(); + createUser1.setUsername(username1); + createUser1.setPassword(password); + + EMCreateUser createUser2 = new EMCreateUser(); + createUser2.setUsername(username2); + createUser2.setPassword(password); + + emCreateUserList.add(createUser1); + emCreateUserList.add(createUser2); + + assertDoesNotThrow(() -> userApi.createUsers(emCreateUserList)); + + EMCreateRoom createRoom = new EMCreateRoom(); + createRoom.setOwner(username1); + createRoom.setName("test-room"); + createRoom.setDescription("元梦之星"); + createRoom.setMaxusers(200); + createRoom.setMembers(Arrays.asList(username2)); + createRoom.setCustom("custom"); + + EMCreateRoomResult createRoomResult= assertDoesNotThrow(() -> api.createRoom(createRoom)); + assertNotNull(createRoomResult); + assertNotNull(createRoomResult.getData()); + assertNotNull(createRoomResult.getData().getId()); + + String roomId = createRoomResult.getData().getId(); + + EMGetRoomListResult getRoomListResult = assertDoesNotThrow(() -> api.getRoomList(1, null)); + assertNotNull(getRoomListResult); + assertNotNull(getRoomListResult.getData()); + assertNotNull(getRoomListResult.getData().get(0)); + assertNotNull(getRoomListResult.getCursor()); + + assertDoesNotThrow(() -> userApi.deleteUser(username1)); + assertDoesNotThrow(() -> userApi.deleteUser(username2)); + try {api.deleteRoom(roomId);} catch (ApiException ignored) {} + } + + /** + * 分页获取聊天室成员列表 + * + * 可以分页获取聊天室成员列表。文档介绍:https://docs-im-beta.easemob.com/document/server-side/chatroom.html#%E5%88%86%E9%A1%B5%E8%8E%B7%E5%8F%96%E8%81%8A%E5%A4%A9%E5%AE%A4%E6%88%90%E5%91%98%E5%88%97%E8%A1%A8 + * + * @throws ApiException if the Api call fails + */ + @Test + public void getRoomMemberListTest() throws ApiException { + String username1 = randomUserName(); + String username2 = randomUserName(); + String password = "123456"; + + List emCreateUserList = new ArrayList<>(); + EMCreateUser createUser1 = new EMCreateUser(); + createUser1.setUsername(username1); + createUser1.setPassword(password); + + EMCreateUser createUser2 = new EMCreateUser(); + createUser2.setUsername(username2); + createUser2.setPassword(password); + + emCreateUserList.add(createUser1); + emCreateUserList.add(createUser2); + + assertDoesNotThrow(() -> userApi.createUsers(emCreateUserList)); + + EMCreateRoom createRoom = new EMCreateRoom(); + createRoom.setOwner(username1); + createRoom.setName("test-room"); + createRoom.setDescription("元梦之星"); + createRoom.setMaxusers(200); + createRoom.setMembers(Arrays.asList(username2)); + createRoom.setCustom("custom"); + + EMCreateRoomResult createRoomResult= assertDoesNotThrow(() -> api.createRoom(createRoom)); + assertNotNull(createRoomResult); + assertNotNull(createRoomResult.getData()); + assertNotNull(createRoomResult.getData().getId()); + + String roomId = createRoomResult.getData().getId(); + + EMGetRoomMemberListResult getRoomMemberListResult = assertDoesNotThrow(() -> api.getRoomMemberList(roomId, 1, 1)); + assertNotNull(getRoomMemberListResult); + assertNotNull(getRoomMemberListResult.getData()); + + assertDoesNotThrow(() -> userApi.deleteUser(username1)); + assertDoesNotThrow(() -> userApi.deleteUser(username2)); + try {api.deleteRoom(roomId);} catch (ApiException ignored) {} + } + + /** + * 分页获取超级管理员列表 + * + * 可以分页获取超级管理员列表的接口。文档介绍:https://docs-im-beta.easemob.com/document/server-side/chatroom.html#%E5%88%86%E9%A1%B5%E8%8E%B7%E5%8F%96%E8%B6%85%E7%BA%A7%E7%AE%A1%E7%90%86%E5%91%98%E5%88%97%E8%A1%A8 + * + * @throws ApiException if the Api call fails + */ + @Test + public void getRoomSuperAdminListTest() throws ApiException { + String username1 = randomUserName(); + String username2 = randomUserName(); + String password = "123456"; + + List emCreateUserList = new ArrayList<>(); + EMCreateUser createUser1 = new EMCreateUser(); + createUser1.setUsername(username1); + createUser1.setPassword(password); + + EMCreateUser createUser2 = new EMCreateUser(); + createUser2.setUsername(username2); + createUser2.setPassword(password); + + emCreateUserList.add(createUser1); + emCreateUserList.add(createUser2); + + assertDoesNotThrow(() -> userApi.createUsers(emCreateUserList)); + + EMCreateRoom createRoom = new EMCreateRoom(); + createRoom.setOwner(username1); + createRoom.setName("test-room"); + createRoom.setDescription("元梦之星"); + createRoom.setMaxusers(200); + createRoom.setMembers(Arrays.asList(username2)); + createRoom.setCustom("custom"); + + EMCreateRoomResult createRoomResult= assertDoesNotThrow(() -> api.createRoom(createRoom)); + assertNotNull(createRoomResult); + assertNotNull(createRoomResult.getData()); + assertNotNull(createRoomResult.getData().getId()); + + String roomId = createRoomResult.getData().getId(); + + EMAddRoomSuperAdmin addRoomSuperAdmin = new EMAddRoomSuperAdmin(); + addRoomSuperAdmin.setSuperadmin(username2); + assertDoesNotThrow(() -> api.addRoomSuperAdmin(addRoomSuperAdmin)); + + EMGetRoomSuperAdminListResult getRoomSuperAdminListResult = assertDoesNotThrow(() -> api.getRoomSuperAdminList(1, 1)); + assertNotNull(getRoomSuperAdminListResult); + assertNotNull(getRoomSuperAdminListResult.getData()); + assertEquals(1, getRoomSuperAdminListResult.getData().size()); + assertEquals(username2, getRoomSuperAdminListResult.getData().get(0)); + + assertDoesNotThrow(() -> userApi.deleteUser(username1)); + assertDoesNotThrow(() -> userApi.deleteUser(username2)); + try {api.deleteRoom(roomId);} catch (ApiException ignored) {} + } + + /** + * 查询聊天室白名单 + * + * 查询一个聊天室白名单中的用户列表。文档介绍:https://docs-im-beta.easemob.com/document/server-side/chatroom.html#%E6%9F%A5%E8%AF%A2%E8%81%8A%E5%A4%A9%E5%AE%A4%E7%99%BD%E5%90%8D%E5%8D%95 + * + * @throws ApiException if the Api call fails + */ + @Test + public void getRoomWhiteListTest() throws ApiException { + String username1 = randomUserName(); + String username2 = randomUserName(); + String password = "123456"; + + List emCreateUserList = new ArrayList<>(); + EMCreateUser createUser1 = new EMCreateUser(); + createUser1.setUsername(username1); + createUser1.setPassword(password); + + EMCreateUser createUser2 = new EMCreateUser(); + createUser2.setUsername(username2); + createUser2.setPassword(password); + + emCreateUserList.add(createUser1); + emCreateUserList.add(createUser2); + + assertDoesNotThrow(() -> userApi.createUsers(emCreateUserList)); + + EMCreateRoom createRoom = new EMCreateRoom(); + createRoom.setOwner(username1); + createRoom.setName("test-room"); + createRoom.setDescription("元梦之星"); + createRoom.setMaxusers(200); + createRoom.setMembers(Arrays.asList(username2)); + createRoom.setCustom("custom"); + + EMCreateRoomResult createRoomResult= assertDoesNotThrow(() -> api.createRoom(createRoom)); + assertNotNull(createRoomResult); + assertNotNull(createRoomResult.getData()); + assertNotNull(createRoomResult.getData().getId()); + + String roomId = createRoomResult.getData().getId(); + + assertDoesNotThrow(() -> api.addUserToRoomWhiteList(roomId, username2)); + + EMGetRoomWhiteListResult getRoomWhiteListResult = assertDoesNotThrow(() -> api.getRoomWhiteList(roomId)); + assertNotNull(getRoomWhiteListResult); + assertNotNull(getRoomWhiteListResult.getData()); + assertEquals(2, getRoomWhiteListResult.getData().size()); + assertEquals(username2, getRoomWhiteListResult.getData().get(0)); + + assertDoesNotThrow(() -> userApi.deleteUser(username1)); + assertDoesNotThrow(() -> userApi.deleteUser(username2)); + try {api.deleteRoom(roomId);} catch (ApiException ignored) {} + } + + /** + * 获取用户加入的聊天室 + * + * 根据用户 ID 分页获取该用户加入的聊天室。文档介绍:https://docs-im-beta.easemob.com/document/server-side/chatroom.html#%E8%8E%B7%E5%8F%96%E7%94%A8%E6%88%B7%E5%8A%A0%E5%85%A5%E7%9A%84%E8%81%8A%E5%A4%A9%E5%AE%A4 + * + * @throws ApiException if the Api call fails + */ + @Test + public void getUserJoinedRoomListTest() throws ApiException { + String username1 = randomUserName(); + String username2 = randomUserName(); + String password = "123456"; + + List emCreateUserList = new ArrayList<>(); + EMCreateUser createUser1 = new EMCreateUser(); + createUser1.setUsername(username1); + createUser1.setPassword(password); + + EMCreateUser createUser2 = new EMCreateUser(); + createUser2.setUsername(username2); + createUser2.setPassword(password); + + emCreateUserList.add(createUser1); + emCreateUserList.add(createUser2); + + assertDoesNotThrow(() -> userApi.createUsers(emCreateUserList)); + + EMCreateRoom createRoom = new EMCreateRoom(); + createRoom.setOwner(username1); + createRoom.setName("test-room"); + createRoom.setDescription("元梦之星"); + createRoom.setMaxusers(200); + createRoom.setMembers(Arrays.asList(username2)); + createRoom.setCustom("custom"); + + EMCreateRoomResult createRoomResult= assertDoesNotThrow(() -> api.createRoom(createRoom)); + assertNotNull(createRoomResult); + assertNotNull(createRoomResult.getData()); + assertNotNull(createRoomResult.getData().getId()); + + String roomId = createRoomResult.getData().getId(); + + EMGetUserJoinedRoomListResult getUserJoinedRoomListResult = assertDoesNotThrow(() -> api.getUserJoinedRoomList(username1, 1, 1)); + assertNotNull(getUserJoinedRoomListResult); + assertNotNull(getUserJoinedRoomListResult.getData()); + assertEquals(1, getUserJoinedRoomListResult.getData().size()); + + assertDoesNotThrow(() -> userApi.deleteUser(username1)); + assertDoesNotThrow(() -> userApi.deleteUser(username2)); + try {api.deleteRoom(roomId);} catch (ApiException ignored) {} + } + + /** + * 修改聊天室信息 + * + * 修改指定聊天室的信息。仅支持修改聊天室名称、聊天室描述和聊天室最大成员数。文档介绍:https://docs-im-beta.easemob.com/document/server-side/chatroom.html#%E4%BF%AE%E6%94%B9%E8%81%8A%E5%A4%A9%E5%AE%A4%E4%BF%A1%E6%81%AF + * + * @throws ApiException if the Api call fails + */ + @Test + public void modifyRoomTest() throws ApiException { + String username1 = randomUserName(); + String username2 = randomUserName(); + String password = "123456"; + + List emCreateUserList = new ArrayList<>(); + EMCreateUser createUser1 = new EMCreateUser(); + createUser1.setUsername(username1); + createUser1.setPassword(password); + + EMCreateUser createUser2 = new EMCreateUser(); + createUser2.setUsername(username2); + createUser2.setPassword(password); + + emCreateUserList.add(createUser1); + emCreateUserList.add(createUser2); + + assertDoesNotThrow(() -> userApi.createUsers(emCreateUserList)); + + EMCreateRoom createRoom = new EMCreateRoom(); + createRoom.setOwner(username1); + createRoom.setName("test-room"); + createRoom.setDescription("元梦之星"); + createRoom.setMaxusers(200); + createRoom.setMembers(Arrays.asList(username2)); + createRoom.setCustom("custom"); + + EMCreateRoomResult createRoomResult= assertDoesNotThrow(() -> api.createRoom(createRoom)); + assertNotNull(createRoomResult); + assertNotNull(createRoomResult.getData()); + assertNotNull(createRoomResult.getData().getId()); + + String roomId = createRoomResult.getData().getId(); + + EMModifyRoom modifyRoom = new EMModifyRoom(); + modifyRoom.setDescription("元梦之星"); + modifyRoom.setMaxusers(300); + modifyRoom.setName("room name"); + + EMModifyRoomResult modifyRoomResult = assertDoesNotThrow(() -> api.modifyRoom(roomId, modifyRoom)); + assertNotNull(modifyRoomResult); + assertNotNull(modifyRoomResult.getData()); + + assertDoesNotThrow(() -> userApi.deleteUser(username1)); + assertDoesNotThrow(() -> userApi.deleteUser(username2)); + try {api.deleteRoom(roomId);} catch (ApiException ignored) {} + } + + /** + * 修改聊天室公告 + * + * 修改指定聊天室 ID 的聊天室公告。聊天室公告内容不能超过 512 个字符。文档介绍:https://docs-im-beta.easemob.com/document/server-side/chatroom.html#%E4%BF%AE%E6%94%B9%E8%81%8A%E5%A4%A9%E5%AE%A4%E5%85%AC%E5%91%8A + * + * @throws ApiException if the Api call fails + */ + @Test + public void modifyRoomAnnouncementTest() throws ApiException { + String username1 = randomUserName(); + String username2 = randomUserName(); + String password = "123456"; + + List emCreateUserList = new ArrayList<>(); + EMCreateUser createUser1 = new EMCreateUser(); + createUser1.setUsername(username1); + createUser1.setPassword(password); + + EMCreateUser createUser2 = new EMCreateUser(); + createUser2.setUsername(username2); + createUser2.setPassword(password); + + emCreateUserList.add(createUser1); + emCreateUserList.add(createUser2); + + assertDoesNotThrow(() -> userApi.createUsers(emCreateUserList)); + + EMCreateRoom createRoom = new EMCreateRoom(); + createRoom.setOwner(username1); + createRoom.setName("test-room"); + createRoom.setDescription("元梦之星"); + createRoom.setMaxusers(200); + createRoom.setMembers(Arrays.asList(username2)); + createRoom.setCustom("custom"); + + EMCreateRoomResult createRoomResult= assertDoesNotThrow(() -> api.createRoom(createRoom)); + assertNotNull(createRoomResult); + assertNotNull(createRoomResult.getData()); + assertNotNull(createRoomResult.getData().getId()); + + String roomId = createRoomResult.getData().getId(); + + EMModifyRoomAnnouncement modifyRoomAnnouncement = new EMModifyRoomAnnouncement(); + modifyRoomAnnouncement.setAnnouncement("元梦之星"); + + EMModifyRoomAnnouncementResult modifyRoomAnnouncementResult = assertDoesNotThrow(() -> api.modifyRoomAnnouncement(roomId, modifyRoomAnnouncement)); + assertNotNull(modifyRoomAnnouncementResult); + assertNotNull(modifyRoomAnnouncementResult.getData()); + assertEquals(true, modifyRoomAnnouncementResult.getData().getResult()); + + EMGetRoomAnnouncementResult getRoomAnnouncementResult = assertDoesNotThrow(() -> api.getRoomAnnouncement(roomId)); + assertNotNull(getRoomAnnouncementResult); + assertNotNull(getRoomAnnouncementResult.getData()); + + assertDoesNotThrow(() -> userApi.deleteUser(username1)); + assertDoesNotThrow(() -> userApi.deleteUser(username2)); + try {api.deleteRoom(roomId);} catch (ApiException ignored) {} + } + + /** + * 禁言聊天室全体成员 + * + * 对所有聊天室成员一键禁言。该操作不影响聊天室禁言列表,即一键禁言不会将聊天室所有成员加入聊天室禁言列表。设置聊天室全员禁言后,仅聊天室白名单中的用户可在聊天室内发消息。文档介绍:https://docs-im-beta.easemob.com/document/server-side/chatroom.html#%E7%A6%81%E8%A8%80%E8%81%8A%E5%A4%A9%E5%AE%A4%E5%85%A8%E4%BD%93%E6%88%90%E5%91%98 + * + * @throws ApiException if the Api call fails + */ + @Test + public void muteAllRoomMemberTest() throws ApiException { + String username1 = randomUserName(); + String username2 = randomUserName(); + String password = "123456"; + + List emCreateUserList = new ArrayList<>(); + EMCreateUser createUser1 = new EMCreateUser(); + createUser1.setUsername(username1); + createUser1.setPassword(password); + + EMCreateUser createUser2 = new EMCreateUser(); + createUser2.setUsername(username2); + createUser2.setPassword(password); + + emCreateUserList.add(createUser1); + emCreateUserList.add(createUser2); + + assertDoesNotThrow(() -> userApi.createUsers(emCreateUserList)); + + EMCreateRoom createRoom = new EMCreateRoom(); + createRoom.setOwner(username1); + createRoom.setName("test-room"); + createRoom.setDescription("元梦之星"); + createRoom.setMaxusers(200); + createRoom.setMembers(Arrays.asList(username2)); + createRoom.setCustom("custom"); + + EMCreateRoomResult createRoomResult= assertDoesNotThrow(() -> api.createRoom(createRoom)); + assertNotNull(createRoomResult); + assertNotNull(createRoomResult.getData()); + assertNotNull(createRoomResult.getData().getId()); + + String roomId = createRoomResult.getData().getId(); + + EMMuteAllRoomMemberResult muteAllRoomMemberResult = assertDoesNotThrow(() -> api.muteAllRoomMember(roomId)); + assertNotNull(muteAllRoomMemberResult); + assertNotNull(muteAllRoomMemberResult.getData()); + assertEquals(true, muteAllRoomMemberResult.getData().getMute()); + + assertDoesNotThrow(() -> userApi.deleteUser(username1)); + assertDoesNotThrow(() -> userApi.deleteUser(username2)); + try {api.deleteRoom(roomId);} catch (ApiException ignored) {} + } + + /** + * 禁言聊天室成员 + * + * 禁言单个或多个聊天室成员。你一次最多可禁言 60 个成员。用户被禁言后,将无法在聊天室中发送消息。文档介绍:https://docs-im-beta.easemob.com/document/server-side/chatroom.html#%E7%A6%81%E8%A8%80%E8%81%8A%E5%A4%A9%E5%AE%A4%E6%88%90%E5%91%98 + * + * @throws ApiException if the Api call fails + */ + @Test + public void muteRoomMemberTest() throws ApiException { + String username1 = randomUserName(); + String username2 = randomUserName(); + String password = "123456"; + + List emCreateUserList = new ArrayList<>(); + EMCreateUser createUser1 = new EMCreateUser(); + createUser1.setUsername(username1); + createUser1.setPassword(password); + + EMCreateUser createUser2 = new EMCreateUser(); + createUser2.setUsername(username2); + createUser2.setPassword(password); + + emCreateUserList.add(createUser1); + emCreateUserList.add(createUser2); + + assertDoesNotThrow(() -> userApi.createUsers(emCreateUserList)); + + EMCreateRoom createRoom = new EMCreateRoom(); + createRoom.setOwner(username1); + createRoom.setName("test-room"); + createRoom.setDescription("元梦之星"); + createRoom.setMaxusers(200); + createRoom.setMembers(Arrays.asList(username2)); + createRoom.setCustom("custom"); + + EMCreateRoomResult createRoomResult= assertDoesNotThrow(() -> api.createRoom(createRoom)); + assertNotNull(createRoomResult); + assertNotNull(createRoomResult.getData()); + assertNotNull(createRoomResult.getData().getId()); + + String roomId = createRoomResult.getData().getId(); + + EMMuteRoomMember muteRoomMember = new EMMuteRoomMember(); + muteRoomMember.setUsernames(Arrays.asList(username2)); + muteRoomMember.setMuteDuration(new BigDecimal(1000)); + + EMMuteRoomMemberResult muteRoomMemberResult = assertDoesNotThrow(() -> api.muteRoomMember(roomId, muteRoomMember)); + assertNotNull(muteRoomMemberResult); + assertNotNull(muteRoomMemberResult.getData()); + assertEquals(username2, muteRoomMemberResult.getData().get(0).getUser()); + assertEquals(true, muteRoomMemberResult.getData().get(0).getResult()); + + assertDoesNotThrow(() -> userApi.deleteUser(username1)); + assertDoesNotThrow(() -> userApi.deleteUser(username2)); + try {api.deleteRoom(roomId);} catch (ApiException ignored) {} + } + + /** + * 移除聊天室管理员 + * + * 将用户的角色从聊天室管理员降为普通聊天室成员。文档介绍:https://docs-im-beta.easemob.com/document/server-side/chatroom.html#%E6%B7%BB%E5%8A%A0%E8%81%8A%E5%A4%A9%E5%AE%A4%E7%AE%A1%E7%90%86%E5%91%98 + * + * @throws ApiException if the Api call fails + */ + @Test + public void removeRoomAdminTest() throws ApiException { + String username1 = randomUserName(); + String username2 = randomUserName(); + String password = "123456"; + + List emCreateUserList = new ArrayList<>(); + EMCreateUser createUser1 = new EMCreateUser(); + createUser1.setUsername(username1); + createUser1.setPassword(password); + + EMCreateUser createUser2 = new EMCreateUser(); + createUser2.setUsername(username2); + createUser2.setPassword(password); + + emCreateUserList.add(createUser1); + emCreateUserList.add(createUser2); + + assertDoesNotThrow(() -> userApi.createUsers(emCreateUserList)); + + EMCreateRoom createRoom = new EMCreateRoom(); + createRoom.setOwner(username1); + createRoom.setName("test-room"); + createRoom.setDescription("元梦之星"); + createRoom.setMaxusers(200); + createRoom.setMembers(Arrays.asList(username2)); + createRoom.setCustom("custom"); + + EMCreateRoomResult createRoomResult= assertDoesNotThrow(() -> api.createRoom(createRoom)); + assertNotNull(createRoomResult); + assertNotNull(createRoomResult.getData()); + assertNotNull(createRoomResult.getData().getId()); + + String roomId = createRoomResult.getData().getId(); + + EMAddRoomAdmin addRoomAdmin = new EMAddRoomAdmin(); + addRoomAdmin.setNewadmin(username2); + assertDoesNotThrow(() -> api.addRoomAdmin(roomId, addRoomAdmin)); + + EMRemoveRoomAdminResult removeRoomAdminResult = assertDoesNotThrow(() -> api.removeRoomAdmin(roomId, username2)); + assertNotNull(removeRoomAdminResult); + assertNotNull(removeRoomAdminResult.getData()); + assertEquals("success", removeRoomAdminResult.getData().getResult()); + + assertDoesNotThrow(() -> userApi.deleteUser(username1)); + assertDoesNotThrow(() -> userApi.deleteUser(username2)); + try {api.deleteRoom(roomId);} catch (ApiException ignored) {} + } + + /** + * 撤销超级管理员 + * + * 撤销超级管理员权限,用户将不能再创建聊天室。文档介绍:https://docs-im-beta.easemob.com/document/server-side/chatroom.html#%E6%92%A4%E9%94%80%E8%B6%85%E7%BA%A7%E7%AE%A1%E7%90%86%E5%91%98 + * + * @throws ApiException if the Api call fails + */ + @Test + public void removeRoomSuperAdminTest() throws ApiException { + String username1 = randomUserName(); + String username2 = randomUserName(); + String password = "123456"; + + List emCreateUserList = new ArrayList<>(); + EMCreateUser createUser1 = new EMCreateUser(); + createUser1.setUsername(username1); + createUser1.setPassword(password); + + EMCreateUser createUser2 = new EMCreateUser(); + createUser2.setUsername(username2); + createUser2.setPassword(password); + + emCreateUserList.add(createUser1); + emCreateUserList.add(createUser2); + + assertDoesNotThrow(() -> userApi.createUsers(emCreateUserList)); + + EMCreateRoom createRoom = new EMCreateRoom(); + createRoom.setOwner(username1); + createRoom.setName("test-room"); + createRoom.setDescription("元梦之星"); + createRoom.setMaxusers(200); + createRoom.setMembers(Arrays.asList(username2)); + createRoom.setCustom("custom"); + + EMCreateRoomResult createRoomResult= assertDoesNotThrow(() -> api.createRoom(createRoom)); + assertNotNull(createRoomResult); + assertNotNull(createRoomResult.getData()); + assertNotNull(createRoomResult.getData().getId()); + + String roomId = createRoomResult.getData().getId(); + + EMAddRoomSuperAdmin addRoomSuperAdmin = new EMAddRoomSuperAdmin(); + addRoomSuperAdmin.setSuperadmin(username2); + assertDoesNotThrow(() -> api.addRoomSuperAdmin(addRoomSuperAdmin)); + + EMRemoveRoomSuperAdminResult removeRoomSuperAdminResult = assertDoesNotThrow(() -> api.removeRoomSuperAdmin(username2)); + assertNotNull(removeRoomSuperAdminResult); + assertNotNull(removeRoomSuperAdminResult.getData()); + assertNotNull(removeRoomSuperAdminResult.getData().getResource()); + + assertDoesNotThrow(() -> userApi.deleteUser(username1)); + assertDoesNotThrow(() -> userApi.deleteUser(username2)); + try {api.deleteRoom(roomId);} catch (ApiException ignored) {} + } + + /** + * 移除单个聊天室成员 + * + * 从聊天室移除一个成员。如果被移除用户不在聊天室中或聊天室不存在,将返回错误。文档介绍:https://docs-im-beta.easemob.com/document/server-side/chatroom.html#%E7%A7%BB%E9%99%A4%E5%8D%95%E4%B8%AA%E8%81%8A%E5%A4%A9%E5%AE%A4%E6%88%90%E5%91%98 + * + * @throws ApiException if the Api call fails + */ + @Test + public void removeUserFromRoomTest() throws ApiException { + String username1 = randomUserName(); + String username2 = randomUserName(); + String password = "123456"; + + List emCreateUserList = new ArrayList<>(); + EMCreateUser createUser1 = new EMCreateUser(); + createUser1.setUsername(username1); + createUser1.setPassword(password); + + EMCreateUser createUser2 = new EMCreateUser(); + createUser2.setUsername(username2); + createUser2.setPassword(password); + + emCreateUserList.add(createUser1); + emCreateUserList.add(createUser2); + + assertDoesNotThrow(() -> userApi.createUsers(emCreateUserList)); + + EMCreateRoom createRoom = new EMCreateRoom(); + createRoom.setOwner(username1); + createRoom.setName("test-room"); + createRoom.setDescription("元梦之星"); + createRoom.setMaxusers(200); + createRoom.setMembers(Arrays.asList(username2)); + createRoom.setCustom("custom"); + + EMCreateRoomResult createRoomResult= assertDoesNotThrow(() -> api.createRoom(createRoom)); + assertNotNull(createRoomResult); + assertNotNull(createRoomResult.getData()); + assertNotNull(createRoomResult.getData().getId()); + + String roomId = createRoomResult.getData().getId(); + + EMRemoveUserFromRoomResult removeUserFromRoomResult = assertDoesNotThrow(() -> api.removeUserFromRoom(roomId, username2)); + assertNotNull(removeUserFromRoomResult); + assertNotNull(removeUserFromRoomResult.getData()); + assertEquals(true, removeUserFromRoomResult.getData().getResult()); + + assertDoesNotThrow(() -> userApi.deleteUser(username1)); + assertDoesNotThrow(() -> userApi.deleteUser(username2)); + try {api.deleteRoom(roomId);} catch (ApiException ignored) {} + } + + /** + * 从聊天室黑名单移出单个用户 + * + * 将指定用户移出聊天室黑名单。对于聊天室黑名单中的用户,如果需要将其再次加入聊天室,需要先将其从聊天室黑名单中移除。文档介绍:https://docs-im-beta.easemob.com/document/server-side/chatroom.html#%E4%BB%8E%E8%81%8A%E5%A4%A9%E5%AE%A4%E9%BB%91%E5%90%8D%E5%8D%95%E7%A7%BB%E5%87%BA%E5%8D%95%E4%B8%AA%E7%94%A8%E6%88%B7 + * + * @throws ApiException if the Api call fails + */ + @Test + public void removeUserFromRoomBlockListTest() throws ApiException { + String username1 = randomUserName(); + String username2 = randomUserName(); + String password = "123456"; + + List emCreateUserList = new ArrayList<>(); + EMCreateUser createUser1 = new EMCreateUser(); + createUser1.setUsername(username1); + createUser1.setPassword(password); + + EMCreateUser createUser2 = new EMCreateUser(); + createUser2.setUsername(username2); + createUser2.setPassword(password); + + emCreateUserList.add(createUser1); + emCreateUserList.add(createUser2); + + assertDoesNotThrow(() -> userApi.createUsers(emCreateUserList)); + + EMCreateRoom createRoom = new EMCreateRoom(); + createRoom.setOwner(username1); + createRoom.setName("test-room"); + createRoom.setDescription("元梦之星"); + createRoom.setMaxusers(200); + createRoom.setMembers(Arrays.asList(username2)); + createRoom.setCustom("custom"); + + EMCreateRoomResult createRoomResult= assertDoesNotThrow(() -> api.createRoom(createRoom)); + assertNotNull(createRoomResult); + assertNotNull(createRoomResult.getData()); + assertNotNull(createRoomResult.getData().getId()); + + String roomId = createRoomResult.getData().getId(); + + assertDoesNotThrow(() -> api.addUserToRoomBlockList(roomId, username2)); + + EMRemoveUserFromRoomBlockListResult removeUserFromRoomBlockListResult = assertDoesNotThrow(() -> api.removeUserFromRoomBlockList(roomId, username2)); + assertNotNull(removeUserFromRoomBlockListResult); + assertNotNull(removeUserFromRoomBlockListResult.getData()); + assertEquals(true, removeUserFromRoomBlockListResult.getData().getResult()); + + assertDoesNotThrow(() -> userApi.deleteUser(username1)); + assertDoesNotThrow(() -> userApi.deleteUser(username2)); + try {api.deleteRoom(roomId);} catch (ApiException ignored) {} + } + + /** + * 将用户移出聊天室白名单 + * + * 将指定用户从聊天室白名单移除。文档介绍:https://docs-im-beta.easemob.com/document/server-side/chatroom.html#%E5%B0%86%E7%94%A8%E6%88%B7%E7%A7%BB%E5%87%BA%E8%81%8A%E5%A4%A9%E5%AE%A4%E7%99%BD%E5%90%8D%E5%8D%95 + * + * @throws ApiException if the Api call fails + */ + @Test + public void removeUserFromRoomWhiteListTest() throws ApiException { + String username1 = randomUserName(); + String username2 = randomUserName(); + String password = "123456"; + + List emCreateUserList = new ArrayList<>(); + EMCreateUser createUser1 = new EMCreateUser(); + createUser1.setUsername(username1); + createUser1.setPassword(password); + + EMCreateUser createUser2 = new EMCreateUser(); + createUser2.setUsername(username2); + createUser2.setPassword(password); + + emCreateUserList.add(createUser1); + emCreateUserList.add(createUser2); + + assertDoesNotThrow(() -> userApi.createUsers(emCreateUserList)); + + EMCreateRoom createRoom = new EMCreateRoom(); + createRoom.setOwner(username1); + createRoom.setName("test-room"); + createRoom.setDescription("元梦之星"); + createRoom.setMaxusers(200); + createRoom.setMembers(Arrays.asList(username2)); + createRoom.setCustom("custom"); + + EMCreateRoomResult createRoomResult= assertDoesNotThrow(() -> api.createRoom(createRoom)); + assertNotNull(createRoomResult); + assertNotNull(createRoomResult.getData()); + assertNotNull(createRoomResult.getData().getId()); + + String roomId = createRoomResult.getData().getId(); + + assertDoesNotThrow(() -> api.addUserToRoomWhiteList(roomId, username2)); + + EMRemoveUserFromRoomWhiteListResult removeUserFromRoomWhiteListResult = assertDoesNotThrow(() -> api.removeUserFromRoomWhiteList(roomId, username2)); + assertNotNull(removeUserFromRoomWhiteListResult); + assertNotNull(removeUserFromRoomWhiteListResult.getData()); + assertEquals(true, removeUserFromRoomWhiteListResult.getData().getResult()); + + assertDoesNotThrow(() -> userApi.deleteUser(username1)); + assertDoesNotThrow(() -> userApi.deleteUser(username2)); + try {api.deleteRoom(roomId);} catch (ApiException ignored) {} + } + + /** + * 设置聊天室自定义属性 + * + * 指定用户设置特定聊天室的自定义属性。文档介绍:https://docs-im-beta.easemob.com/document/server-side/chatroom.html#%E8%AE%BE%E7%BD%AE%E8%81%8A%E5%A4%A9%E5%AE%A4%E8%87%AA%E5%AE%9A%E4%B9%89%E5%B1%9E%E6%80%A7 + * + * @throws ApiException if the Api call fails + */ + @Test + public void setRoomCustomAttributesTest() throws ApiException { + String username1 = randomUserName(); + String username2 = randomUserName(); + String password = "123456"; + + List emCreateUserList = new ArrayList<>(); + EMCreateUser createUser1 = new EMCreateUser(); + createUser1.setUsername(username1); + createUser1.setPassword(password); + + EMCreateUser createUser2 = new EMCreateUser(); + createUser2.setUsername(username2); + createUser2.setPassword(password); + + emCreateUserList.add(createUser1); + emCreateUserList.add(createUser2); + + assertDoesNotThrow(() -> userApi.createUsers(emCreateUserList)); + + EMCreateRoom createRoom = new EMCreateRoom(); + createRoom.setOwner(username1); + createRoom.setName("test-room"); + createRoom.setDescription("元梦之星"); + createRoom.setMaxusers(200); + createRoom.setMembers(Arrays.asList(username2)); + createRoom.setCustom("custom"); + + EMCreateRoomResult createRoomResult= assertDoesNotThrow(() -> api.createRoom(createRoom)); + assertNotNull(createRoomResult); + assertNotNull(createRoomResult.getData()); + assertNotNull(createRoomResult.getData().getId()); + + String roomId = createRoomResult.getData().getId(); + + Map metadata = new HashMap<>(); + metadata.put("key1", "value1"); + metadata.put("key2", "value2"); + + EMSetRoomCustomAttributes setRoomCustomAttributes = new EMSetRoomCustomAttributes(); + setRoomCustomAttributes.setAutoDelete("delete"); + setRoomCustomAttributes.setMetaData(metadata); + + EMSetRoomCustomAttributesResult setRoomCustomAttributesResult = assertDoesNotThrow(() -> api.setRoomCustomAttributes(roomId, username2, setRoomCustomAttributes)); + assertNotNull(setRoomCustomAttributesResult); + assertNotNull(setRoomCustomAttributesResult.getData()); + assertNotNull(setRoomCustomAttributesResult.getData().getSuccessKeys()); + assertEquals(2, setRoomCustomAttributesResult.getData().getSuccessKeys().size()); + + EMGetRoomCustomAttributes getRoomCustomAttributes = new EMGetRoomCustomAttributes(); + getRoomCustomAttributes.setKeys(Arrays.asList("key1", "key2")); + + EMGetRoomCustomAttributesResult getRoomCustomAttributesResult = assertDoesNotThrow(() -> api.getRoomCustomAttributes(roomId, getRoomCustomAttributes)); + assertNotNull(getRoomCustomAttributesResult); + assertNotNull(getRoomCustomAttributesResult.getData()); + assertEquals("value1", ((Map) getRoomCustomAttributesResult.getData()).get("key1")); + assertEquals("value2", ((Map) getRoomCustomAttributesResult.getData()).get("key2")); + + assertDoesNotThrow(() -> userApi.deleteUser(username1)); + assertDoesNotThrow(() -> userApi.deleteUser(username2)); + try {api.deleteRoom(roomId);} catch (ApiException ignored) {} + } + + /** + * 解除聊天室全员禁言 + * + * 一键取消对聊天室全体成员的禁言。解除禁言后,聊天室成员可以在聊天室中正常发送消息。文档介绍:https://docs-im-beta.easemob.com/document/server-side/chatroom.html#%E8%A7%A3%E9%99%A4%E8%81%8A%E5%A4%A9%E5%AE%A4%E5%85%A8%E5%91%98%E7%A6%81%E8%A8%80 + * + * @throws ApiException if the Api call fails + */ + @Test + public void unmuteAllRoomMemberTest() throws ApiException { + String username1 = randomUserName(); + String username2 = randomUserName(); + String password = "123456"; + + List emCreateUserList = new ArrayList<>(); + EMCreateUser createUser1 = new EMCreateUser(); + createUser1.setUsername(username1); + createUser1.setPassword(password); + + EMCreateUser createUser2 = new EMCreateUser(); + createUser2.setUsername(username2); + createUser2.setPassword(password); + + emCreateUserList.add(createUser1); + emCreateUserList.add(createUser2); + + assertDoesNotThrow(() -> userApi.createUsers(emCreateUserList)); + + EMCreateRoom createRoom = new EMCreateRoom(); + createRoom.setOwner(username1); + createRoom.setName("test-room"); + createRoom.setDescription("元梦之星"); + createRoom.setMaxusers(200); + createRoom.setMembers(Arrays.asList(username2)); + createRoom.setCustom("custom"); + + EMCreateRoomResult createRoomResult= assertDoesNotThrow(() -> api.createRoom(createRoom)); + assertNotNull(createRoomResult); + assertNotNull(createRoomResult.getData()); + assertNotNull(createRoomResult.getData().getId()); + + String roomId = createRoomResult.getData().getId(); + + assertDoesNotThrow(() -> api.muteAllRoomMember(roomId)); + + EMUnmuteAllRoomMemberResult unmuteAllRoomMemberResult = assertDoesNotThrow(() -> api.unmuteAllRoomMember(roomId)); + assertNotNull(unmuteAllRoomMemberResult); + assertNotNull(unmuteAllRoomMemberResult.getData()); + assertEquals(false, unmuteAllRoomMemberResult.getData().getMute()); + + assertDoesNotThrow(() -> userApi.deleteUser(username1)); + assertDoesNotThrow(() -> userApi.deleteUser(username2)); + try {api.deleteRoom(roomId);} catch (ApiException ignored) {} + } + + /** + * 解除聊天室禁言成员 + * + * 解除对一个聊天室成员的禁言。解除禁言后,该成员可以正常在聊天室中发送消息。文档介绍:https://docs-im-beta.easemob.com/document/server-side/chatroom.html#%E8%A7%A3%E9%99%A4%E8%81%8A%E5%A4%A9%E5%AE%A4%E7%A6%81%E8%A8%80%E6%88%90%E5%91%98 + * + * @throws ApiException if the Api call fails + */ + @Test + public void unmuteRoomMemberTest() throws ApiException { + String username1 = randomUserName(); + String username2 = randomUserName(); + String password = "123456"; + + List emCreateUserList = new ArrayList<>(); + EMCreateUser createUser1 = new EMCreateUser(); + createUser1.setUsername(username1); + createUser1.setPassword(password); + + EMCreateUser createUser2 = new EMCreateUser(); + createUser2.setUsername(username2); + createUser2.setPassword(password); + + emCreateUserList.add(createUser1); + emCreateUserList.add(createUser2); + + assertDoesNotThrow(() -> userApi.createUsers(emCreateUserList)); + + EMCreateRoom createRoom = new EMCreateRoom(); + createRoom.setOwner(username1); + createRoom.setName("test-room"); + createRoom.setDescription("元梦之星"); + createRoom.setMaxusers(200); + createRoom.setMembers(Arrays.asList(username2)); + createRoom.setCustom("custom"); + + EMCreateRoomResult createRoomResult= assertDoesNotThrow(() -> api.createRoom(createRoom)); + assertNotNull(createRoomResult); + assertNotNull(createRoomResult.getData()); + assertNotNull(createRoomResult.getData().getId()); + + String roomId = createRoomResult.getData().getId(); + + EMMuteRoomMember muteRoomMember = new EMMuteRoomMember(); + muteRoomMember.setUsernames(Arrays.asList(username2)); + muteRoomMember.setMuteDuration(new BigDecimal(1000)); + + assertDoesNotThrow(() -> api.muteRoomMember(roomId, muteRoomMember)); + + EMUnmuteRoomMemberResult unmuteRoomMemberResult = assertDoesNotThrow(() -> api.unmuteRoomMember(roomId, username2)); + assertNotNull(unmuteRoomMemberResult); + assertNotNull(unmuteRoomMemberResult.getData()); + assertEquals(true, unmuteRoomMemberResult.getData().get(0).getResult()); + + assertDoesNotThrow(() -> userApi.deleteUser(username1)); + assertDoesNotThrow(() -> userApi.deleteUser(username2)); + try {api.deleteRoom(roomId);} catch (ApiException ignored) {} + } + +} diff --git a/src/test/java/com/easemob/im/api/ThreadApiTest.java b/src/test/java/com/easemob/im/api/ThreadApiTest.java new file mode 100644 index 000000000..2b48aa34f --- /dev/null +++ b/src/test/java/com/easemob/im/api/ThreadApiTest.java @@ -0,0 +1,869 @@ +/* + * EMService + * Easemob Rest API + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.easemob.im.api; + +import com.easemob.im.ApiException; +import com.easemob.im.api.model.*; +import org.junit.jupiter.api.Test; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import java.util.Map; + +import static org.junit.jupiter.api.Assertions.*; + +/** + * API tests for ThreadApi + */ +public class ThreadApiTest extends AbstractTest { + + private final ThreadApi api = new ThreadApi(); + + private final GroupApi groupApi = new GroupApi(); + + private final UserApi userApi = new UserApi(); + + private final MessageApi messageApi = new MessageApi(); + + /** + * 用户批量加入子区 + * + * 用户批量加入指定的子区。文档介绍:https://docs-im-beta.easemob.com/document/server-side/group.html#%E7%94%A8%E6%88%B7%E6%89%B9%E9%87%8F%E5%8A%A0%E5%85%A5%E5%AD%90%E5%8C%BA + * + * @throws ApiException if the Api call fails + */ + @Test + public void addMultipleUsersToThreadTest() throws ApiException { + String username1 = randomUserName(); + String username2 = randomUserName(); + String password = "123456"; + + List emCreateUserList = new ArrayList<>(); + EMCreateUser createUser1 = new EMCreateUser(); + createUser1.setUsername(username1); + createUser1.setPassword(password); + + EMCreateUser createUser2 = new EMCreateUser(); + createUser2.setUsername(username2); + createUser2.setPassword(password); + + emCreateUserList.add(createUser1); + emCreateUserList.add(createUser2); + + assertDoesNotThrow(() -> userApi.createUsers(emCreateUserList)); + + EMCreateGroup createGroup = new EMCreateGroup(); + createGroup.setOwner(username1); + createGroup.setGroupname("test-group"); + createGroup.setDescription("元梦之星"); + createGroup.setMaxusers(200); + createGroup.setMembers(Arrays.asList(username2)); + createGroup.setPublic(true); + + EMCreateGroupResult createGroupResult = + assertDoesNotThrow(() -> groupApi.createGroup(createGroup)); + assertNotNull(createGroupResult); + assertNotNull(createGroupResult.getData()); + assertNotNull(createGroupResult.getData().getGroupid()); + + String groupId = createGroupResult.getData().getGroupid(); + + EMCreateMessage emCreateMessage = new EMCreateMessage(); + emCreateMessage.setFrom(username1); + emCreateMessage.setTo(new ArrayList(){{add(groupId);}}); + emCreateMessage.setType("txt"); + EMMessageContent messageContent = new EMMessageContent(); + messageContent.setMsg("test message"); + emCreateMessage.setBody(messageContent); + + EMSendMessageResult response = messageApi.sendMessagesToGroup(emCreateMessage); + assertNotNull(response.getData()); + Map data = (Map) response.getData(); + + String messageId = data.get(groupId).toString(); + + EMCreateThread createThread = new EMCreateThread(); + createThread.setGroupId(groupId); + createThread.setOwner(username1); + createThread.setMsgId(messageId); + createThread.setName("test-thread"); + + EMCreateThreadResult createThreadResult = + assertDoesNotThrow(() -> api.createThread(createThread)); + assertNotNull(createThreadResult); + assertNotNull(createThreadResult.getData()); + assertNotNull(createThreadResult.getData().getThreadId()); + + String threadId = createThreadResult.getData().getThreadId(); + + EMAddMultipleUsersToThread addMultipleUsersToThread = new EMAddMultipleUsersToThread(); + addMultipleUsersToThread.setUsernames(Arrays.asList(username2)); + + EMAddMultipleUsersToThreadResult addMultipleUsersToThreadResult = + assertDoesNotThrow(() -> api.addMultipleUsersToThread(threadId, addMultipleUsersToThread)); + assertNotNull(addMultipleUsersToThreadResult); + assertNotNull(addMultipleUsersToThreadResult.getData()); + assertEquals("ok", addMultipleUsersToThreadResult.getData().getStatus()); + + EMRemoveMultipleUsersFromThread removeMultipleUsersFromThread = new EMRemoveMultipleUsersFromThread(); + removeMultipleUsersFromThread.setUsernames(Arrays.asList(username2)); + + EMRemoveMultipleUsersFromThreadResult removeMultipleUsersFromThreadResult = + assertDoesNotThrow(() -> api.removeMultipleUsersFromThread(threadId, removeMultipleUsersFromThread)); + assertNotNull(removeMultipleUsersFromThreadResult); + assertNotNull(removeMultipleUsersFromThreadResult.getEntities()); + assertEquals(true, removeMultipleUsersFromThreadResult.getEntities().get(0).getResult()); + + assertDoesNotThrow(() -> userApi.deleteUser(username1)); + assertDoesNotThrow(() -> userApi.deleteUser(username2)); + try { + groupApi.deleteGroup(groupId); + } catch (ApiException ignored) { + } + } + + /** + * 创建子区 + * + * 创建子区。文档介绍:https://docs-im-beta.easemob.com/document/server-side/group.html#%E5%88%9B%E5%BB%BA%E5%AD%90%E5%8C%BA + * + * @throws ApiException if the Api call fails + */ + @Test + public void createThreadTest() throws ApiException { + String username1 = randomUserName(); + String username2 = randomUserName(); + String password = "123456"; + + List emCreateUserList = new ArrayList<>(); + EMCreateUser createUser1 = new EMCreateUser(); + createUser1.setUsername(username1); + createUser1.setPassword(password); + + EMCreateUser createUser2 = new EMCreateUser(); + createUser2.setUsername(username2); + createUser2.setPassword(password); + + emCreateUserList.add(createUser1); + emCreateUserList.add(createUser2); + + assertDoesNotThrow(() -> userApi.createUsers(emCreateUserList)); + + EMCreateGroup createGroup = new EMCreateGroup(); + createGroup.setOwner(username1); + createGroup.setGroupname("test-group"); + createGroup.setDescription("元梦之星"); + createGroup.setMaxusers(200); + createGroup.setMembers(Arrays.asList(username2)); + createGroup.setPublic(true); + + EMCreateGroupResult createGroupResult = + assertDoesNotThrow(() -> groupApi.createGroup(createGroup)); + assertNotNull(createGroupResult); + assertNotNull(createGroupResult.getData()); + assertNotNull(createGroupResult.getData().getGroupid()); + + String groupId = createGroupResult.getData().getGroupid(); + + EMCreateMessage emCreateMessage = new EMCreateMessage(); + emCreateMessage.setFrom(username1); + emCreateMessage.setTo(new ArrayList(){{add(groupId);}}); + emCreateMessage.setType("txt"); + EMMessageContent messageContent = new EMMessageContent(); + messageContent.setMsg("test message"); + emCreateMessage.setBody(messageContent); + + EMSendMessageResult response = messageApi.sendMessagesToGroup(emCreateMessage); + assertNotNull(response.getData()); + Map data = (Map) response.getData(); + + String messageId = data.get(groupId).toString(); + + EMCreateThread createThread = new EMCreateThread(); + createThread.setGroupId(groupId); + createThread.setOwner(username2); + createThread.setMsgId(messageId); + createThread.setName("test-thread"); + + EMCreateThreadResult createThreadResult = + assertDoesNotThrow(() -> api.createThread(createThread)); + assertNotNull(createThreadResult); + assertNotNull(createThreadResult.getData()); + assertNotNull(createThreadResult.getData().getThreadId()); + + assertDoesNotThrow(() -> userApi.deleteUser(username1)); + assertDoesNotThrow(() -> userApi.deleteUser(username2)); + try { + groupApi.deleteGroup(groupId); + } catch (ApiException ignored) { + } + } + + /** + * 删除子区 + * + * 删除指定子区。文档介绍:https://docs-im-beta.easemob.com/document/server-side/group.html#%E5%88%A0%E9%99%A4%E5%AD%90%E5%8C%BA + * + * @throws ApiException if the Api call fails + */ + @Test + public void deleteThreadTest() throws ApiException { + String username1 = randomUserName(); + String username2 = randomUserName(); + String password = "123456"; + + List emCreateUserList = new ArrayList<>(); + EMCreateUser createUser1 = new EMCreateUser(); + createUser1.setUsername(username1); + createUser1.setPassword(password); + + EMCreateUser createUser2 = new EMCreateUser(); + createUser2.setUsername(username2); + createUser2.setPassword(password); + + emCreateUserList.add(createUser1); + emCreateUserList.add(createUser2); + + assertDoesNotThrow(() -> userApi.createUsers(emCreateUserList)); + + EMCreateGroup createGroup = new EMCreateGroup(); + createGroup.setOwner(username1); + createGroup.setGroupname("test-group"); + createGroup.setDescription("元梦之星"); + createGroup.setMaxusers(200); + createGroup.setMembers(Arrays.asList(username2)); + createGroup.setPublic(true); + + EMCreateGroupResult createGroupResult = + assertDoesNotThrow(() -> groupApi.createGroup(createGroup)); + assertNotNull(createGroupResult); + assertNotNull(createGroupResult.getData()); + assertNotNull(createGroupResult.getData().getGroupid()); + + String groupId = createGroupResult.getData().getGroupid(); + + EMCreateMessage emCreateMessage = new EMCreateMessage(); + emCreateMessage.setFrom(username1); + emCreateMessage.setTo(new ArrayList(){{add(groupId);}}); + emCreateMessage.setType("txt"); + EMMessageContent messageContent = new EMMessageContent(); + messageContent.setMsg("test message"); + emCreateMessage.setBody(messageContent); + + EMSendMessageResult response = messageApi.sendMessagesToGroup(emCreateMessage); + assertNotNull(response.getData()); + Map data = (Map) response.getData(); + + String messageId = data.get(groupId).toString(); + + EMCreateThread createThread = new EMCreateThread(); + createThread.setGroupId(groupId); + createThread.setOwner(username2); + createThread.setMsgId(messageId); + createThread.setName("test-thread"); + + EMCreateThreadResult createThreadResult = + assertDoesNotThrow(() -> api.createThread(createThread)); + assertNotNull(createThreadResult); + assertNotNull(createThreadResult.getData()); + assertNotNull(createThreadResult.getData().getThreadId()); + + String threadId = createThreadResult.getData().getThreadId(); + + EMDeleteThreadResult deleteThreadResult = + assertDoesNotThrow(() -> api.deleteThread(threadId)); + assertNotNull(deleteThreadResult); + assertNotNull(deleteThreadResult.getData()); + assertEquals("ok", deleteThreadResult.getData().getStatus()); + + assertDoesNotThrow(() -> userApi.deleteUser(username1)); + assertDoesNotThrow(() -> userApi.deleteUser(username2)); + try { + groupApi.deleteGroup(groupId); + } catch (ApiException ignored) { + } + } + + /** + * 获取子区成员列表(分页) + * + * 分页获取应用下的子区列表。文档介绍:https://docs-im-beta.easemob.com/document/server-side/group.html#%E8%8E%B7%E5%8F%96%E5%AD%90%E5%8C%BA%E6%88%90%E5%91%98%E5%88%97%E8%A1%A8-%E5%88%86%E9%A1%B5 + * + * @throws ApiException if the Api call fails + */ + @Test + public void getThreadMemberListTest() throws ApiException { + String username1 = randomUserName(); + String username2 = randomUserName(); + String password = "123456"; + + List emCreateUserList = new ArrayList<>(); + EMCreateUser createUser1 = new EMCreateUser(); + createUser1.setUsername(username1); + createUser1.setPassword(password); + + EMCreateUser createUser2 = new EMCreateUser(); + createUser2.setUsername(username2); + createUser2.setPassword(password); + + emCreateUserList.add(createUser1); + emCreateUserList.add(createUser2); + + assertDoesNotThrow(() -> userApi.createUsers(emCreateUserList)); + + EMCreateGroup createGroup = new EMCreateGroup(); + createGroup.setOwner(username1); + createGroup.setGroupname("test-group"); + createGroup.setDescription("元梦之星"); + createGroup.setMaxusers(200); + createGroup.setMembers(Arrays.asList(username2)); + createGroup.setPublic(true); + + EMCreateGroupResult createGroupResult = + assertDoesNotThrow(() -> groupApi.createGroup(createGroup)); + assertNotNull(createGroupResult); + assertNotNull(createGroupResult.getData()); + assertNotNull(createGroupResult.getData().getGroupid()); + + String groupId = createGroupResult.getData().getGroupid(); + + EMCreateMessage emCreateMessage = new EMCreateMessage(); + emCreateMessage.setFrom(username1); + emCreateMessage.setTo(new ArrayList(){{add(groupId);}}); + emCreateMessage.setType("txt"); + EMMessageContent messageContent = new EMMessageContent(); + messageContent.setMsg("test message"); + emCreateMessage.setBody(messageContent); + + EMSendMessageResult response = messageApi.sendMessagesToGroup(emCreateMessage); + assertNotNull(response.getData()); + Map data = (Map) response.getData(); + + String messageId = data.get(groupId).toString(); + + EMCreateThread createThread = new EMCreateThread(); + createThread.setGroupId(groupId); + createThread.setOwner(username1); + createThread.setMsgId(messageId); + createThread.setName("test-thread"); + + EMCreateThreadResult createThreadResult = + assertDoesNotThrow(() -> api.createThread(createThread)); + assertNotNull(createThreadResult); + assertNotNull(createThreadResult.getData()); + assertNotNull(createThreadResult.getData().getThreadId()); + + String threadId = createThreadResult.getData().getThreadId(); + + EMAddMultipleUsersToThread addMultipleUsersToThread = new EMAddMultipleUsersToThread(); + addMultipleUsersToThread.setUsernames(Arrays.asList(username2)); + + EMAddMultipleUsersToThreadResult addMultipleUsersToThreadResult = + assertDoesNotThrow(() -> api.addMultipleUsersToThread(threadId, addMultipleUsersToThread)); + assertNotNull(addMultipleUsersToThreadResult); + assertNotNull(addMultipleUsersToThreadResult.getData()); + assertEquals("ok", addMultipleUsersToThreadResult.getData().getStatus()); + + EMGetThreadMemberListResult getThreadMemberListResult = + assertDoesNotThrow(() -> api.getThreadMemberList(threadId, 2, null)); + assertNotNull(getThreadMemberListResult); + assertNotNull(getThreadMemberListResult.getData()); + assertNotNull(getThreadMemberListResult.getProperties()); + assertNotNull(getThreadMemberListResult.getProperties().getCursor()); + assertEquals(2, getThreadMemberListResult.getData().getAffiliations().size()); + + assertDoesNotThrow(() -> userApi.deleteUser(username1)); + assertDoesNotThrow(() -> userApi.deleteUser(username2)); + try { + groupApi.deleteGroup(groupId); + } catch (ApiException ignored) { + } + } + + /** + * 获取 app 中的子区 + * + * 分页获取应用下的子区列表。文档介绍:https://docs-im-beta.easemob.com/document/server-side/group.html#%E8%8E%B7%E5%8F%96-app-%E4%B8%AD%E7%9A%84%E5%AD%90%E5%8C%BA + * + * @throws ApiException if the Api call fails + */ + @Test + public void getThreadsUnderAppTest() throws ApiException { + String username1 = randomUserName(); + String username2 = randomUserName(); + String password = "123456"; + + List emCreateUserList = new ArrayList<>(); + EMCreateUser createUser1 = new EMCreateUser(); + createUser1.setUsername(username1); + createUser1.setPassword(password); + + EMCreateUser createUser2 = new EMCreateUser(); + createUser2.setUsername(username2); + createUser2.setPassword(password); + + emCreateUserList.add(createUser1); + emCreateUserList.add(createUser2); + + assertDoesNotThrow(() -> userApi.createUsers(emCreateUserList)); + + EMCreateGroup createGroup = new EMCreateGroup(); + createGroup.setOwner(username1); + createGroup.setGroupname("test-group"); + createGroup.setDescription("元梦之星"); + createGroup.setMaxusers(200); + createGroup.setMembers(Arrays.asList(username2)); + createGroup.setPublic(true); + + EMCreateGroupResult createGroupResult = + assertDoesNotThrow(() -> groupApi.createGroup(createGroup)); + assertNotNull(createGroupResult); + assertNotNull(createGroupResult.getData()); + assertNotNull(createGroupResult.getData().getGroupid()); + + String groupId = createGroupResult.getData().getGroupid(); + + EMCreateMessage emCreateMessage = new EMCreateMessage(); + emCreateMessage.setFrom(username1); + emCreateMessage.setTo(new ArrayList(){{add(groupId);}}); + emCreateMessage.setType("txt"); + EMMessageContent messageContent = new EMMessageContent(); + messageContent.setMsg("test message"); + emCreateMessage.setBody(messageContent); + + EMSendMessageResult response = messageApi.sendMessagesToGroup(emCreateMessage); + assertNotNull(response.getData()); + Map data = (Map) response.getData(); + + String messageId = data.get(groupId).toString(); + + EMCreateThread createThread = new EMCreateThread(); + createThread.setGroupId(groupId); + createThread.setOwner(username1); + createThread.setMsgId(messageId); + createThread.setName("test-thread"); + + EMCreateThreadResult createThreadResult = + assertDoesNotThrow(() -> api.createThread(createThread)); + assertNotNull(createThreadResult); + assertNotNull(createThreadResult.getData()); + assertNotNull(createThreadResult.getData().getThreadId()); + + String threadId = createThreadResult.getData().getThreadId(); + + EMAddMultipleUsersToThread addMultipleUsersToThread = new EMAddMultipleUsersToThread(); + addMultipleUsersToThread.setUsernames(Arrays.asList(username2)); + + EMAddMultipleUsersToThreadResult addMultipleUsersToThreadResult = + assertDoesNotThrow(() -> api.addMultipleUsersToThread(threadId, addMultipleUsersToThread)); + assertNotNull(addMultipleUsersToThreadResult); + assertNotNull(addMultipleUsersToThreadResult.getData()); + assertEquals("ok", addMultipleUsersToThreadResult.getData().getStatus()); + + EMGetThreadsUnderAppResult getThreadsUnderAppResult = + assertDoesNotThrow(() -> api.getThreadsUnderApp(1, null, "asc")); + assertNotNull(getThreadsUnderAppResult); + assertNotNull(getThreadsUnderAppResult.getEntities()); + assertNotNull(getThreadsUnderAppResult.getProperties()); + assertNotNull(getThreadsUnderAppResult.getProperties().getCursor()); + assertEquals(1, getThreadsUnderAppResult.getEntities().size()); + + assertDoesNotThrow(() -> userApi.deleteUser(username1)); + assertDoesNotThrow(() -> userApi.deleteUser(username2)); + try { + groupApi.deleteGroup(groupId); + } catch (ApiException ignored) { + } + } + + /** + * 获取单个用户加入的所有子区(分页获取) + * + * 根据用户 ID 获取该用户加入的所有子区。文档介绍:https://docs-im-beta.easemob.com/document/server-side/group.html#%E8%8E%B7%E5%8F%96%E5%8D%95%E4%B8%AA%E7%94%A8%E6%88%B7%E5%8A%A0%E5%85%A5%E7%9A%84%E6%89%80%E6%9C%89%E5%AD%90%E5%8C%BA-%E5%88%86%E9%A1%B5%E8%8E%B7%E5%8F%96 + * + * @throws ApiException if the Api call fails + */ + @Test + public void getUserJoinedThreadsTest() throws ApiException { + String username1 = randomUserName(); + String username2 = randomUserName(); + String password = "123456"; + + List emCreateUserList = new ArrayList<>(); + EMCreateUser createUser1 = new EMCreateUser(); + createUser1.setUsername(username1); + createUser1.setPassword(password); + + EMCreateUser createUser2 = new EMCreateUser(); + createUser2.setUsername(username2); + createUser2.setPassword(password); + + emCreateUserList.add(createUser1); + emCreateUserList.add(createUser2); + + assertDoesNotThrow(() -> userApi.createUsers(emCreateUserList)); + + EMCreateGroup createGroup = new EMCreateGroup(); + createGroup.setOwner(username1); + createGroup.setGroupname("test-group"); + createGroup.setDescription("元梦之星"); + createGroup.setMaxusers(200); + createGroup.setMembers(Arrays.asList(username2)); + createGroup.setPublic(true); + + EMCreateGroupResult createGroupResult = + assertDoesNotThrow(() -> groupApi.createGroup(createGroup)); + assertNotNull(createGroupResult); + assertNotNull(createGroupResult.getData()); + assertNotNull(createGroupResult.getData().getGroupid()); + + String groupId = createGroupResult.getData().getGroupid(); + + EMCreateMessage emCreateMessage = new EMCreateMessage(); + emCreateMessage.setFrom(username1); + emCreateMessage.setTo(new ArrayList(){{add(groupId);}}); + emCreateMessage.setType("txt"); + EMMessageContent messageContent = new EMMessageContent(); + messageContent.setMsg("test message"); + emCreateMessage.setBody(messageContent); + + EMSendMessageResult response = messageApi.sendMessagesToGroup(emCreateMessage); + assertNotNull(response.getData()); + Map data = (Map) response.getData(); + + String messageId = data.get(groupId).toString(); + + EMCreateThread createThread = new EMCreateThread(); + createThread.setGroupId(groupId); + createThread.setOwner(username1); + createThread.setMsgId(messageId); + createThread.setName("test-thread"); + + EMCreateThreadResult createThreadResult = + assertDoesNotThrow(() -> api.createThread(createThread)); + assertNotNull(createThreadResult); + assertNotNull(createThreadResult.getData()); + assertNotNull(createThreadResult.getData().getThreadId()); + + String threadId = createThreadResult.getData().getThreadId(); + + EMAddMultipleUsersToThread addMultipleUsersToThread = new EMAddMultipleUsersToThread(); + addMultipleUsersToThread.setUsernames(Arrays.asList(username2)); + + EMAddMultipleUsersToThreadResult addMultipleUsersToThreadResult = + assertDoesNotThrow(() -> api.addMultipleUsersToThread(threadId, addMultipleUsersToThread)); + assertNotNull(addMultipleUsersToThreadResult); + assertNotNull(addMultipleUsersToThreadResult.getData()); + assertEquals("ok", addMultipleUsersToThreadResult.getData().getStatus()); + + EMGetUserJoinedThreadsResult getUserJoinedThreadsResult = + assertDoesNotThrow(() -> api.getUserJoinedThreads(username1, 1, null, "asc")); + assertNotNull(getUserJoinedThreadsResult); + assertNotNull(getUserJoinedThreadsResult.getEntities()); + assertNotNull(getUserJoinedThreadsResult.getProperties()); + assertNotNull(getUserJoinedThreadsResult.getProperties().getCursor()); + assertEquals(1, getUserJoinedThreadsResult.getEntities().size()); + + assertDoesNotThrow(() -> userApi.deleteUser(username1)); + assertDoesNotThrow(() -> userApi.deleteUser(username2)); + try { + groupApi.deleteGroup(groupId); + } catch (ApiException ignored) { + } + } + + /** + * 获取单个用户在指定群组中加入的所有子区 (分页获取) + * + * 根据用户 ID 获取该用户在指定群组中加入的所有子区。文档介绍:https://docs-im-beta.easemob.com/document/server-side/group.html#%E8%8E%B7%E5%8F%96%E5%8D%95%E4%B8%AA%E7%94%A8%E6%88%B7%E5%9C%A8%E6%8C%87%E5%AE%9A%E7%BE%A4%E7%BB%84%E4%B8%AD%E5%8A%A0%E5%85%A5%E7%9A%84%E6%89%80%E6%9C%89%E5%AD%90%E5%8C%BA-%E5%88%86%E9%A1%B5%E8%8E%B7%E5%8F%96 + * + * @throws ApiException if the Api call fails + */ + @Test + public void getUserJoinedThreadsUnderGroupTest() throws ApiException { + String username1 = randomUserName(); + String username2 = randomUserName(); + String password = "123456"; + + List emCreateUserList = new ArrayList<>(); + EMCreateUser createUser1 = new EMCreateUser(); + createUser1.setUsername(username1); + createUser1.setPassword(password); + + EMCreateUser createUser2 = new EMCreateUser(); + createUser2.setUsername(username2); + createUser2.setPassword(password); + + emCreateUserList.add(createUser1); + emCreateUserList.add(createUser2); + + assertDoesNotThrow(() -> userApi.createUsers(emCreateUserList)); + + EMCreateGroup createGroup = new EMCreateGroup(); + createGroup.setOwner(username1); + createGroup.setGroupname("test-group"); + createGroup.setDescription("元梦之星"); + createGroup.setMaxusers(200); + createGroup.setMembers(Arrays.asList(username2)); + createGroup.setPublic(true); + + EMCreateGroupResult createGroupResult = + assertDoesNotThrow(() -> groupApi.createGroup(createGroup)); + assertNotNull(createGroupResult); + assertNotNull(createGroupResult.getData()); + assertNotNull(createGroupResult.getData().getGroupid()); + + String groupId = createGroupResult.getData().getGroupid(); + + EMCreateMessage emCreateMessage = new EMCreateMessage(); + emCreateMessage.setFrom(username1); + emCreateMessage.setTo(new ArrayList(){{add(groupId);}}); + emCreateMessage.setType("txt"); + EMMessageContent messageContent = new EMMessageContent(); + messageContent.setMsg("test message"); + emCreateMessage.setBody(messageContent); + + EMSendMessageResult response = messageApi.sendMessagesToGroup(emCreateMessage); + assertNotNull(response.getData()); + Map data = (Map) response.getData(); + + String messageId = data.get(groupId).toString(); + + EMCreateThread createThread = new EMCreateThread(); + createThread.setGroupId(groupId); + createThread.setOwner(username1); + createThread.setMsgId(messageId); + createThread.setName("test-thread"); + + EMCreateThreadResult createThreadResult = + assertDoesNotThrow(() -> api.createThread(createThread)); + assertNotNull(createThreadResult); + assertNotNull(createThreadResult.getData()); + assertNotNull(createThreadResult.getData().getThreadId()); + + String threadId = createThreadResult.getData().getThreadId(); + + EMAddMultipleUsersToThread addMultipleUsersToThread = new EMAddMultipleUsersToThread(); + addMultipleUsersToThread.setUsernames(Arrays.asList(username2)); + + EMAddMultipleUsersToThreadResult addMultipleUsersToThreadResult = + assertDoesNotThrow(() -> api.addMultipleUsersToThread(threadId, addMultipleUsersToThread)); + assertNotNull(addMultipleUsersToThreadResult); + assertNotNull(addMultipleUsersToThreadResult.getData()); + assertEquals("ok", addMultipleUsersToThreadResult.getData().getStatus()); + + EMGetUserJoinedThreadsUnderGroupResult getUserJoinedThreadsUnderGroupResult = + assertDoesNotThrow(() -> api.getUserJoinedThreadsUnderGroup(groupId, username1, 1, null, "asc")); + assertNotNull(getUserJoinedThreadsUnderGroupResult); + assertNotNull(getUserJoinedThreadsUnderGroupResult.getEntities()); + assertNotNull(getUserJoinedThreadsUnderGroupResult.getProperties()); + assertNotNull(getUserJoinedThreadsUnderGroupResult.getProperties().getCursor()); + assertEquals(1, getUserJoinedThreadsUnderGroupResult.getEntities().size()); + assertEquals(threadId, getUserJoinedThreadsUnderGroupResult.getEntities().get(0).getId()); + + assertDoesNotThrow(() -> userApi.deleteUser(username1)); + assertDoesNotThrow(() -> userApi.deleteUser(username2)); + try { + groupApi.deleteGroup(groupId); + } catch (ApiException ignored) { + } + } + + /** + * 修改子区 + * + * 分页获取应用下的子区列表。文档介绍:https://docs-im-beta.easemob.com/document/server-side/group.html#%E4%BF%AE%E6%94%B9%E5%AD%90%E5%8C%BA + * + * @throws ApiException if the Api call fails + */ + @Test + public void modifyThreadTest() throws ApiException { + String username1 = randomUserName(); + String username2 = randomUserName(); + String password = "123456"; + + List emCreateUserList = new ArrayList<>(); + EMCreateUser createUser1 = new EMCreateUser(); + createUser1.setUsername(username1); + createUser1.setPassword(password); + + EMCreateUser createUser2 = new EMCreateUser(); + createUser2.setUsername(username2); + createUser2.setPassword(password); + + emCreateUserList.add(createUser1); + emCreateUserList.add(createUser2); + + assertDoesNotThrow(() -> userApi.createUsers(emCreateUserList)); + + EMCreateGroup createGroup = new EMCreateGroup(); + createGroup.setOwner(username1); + createGroup.setGroupname("test-group"); + createGroup.setDescription("元梦之星"); + createGroup.setMaxusers(200); + createGroup.setMembers(Arrays.asList(username2)); + createGroup.setPublic(true); + + EMCreateGroupResult createGroupResult = + assertDoesNotThrow(() -> groupApi.createGroup(createGroup)); + assertNotNull(createGroupResult); + assertNotNull(createGroupResult.getData()); + assertNotNull(createGroupResult.getData().getGroupid()); + + String groupId = createGroupResult.getData().getGroupid(); + + EMCreateMessage emCreateMessage = new EMCreateMessage(); + emCreateMessage.setFrom(username1); + emCreateMessage.setTo(new ArrayList(){{add(groupId);}}); + emCreateMessage.setType("txt"); + EMMessageContent messageContent = new EMMessageContent(); + messageContent.setMsg("test message"); + emCreateMessage.setBody(messageContent); + + EMSendMessageResult response = messageApi.sendMessagesToGroup(emCreateMessage); + assertNotNull(response.getData()); + Map data = (Map) response.getData(); + + String messageId = data.get(groupId).toString(); + + EMCreateThread createThread = new EMCreateThread(); + createThread.setGroupId(groupId); + createThread.setOwner(username2); + createThread.setMsgId(messageId); + createThread.setName("test-thread"); + + EMCreateThreadResult createThreadResult = + assertDoesNotThrow(() -> api.createThread(createThread)); + assertNotNull(createThreadResult); + assertNotNull(createThreadResult.getData()); + assertNotNull(createThreadResult.getData().getThreadId()); + + String threadId = createThreadResult.getData().getThreadId(); + + EMModifyThread modifyThread = new EMModifyThread(); + modifyThread.setName("modify thread name"); + + EMModifyThreadResult modifyThreadResult = + assertDoesNotThrow(() -> api.modifyThread(threadId, modifyThread)); + assertNotNull(modifyThreadResult); + assertNotNull(modifyThreadResult.getData()); + assertEquals("modify thread name", modifyThreadResult.getData().getName()); + + assertDoesNotThrow(() -> userApi.deleteUser(username1)); + assertDoesNotThrow(() -> userApi.deleteUser(username2)); + try { + groupApi.deleteGroup(groupId); + } catch (ApiException ignored) { + } + } + + /** + * 批量踢出子区成员 + * + * 批量踢出子区成员。文档介绍:https://docs-im-beta.easemob.com/document/server-side/group.html#%E6%89%B9%E9%87%8F%E8%B8%A2%E5%87%BA%E5%AD%90%E5%8C%BA%E6%88%90%E5%91%98 + * + * @throws ApiException if the Api call fails + */ + @Test + public void removeMultipleUsersFromThreadTest() throws ApiException { + String username1 = randomUserName(); + String username2 = randomUserName(); + String password = "123456"; + + List emCreateUserList = new ArrayList<>(); + EMCreateUser createUser1 = new EMCreateUser(); + createUser1.setUsername(username1); + createUser1.setPassword(password); + + EMCreateUser createUser2 = new EMCreateUser(); + createUser2.setUsername(username2); + createUser2.setPassword(password); + + emCreateUserList.add(createUser1); + emCreateUserList.add(createUser2); + + assertDoesNotThrow(() -> userApi.createUsers(emCreateUserList)); + + EMCreateGroup createGroup = new EMCreateGroup(); + createGroup.setOwner(username1); + createGroup.setGroupname("test-group"); + createGroup.setDescription("元梦之星"); + createGroup.setMaxusers(200); + createGroup.setMembers(Arrays.asList(username2)); + createGroup.setPublic(true); + + EMCreateGroupResult createGroupResult = + assertDoesNotThrow(() -> groupApi.createGroup(createGroup)); + assertNotNull(createGroupResult); + assertNotNull(createGroupResult.getData()); + assertNotNull(createGroupResult.getData().getGroupid()); + + String groupId = createGroupResult.getData().getGroupid(); + + EMCreateMessage emCreateMessage = new EMCreateMessage(); + emCreateMessage.setFrom(username1); + emCreateMessage.setTo(new ArrayList(){{add(groupId);}}); + emCreateMessage.setType("txt"); + EMMessageContent messageContent = new EMMessageContent(); + messageContent.setMsg("test message"); + emCreateMessage.setBody(messageContent); + + EMSendMessageResult response = messageApi.sendMessagesToGroup(emCreateMessage); + assertNotNull(response.getData()); + Map data = (Map) response.getData(); + + String messageId = data.get(groupId).toString(); + + EMCreateThread createThread = new EMCreateThread(); + createThread.setGroupId(groupId); + createThread.setOwner(username1); + createThread.setMsgId(messageId); + createThread.setName("test-thread"); + + EMCreateThreadResult createThreadResult = + assertDoesNotThrow(() -> api.createThread(createThread)); + assertNotNull(createThreadResult); + assertNotNull(createThreadResult.getData()); + assertNotNull(createThreadResult.getData().getThreadId()); + + String threadId = createThreadResult.getData().getThreadId(); + + EMAddMultipleUsersToThread addMultipleUsersToThread = new EMAddMultipleUsersToThread(); + addMultipleUsersToThread.setUsernames(Arrays.asList(username2)); + + EMAddMultipleUsersToThreadResult addMultipleUsersToThreadResult = + assertDoesNotThrow(() -> api.addMultipleUsersToThread(threadId, addMultipleUsersToThread)); + assertNotNull(addMultipleUsersToThreadResult); + assertNotNull(addMultipleUsersToThreadResult.getData()); + assertEquals("ok", addMultipleUsersToThreadResult.getData().getStatus()); + + EMRemoveMultipleUsersFromThread removeMultipleUsersFromThread = new EMRemoveMultipleUsersFromThread(); + removeMultipleUsersFromThread.setUsernames(Arrays.asList(username2)); + + EMRemoveMultipleUsersFromThreadResult removeMultipleUsersFromThreadResult = + assertDoesNotThrow(() -> api.removeMultipleUsersFromThread(threadId, removeMultipleUsersFromThread)); + assertNotNull(removeMultipleUsersFromThreadResult); + assertNotNull(removeMultipleUsersFromThreadResult.getEntities()); + assertEquals(true, removeMultipleUsersFromThreadResult.getEntities().get(0).getResult()); + + assertDoesNotThrow(() -> userApi.deleteUser(username1)); + assertDoesNotThrow(() -> userApi.deleteUser(username2)); + try { + groupApi.deleteGroup(groupId); + } catch (ApiException ignored) { + } + } + +} diff --git a/src/test/java/com/easemob/im/api/TokenApiTest.java b/src/test/java/com/easemob/im/api/TokenApiTest.java new file mode 100644 index 000000000..2658dfaeb --- /dev/null +++ b/src/test/java/com/easemob/im/api/TokenApiTest.java @@ -0,0 +1,109 @@ +/* + * EMService + * Easemob Rest API + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.easemob.im.api; + +import com.easemob.im.ApiException; +import com.easemob.im.api.model.EMCreateToken; +import com.easemob.im.api.model.EMCreateUser; +import com.easemob.im.api.model.EMGetToken; +import org.junit.jupiter.api.Test; + +import java.util.ArrayList; +import java.util.List; + +import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; +import static org.junit.jupiter.api.Assertions.assertNotNull; + +/** + * API tests for TokenApi + */ +public class TokenApiTest extends AbstractTest { + + private final TokenApi tokenApi = new TokenApi(); + + private final UserApi userApi = new UserApi(); + + public TokenApiTest() { + } + + /** + * 获取管理员 Token + *

+ * 管理员权限 Token 可以用来调用环信 Rest API 接口,获取管理员 Token 文档介绍:https://docs-im-beta.easemob.com/document/server-side/easemob_app_token.html + * + * @throws ApiException if the Api call fails + */ + @Test + public void getTokenTest() throws ApiException { + EMCreateToken emCreateAppToken = new EMCreateToken(); + emCreateAppToken.setGrantType("client_credentials"); + emCreateAppToken.setClientId("YXA6a1jQXZnASMeiRB_z6Vo9wA"); + emCreateAppToken.setClientSecret("YXA6LDJ_YHmppwgccxHNEZmyMnjWy1E"); + EMGetToken appToken = assertDoesNotThrow(() -> tokenApi.getToken(emCreateAppToken)); + assertNotNull(appToken.getAccessToken()); + } + + /** + * 根据用户名和密码获取用户 Token + *

+ * 获取用户 Token 文档介绍:https://docs-im-beta.easemob.com/document/server-side/easemob_user_token.html + * + * @throws ApiException if the Api call fails + */ + @Test + public void getUserTokenWithUsernameAndPasswordTest() throws ApiException { + String username = randomUserName(); + String password = "123456"; + + List emCreateUserList = new ArrayList<>(); + EMCreateUser createUser = new EMCreateUser(); + createUser.setUsername(username); + createUser.setPassword(password); + + emCreateUserList.add(createUser); + + assertDoesNotThrow(() -> userApi.createUsers(emCreateUserList)); + + EMCreateToken emCreateUserToken = new EMCreateToken(); + emCreateUserToken.setGrantType("password"); + emCreateUserToken.setUsername(username); + emCreateUserToken.setPassword(password); + EMGetToken userToken = assertDoesNotThrow(() -> tokenApi.getToken(emCreateUserToken)); + assertNotNull(userToken.getAccessToken()); + + assertDoesNotThrow(() -> userApi.deleteUser(username)); + } + + /** + * 根据用户名获取用户 Token + *

+ * 获取用户 Token 文档介绍:https://docs-im-beta.easemob.com/document/server-side/easemob_user_token.html + * + * @throws ApiException if the Api call fails + */ + @Test + public void getUserTokenWithUsernameTest() throws ApiException { + String username = randomUserName(); + + EMCreateToken emCreateUserToken = new EMCreateToken(); + emCreateUserToken.setGrantType("inherit"); + emCreateUserToken.setUsername(username); + emCreateUserToken.setAutoCreateUser(true); + EMGetToken userToken = assertDoesNotThrow(() -> tokenApi.getToken(emCreateUserToken)); + assertNotNull(userToken.getAccessToken()); + + assertDoesNotThrow(() -> userApi.deleteUser(username)); + } + +} diff --git a/src/test/java/com/easemob/im/api/UserApiTest.java b/src/test/java/com/easemob/im/api/UserApiTest.java new file mode 100644 index 000000000..53632a0d2 --- /dev/null +++ b/src/test/java/com/easemob/im/api/UserApiTest.java @@ -0,0 +1,595 @@ +/* + * EMService + * Easemob Rest API + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.easemob.im.api; + +import com.easemob.im.ApiException; +import com.easemob.im.api.model.*; +import org.junit.jupiter.api.Test; + +import java.util.ArrayList; +import java.util.List; +import java.util.Map; + +import static org.junit.jupiter.api.Assertions.*; + +/** + * API tests for UserApi + */ +public class UserApiTest extends AbstractTest { + + private final UserApi api = new UserApi(); + + public UserApiTest() { + } + + /** + * 批量注册用户 + *

+ * 文档介绍:https://docs-im-beta.easemob.com/document/server-side/account_system.html#%E6%89%B9%E9%87%8F%E6%B3%A8%E5%86%8C%E7%94%A8%E6%88%B7 + * + * @throws ApiException if the Api call fails + */ + @Test + public void createUsersTest() throws ApiException { + String username1 = randomUserName(); + String username2 = randomUserName(); + String username3 = randomUserName(); + String password = "123456"; + + List emCreateUserList = new ArrayList<>(); + EMCreateUser createUser1 = new EMCreateUser(); + createUser1.setUsername(username1); + createUser1.setPassword(password); + + EMCreateUser createUser2 = new EMCreateUser(); + createUser2.setUsername(username2); + createUser2.setPassword(password); + + EMCreateUser createUser3 = new EMCreateUser(); + createUser3.setUsername(username3); + createUser3.setPassword(password); + + emCreateUserList.add(createUser1); + emCreateUserList.add(createUser2); + emCreateUserList.add(createUser3); + + EMCreateUsersResult result = assertDoesNotThrow(() -> api.createUsers(emCreateUserList)); + assertNotNull(result.getEntities()); + assertEquals(3, result.getEntities().size()); + + assertDoesNotThrow(() -> api.deleteUser(username1)); + assertDoesNotThrow(() -> api.deleteUser(username2)); + assertDoesNotThrow(() -> api.deleteUser(username3)); + } + + /** + * 删除用户账号 + *

+ * 删除单个用户。如果该用户是群主或者聊天室所有者,系统会同时删除对应的群组和聊天室。文档介绍:https://docs-im-beta.easemob.com/document/server-side/account_system.html#%E5%88%A0%E9%99%A4%E5%8D%95%E4%B8%AA%E7%94%A8%E6%88%B7 + * + * @throws ApiException if the Api call fails + */ + @Test + public void deleteUserTest() throws ApiException { + String username = randomUserName(); + String password = "123456"; + + List emCreateUserList = new ArrayList<>(); + EMCreateUser createUser = new EMCreateUser(); + createUser.setUsername(username); + createUser.setPassword(password); + emCreateUserList.add(createUser); + + assertDoesNotThrow(() -> api.createUsers(emCreateUserList)); + assertDoesNotThrow(() -> api.deleteUser(username)); + } + + /** + * 批量删除用户 + *

+ * 删除某个 App 下指定数量的用户账号。建议一次删除的用户数量不要超过100。需要注意的是,这里只指定了要删除的用户数量,并未指定要删除的具体用户,你可以在响应中查看删除的用户。文档介绍:https://docs-im-beta.easemob.com/document/server-side/account_system.html#%E6%89%B9%E9%87%8F%E8%8E%B7%E5%8F%96%E7%94%A8%E6%88%B7%E8%AF%A6%E6%83%85 + * + * @throws ApiException if the Api call fails + */ + @Test + public void deleteUsersTest() throws ApiException { + String username1 = randomUserName(); + String username2 = randomUserName(); + String password = "123456"; + + List emCreateUserList = new ArrayList<>(); + EMCreateUser createUser1 = new EMCreateUser(); + createUser1.setUsername(username1); + createUser1.setPassword(password); + + EMCreateUser createUser2 = new EMCreateUser(); + createUser2.setUsername(username2); + createUser2.setPassword(password); + + emCreateUserList.add(createUser1); + emCreateUserList.add(createUser2); + + assertDoesNotThrow(() -> api.createUsers(emCreateUserList)); + + Integer limit = 1; + EMDeleteUsersResult result = assertDoesNotThrow(() -> api.deleteUsers(limit, null)); + assertDoesNotThrow(() -> api.deleteUsers(limit, result.getCursor())); + assertDoesNotThrow(() -> api.deleteUser(username1)); + assertDoesNotThrow(() -> api.deleteUser(username2)); + + } + + /** + * 强制下线 + *

+ * 强制用户即将用户状态改为离线,用户需要重新登录才能正常使用。文档介绍:https://docs-im-beta.easemob.com/document/server-side/account_system.html#%E5%BC%BA%E5%88%B6%E4%B8%8B%E7%BA%BF + * + * @throws ApiException if the Api call fails + */ + @Test + public void forceUserLogoutTest() throws ApiException { + String username = randomUserName(); + String password = "123456"; + + List emCreateUserList = new ArrayList<>(); + EMCreateUser createUser = new EMCreateUser(); + createUser.setUsername(username); + createUser.setPassword(password); + emCreateUserList.add(createUser); + + assertDoesNotThrow(() -> api.createUsers(emCreateUserList)); + + EMForceUserLogoutResult result = assertDoesNotThrow(() -> api.forceUserLogout(username)); + assertNotNull(result.getData()); + assertEquals(true, result.getData().getResult()); + assertDoesNotThrow(() -> api.deleteUser(username)); + } + + /** + * 查询 app 下的所有全局禁言的用户 + *

+ * 该方法查询 app 下所有全局禁言的用户及其禁言剩余时间。文档介绍:https://docs-im-beta.easemob.com/document/server-side/account_system.html#%E6%9F%A5%E8%AF%A2-app-%E4%B8%8B%E7%9A%84%E6%89%80%E6%9C%89%E5%85%A8%E5%B1%80%E7%A6%81%E8%A8%80%E7%9A%84%E7%94%A8%E6%88%B7 + * + * @throws ApiException if the Api call fails + */ + @Test + public void getAllGloballyMutedUsersTest() throws ApiException { + String username1 = randomUserName(); + String username2 = randomUserName(); + String password = "123456"; + + List emCreateUserList = new ArrayList<>(); + EMCreateUser createUser1 = new EMCreateUser(); + createUser1.setUsername(username1); + createUser1.setPassword(password); + + EMCreateUser createUser2 = new EMCreateUser(); + createUser2.setUsername(username2); + createUser2.setPassword(password); + + emCreateUserList.add(createUser1); + emCreateUserList.add(createUser2); + + assertDoesNotThrow(() -> api.createUsers(emCreateUserList)); + + EMSetUserGlobalMute emSetUserGlobalMute1 = new EMSetUserGlobalMute(); + emSetUserGlobalMute1.username(username1); + emSetUserGlobalMute1.chat(1000); + + EMSetUserGlobalMute emSetUserGlobalMute2 = new EMSetUserGlobalMute(); + emSetUserGlobalMute2.username(username2); + emSetUserGlobalMute2.chat(1000); + + EMSetUserGlobalMuteResult emSetUserGlobalMuteResult = + assertDoesNotThrow(() -> api.setUserGlobalMute(emSetUserGlobalMute1)); + assertNotNull(emSetUserGlobalMuteResult.getData()); + assertEquals("ok", emSetUserGlobalMuteResult.getData().getResult()); + assertDoesNotThrow(() -> api.setUserGlobalMute(emSetUserGlobalMute2)); + + EMGetAllGloballyMutedUsersResult result = + assertDoesNotThrow(() -> api.getAllGloballyMutedUsers(1, 10)); + assertNotNull(result.getData()); + assertNotNull(result.getData().getData()); + + assertDoesNotThrow(() -> api.deleteUser(username1)); + assertDoesNotThrow(() -> api.deleteUser(username2)); + } + + /** + * 获取指定离线消息的投递状态 + *

+ * 获取用户的指定离线消息的投递状态,即查看该消息是否已投递。文档介绍:https://docs-im-beta.easemob.com/document/server-side/account_system.html#%E8%8E%B7%E5%8F%96%E6%8C%87%E5%AE%9A%E7%A6%BB%E7%BA%BF%E6%B6%88%E6%81%AF%E7%9A%84%E6%8A%95%E9%80%92%E7%8A%B6%E6%80%81 + * + * @throws ApiException if the Api call fails + */ + @Test + public void getOfflineMessageStatusTest() throws ApiException { + String username1 = randomUserName(); + String username2 = randomUserName(); + String password = "123456"; + + List emCreateUserList = new ArrayList<>(); + EMCreateUser createUser1 = new EMCreateUser(); + createUser1.setUsername(username1); + createUser1.setPassword(password); + + EMCreateUser createUser2 = new EMCreateUser(); + createUser2.setUsername(username2); + createUser2.setPassword(password); + + emCreateUserList.add(createUser1); + emCreateUserList.add(createUser2); + + assertDoesNotThrow(() -> api.createUsers(emCreateUserList)); + + EMGetOfflineMessageStatusResult result = + assertDoesNotThrow(() -> api.getOfflineMessageStatus(username1, "12903244353")); + assertNotNull(result.getData()); + + assertDoesNotThrow(() -> api.deleteUser(username1)); + assertDoesNotThrow(() -> api.deleteUser(username2)); + } + + /** + * 获取用户详情 + *

+ * 文档介绍:https://docs-im-beta.easemob.com/document/server-side/account_system.html#%E8%8E%B7%E5%8F%96%E5%8D%95%E4%B8%AA%E7%94%A8%E6%88%B7%E7%9A%84%E8%AF%A6%E6%83%85 + * + * @throws ApiException if the Api call fails + */ + @Test + public void getUserTest() throws ApiException { + String username = randomUserName(); + String password = "123456"; + + List emCreateUserList = new ArrayList<>(); + EMCreateUser createUser = new EMCreateUser(); + createUser.setUsername(username); + createUser.setPassword(password); + + emCreateUserList.add(createUser); + + assertDoesNotThrow(() -> api.createUsers(emCreateUserList)); + + EMGetUserResult result = assertDoesNotThrow(() -> api.getUser(username)); + assertNotNull(result.getEntities()); + assertEquals(username, result.getEntities().get(0).getUsername()); + assertEquals(true, result.getEntities().get(0).getActivated()); + + assertDoesNotThrow(() -> api.deleteUser(username)); + } + + /** + * 查询单个用户 ID 全局禁言 + *

+ * 查询单个用户的单聊、群聊和聊天室的全局禁言详情。文档介绍:https://docs-im-beta.easemob.com/document/server-side/account_system.html#%E6%9F%A5%E8%AF%A2%E5%8D%95%E4%B8%AA%E7%94%A8%E6%88%B7-id-%E5%85%A8%E5%B1%80%E7%A6%81%E8%A8%80 + * + * @throws ApiException if the Api call fails + */ + @Test + public void getUserGlobalMuteTest() throws ApiException { + String username = randomUserName(); + String password = "123456"; + + List emCreateUserList = new ArrayList<>(); + EMCreateUser createUser = new EMCreateUser(); + createUser.setUsername(username); + createUser.setPassword(password); + + emCreateUserList.add(createUser); + + assertDoesNotThrow(() -> api.createUsers(emCreateUserList)); + + EMSetUserGlobalMute emSetUserGlobalMute = new EMSetUserGlobalMute(); + emSetUserGlobalMute.username(username); + emSetUserGlobalMute.chat(1000); + + EMSetUserGlobalMuteResult emSetUserGlobalMuteResult = + assertDoesNotThrow(() -> api.setUserGlobalMute(emSetUserGlobalMute)); + assertNotNull(emSetUserGlobalMuteResult.getData()); + assertEquals("ok", emSetUserGlobalMuteResult.getData().getResult()); + + EMGetUserGlobalMuteResult result = + assertDoesNotThrow(() -> api.getUserGlobalMute(username)); + assertNotNull(result.getData()); + assertNotNull(result.getData().getChat()); + + assertDoesNotThrow(() -> api.deleteUser(username)); + } + + /** + * 获取用户离线消息数量 + *

+ * 文档介绍:https://docs-im-beta.easemob.com/document/server-side/account_system.html#%E8%8E%B7%E5%8F%96%E7%94%A8%E6%88%B7%E7%A6%BB%E7%BA%BF%E6%B6%88%E6%81%AF%E6%95%B0%E9%87%8F + * + * @throws ApiException if the Api call fails + */ + @Test + public void getUserOfflineMessageCountTest() throws ApiException { + String username = randomUserName(); + String password = "123456"; + + List emCreateUserList = new ArrayList<>(); + EMCreateUser createUser = new EMCreateUser(); + createUser.setUsername(username); + createUser.setPassword(password); + + emCreateUserList.add(createUser); + + assertDoesNotThrow(() -> api.createUsers(emCreateUserList)); + + EMGetUserOfflineMessageCountResult result = + assertDoesNotThrow(() -> api.getUserOfflineMessageCount(username)); + assertNotNull(result.getData()); + Map map = (Map) result.getData(); + assertEquals(0, ((Number) map.get(username)).intValue()); + + assertDoesNotThrow(() -> api.deleteUser(username)); + } + + /** + * 获取指定账号的在线登录设备列表 + *

+ * 多设备登录情况下,你可以调用该接口获取指定账号的在线登录设备列表。文档介绍:https://docs-im-beta.easemob.com/document/server-side/account_system.html#%E8%8E%B7%E5%8F%96%E6%8C%87%E5%AE%9A%E8%B4%A6%E5%8F%B7%E7%9A%84%E5%9C%A8%E7%BA%BF%E7%99%BB%E5%BD%95%E8%AE%BE%E5%A4%87%E5%88%97%E8%A1%A8 + * + * @throws ApiException if the Api call fails + */ + @Test + public void getUserOnlineLoginDeviceListTest() throws ApiException { + String username = randomUserName(); + String password = "123456"; + + List emCreateUserList = new ArrayList<>(); + EMCreateUser createUser = new EMCreateUser(); + createUser.setUsername(username); + createUser.setPassword(password); + + emCreateUserList.add(createUser); + + assertDoesNotThrow(() -> api.createUsers(emCreateUserList)); + + EMGetUserOnlineLoginDeviceListResult result = + assertDoesNotThrow(() -> api.getUserOnlineLoginDeviceList(username)); + assertNotNull(result.getData()); + + assertDoesNotThrow(() -> api.deleteUser(username)); + } + + /** + * 获取单个用户在线状态 + *

+ * 查看单个用户是在线还是离线状态。文档介绍:https://docs-im-beta.easemob.com/document/server-side/account_system.html#%E8%8E%B7%E5%8F%96%E5%8D%95%E4%B8%AA%E7%94%A8%E6%88%B7%E5%9C%A8%E7%BA%BF%E7%8A%B6%E6%80%81 + * + * @throws ApiException if the Api call fails + */ + @Test + public void getUserOnlineStateTest() throws ApiException { + String username = randomUserName(); + String password = "123456"; + + List emCreateUserList = new ArrayList<>(); + EMCreateUser createUser = new EMCreateUser(); + createUser.setUsername(username); + createUser.setPassword(password); + + emCreateUserList.add(createUser); + + assertDoesNotThrow(() -> api.createUsers(emCreateUserList)); + + EMGetUserOnlineStateResult result = + assertDoesNotThrow(() -> api.getUserOnlineState(username)); + assertNotNull(result.getData()); + assertEquals("offline", ((Map) result.getData()).get(username)); + + assertDoesNotThrow(() -> api.deleteUser(username)); + } + + /** + * 获取用户列表 + *

+ * 该接口查询多个用户的信息列表,按照用户创建时间顺序返回。文档介绍:https://docs-im-beta.easemob.com/document/server-side/account_system.html#%E6%89%B9%E9%87%8F%E8%8E%B7%E5%8F%96%E7%94%A8%E6%88%B7%E8%AF%A6%E6%83%85 + * + * @throws ApiException if the Api call fails + */ + @Test + public void getUsersTest() throws ApiException { + String username1 = randomUserName(); + String username2 = randomUserName(); + String password = "123456"; + + List emCreateUserList = new ArrayList<>(); + EMCreateUser createUser1 = new EMCreateUser(); + createUser1.setUsername(username1); + createUser1.setPassword(password); + + EMCreateUser createUser2 = new EMCreateUser(); + createUser2.setUsername(username2); + createUser2.setPassword(password); + + emCreateUserList.add(createUser1); + emCreateUserList.add(createUser2); + + assertDoesNotThrow(() -> api.createUsers(emCreateUserList)); + + EMGetUsersResult result = + assertDoesNotThrow(() -> api.getUsers(1, null)); + assertNotNull(result.getEntities()); + + assertDoesNotThrow(() -> api.getUsers(1, result.getCursor())); + + assertDoesNotThrow(() -> api.deleteUser(username1)); + assertDoesNotThrow(() -> api.deleteUser(username2)); + } + + /** + * 批量获取用户在线状态 + *

+ * 批量查看用户是在线还是离线状态,单次请求最多可查看 100 个用户的在线状态。文档介绍:https://docs-im-beta.easemob.com/document/server-side/account_system.html#%E6%89%B9%E9%87%8F%E8%8E%B7%E5%8F%96%E7%94%A8%E6%88%B7%E5%9C%A8%E7%BA%BF%E7%8A%B6%E6%80%81 + * + * @throws ApiException if the Api call fails + */ + @Test + public void getUsersOnlineStateTest() throws ApiException { + String username1 = randomUserName(); + String username2 = randomUserName(); + String password = "123456"; + + List emCreateUserList = new ArrayList<>(); + EMCreateUser createUser1 = new EMCreateUser(); + createUser1.setUsername(username1); + createUser1.setPassword(password); + + EMCreateUser createUser2 = new EMCreateUser(); + createUser2.setUsername(username2); + createUser2.setPassword(password); + + emCreateUserList.add(createUser1); + emCreateUserList.add(createUser2); + + assertDoesNotThrow(() -> api.createUsers(emCreateUserList)); + + EMGetUsersOnlineState emGetUsersOnlineState = new EMGetUsersOnlineState(); + emGetUsersOnlineState.addUsernamesItem(username1); + emGetUsersOnlineState.addUsernamesItem(username2); + + EMGetUsersOnlineStateResult result = + assertDoesNotThrow(() -> api.getUsersOnlineState(emGetUsersOnlineState)); + assertNotNull(result.getData()); + assertEquals(2, result.getData().size()); + + assertDoesNotThrow(() -> api.deleteUser(username1)); + assertDoesNotThrow(() -> api.deleteUser(username2)); + } + + /** + * 修改用户密码 + *

+ * 通过服务端接口修改用户的登录密码,不需要提供原密码。文档介绍:https://docs-im-beta.easemob.com/document/server-side/account_system.html#%E4%BF%AE%E6%94%B9%E7%94%A8%E6%88%B7%E5%AF%86%E7%A0%81 + * + * @throws ApiException if the Api call fails + */ + @Test + public void modifyUserPasswordTest() throws ApiException { + String username = randomUserName(); + String password = "123456"; + + List emCreateUserList = new ArrayList<>(); + EMCreateUser createUser = new EMCreateUser(); + createUser.setUsername(username); + createUser.setPassword(password); + + emCreateUserList.add(createUser); + + assertDoesNotThrow(() -> api.createUsers(emCreateUserList)); + + EMModifyUserPassword emModifyUserPassword = new EMModifyUserPassword(); + emModifyUserPassword.setNewpassword("456789"); + + assertDoesNotThrow(() -> api.modifyUserPassword(username, emModifyUserPassword)); + + assertDoesNotThrow(() -> api.deleteUser(username)); + } + + /** + * 设置用户全局禁言 + *

+ * 设置单个用户 ID 的单聊、群组或聊天室消息的全局禁言。设置成功后,该用户将无法在对应的单聊、群组或聊天室中发送消息。文档介绍:https://docs-im-beta.easemob.com/document/server-side/account_system.html#%E7%94%A8%E6%88%B7%E5%85%A8%E5%B1%80%E7%A6%81%E8%A8%80 + * + * @throws ApiException if the Api call fails + */ + @Test + public void setUserGlobalMuteTest() throws ApiException { + String username = randomUserName(); + String password = "123456"; + + List emCreateUserList = new ArrayList<>(); + EMCreateUser createUser = new EMCreateUser(); + createUser.setUsername(username); + createUser.setPassword(password); + + emCreateUserList.add(createUser); + + assertDoesNotThrow(() -> api.createUsers(emCreateUserList)); + + EMSetUserGlobalMute emSetUserGlobalMute = new EMSetUserGlobalMute(); + emSetUserGlobalMute.setUsername(username); + emSetUserGlobalMute.setChat(1000); + + EMSetUserGlobalMuteResult result = + assertDoesNotThrow(() -> api.setUserGlobalMute(emSetUserGlobalMute)); + assertNotNull(result.getData()); + assertEquals("ok", result.getData().getResult()); + + assertDoesNotThrow(() -> api.deleteUser(username)); + } + + /** + * 账号解禁 + *

+ * 被解禁后用户才能恢复登录。文档介绍:https://docs-im-beta.easemob.com/document/server-side/account_system.html#%E8%B4%A6%E5%8F%B7%E8%A7%A3%E7%A6%81 + * + * @throws ApiException if the Api call fails + */ + @Test + public void userActivateTest() throws ApiException { + String username = randomUserName(); + String password = "123456"; + + List emCreateUserList = new ArrayList<>(); + EMCreateUser createUser = new EMCreateUser(); + createUser.setUsername(username); + createUser.setPassword(password); + + emCreateUserList.add(createUser); + + assertDoesNotThrow(() -> api.createUsers(emCreateUserList)); + + assertDoesNotThrow(() -> api.userActivate(username)); + EMGetUserResult result = assertDoesNotThrow(() -> api.getUser(username)); + assertNotNull(result.getEntities()); + assertEquals(true, result.getEntities().get(0).getActivated()); + + assertDoesNotThrow(() -> api.deleteUser(username)); + } + + /** + * 账号封禁 + *

+ * 环信即时通讯 IM 提供了对用户的禁用以及解禁接口操作,用户若被禁用将立即下线并无法登录进入环信即时通讯 IM,直到被解禁后才能恢复登录。常用在对异常用户的即时处理场景使用。文档介绍:https://docs-im-beta.easemob.com/document/server-side/account_system.html#%E8%B4%A6%E5%8F%B7%E5%B0%81%E7%A6%81 + * + * @throws ApiException if the Api call fails + */ + @Test + public void userDeactivateTest() throws ApiException { + String username = randomUserName(); + String password = "123456"; + + List emCreateUserList = new ArrayList<>(); + EMCreateUser createUser = new EMCreateUser(); + createUser.setUsername(username); + createUser.setPassword(password); + + emCreateUserList.add(createUser); + + assertDoesNotThrow(() -> api.createUsers(emCreateUserList)); + + assertDoesNotThrow(() -> api.userDeactivate(username)); + EMGetUserResult result = assertDoesNotThrow(() -> api.getUser(username)); + assertNotNull(result.getEntities()); + assertEquals(false, result.getEntities().get(0).getActivated()); + + assertDoesNotThrow(() -> api.deleteUser(username)); + } + +} diff --git a/src/test/resources/upload/blue.png b/src/test/resources/upload/blue.png new file mode 100644 index 000000000..279bd2c21 Binary files /dev/null and b/src/test/resources/upload/blue.png differ