Search in sources :

Example 11 with ChatMessage

use of com.fanap.podchat.mainmodel.ChatMessage in project pod-chat-android-sdk by FanapSoft.

the class MessageManager method prepareSendTextMessageRequest.

public static JsonObject prepareSendTextMessageRequest(String textMessage, long threadId, Integer messageType, String jsonSystemMetadata, String uniqueId, String mTypecode, String token) {
    ChatMessage chatMessageQueue = new ChatMessage();
    chatMessageQueue.setContent(textMessage);
    chatMessageQueue.setType(ChatMessageType.Constants.MESSAGE);
    chatMessageQueue.setTokenIssuer("1");
    chatMessageQueue.setToken(token);
    if (jsonSystemMetadata != null) {
        chatMessageQueue.setSystemMetadata(jsonSystemMetadata);
    }
    chatMessageQueue.setUniqueId(uniqueId);
    chatMessageQueue.setTime(1000);
    chatMessageQueue.setSubjectId(threadId);
    JsonObject jsonObject = (JsonObject) App.getGson().toJsonTree(chatMessageQueue);
    if (Util.isNullOrEmpty(mTypecode)) {
        jsonObject.remove("typeCode");
    } else {
        jsonObject.remove("typeCode");
        jsonObject.addProperty("typeCode", mTypecode);
    }
    if (!Util.isNullOrEmpty(messageType)) {
        jsonObject.addProperty("messageType", messageType);
    } else {
        jsonObject.remove("messageType");
    }
    return jsonObject;
}
Also used : ChatMessage(com.fanap.podchat.mainmodel.ChatMessage) JsonObject(com.google.gson.JsonObject)

Example 12 with ChatMessage

use of com.fanap.podchat.mainmodel.ChatMessage in project pod-chat-android-sdk by FanapSoft.

the class SearchManager method prepareSearchRequest.

public static String prepareSearchRequest(SearchSystemMetadataRequest messageCriteriaVO, String uniqueId, String typecode, String token) {
    if (messageCriteriaVO.getCount() == 0)
        messageCriteriaVO.setCount(25);
    String content = App.getGson().toJson(messageCriteriaVO);
    ChatMessage chatMessage = new ChatMessage();
    chatMessage.setContent(content);
    chatMessage.setType(ChatMessageType.Constants.GET_HISTORY);
    chatMessage.setToken(token);
    chatMessage.setTokenIssuer("1");
    chatMessage.setUniqueId(uniqueId);
    chatMessage.setSubjectId(messageCriteriaVO.getMessageThreadId());
    JsonObject jsonObject = (JsonObject) App.getGson().toJsonTree(chatMessage);
    if (Util.isNullOrEmpty(typecode)) {
        jsonObject.remove("typeCode");
    } else {
        jsonObject.remove("typeCode");
        jsonObject.addProperty("typeCode", typecode);
    }
    return jsonObject.toString();
}
Also used : ChatMessage(com.fanap.podchat.mainmodel.ChatMessage) JsonObject(com.google.gson.JsonObject)

Example 13 with ChatMessage

use of com.fanap.podchat.mainmodel.ChatMessage in project pod-chat-android-sdk by FanapSoft.

the class TagManager method createTagListRequest.

public static String createTagListRequest(GetTagListRequest request, String uniqueId) {
    AsyncMessage message = new ChatMessage();
    message.setType(ChatMessageType.Constants.GET_TAG_LIST);
    message.setToken(CoreConfig.token);
    message.setTokenIssuer(CoreConfig.tokenIssuer);
    message.setTypeCode(request.getTypeCode() != null ? request.getTypeCode() : CoreConfig.typeCode);
    message.setUniqueId(uniqueId);
    return App.getGson().toJson(message);
}
Also used : ChatMessage(com.fanap.podchat.mainmodel.ChatMessage) AsyncMessage(com.fanap.podchat.mainmodel.AsyncMessage)

Example 14 with ChatMessage

use of com.fanap.podchat.mainmodel.ChatMessage in project pod-chat-android-sdk by FanapSoft.

the class TagManager method createAddTagRequest.

public static String createAddTagRequest(CreateTagRequest request, String uniqueId) {
    JsonObject contentObject = new JsonObject();
    if (request.getName() != null)
        contentObject.addProperty("name", request.getName());
    String content = App.getGson().toJson(contentObject);
    AsyncMessage message = new ChatMessage();
    message.setType(ChatMessageType.Constants.CREATE_TAG);
    message.setToken(CoreConfig.token);
    message.setTokenIssuer(CoreConfig.tokenIssuer);
    message.setTypeCode(request.getTypeCode() != null ? request.getTypeCode() : CoreConfig.typeCode);
    message.setContent(content);
    message.setUniqueId(uniqueId);
    return App.getGson().toJson(message);
}
Also used : ChatMessage(com.fanap.podchat.mainmodel.ChatMessage) AsyncMessage(com.fanap.podchat.mainmodel.AsyncMessage) JsonObject(com.google.gson.JsonObject)

Example 15 with ChatMessage

use of com.fanap.podchat.mainmodel.ChatMessage in project pod-chat-android-sdk by FanapSoft.

the class TagManager method createAddTagParticipantRequest.

public static String createAddTagParticipantRequest(AddTagParticipantRequest request, String uniqueId) {
    JsonArray participants = new JsonArray();
    for (Long p : request.getThreadIds()) {
        participants.add(p);
    }
    String content = App.getGson().toJson(participants);
    AsyncMessage message = new ChatMessage();
    message.setType(ChatMessageType.Constants.ADD_TAG_PARTICIPANT);
    message.setToken(CoreConfig.token);
    message.setTokenIssuer(CoreConfig.tokenIssuer);
    message.setTypeCode(request.getTypeCode() != null ? request.getTypeCode() : CoreConfig.typeCode);
    message.setContent(content);
    message.setSubjectId(request.getTagId());
    message.setUniqueId(uniqueId);
    return App.getGson().toJson(message);
}
Also used : JsonArray(com.google.gson.JsonArray) ChatMessage(com.fanap.podchat.mainmodel.ChatMessage) AsyncMessage(com.fanap.podchat.mainmodel.AsyncMessage)

Aggregations

ChatMessage (com.fanap.podchat.mainmodel.ChatMessage)56 JsonObject (com.google.gson.JsonObject)33 AsyncMessage (com.fanap.podchat.mainmodel.AsyncMessage)20 RoomIntegrityException (com.fanap.podchat.persistance.RoomIntegrityException)9 PodChatException (com.fanap.podchat.util.PodChatException)9 JsonSyntaxException (com.google.gson.JsonSyntaxException)9 SentryException (io.sentry.core.protocol.SentryException)9 IOException (java.io.IOException)9 JSONException (org.json.JSONException)9 ArrayList (java.util.ArrayList)5 ChatResponse (com.fanap.podchat.model.ChatResponse)4 JsonArray (com.google.gson.JsonArray)4 NonNull (android.support.annotation.NonNull)3 CacheMessageVO (com.fanap.podchat.cachemodel.CacheMessageVO)3 GapMessageVO (com.fanap.podchat.cachemodel.GapMessageVO)3 MessageVO (com.fanap.podchat.mainmodel.MessageVO)3 ResultNewMessage (com.fanap.podchat.model.ResultNewMessage)3 JsonElement (com.google.gson.JsonElement)3 TypeToken (com.google.gson.reflect.TypeToken)3 SendingQueueCache (com.fanap.podchat.cachemodel.queue.SendingQueueCache)2