diff --git a/src/main/java/com/easemob/im/api/MessageApi.java b/src/main/java/com/easemob/im/api/MessageApi.java index b278ad45..82d3c736 100644 --- a/src/main/java/com/easemob/im/api/MessageApi.java +++ b/src/main/java/com/easemob/im/api/MessageApi.java @@ -341,6 +341,290 @@ private okhttp3.Call oneWayDeleteConversationValidateBeforeCall(String username, } + /** + * Build call for oneWayClearUserRoamingMessagesByMsgId + * @param username 用户 ID (required) + * @param userId 单聊会话中的对端用户 ID (required) + * @param msgIdList 要删除的消息的消息 ID。每次最多可传入 50 个消息 ID,消息 ID 之间以英文逗号分隔,例如 message ID 1,message ID 2 (required) + * @param isNotify 消息删除后,是否同步到消息所属用户的所有在线设备。- (默认)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 + */ + public okhttp3.Call oneWayClearUserRoamingMessagesByMsgIdCall(String username, String userId, String msgIdList, Boolean isNotify, 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 = "/rest/message/roaming/chat/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 (userId != null) { + localVarQueryParams.addAll(localVarApiClient.parameterToPair("userId", userId)); + } + + if (msgIdList != null) { + localVarQueryParams.addAll(localVarApiClient.parameterToPair("msgIdList", msgIdList)); + } + + if (isNotify != null) { + localVarQueryParams.addAll(localVarApiClient.parameterToPair("isNotify", isNotify)); + } + + 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 oneWayClearUserRoamingMessagesByMsgIdValidateBeforeCall(String username, String userId, String msgIdList, Boolean isNotify, 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 oneWayClearUserRoamingMessagesByMsgId(Async)"); + } + + // verify the required parameter 'userId' is set + if (userId == null) { + throw new ApiException("Missing the required parameter 'userId' when calling oneWayClearUserRoamingMessagesByMsgId(Async)"); + } + + // verify the required parameter 'msgIdList' is set + if (msgIdList == null) { + throw new ApiException("Missing the required parameter 'msgIdList' when calling oneWayClearUserRoamingMessagesByMsgId(Async)"); + } + + return oneWayClearUserRoamingMessagesByMsgIdCall(username, userId, msgIdList, isNotify, _callback); + + } + + /** + * 根据消息 ID 单向删除单聊漫游消息 + * 根据消息 ID 单向删除指定用户的单聊会话的一条或多条漫游消息。调用该接口后,该用户的指定漫游消息会从服务器和本地删除,该用户无法从环信服务端拉取到这些消息。若该会话的全部漫游消息均被删除了,该用户的这个会话在服务端也会被清除,拉取会话列表时拉不到该会话。不过,其他用户不受影响,仍然可以拉取与该用户的漫游消息和会话。文档介绍:https://doc.easemob.com/document/server-side/message_delete.html#%E6%A0%B9%E6%8D%AE%E6%B6%88%E6%81%AF-id-%E5%8D%95%E5%90%91%E5%88%A0%E9%99%A4%E5%8D%95%E8%81%8A%E6%BC%AB%E6%B8%B8%E6%B6%88%E6%81%AF + * @param username 用户 ID (required) + * @param userId 单聊会话中的对端用户 ID (required) + * @param msgIdList 要删除的消息的消息 ID。每次最多可传入 50 个消息 ID,消息 ID 之间以英文逗号分隔,例如 message ID 1,message ID 2 (required) + * @param isNotify 消息删除后,是否同步到消息所属用户的所有在线设备。- (默认)true:是 - false:否 (optional) + * @return EMOneWayClearUserRoamingMessagesByMsgIdResult + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * http.response.details + */ + public EMOneWayClearUserRoamingMessagesByMsgIdResult oneWayClearUserRoamingMessagesByMsgId(String username, String userId, String msgIdList, Boolean isNotify) throws ApiException { + ApiResponse localVarResp = oneWayClearUserRoamingMessagesByMsgIdWithHttpInfo(username, userId, msgIdList, isNotify); + return localVarResp.getData(); + } + + /** + * 根据消息 ID 单向删除单聊漫游消息 + * 根据消息 ID 单向删除指定用户的单聊会话的一条或多条漫游消息。调用该接口后,该用户的指定漫游消息会从服务器和本地删除,该用户无法从环信服务端拉取到这些消息。若该会话的全部漫游消息均被删除了,该用户的这个会话在服务端也会被清除,拉取会话列表时拉不到该会话。不过,其他用户不受影响,仍然可以拉取与该用户的漫游消息和会话。文档介绍:https://doc.easemob.com/document/server-side/message_delete.html#%E6%A0%B9%E6%8D%AE%E6%B6%88%E6%81%AF-id-%E5%8D%95%E5%90%91%E5%88%A0%E9%99%A4%E5%8D%95%E8%81%8A%E6%BC%AB%E6%B8%B8%E6%B6%88%E6%81%AF + * @param username 用户 ID (required) + * @param userId 单聊会话中的对端用户 ID (required) + * @param msgIdList 要删除的消息的消息 ID。每次最多可传入 50 个消息 ID,消息 ID 之间以英文逗号分隔,例如 message ID 1,message ID 2 (required) + * @param isNotify 消息删除后,是否同步到消息所属用户的所有在线设备。- (默认)true:是 - false:否 (optional) + * @return ApiResponse<EMOneWayClearUserRoamingMessagesByMsgIdResult> + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * http.response.details + */ + public ApiResponse oneWayClearUserRoamingMessagesByMsgIdWithHttpInfo(String username, String userId, String msgIdList, Boolean isNotify) throws ApiException { + okhttp3.Call localVarCall = oneWayClearUserRoamingMessagesByMsgIdValidateBeforeCall(username, userId, msgIdList, isNotify, null); + Type localVarReturnType = new TypeToken(){}.getType(); + return localVarApiClient.execute(localVarCall, localVarReturnType); + } + + /** + * 根据消息 ID 单向删除单聊漫游消息 (asynchronously) + * 根据消息 ID 单向删除指定用户的单聊会话的一条或多条漫游消息。调用该接口后,该用户的指定漫游消息会从服务器和本地删除,该用户无法从环信服务端拉取到这些消息。若该会话的全部漫游消息均被删除了,该用户的这个会话在服务端也会被清除,拉取会话列表时拉不到该会话。不过,其他用户不受影响,仍然可以拉取与该用户的漫游消息和会话。文档介绍:https://doc.easemob.com/document/server-side/message_delete.html#%E6%A0%B9%E6%8D%AE%E6%B6%88%E6%81%AF-id-%E5%8D%95%E5%90%91%E5%88%A0%E9%99%A4%E5%8D%95%E8%81%8A%E6%BC%AB%E6%B8%B8%E6%B6%88%E6%81%AF + * @param username 用户 ID (required) + * @param userId 单聊会话中的对端用户 ID (required) + * @param msgIdList 要删除的消息的消息 ID。每次最多可传入 50 个消息 ID,消息 ID 之间以英文逗号分隔,例如 message ID 1,message ID 2 (required) + * @param isNotify 消息删除后,是否同步到消息所属用户的所有在线设备。- (默认)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 + */ + public okhttp3.Call oneWayClearUserRoamingMessagesByMsgIdAsync(String username, String userId, String msgIdList, Boolean isNotify, final ApiCallback _callback) throws ApiException { + + okhttp3.Call localVarCall = oneWayClearUserRoamingMessagesByMsgIdValidateBeforeCall(username, userId, msgIdList, isNotify, _callback); + Type localVarReturnType = new TypeToken(){}.getType(); + localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); + return localVarCall; + } + + /** + * Build call for oneWayClearGroupRoamingMessagesByMsgId + * @param username 用户 ID (required) + * @param groupId 群组 ID (required) + * @param msgIdList 要删除的消息的消息 ID。每次最多可传入 50 个消息 ID,消息 ID 之间以英文逗号分隔,例如 message ID 1,message ID 2 (required) + * @param isNotify 消息删除后,是否同步到消息所属用户的所有在线设备。- (默认)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 + */ + public okhttp3.Call oneWayClearGroupRoamingMessagesByMsgIdCall(String username, String groupId, String msgIdList, Boolean isNotify, 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 = "/rest/message/roaming/group/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 (groupId != null) { + localVarQueryParams.addAll(localVarApiClient.parameterToPair("groupId", groupId)); + } + + if (msgIdList != null) { + localVarQueryParams.addAll(localVarApiClient.parameterToPair("msgIdList", msgIdList)); + } + + if (isNotify != null) { + localVarQueryParams.addAll(localVarApiClient.parameterToPair("isNotify", isNotify)); + } + + 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 oneWayClearGroupRoamingMessagesByMsgIdValidateBeforeCall(String username, String groupId, String msgIdList, Boolean isNotify, 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 oneWayClearGroupRoamingMessagesByMsgId(Async)"); + } + + // verify the required parameter 'groupId' is set + if (groupId == null) { + throw new ApiException("Missing the required parameter 'groupId' when calling oneWayClearGroupRoamingMessagesByMsgId(Async)"); + } + + // verify the required parameter 'msgIdList' is set + if (msgIdList == null) { + throw new ApiException("Missing the required parameter 'msgIdList' when calling oneWayClearGroupRoamingMessagesByMsgId(Async)"); + } + + return oneWayClearGroupRoamingMessagesByMsgIdCall(username, groupId, msgIdList, isNotify, _callback); + + } + + /** + * 根据消息 ID 单向删除群聊漫游消息 + * 根据消息 ID 单向删除指定用户的某个群聊会话的一条或多条漫游消息。调用该接口后,该用户的指定漫游消息会从服务器和本地删除,该用户无法从环信服务端拉取到这些消息。若删除了该群聊会话的全部漫游消息,该用户的这个会话在服务端也会被清除,拉取会话列表时拉不到该会话。不过,其他用户不受影响,仍然可以拉取这些漫游消息和会话。文档介绍:https://doc.easemob.com/document/server-side/message_delete.html#%E6%A0%B9%E6%8D%AE%E6%B6%88%E6%81%AF-id-%E5%8D%95%E5%90%91%E5%88%A0%E9%99%A4%E7%BE%A4%E8%81%8A%E6%BC%AB%E6%B8%B8%E6%B6%88%E6%81%AF + * @param username 用户 ID (required) + * @param groupId 群组 ID (required) + * @param msgIdList 要删除的消息的消息 ID。每次最多可传入 50 个消息 ID,消息 ID 之间以英文逗号分隔,例如 message ID 1,message ID 2 (required) + * @param isNotify 消息删除后,是否同步到消息所属用户的所有在线设备。- (默认)true:是 - false:否 (optional) + * @return EMOneWayClearGroupRoamingMessagesByMsgIdResult + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * http.response.details + */ + public EMOneWayClearGroupRoamingMessagesByMsgIdResult oneWayClearGroupRoamingMessagesByMsgId(String username, String groupId, String msgIdList, Boolean isNotify) throws ApiException { + ApiResponse localVarResp = oneWayClearGroupRoamingMessagesByMsgIdWithHttpInfo(username, groupId, msgIdList, isNotify); + return localVarResp.getData(); + } + + /** + * 根据消息 ID 单向删除群聊漫游消息 + * 根据消息 ID 单向删除指定用户的某个群聊会话的一条或多条漫游消息。调用该接口后,该用户的指定漫游消息会从服务器和本地删除,该用户无法从环信服务端拉取到这些消息。若删除了该群聊会话的全部漫游消息,该用户的这个会话在服务端也会被清除,拉取会话列表时拉不到该会话。不过,其他用户不受影响,仍然可以拉取这些漫游消息和会话。文档介绍:https://doc.easemob.com/document/server-side/message_delete.html#%E6%A0%B9%E6%8D%AE%E6%B6%88%E6%81%AF-id-%E5%8D%95%E5%90%91%E5%88%A0%E9%99%A4%E7%BE%A4%E8%81%8A%E6%BC%AB%E6%B8%B8%E6%B6%88%E6%81%AF + * @param username 用户 ID (required) + * @param groupId 群组 ID (required) + * @param msgIdList 要删除的消息的消息 ID。每次最多可传入 50 个消息 ID,消息 ID 之间以英文逗号分隔,例如 message ID 1,message ID 2 (required) + * @param isNotify 消息删除后,是否同步到消息所属用户的所有在线设备。- (默认)true:是 - false:否 (optional) + * @return ApiResponse<EMOneWayClearGroupRoamingMessagesByMsgIdResult> + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * http.response.details + */ + public ApiResponse oneWayClearGroupRoamingMessagesByMsgIdWithHttpInfo(String username, String groupId, String msgIdList, Boolean isNotify) throws ApiException { + okhttp3.Call localVarCall = oneWayClearGroupRoamingMessagesByMsgIdValidateBeforeCall(username, groupId, msgIdList, isNotify, null); + Type localVarReturnType = new TypeToken(){}.getType(); + return localVarApiClient.execute(localVarCall, localVarReturnType); + } + + /** + * 根据消息 ID 单向删除群聊漫游消息 (asynchronously) + * 根据消息 ID 单向删除指定用户的某个群聊会话的一条或多条漫游消息。调用该接口后,该用户的指定漫游消息会从服务器和本地删除,该用户无法从环信服务端拉取到这些消息。若删除了该群聊会话的全部漫游消息,该用户的这个会话在服务端也会被清除,拉取会话列表时拉不到该会话。不过,其他用户不受影响,仍然可以拉取这些漫游消息和会话。文档介绍:https://doc.easemob.com/document/server-side/message_delete.html#%E6%A0%B9%E6%8D%AE%E6%B6%88%E6%81%AF-id-%E5%8D%95%E5%90%91%E5%88%A0%E9%99%A4%E7%BE%A4%E8%81%8A%E6%BC%AB%E6%B8%B8%E6%B6%88%E6%81%AF + * @param username 用户 ID (required) + * @param groupId 群组 ID (required) + * @param msgIdList 要删除的消息的消息 ID。每次最多可传入 50 个消息 ID,消息 ID 之间以英文逗号分隔,例如 message ID 1,message ID 2 (required) + * @param isNotify 消息删除后,是否同步到消息所属用户的所有在线设备。- (默认)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 + */ + public okhttp3.Call oneWayClearGroupRoamingMessagesByMsgIdAsync(String username, String groupId, String msgIdList, Boolean isNotify, final ApiCallback _callback) throws ApiException { + + okhttp3.Call localVarCall = oneWayClearGroupRoamingMessagesByMsgIdValidateBeforeCall(username, groupId, msgIdList, isNotify, _callback); + Type localVarReturnType = new TypeToken(){}.getType(); + localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); + return localVarCall; + } + /** * 单向删除会话 * 该方法使聊天用户能够从服务器中删除会话。删除会话后,该用户将从服务器获取不到该会话。该会话的其他参与聊天用户仍然可以从服务器获取会话内容。文档介绍: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 diff --git a/src/main/java/com/easemob/im/api/model/EMCreateGroup.java b/src/main/java/com/easemob/im/api/model/EMCreateGroup.java index 77e61221..a574e336 100644 --- a/src/main/java/com/easemob/im/api/model/EMCreateGroup.java +++ b/src/main/java/com/easemob/im/api/model/EMCreateGroup.java @@ -16,36 +16,21 @@ 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; @@ -54,518 +39,551 @@ /** * EMCreateGroup */ -@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-07-29T15:02:31.237631+08:00[Asia/Shanghai]") +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-09-19T17:22:04.272445+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_AVATAR = "avatar"; - @SerializedName(SERIALIZED_NAME_AVATAR) - private String avatar; - - 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 avatar(String avatar) { - - this.avatar = avatar; - return this; - } - - /** - * 群组头像的 URL,最大长度为 1024 字符 - * - * @return avatar - **/ - @javax.annotation.Nullable - public String getAvatar() { - return avatar; - } - - public void setAvatar(String avatar) { - this.avatar = avatar; - } - - 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; - } - - /** - * 用户申请入群是否需要群主或者群管理员审批。 - true:需要; - (默认)false:不需要,用户直接进群。 该参数仅对公开群生效,因为对于私有群,用户无法申请加入群组,只能通过群成员邀请加入群 - * - * @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.avatar, createGroup.avatar) && - 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, avatar, 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(" avatar: ").append(toIndentedString(avatar)).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("avatar"); - 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("avatar") != null && !jsonObj.get("avatar").isJsonNull()) && !jsonObj.get( - "avatar").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format( - "Expected the field `avatar` to be a primitive type in the JSON string but got `%s`", - jsonObj.get("avatar").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") + public static final String SERIALIZED_NAME_GROUPID = "groupid"; + @SerializedName(SERIALIZED_NAME_GROUPID) + private String groupid; + + public static final String SERIALIZED_NAME_GROUPNAME = "groupname"; + @SerializedName(SERIALIZED_NAME_GROUPNAME) + private String groupname; + + public static final String SERIALIZED_NAME_AVATAR = "avatar"; + @SerializedName(SERIALIZED_NAME_AVATAR) + private String avatar; + + 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 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 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 avatar(String avatar) { + + this.avatar = avatar; + return this; + } + + /** + * 群组头像的 URL,最大长度为 1024 字符 + * + * @return avatar + **/ + @javax.annotation.Nullable + public String getAvatar() { + return avatar; + } + + public void setAvatar(String avatar) { + this.avatar = avatar; + } + + 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; + } + + /** + * 用户申请入群是否需要群主或者群管理员审批。 - true:需要; - (默认)false:不需要,用户直接进群。 该参数仅对公开群生效,因为对于私有群,用户无法申请加入群组,只能通过群成员邀请加入群 + * + * @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 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); + 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.groupid, createGroup.groupid) && + Objects.equals(this.groupname, createGroup.groupname) && + Objects.equals(this.avatar, createGroup.avatar) && + 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(groupid, groupname, avatar, 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(" groupid: ").append(toIndentedString(groupid)).append("\n"); + sb.append(" groupname: ").append(toIndentedString(groupname)).append("\n"); + sb.append(" avatar: ").append(toIndentedString(avatar)).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("groupid"); + openapiFields.add("groupname"); + openapiFields.add("avatar"); + 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("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("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("avatar") != null && !jsonObj.get("avatar").isJsonNull()) && !jsonObj.get( + "avatar").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format( + "Expected the field `avatar` to be a primitive type in the JSON string but got `%s`", + jsonObj.get("avatar").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 EMCreateGroup read(JsonReader in) throws IOException { - JsonElement jsonElement = elementAdapter.read(in); - validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + 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); + } - }.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); - } + /** + * 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/EMCreateRoom.java b/src/main/java/com/easemob/im/api/model/EMCreateRoom.java index dc5d43a4..6dd27ebd 100644 --- a/src/main/java/com/easemob/im/api/model/EMCreateRoom.java +++ b/src/main/java/com/easemob/im/api/model/EMCreateRoom.java @@ -3,7 +3,7 @@ * Easemob Rest API * * The version of the OpenAPI document: 1.0.0 - * + * * * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). * https://openapi-generator.tech @@ -14,35 +14,23 @@ 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; @@ -51,331 +39,374 @@ /** * EMCreateRoom */ -@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-01-25T14:51:53.998371+08:00[Asia/Shanghai]") +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-09-19T17:22:04.272445+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 static final String SERIALIZED_NAME_GROUPID = "groupid"; + @SerializedName(SERIALIZED_NAME_GROUPID) + private String groupid; + + 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 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 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) { - - 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())); + 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; + } - 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())); + 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.groupid, createRoom.groupid) && + 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(groupid, name, description, maxusers, owner, members, custom); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class EMCreateRoom {\n"); + sb.append(" groupid: ").append(toIndentedString(groupid)).append("\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(); + } - // 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())); + /** + * 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"); + 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); - } + 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("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/EMOneWayClearGroupRoamingMessagesByMsgIdResult.java b/src/main/java/com/easemob/im/api/model/EMOneWayClearGroupRoamingMessagesByMsgIdResult.java new file mode 100644 index 00000000..8750a30c --- /dev/null +++ b/src/main/java/com/easemob/im/api/model/EMOneWayClearGroupRoamingMessagesByMsgIdResult.java @@ -0,0 +1,188 @@ +/* + * EMService + * Easemob Rest API + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class 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.JSON; +import com.google.gson.*; +import com.google.gson.annotations.SerializedName; +import com.google.gson.reflect.TypeToken; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; + +import java.io.IOException; +import java.util.HashSet; +import java.util.Map; +import java.util.Objects; +import java.util.Set; + +/** + * EMOneWayClearGroupRoamingMessagesByMsgIdResult + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-09-19T17:22:04.272445+08:00[Asia/Shanghai]") +public class EMOneWayClearGroupRoamingMessagesByMsgIdResult { + public static final String SERIALIZED_NAME_REQUEST_STATUS_CODE = "requestStatusCode"; + @SerializedName(SERIALIZED_NAME_REQUEST_STATUS_CODE) + private String requestStatusCode; + + public EMOneWayClearGroupRoamingMessagesByMsgIdResult() { + } + + public EMOneWayClearGroupRoamingMessagesByMsgIdResult requestStatusCode(String requestStatusCode) { + + this.requestStatusCode = requestStatusCode; + return this; + } + + /** + * Get requestStatusCode + * @return requestStatusCode + **/ + @javax.annotation.Nullable + public String getRequestStatusCode() { + return requestStatusCode; + } + + + public void setRequestStatusCode(String requestStatusCode) { + this.requestStatusCode = requestStatusCode; + } + + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + EMOneWayClearGroupRoamingMessagesByMsgIdResult oneWayClearGroupRoamingMessagesByMsgIdResult = (EMOneWayClearGroupRoamingMessagesByMsgIdResult) o; + return Objects.equals(this.requestStatusCode, oneWayClearGroupRoamingMessagesByMsgIdResult.requestStatusCode); + } + + @Override + public int hashCode() { + return Objects.hash(requestStatusCode); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class EMOneWayClearGroupRoamingMessagesByMsgIdResult {\n"); + sb.append(" requestStatusCode: ").append(toIndentedString(requestStatusCode)).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("requestStatusCode"); + + // 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 EMOneWayClearGroupRoamingMessagesByMsgIdResult + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!EMOneWayClearGroupRoamingMessagesByMsgIdResult.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format("The required field(s) %s in EMOneWayClearGroupRoamingMessagesByMsgIdResult is not found in the empty JSON string", EMOneWayClearGroupRoamingMessagesByMsgIdResult.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!EMOneWayClearGroupRoamingMessagesByMsgIdResult.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `EMOneWayClearGroupRoamingMessagesByMsgIdResult` properties. JSON: %s", entry.getKey(), jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + if ((jsonObj.get("requestStatusCode") != null && !jsonObj.get("requestStatusCode").isJsonNull()) && !jsonObj.get("requestStatusCode").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `requestStatusCode` to be a primitive type in the JSON string but got `%s`", jsonObj.get("requestStatusCode").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!EMOneWayClearGroupRoamingMessagesByMsgIdResult.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'EMOneWayClearGroupRoamingMessagesByMsgIdResult' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(EMOneWayClearGroupRoamingMessagesByMsgIdResult.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, EMOneWayClearGroupRoamingMessagesByMsgIdResult value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public EMOneWayClearGroupRoamingMessagesByMsgIdResult read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + return thisAdapter.fromJsonTree(jsonElement); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of EMOneWayClearGroupRoamingMessagesByMsgIdResult given an JSON string + * + * @param jsonString JSON string + * @return An instance of EMOneWayClearGroupRoamingMessagesByMsgIdResult + * @throws IOException if the JSON string is invalid with respect to EMOneWayClearGroupRoamingMessagesByMsgIdResult + */ + public static EMOneWayClearGroupRoamingMessagesByMsgIdResult fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, EMOneWayClearGroupRoamingMessagesByMsgIdResult.class); + } + + /** + * Convert an instance of EMOneWayClearGroupRoamingMessagesByMsgIdResult 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/EMOneWayClearUserRoamingMessagesByMsgIdResult.java b/src/main/java/com/easemob/im/api/model/EMOneWayClearUserRoamingMessagesByMsgIdResult.java new file mode 100644 index 00000000..da4af757 --- /dev/null +++ b/src/main/java/com/easemob/im/api/model/EMOneWayClearUserRoamingMessagesByMsgIdResult.java @@ -0,0 +1,188 @@ +/* + * EMService + * Easemob Rest API + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class 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.JSON; +import com.google.gson.*; +import com.google.gson.annotations.SerializedName; +import com.google.gson.reflect.TypeToken; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; + +import java.io.IOException; +import java.util.HashSet; +import java.util.Map; +import java.util.Objects; +import java.util.Set; + +/** + * EMOneWayClearUserRoamingMessagesByMsgIdResult + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-09-19T17:22:04.272445+08:00[Asia/Shanghai]") +public class EMOneWayClearUserRoamingMessagesByMsgIdResult { + public static final String SERIALIZED_NAME_REQUEST_STATUS_CODE = "requestStatusCode"; + @SerializedName(SERIALIZED_NAME_REQUEST_STATUS_CODE) + private String requestStatusCode; + + public EMOneWayClearUserRoamingMessagesByMsgIdResult() { + } + + public EMOneWayClearUserRoamingMessagesByMsgIdResult requestStatusCode(String requestStatusCode) { + + this.requestStatusCode = requestStatusCode; + return this; + } + + /** + * Get requestStatusCode + * @return requestStatusCode + **/ + @javax.annotation.Nullable + public String getRequestStatusCode() { + return requestStatusCode; + } + + + public void setRequestStatusCode(String requestStatusCode) { + this.requestStatusCode = requestStatusCode; + } + + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + EMOneWayClearUserRoamingMessagesByMsgIdResult oneWayClearUserRoamingMessagesByMsgIdResult = (EMOneWayClearUserRoamingMessagesByMsgIdResult) o; + return Objects.equals(this.requestStatusCode, oneWayClearUserRoamingMessagesByMsgIdResult.requestStatusCode); + } + + @Override + public int hashCode() { + return Objects.hash(requestStatusCode); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class EMOneWayClearUserRoamingMessagesByMsgIdResult {\n"); + sb.append(" requestStatusCode: ").append(toIndentedString(requestStatusCode)).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("requestStatusCode"); + + // 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 EMOneWayClearUserRoamingMessagesByMsgIdResult + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!EMOneWayClearUserRoamingMessagesByMsgIdResult.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format("The required field(s) %s in EMOneWayClearUserRoamingMessagesByMsgIdResult is not found in the empty JSON string", EMOneWayClearUserRoamingMessagesByMsgIdResult.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!EMOneWayClearUserRoamingMessagesByMsgIdResult.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `EMOneWayClearUserRoamingMessagesByMsgIdResult` properties. JSON: %s", entry.getKey(), jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + if ((jsonObj.get("requestStatusCode") != null && !jsonObj.get("requestStatusCode").isJsonNull()) && !jsonObj.get("requestStatusCode").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `requestStatusCode` to be a primitive type in the JSON string but got `%s`", jsonObj.get("requestStatusCode").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!EMOneWayClearUserRoamingMessagesByMsgIdResult.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'EMOneWayClearUserRoamingMessagesByMsgIdResult' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(EMOneWayClearUserRoamingMessagesByMsgIdResult.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, EMOneWayClearUserRoamingMessagesByMsgIdResult value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public EMOneWayClearUserRoamingMessagesByMsgIdResult read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + return thisAdapter.fromJsonTree(jsonElement); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of EMOneWayClearUserRoamingMessagesByMsgIdResult given an JSON string + * + * @param jsonString JSON string + * @return An instance of EMOneWayClearUserRoamingMessagesByMsgIdResult + * @throws IOException if the JSON string is invalid with respect to EMOneWayClearUserRoamingMessagesByMsgIdResult + */ + public static EMOneWayClearUserRoamingMessagesByMsgIdResult fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, EMOneWayClearUserRoamingMessagesByMsgIdResult.class); + } + + /** + * Convert an instance of EMOneWayClearUserRoamingMessagesByMsgIdResult to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/test/java/com/easemob/im/api/GroupApiTest.java b/src/test/java/com/easemob/im/api/GroupApiTest.java index 50fa78fb..dd9d1759 100644 --- a/src/test/java/com/easemob/im/api/GroupApiTest.java +++ b/src/test/java/com/easemob/im/api/GroupApiTest.java @@ -593,6 +593,89 @@ public void createGroupTest() throws ApiException { } } + /** + * 创建群组,自定义群组id + *

