Search in sources :

Example 56 with AsyncMessage

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

the class TagManager method createDeleteTagRequest.

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

Example 57 with AsyncMessage

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

the class TagManager method createEditTagRequest.

public static String createEditTagRequest(EditTagRequest 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.EDIT_TAG);
    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 : ChatMessage(com.fanap.podchat.mainmodel.ChatMessage) AsyncMessage(com.fanap.podchat.mainmodel.AsyncMessage) JsonObject(com.google.gson.JsonObject)

Example 58 with AsyncMessage

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

the class ParticipantsManager method prepareAddParticipantsRequest.

public static String prepareAddParticipantsRequest(RequestAddParticipants request, String uniqueId, String mTypeCode, String token) {
    JsonArray participantsJsonArray = new JsonArray();
    if (request.getContactIds() != null) {
        for (Long p : request.getContactIds()) {
            participantsJsonArray.add(p);
        }
    } else if (request.getUserNames() != null) {
        for (String username : request.getUserNames()) {
            Invitee invitee = new Invitee();
            invitee.setId(username);
            invitee.setIdType(InviteType.Constants.TO_BE_USER_USERNAME);
            JsonElement jsonElement = App.getGson().toJsonTree(invitee);
            participantsJsonArray.add(jsonElement);
        }
    } else {
        for (Long coreUserId : request.getCoreUserIds()) {
            Invitee invitee = new Invitee();
            invitee.setId(coreUserId);
            invitee.setIdType(InviteType.Constants.TO_BE_USER_ID);
            JsonElement jsonElement = App.getGson().toJsonTree(invitee);
            participantsJsonArray.add(jsonElement);
        }
    }
    AsyncMessage chatMessage = new AsyncMessage();
    chatMessage.setTokenIssuer("1");
    chatMessage.setToken(token);
    chatMessage.setContent(participantsJsonArray.toString());
    chatMessage.setSubjectId(request.getThreadId());
    chatMessage.setUniqueId(uniqueId);
    chatMessage.setType(ChatMessageType.Constants.ADD_PARTICIPANT);
    chatMessage.setTypeCode(mTypeCode);
    JsonObject jsonObject = (JsonObject) App.getGson().toJsonTree(chatMessage);
    return jsonObject.toString();
}
Also used : JsonArray(com.google.gson.JsonArray) Invitee(com.fanap.podchat.mainmodel.Invitee) JsonElement(com.google.gson.JsonElement) AsyncMessage(com.fanap.podchat.mainmodel.AsyncMessage) JsonObject(com.google.gson.JsonObject)

Example 59 with AsyncMessage

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

the class PinMessage method unPinMessage.

public static String unPinMessage(RequestPinMessage request, String uniqueId) {
    long messageId = request.getMessageId();
    AsyncMessage message = new AsyncMessage();
    message.setSubjectId(messageId);
    message.setToken(CoreConfig.token);
    message.setType(ChatMessageType.Constants.UNPIN_MESSAGE);
    message.setTokenIssuer(CoreConfig.tokenIssuer);
    message.setUniqueId(uniqueId);
    message.setTypeCode(!Util.isNullOrEmpty(request.getTypeCode()) ? request.getTypeCode() : CoreConfig.typeCode);
    return App.getGson().toJson(message);
}
Also used : AsyncMessage(com.fanap.podchat.mainmodel.AsyncMessage)

Example 60 with AsyncMessage

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

the class PinThread method pinThread.

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

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