Skip to content

Commit

Permalink
Add push & presence & reaction api
Browse files Browse the repository at this point in the history
  • Loading branch information
FuDongHai committed Feb 19, 2024
1 parent ab6c15c commit 1fba5bd
Show file tree
Hide file tree
Showing 48 changed files with 14,008 additions and 6 deletions.
945 changes: 945 additions & 0 deletions src/main/java/com/easemob/im/api/PresenceApi.java

Large diffs are not rendered by default.

1,586 changes: 1,586 additions & 0 deletions src/main/java/com/easemob/im/api/PushApi.java

Large diffs are not rendered by default.

710 changes: 710 additions & 0 deletions src/main/java/com/easemob/im/api/ReactionApi.java

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,270 @@
/*
* EMService
* Easemob Rest API
*
* The version of the OpenAPI document: 1.0.0
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/


package com.easemob.im.api.model;

import java.util.Objects;
import com.google.gson.TypeAdapter;
import com.google.gson.annotations.JsonAdapter;
import com.google.gson.annotations.SerializedName;
import com.google.gson.stream.JsonReader;
import com.google.gson.stream.JsonWriter;
import java.io.IOException;
import java.util.Arrays;

import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.JsonArray;
import com.google.gson.JsonDeserializationContext;
import com.google.gson.JsonDeserializer;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import com.google.gson.JsonParseException;
import com.google.gson.TypeAdapterFactory;
import com.google.gson.reflect.TypeToken;
import com.google.gson.TypeAdapter;
import com.google.gson.stream.JsonReader;
import com.google.gson.stream.JsonWriter;
import java.io.IOException;

import java.lang.reflect.Type;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;

import com.easemob.im.JSON;

/**
* EMCreateOfflinePushTemplate
*/
@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-02-19T14:46:11.706022+08:00[Asia/Shanghai]")
public class EMCreateOfflinePushTemplate {
public static final String SERIALIZED_NAME_NAME = "name";
@SerializedName(SERIALIZED_NAME_NAME)
private String name;

public static final String SERIALIZED_NAME_TITLE_PATTERN = "title_pattern";
@SerializedName(SERIALIZED_NAME_TITLE_PATTERN)
private String titlePattern;

public static final String SERIALIZED_NAME_CONTENT_PATTERN = "content_pattern";
@SerializedName(SERIALIZED_NAME_CONTENT_PATTERN)
private String contentPattern;

public EMCreateOfflinePushTemplate() {
}

public EMCreateOfflinePushTemplate name(String name) {

this.name = name;
return this;
}

/**
* 要添加的推送模板的名称。模板名称最多可包含 64 个字符,支持以下字符集: - 26 个小写英文字母 a-z; - 26 个大写英文字母 A-Z; - 10 个数字 0-9
* @return name
**/
@javax.annotation.Nullable
public String getName() {
return name;
}


public void setName(String name) {
this.name = name;
}


public EMCreateOfflinePushTemplate titlePattern(String titlePattern) {

this.titlePattern = titlePattern;
return this;
}

/**
* 自定义推送标题,例如: 标题 {0}
* @return titlePattern
**/
@javax.annotation.Nullable
public String getTitlePattern() {
return titlePattern;
}


public void setTitlePattern(String titlePattern) {
this.titlePattern = titlePattern;
}


public EMCreateOfflinePushTemplate contentPattern(String contentPattern) {

this.contentPattern = contentPattern;
return this;
}

/**
* 自定义推送内容,例如:内容 {0}, {1}
* @return contentPattern
**/
@javax.annotation.Nullable
public String getContentPattern() {
return contentPattern;
}


public void setContentPattern(String contentPattern) {
this.contentPattern = contentPattern;
}



@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
EMCreateOfflinePushTemplate createOfflinePushTemplate = (EMCreateOfflinePushTemplate) o;
return Objects.equals(this.name, createOfflinePushTemplate.name) &&
Objects.equals(this.titlePattern, createOfflinePushTemplate.titlePattern) &&
Objects.equals(this.contentPattern, createOfflinePushTemplate.contentPattern);
}

