use of com.fanap.podchat.mainmodel.AsyncMessage in project pod-chat-android-sdk by FanapSoft.
the class ThreadManager method prepareThreadInfoFromServer.
public static String prepareThreadInfoFromServer(long threadId, String uniqueId, String typeCode, String mtypeCode, String token) {
ChatMessageContent chatMessageContent = new ChatMessageContent();
chatMessageContent.setCount(1);
chatMessageContent.setOffset(0);
ArrayList<Integer> threadIds = new ArrayList<>();
threadIds.add((int) threadId);
chatMessageContent.setThreadIds(threadIds);
JsonObject content = (JsonObject) App.getGson().toJsonTree(chatMessageContent);
AsyncMessage asyncMessage = new AsyncMessage();
asyncMessage.setContent(content.toString());
asyncMessage.setType(ChatMessageType.Constants.GET_THREADS);
asyncMessage.setTokenIssuer("1");
asyncMessage.setToken(token);
asyncMessage.setUniqueId(uniqueId);
asyncMessage.setTypeCode(typeCode != null ? typeCode : mtypeCode);
JsonObject jsonObject = (JsonObject) App.getGson().toJsonTree(asyncMessage);
return jsonObject.toString();
}
use of com.fanap.podchat.mainmodel.AsyncMessage in project pod-chat-android-sdk by FanapSoft.
the class ThreadManager method prepareGetThreadRequest.
public static String prepareGetThreadRequest(boolean isNew, int finalCount, long finalOffset, String threadName, ArrayList<Integer> threadIds, long creatorCoreUserId, long partnerCoreUserId, long partnerCoreContactId, String uniqueId, String typeCode, String mtypeCode, String token) {
ChatMessageContent chatMessageContent = new ChatMessageContent();
chatMessageContent.setNew(isNew);
chatMessageContent.setCount(finalCount);
chatMessageContent.setOffset(finalOffset);
if (threadName != null) {
chatMessageContent.setName(threadName);
}
JsonObject content;
if (!Util.isNullOrEmpty(threadIds)) {
chatMessageContent.setThreadIds(threadIds);
content = (JsonObject) App.getGson().toJsonTree(chatMessageContent);
} else {
content = (JsonObject) App.getGson().toJsonTree(chatMessageContent);
content.remove("threadIds");
}
if (creatorCoreUserId > 0) {
content.addProperty("creatorCoreUserId", creatorCoreUserId);
}
if (partnerCoreUserId > 0) {
content.addProperty("partnerCoreUserId", partnerCoreUserId);
}
if (partnerCoreContactId > 0) {
content.addProperty("partnerCoreContactId", partnerCoreContactId);
}
if (!isNew)
content.remove("new");
content.remove("lastMessageId");
content.remove("firstMessageId");
AsyncMessage chatMessage = new AsyncMessage();
chatMessage.setContent(content.toString());
chatMessage.setType(ChatMessageType.Constants.GET_THREADS);
chatMessage.setTokenIssuer("1");
chatMessage.setToken(token);
chatMessage.setUniqueId(uniqueId);
chatMessage.setTypeCode(typeCode != null ? typeCode : mtypeCode);
JsonObject jsonObject = (JsonObject) App.getGson().toJsonTree(chatMessage);
jsonObject.remove("subjectId");
return jsonObject.toString();
}
use of com.fanap.podchat.mainmodel.AsyncMessage in project pod-chat-android-sdk by FanapSoft.
the class PublicThread method joinPublicThread.
public static String joinPublicThread(RequestJoinPublicThread request, String uniqueId) {
AsyncMessage message = new AsyncMessage();
message.setContent(request.getUniqueName());
message.setToken(CoreConfig.token);
message.setType(ChatMessageType.Constants.JOIN_THREAD);
message.setTokenIssuer(CoreConfig.tokenIssuer);
message.setUniqueId(uniqueId);
message.setTypeCode(!Util.isNullOrEmpty(request.getTypeCode()) ? request.getTypeCode() : CoreConfig.typeCode);
JsonObject tmp = (JsonObject) App.getGson().toJsonTree(message);
tmp.remove("subjectId");
return tmp.toString();
}
use of com.fanap.podchat.mainmodel.AsyncMessage in project pod-chat-android-sdk by FanapSoft.
the class PingManager method createStatusPingRequest.
public static String createStatusPingRequest(StatusPingRequest request, String uniqueId) throws PodChatException {
validateUpdateStatusRequest(request, uniqueId);
// Map<String, Long> contentMap = new HashMap<>();
JsonObject contentObj = new JsonObject();
long locationId = request.isInChat() ? IN_CHAT_ID : request.isInThread() ? IN_THREAD_ID : request.isInContactsList() ? IN_CONTACTS_LIST_ID : IMPOSSIBLE_STATE_ID;
// contentMap.put(LOCATION, locationId);
contentObj.addProperty(LOCATION, locationId);
if (request.isInThread())
contentObj.addProperty(LOCATION_ID, request.getThreadId());
AsyncMessage message = new AsyncMessage();
message.setContent(contentObj.toString());
message.setToken(CoreConfig.token);
message.setType(ChatMessageType.Constants.LOCATION_PING);
message.setTokenIssuer(CoreConfig.tokenIssuer);
message.setUniqueId(uniqueId);
message.setTypeCode(!Util.isNullOrEmpty(request.getTypeCode()) ? request.getTypeCode() : CoreConfig.typeCode);
JsonObject requestObj = (JsonObject) App.getGson().toJsonTree(message);
requestObj.remove("subjectId");
return requestObj.toString();
}
use of com.fanap.podchat.mainmodel.AsyncMessage in project pod-chat-android-sdk by FanapSoft.
the class TagManager method createRemoveTagParticipantRequest.
public static String createRemoveTagParticipantRequest(RemoveTagParticipantRequest request, String uniqueId) {
JsonArray participants = new JsonArray();
for (Long p : request.getThreadIds()) {
participants.add(p);
}
String content = "[{\"threadId\": 8688 }," + "{\"threadId\": 8730 }," + "{\"threadId\": 8729 }]";
// String content = App.getGson().toJson(participants);
AsyncMessage message = new ChatMessage();
message.setType(ChatMessageType.Constants.REMOVE_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);
}
Aggregations