Search in sources :

Example 46 with AsyncMessage

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

the class AssistantManager method createRegisterAssistantRequest.

public static String createRegisterAssistantRequest(RegisterAssistantRequest request, String uniqueId) {
    String content = App.getGson().toJson(request.getAssistantVos());
    AsyncMessage message = new ChatMessage();
    message.setType(ChatMessageType.Constants.REGISTER_ASSISTANT);
    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)

Example 47 with AsyncMessage

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

the class Mention method getMentionList.

public static String getMentionList(RequestGetMentionList request, String uniqueId) {
    long threadId = request.getThreadId();
    JsonObject criteriaVO = new JsonObject();
    if (request.getAllMentioned() != null && request.getAllMentioned())
        criteriaVO.addProperty("allMentioned", true);
    if (request.getUnreadMentioned() != null && request.getUnreadMentioned())
        criteriaVO.addProperty("unreadMentioned", true);
    long count = request.getCount() > 0 ? request.getCount() : 50;
    criteriaVO.addProperty("count", count);
    criteriaVO.addProperty("offset", request.getOffset());
    AsyncMessage message = new AsyncMessage();
    message.setContent(criteriaVO.toString());
    message.setType(ChatMessageType.Constants.GET_HISTORY);
    message.setToken(CoreConfig.token);
    message.setTokenIssuer(CoreConfig.tokenIssuer);
    message.setUniqueId(uniqueId);
    message.setSubjectId(threadId);
    message.setTypeCode(request.getTypeCode() != null ? request.getTypeCode() : CoreConfig.typeCode);
    return App.getGson().toJson(message);
}
Also used : AsyncMessage(com.fanap.podchat.mainmodel.AsyncMessage) JsonObject(com.google.gson.JsonObject)

Example 48 with AsyncMessage

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

the class MessageManager method generateDeleteMessageRequest.

public static AsyncMessage generateDeleteMessageRequest(boolean deleteForAll, String uniqueId, long messageId, String typecode, String token) {
    AsyncMessage asyncMessage = new AsyncMessage();
    JsonObject contentObj = new JsonObject();
    contentObj.addProperty("deleteForAll", deleteForAll);
    asyncMessage.setContent(contentObj.toString());
    asyncMessage.setToken(token);
    asyncMessage.setTokenIssuer("1");
    asyncMessage.setType(ChatMessageType.Constants.DELETE_MESSAGE);
    asyncMessage.setUniqueId(uniqueId);
    asyncMessage.setSubjectId(messageId);
    asyncMessage.setTypeCode(typecode);
    return asyncMessage;
}
Also used : AsyncMessage(com.fanap.podchat.mainmodel.AsyncMessage) JsonObject(com.google.gson.JsonObject)

Example 49 with AsyncMessage

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

the class MessageManager method prepareDeleteMultipleRequest.

public static String prepareDeleteMultipleRequest(RequestDeleteMessage request, List<String> uniqueIds, String token, String typcode) {
    List<Long> messageIds = request.getMessageIds();
    boolean deleteForAll = request.isDeleteForAll();
    AsyncMessage asyncMessage = new AsyncMessage();
    JsonObject contentObj = new JsonObject();
    JsonElement messageIdsElement = App.getGson().toJsonTree(messageIds, new TypeToken<List<Long>>() {
    }.getType());
    JsonElement uniqueIdsElement = App.getGson().toJsonTree(uniqueIds, new TypeToken<List<String>>() {
    }.getType());
    contentObj.add("ids", messageIdsElement.getAsJsonArray());
    contentObj.add("uniqueIds", uniqueIdsElement.getAsJsonArray());
    contentObj.addProperty("deleteForAll", deleteForAll);
    asyncMessage.setContent(contentObj.toString());
    asyncMessage.setToken(token);
    asyncMessage.setTokenIssuer("1");
    asyncMessage.setType(ChatMessageType.Constants.DELETE_MESSAGE);
    JsonObject jsonObject = (JsonObject) App.getGson().toJsonTree(asyncMessage);
    jsonObject.remove("subjectId");
    if (Util.isNullOrEmpty(typcode)) {
        jsonObject.remove("typeCode");
    } else {
        jsonObject.remove("typeCode");
        jsonObject.addProperty("typeCode", typcode);
    }
    String asyncContent = jsonObject.toString();
    return asyncContent;
}
Also used : AsyncMessage(com.fanap.podchat.mainmodel.AsyncMessage) JsonElement(com.google.gson.JsonElement) TypeToken(com.google.gson.reflect.TypeToken) JsonObject(com.google.gson.JsonObject)

Example 50 with AsyncMessage

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

the class ThreadManager method createChangeThreadTypeRequest.

public static String createChangeThreadTypeRequest(ChangeThreadTypeRequest request, String uniqueId) throws PodChatException {
    JsonObject content = new JsonObject();
    content.addProperty("type", request.getType());
    if (request.getUniqname() != null)
        content.addProperty("uniqueName", request.getUniqname());
    AsyncMessage message = new ChatMessage();
    message.setType(ChatMessageType.Constants.CHANGE_THREAD_TYPE);
    message.setToken(CoreConfig.token);
    message.setTokenIssuer(CoreConfig.tokenIssuer);
    message.setContent(content.toString());
    message.setTypeCode(request.getTypeCode() != null ? request.getTypeCode() : CoreConfig.typeCode);
    message.setSubjectId(request.getThreadId());
    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)

Aggregations

AsyncMessage (com.fanap.podchat.mainmodel.AsyncMessage)78 JsonObject (com.google.gson.JsonObject)53 ChatMessage (com.fanap.podchat.mainmodel.ChatMessage)20 PodChatException (com.fanap.podchat.util.PodChatException)7 JsonElement (com.google.gson.JsonElement)6 JsonArray (com.google.gson.JsonArray)5 ChatMessageContent (com.fanap.podchat.mainmodel.ChatMessageContent)4 ArrayList (java.util.ArrayList)4 SendClientDTO (com.fanap.podchat.call.model.SendClientDTO)3 RoomIntegrityException (com.fanap.podchat.persistance.RoomIntegrityException)3 PodThreadManager (com.fanap.podchat.util.PodThreadManager)3 CreateCallVO (com.fanap.podchat.call.model.CreateCallVO)2 TurnCallParticipantVideoOffRequest (com.fanap.podchat.call.request_model.TurnCallParticipantVideoOffRequest)2 Invitee (com.fanap.podchat.mainmodel.Invitee)2 JsonSyntaxException (com.google.gson.JsonSyntaxException)2 TypeToken (com.google.gson.reflect.TypeToken)2 SentryException (io.sentry.core.protocol.SentryException)2 IOException (java.io.IOException)2 HashMap (java.util.HashMap)2 JSONException (org.json.JSONException)2