+ * 创建一个群组,并设置自定义群组id、群组名称、群组描述、公开群/私有群属性、群成员最大人数(包括群主)、加入公开群是否需要批准、群主、群成员和群组扩展信息。文档介绍: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 customIdCreateGroupTest() throws ApiException { + String username1 = randomUserName(); + String username2 = randomUserName(); + String password = "123456"; + String customGroupId = "123456666"; + String groupAvatar1 = "https://example.com/avatar1.png"; + String groupAvatar2 = "https://example.com/avatar2.png"; + + 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.setGroupid(customGroupId); + createGroup.setOwner(username1); + createGroup.setGroupname("test-group"); + createGroup.setAvatar(groupAvatar1); + 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()); + assertEquals(customGroupId, createGroupResult.getData().getGroupid()); + + String groupId = createGroupResult.getData().getGroupid(); + + EMGetGroupInfoResult groupInfoResult1 = + assertDoesNotThrow(() -> api.getGroupInfo(groupId)); + assertNotNull(groupInfoResult1); + assertNotNull(groupInfoResult1.getData()); + assertNotNull(groupInfoResult1.getData().get(0)); + assertEquals(groupAvatar1, groupInfoResult1.getData().get(0).getAvatar()); + + EMModifyGroup modifyGroup = new EMModifyGroup(); + modifyGroup.setAvatar(groupAvatar2); + + assertDoesNotThrow(() -> api.modifyGroup(groupId, modifyGroup)); + + EMGetGroupInfoResult groupInfoResult2 = + assertDoesNotThrow(() -> api.getGroupInfo(groupId)); + assertNotNull(groupInfoResult2); + assertNotNull(groupInfoResult2.getData()); + assertNotNull(groupInfoResult2.getData().get(0)); + assertEquals(groupAvatar2, groupInfoResult2.getData().get(0).getAvatar()); + + EMGetUserJoinedGroupsResult getUserJoinedGroupsResult = + assertDoesNotThrow(() -> api.getUserJoinedGroups(username1, 0, 1)); + assertNotNull(getUserJoinedGroupsResult); + assertNotNull(getUserJoinedGroupsResult.getEntities()); + assertNotNull(getUserJoinedGroupsResult.getEntities().get(0)); + assertEquals(groupAvatar2, getUserJoinedGroupsResult.getEntities().get(0).getAvatar()); + + 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/MessageApiTest.java b/src/test/java/com/easemob/im/api/MessageApiTest.java index a9055e3c..8a7017dd 100644 --- a/src/test/java/com/easemob/im/api/MessageApiTest.java +++ b/src/test/java/com/easemob/im/api/MessageApiTest.java @@ -2294,6 +2294,122 @@ public void modifyTextOrCustomizeMessageTest() throws ApiException { } + /** + * 根据消息 ID 单向删除单聊漫游消息 + * + * 根据消息 ID 单向删除指定用户的单聊会话的一条或多条漫游消息。调用该接口后,该用户的指定漫游消息会从服务器和本地删除,该用户无法从环信服务端拉取到这些消息。若该会话的全部漫游消息均被删除了,该用户的这个会话在服务端也会被清除,拉取会话列表时拉不到该会话。不过,其他用户不受影响,仍然可以拉取与该用户的漫游消息和会话。文档介绍:https://doc.easemob.com/document/server-side/message_delete.html#%E6%A0%B9%E6%8D%AE%E6%B6%88%E6%81%AF-id-%E5%8D%95%E5%90%91%E5%88%A0%E9%99%A4%E5%8D%95%E8%81%8A%E6%BC%AB%E6%B8%B8%E6%B6%88%E6%81%AF + * + * @throws ApiException if the Api call fails + */ + @Test + public void oneWayClearUserRoamingMessagesByMsgIdTest() 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(Collections.singletonList(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(); + String messageId = data.get(username2); + + EMOneWayClearUserRoamingMessagesByMsgIdResult result = messageApi.oneWayClearUserRoamingMessagesByMsgId(username1, username2, messageId, true); + assertNotNull(result.getRequestStatusCode()); + assertEquals("ok", result.getRequestStatusCode()); + + assertDoesNotThrow(() -> userApi.deleteUser(username1)); + assertDoesNotThrow(() -> userApi.deleteUser(username2)); + } + + /** + * 根据消息 ID 单向删除群聊漫游消息 + * + * 根据消息 ID 单向删除指定用户的某个群聊会话的一条或多条漫游消息。调用该接口后,该用户的指定漫游消息会从服务器和本地删除,该用户无法从环信服务端拉取到这些消息。若删除了该群聊会话的全部漫游消息,该用户的这个会话在服务端也会被清除,拉取会话列表时拉不到该会话。不过,其他用户不受影响,仍然可以拉取这些漫游消息和会话。文档介绍:https://doc.easemob.com/document/server-side/message_delete.html#%E6%A0%B9%E6%8D%AE%E6%B6%88%E6%81%AF-id-%E5%8D%95%E5%90%91%E5%88%A0%E9%99%A4%E7%BE%A4%E8%81%8A%E6%BC%AB%E6%B8%B8%E6%B6%88%E6%81%AF + * + * @throws ApiException if the Api call fails + */ + @Test + public void oneWayClearGroupRoamingMessagesByMsgIdTest() 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(Collections.singletonList(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); + + EMOneWayClearGroupRoamingMessagesByMsgIdResult result = messageApi.oneWayClearGroupRoamingMessagesByMsgId(username1, groupId, messageId, true); + assertNotNull(result.getRequestStatusCode()); + assertEquals("ok", result.getRequestStatusCode()); + + 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/RoomApiTest.java b/src/test/java/com/easemob/im/api/RoomApiTest.java index fc4cffca..f0e63ed2 100644 --- a/src/test/java/com/easemob/im/api/RoomApiTest.java +++ b/src/test/java/com/easemob/im/api/RoomApiTest.java @@ -492,6 +492,56 @@ public void createRoomTest() { try {api.deleteRoom(roomId);} catch (ApiException ignored) {} } + /** + * 创建聊天室,自定义聊天室id + * + * 创建一个聊天室,需设置自定义聊天室id、聊天室名称、聊天室描述、聊天室成员最大人数(包括管理员)、聊天室管理员和普通成员以及聊天室扩展信息。文档介绍: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 customIdCreateRoomTest() { + String username1 = randomUserName(); + String username2 = randomUserName(); + String password = "123456"; + String customRoomId = "125666999"; + + 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.setGroupid(customRoomId); + 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()); + assertEquals(customRoomId, createRoomResult.getData().getId()); + + String roomId = createRoomResult.getData().getId(); + + assertDoesNotThrow(() -> userApi.deleteUser(username1)); + assertDoesNotThrow(() -> userApi.deleteUser(username2)); + try {api.deleteRoom(roomId);} catch (ApiException ignored) {} + } + /** * 删除聊天室 *