@Override
public int hashCode() {
return Objects.hash(name, titlePattern, contentPattern);
}

@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("class EMCreateOfflinePushTemplate {\n");
sb.append(" name: ").append(toIndentedString(name)).append("\n");
sb.append(" titlePattern: ").append(toIndentedString(titlePattern)).append("\n");
sb.append(" contentPattern: ").append(toIndentedString(contentPattern)).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("name");
openapiFields.add("title_pattern");
openapiFields.add("content_pattern");

// 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 EMCreateOfflinePushTemplate
*/
public static void validateJsonElement(JsonElement jsonElement) throws IOException {
if (jsonElement == null) {
if (!EMCreateOfflinePushTemplate.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null
throw new IllegalArgumentException(String.format("The required field(s) %s in EMCreateOfflinePushTemplate is not found in the empty JSON string", EMCreateOfflinePushTemplate.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 (!EMCreateOfflinePushTemplate.openapiFields.contains(entry.getKey())) {
throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `EMCreateOfflinePushTemplate` properties. JSON: %s", entry.getKey(), jsonElement.toString()));
}
}
JsonObject jsonObj = jsonElement.getAsJsonObject();
if ((jsonObj.get("name") != null && !jsonObj.get("name").isJsonNull()) && !jsonObj.get("name").isJsonPrimitive()) {
throw new IllegalArgumentException(String.format("Expected the field `name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("name").toString()));
}
if ((jsonObj.get("title_pattern") != null && !jsonObj.get("title_pattern").isJsonNull()) && !jsonObj.get("title_pattern").isJsonPrimitive()) {
throw new IllegalArgumentException(String.format("Expected the field `title_pattern` to be a primitive type in the JSON string but got `%s`", jsonObj.get("title_pattern").toString()));
}
if ((jsonObj.get("content_pattern") != null && !jsonObj.get("content_pattern").isJsonNull()) && !jsonObj.get("content_pattern").isJsonPrimitive()) {
throw new IllegalArgumentException(String.format("Expected the field `content_pattern` to be a primitive type in the JSON string but got `%s`", jsonObj.get("content_pattern").toString()));
}
}

public static class CustomTypeAdapterFactory implements TypeAdapterFactory {
@SuppressWarnings("unchecked")
@Override
public <T> TypeAdapter<T> create(Gson gson, TypeToken<T> type) {
if (!EMCreateOfflinePushTemplate.class.isAssignableFrom(type.getRawType())) {
return null; // this class only serializes 'EMCreateOfflinePushTemplate' and its subtypes
}
final TypeAdapter<JsonElement> elementAdapter = gson.getAdapter(JsonElement.class);
final TypeAdapter<EMCreateOfflinePushTemplate> thisAdapter
= gson.getDelegateAdapter(this, TypeToken.get(EMCreateOfflinePushTemplate.class));

return (TypeAdapter<T>) new TypeAdapter<EMCreateOfflinePushTemplate>() {
@Override
public void write(JsonWriter out, EMCreateOfflinePushTemplate value) throws IOException {
JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject();
elementAdapter.write(out, obj);
}

@Override
public EMCreateOfflinePushTemplate read(JsonReader in) throws IOException {
JsonElement jsonElement = elementAdapter.read(in);
validateJsonElement(jsonElement);
return thisAdapter.fromJsonTree(jsonElement);
}

}.nullSafe();
}
}

/**
* Create an instance of EMCreateOfflinePushTemplate given an JSON string
*
* @param jsonString JSON string
* @return An instance of EMCreateOfflinePushTemplate
* @throws IOException if the JSON string is invalid with respect to EMCreateOfflinePushTemplate
*/
public static EMCreateOfflinePushTemplate fromJson(String jsonString) throws IOException {
return JSON.getGson().fromJson(jsonString, EMCreateOfflinePushTemplate.class);
}

/**
* Convert an instance of EMCreateOfflinePushTemplate to an JSON string
*
* @return JSON string
*/
public String toJson() {
return JSON.getGson().toJson(this);
}
}

Loading

0 comments on commit 1fba5bd

Please sign in to comment.