// Path: src/main/java/cn/jmessage/api/common/model/IModel.java
// public interface IModel {
// 
//     public JsonElement toJSON();
// 
// }
// 
// Path: src/main/java/cn/jmessage/api/message/MessageType.java
// public enum MessageType {
//     TEXT("text"),
//     IMAGE("image"),
//     VOICE("voice"),
//     CUSTOM("custom");
// 
//     private String value;
// 
//     private MessageType(String value) {
//         this.value = value;
//     }
// 
//     public String getValue() {
//         return value;
//     }
// }
// 
// Path: src/main/java/cn/jmessage/api/utils/StringUtils.java
// public class StringUtils {
// 
// 	public static void checkUsername(String username) {
// 		if ( null == username || username.trim().length() == 0) {
// 			throw new IllegalArgumentException("username must not be empty");
// 		}
// 		if (username.contains("\n") || username.contains("\r") || username.contains("\t")) {
// 			throw new IllegalArgumentException("username must not contain line feed character");
// 		}
// 		byte[] usernameByte = username.getBytes();
// 		if (usernameByte.length < 4 || usernameByte.length > 128) {
// 			throw new IllegalArgumentException("The length of username must between 4 and 128 bytes. Input is " + username);
// 		}
// 		if (!ServiceHelper.checkUsername(username)) {
// 			throw new IllegalArgumentException("The parameter username contains illegal character," +
// 					" a-zA-Z_0-9.、-,@。 is legally, and start with alphabet or number. Input is " + username);
// 		}
// 	}
// 	
// 	public static void checkPassword(String password) {
// 		if (null == password || password.trim().length() == 0) {
// 			throw new IllegalArgumentException("password must not be empty");
// 		}
// 		
// 		byte[] passwordByte = password.getBytes();
// 		if (passwordByte.length < 4 || passwordByte.length > 128) {
// 			throw new IllegalArgumentException("The length of password must between 4 and 128 bytes. Input is " + password);
// 		}
// 		
// 	}
// 	
// 	public static boolean isNotEmpty(String s) {
//         return s != null && s.length() > 0;
//     }
// 	
// 	public static boolean isTrimedEmpty(String s) {
//         return s == null || s.trim().length() == 0;
//     }
// 	
// 	public static boolean isLineBroken(String s) {
// 		if (s.contains("\n") || s.contains("\r")) {
// 			return true;
// 		}
// 		return false;
// 	}
// 	
// }


import cn.jmessage.api.common.model.IModel;
import cn.jmessage.api.message.MessageType;
import com.google.gson.Gson;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import cn.jiguang.common.utils.Preconditions;
import cn.jmessage.api.utils.StringUtils;
package cn.jmessage.api.common.model.message;



/**
 * MessagePayload https://docs.jiguang.cn/jmessage/server/rest_api_im/#_17
 */
public class MessagePayload implements IModel {

    private static final String VERSION = "version";
    private static final String TARGET_TYPE = "target_type";
    private static final String FROM_TYPE = "from_type";
    private static final String MSG_TYPE = "msg_type";
    private static final String TARGET_ID = "target_id";
    private static final String FROM_ID = "from_id";
    private static final String TARGET_APP_KEY = "target_appkey";
    private static final String FROM_NAME = "from_name";
    private static final String TARGET_NAME = "target_name";
    private static final String MSG_BODY = "msg_body";
    private static final String NO_OFFLINE = "no_offline";
    private static final String NO_NOTIFICATION = "no_notification";
    private static final String NOTIFICATION = "notification";


    private static Gson gson = new Gson();

