-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add modify user push nicknames and send message example
- Loading branch information
Showing
12 changed files
with
2,506 additions
and
128 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
219 changes: 219 additions & 0 deletions
219
src/main/java/com/easemob/im/api/model/EMModifyPushNickname.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,219 @@ | ||
/* | ||
* EMService | ||
* Easemob Rest API | ||
* | ||
* The version of the OpenAPI document: 1.0.0 | ||
* | ||
* | ||
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). | ||
* https://openapi-generator.tech | ||
* Do not edit the class manually. | ||
*/ | ||
|
||
|
||
package com.easemob.im.api.model; | ||
|
||
import 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; | ||
|
||
/** | ||
* EMModifyPushNickname | ||
*/ | ||
@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-06-24T17:32:21.382715+08:00[Asia/Shanghai]") | ||
public class EMModifyPushNickname { | ||
public static final String SERIALIZED_NAME_USERNAME = "username"; | ||
@SerializedName(SERIALIZED_NAME_USERNAME) | ||
private String username; | ||
|
||
public static final String SERIALIZED_NAME_PUSH_NICKNAME = "push_nickname"; | ||
@SerializedName(SERIALIZED_NAME_PUSH_NICKNAME) | ||
private String pushNickname; | ||
|
||
public EMModifyPushNickname() { | ||
} | ||
|
||
public EMModifyPushNickname username(String username) { | ||
|
||
this.username = username; | ||
return this; | ||
} | ||
|
||
/** | ||
* 用户 ID,长度不可超过 64 字节 | ||
* @return username | ||
**/ | ||
@javax.annotation.Nullable | ||
public String getUsername() { | ||
return username; | ||
} | ||
|
||
|
||
public void setUsername(String username) { | ||
this.username = username; | ||
} | ||
|
||
|
||
public EMModifyPushNickname pushNickname(String pushNickname) { | ||
|
||
this.pushNickname = pushNickname; | ||
return this; | ||
} | ||
|
||
/** | ||
* 离线推送时在接收方的客户端推送通知栏中显示的发送方的昵称。你可以自定义该昵称,长度不能超过 100 个字符。 | ||
* @return pushNickname | ||
**/ | ||
@javax.annotation.Nullable | ||
public String getPushNickname() { | ||
return pushNickname; | ||
} | ||
|
||
|
||
public void setPushNickname(String pushNickname) { | ||
this.pushNickname = pushNickname; | ||
} | ||
|
||
|
||
|
||
@Override | ||
public boolean equals(Object o) { | ||
if (this == o) { | ||
return true; | ||
} | ||
if (o == null || getClass() != o.getClass()) { | ||
return false; | ||
} | ||
EMModifyPushNickname modifyPushNickname = (EMModifyPushNickname) o; | ||
return Objects.equals(this.username, modifyPushNickname.username) && | ||
Objects.equals(this.pushNickname, modifyPushNickname.pushNickname); | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
return Objects.hash(username, pushNickname); | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
StringBuilder sb = new StringBuilder(); | ||
sb.append("class EMModifyPushNickname {\n"); | ||
sb.append(" username: ").append(toIndentedString(username)).append("\n"); | ||
sb.append(" pushNickname: ").append(toIndentedString(pushNickname)).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<String> openapiFields; | ||
public static HashSet<String> openapiRequiredFields; | ||
|
||
static { | ||
// a set of all properties/fields (JSON key names) | ||
openapiFields = new HashSet<String>(); | ||
openapiFields.add("username"); | ||
openapiFields.add("push_nickname"); | ||
|
||
// a set of required properties/fields (JSON key names) | ||
openapiRequiredFields = new HashSet<String>(); | ||
} | ||
|
||
/** | ||
* 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 EMModifyPushNickname | ||
*/ | ||
public static void validateJsonElement(JsonElement jsonElement) throws IOException { | ||
if (jsonElement == null) { | ||
if (!EMModifyPushNickname.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null | ||
throw new IllegalArgumentException(String.format("The required field(s) %s in EMModifyPushNickname is not found in the empty JSON string", EMModifyPushNickname.openapiRequiredFields.toString())); | ||
} | ||
} | ||
|
||
Set<Map.Entry<String, JsonElement>> entries = jsonElement.getAsJsonObject().entrySet(); | ||
// check to see if the JSON string contains additional fields | ||
for (Map.Entry<String, JsonElement> entry : entries) { | ||
if (!EMModifyPushNickname.openapiFields.contains(entry.getKey())) { | ||
throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `EMModifyPushNickname` properties. JSON: %s", entry.getKey(), jsonElement.toString())); | ||
} | ||
} | ||
JsonObject jsonObj = jsonElement.getAsJsonObject(); | ||
if ((jsonObj.get("username") != null && !jsonObj.get("username").isJsonNull()) && !jsonObj.get("username").isJsonPrimitive()) { | ||
throw new IllegalArgumentException(String.format("Expected the field `username` to be a primitive type in the JSON string but got `%s`", jsonObj.get("username").toString())); | ||
} | ||
if ((jsonObj.get("push_nickname") != null && !jsonObj.get("push_nickname").isJsonNull()) && !jsonObj.get("push_nickname").isJsonPrimitive()) { | ||
throw new IllegalArgumentException(String.format("Expected the field `push_nickname` to be a primitive type in the JSON string but got `%s`", jsonObj.get("push_nickname").toString())); | ||
} | ||
} | ||
|
||
public static class CustomTypeAdapterFactory implements TypeAdapterFactory { | ||
@SuppressWarnings("unchecked") | ||
@Override | ||
public <T> TypeAdapter<T> create(Gson gson, TypeToken<T> type) { | ||
if (!EMModifyPushNickname.class.isAssignableFrom(type.getRawType())) { | ||
return null; // this class only serializes 'EMModifyPushNickname' and its subtypes | ||
} | ||
final TypeAdapter<JsonElement> elementAdapter = gson.getAdapter(JsonElement.class); | ||
final TypeAdapter<EMModifyPushNickname> thisAdapter | ||
= gson.getDelegateAdapter(this, TypeToken.get(EMModifyPushNickname.class)); | ||
|
||
return (TypeAdapter<T>) new TypeAdapter<EMModifyPushNickname>() { | ||
@Override | ||
public void write(JsonWriter out, EMModifyPushNickname value) throws IOException { | ||
JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); | ||
elementAdapter.write(out, obj); | ||
} | ||
|
||
@Override | ||
public EMModifyPushNickname read(JsonReader in) throws IOException { | ||
JsonElement jsonElement = elementAdapter.read(in); | ||
validateJsonElement(jsonElement); | ||
return thisAdapter.fromJsonTree(jsonElement); | ||
} | ||
|
||
}.nullSafe(); | ||
} | ||
} | ||
|
||
/** | ||
* Create an instance of EMModifyPushNickname given an JSON string | ||
* | ||
* @param jsonString JSON string | ||
* @return An instance of EMModifyPushNickname | ||
* @throws IOException if the JSON string is invalid with respect to EMModifyPushNickname | ||
*/ | ||
public static EMModifyPushNickname fromJson(String jsonString) throws IOException { | ||
return JSON.getGson().fromJson(jsonString, EMModifyPushNickname.class); | ||
} | ||
|
||
/** | ||
* Convert an instance of EMModifyPushNickname to an JSON string | ||
* | ||
* @return JSON string | ||
*/ | ||
public String toJson() { | ||
return JSON.getGson().toJson(this); | ||
} | ||
} | ||
|
Oops, something went wrong.