    private Integer mVersion;
    private String mTargetType;
    private String mTargetId;
    private String mFromType;
    private String mFromId;
    private String mTargetAppKey;
    private String mFromName;
    private String mTargetName;
    // 默认为false，表示需要离线存储
    private boolean mNoOffline = false;
    // 默认为false，表示在通知栏展示
    private boolean mNoNotification = false;
// Path: src/main/java/cn/jmessage/api/common/model/IModel.java
// public interface IModel {
// 
//     public JsonElement toJSON();
// 
// }
// 
// Path: src/main/java/cn/jmessage/api/message/MessageType.java
// public enum MessageType {
//     TEXT("text"),
//     IMAGE("image"),
//     VOICE("voice"),
//     CUSTOM("custom");
// 
//     private String value;
// 
//     private MessageType(String value) {
//         this.value = value;
//     }
// 
//     public String getValue() {
//         return value;
//     }
// }
// 
// Path: src/main/java/cn/jmessage/api/utils/StringUtils.java
// public class StringUtils {
// 
// 	public static void checkUsername(String username) {
// 		if ( null == username || username.trim().length() == 0) {
// 			throw new IllegalArgumentException("username must not be empty");
// 		}
// 		if (username.contains("\n") || username.contains("\r") || username.contains("\t")) {
// 			throw new IllegalArgumentException("username must not contain line feed character");
// 		}
// 		byte[] usernameByte = username.getBytes();
// 		if (usernameByte.length < 4 || usernameByte.length > 128) {
// 			throw new IllegalArgumentException("The length of username must between 4 and 128 bytes. Input is " + username);
// 		}
// 		if (!ServiceHelper.checkUsername(username)) {
// 			throw new IllegalArgumentException("The parameter username contains illegal character," +
// 					" a-zA-Z_0-9.、-,@。 is legally, and start with alphabet or number. Input is " + username);
// 		}
// 	}
// 	
// 	public static void checkPassword(String password) {
// 		if (null == password || password.trim().length() == 0) {
// 			throw new IllegalArgumentException("password must not be empty");
// 		}
// 		
// 		byte[] passwordByte = password.getBytes();
// 		if (passwordByte.length < 4 || passwordByte.length > 128) {
// 			throw new IllegalArgumentException("The length of password must between 4 and 128 bytes. Input is " + password);
// 		}
// 		
// 	}
// 	
// 	public static boolean isNotEmpty(String s) {
//         return s != null && s.length() > 0;
//     }
// 	
// 	public static boolean isTrimedEmpty(String s) {
//         return s == null || s.trim().length() == 0;
//     }
// 	
// 	public static boolean isLineBroken(String s) {
// 		if (s.contains("\n") || s.contains("\r")) {
// 			return true;
// 		}
// 		return false;
// 	}
// 	
// }


// Path: src/main/java/cn/jmessage/api/common/model/message/MessagePayload.java
import cn.jmessage.api.common.model.IModel;
import cn.jmessage.api.message.MessageType;
import com.google.gson.Gson;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import cn.jiguang.common.utils.Preconditions;
import cn.jmessage.api.utils.StringUtils;

package cn.jmessage.api.common.model.message;



/**
 * MessagePayload https://docs.jiguang.cn/jmessage/server/rest_api_im/#_17
 */
public class MessagePayload implements IModel {

    private static final String VERSION = "version";
    private static final String TARGET_TYPE = "target_type";
    private static final String FROM_TYPE = "from_type";
    private static final String MSG_TYPE = "msg_type";
    private static final String TARGET_ID = "target_id";
    private static final String FROM_ID = "from_id";
    private static final String TARGET_APP_KEY = "target_appkey";
    private static final String FROM_NAME = "from_name";
    private static final String TARGET_NAME = "target_name";
    private static final String MSG_BODY = "msg_body";
    private static final String NO_OFFLINE = "no_offline";
    private static final String NO_NOTIFICATION = "no_notification";
    private static final String NOTIFICATION = "notification";


    private static Gson gson = new Gson();

    private Integer mVersion;
    private String mTargetType;
    private String mTargetId;
    private String mFromType;
    private String mFromId;
    private String mTargetAppKey;
    private String mFromName;
    private String mTargetName;
    // 默认为false，表示需要离线存储
    private boolean mNoOffline = false;
    // 默认为false，表示在通知栏展示
    private boolean mNoNotification = false;
    private MessageType mMsgType;