use of com.fanap.podchat.mainmodel.AsyncMessage in project pod-chat-android-sdk by FanapSoft.
the class MessageManager method prepareMainHistoryResponse.
public static String prepareMainHistoryResponse(History history, long threadId, String uniqueId, String typecode, String token) {
// long offsets = history.getOffset();
long fromTime = history.getFromTime();
long fromTimeNanos = history.getFromTimeNanos();
long toTime = history.getToTime();
long toTimeNanos = history.getToTimeNanos();
String query = history.getQuery();
JsonObject content = (JsonObject) App.getGson().toJsonTree(history);
if (history.getLastMessageId() == 0) {
content.remove("lastMessageId");
}
if (history.getFirstMessageId() == 0) {
content.remove("firstMessageId");
}
if (history.getId() <= 0) {
content.remove("id");
}
if (Util.isNullOrEmpty(query)) {
content.remove("query");
}
if (Util.isNullOrEmpty(fromTime)) {
content.remove("fromTime");
}
if (Util.isNullOrEmpty(fromTimeNanos)) {
content.remove("fromTimeNanos");
}
if (Util.isNullOrEmpty(toTime)) {
content.remove("toTime");
}
if (Util.isNullOrEmpty(toTimeNanos)) {
content.remove("toTimeNanos");
}
if (history.getUniqueIds() == null) {
content.remove("uniqueIds");
}
if (history.getMessageType() == 0) {
content.remove("messageType");
}
AsyncMessage chatMessage = new AsyncMessage();
chatMessage.setContent(content.toString());
chatMessage.setType(ChatMessageType.Constants.GET_HISTORY);
chatMessage.setToken(token);
chatMessage.setTokenIssuer("1");
chatMessage.setUniqueId(uniqueId);
chatMessage.setSubjectId(threadId);
chatMessage.setTypeCode(typecode);
return App.getGson().toJsonTree(chatMessage).toString();
}
use of com.fanap.podchat.mainmodel.AsyncMessage in project pod-chat-android-sdk by FanapSoft.
the class MessageManager method getAllUnreadMessgesCount.
public static String getAllUnreadMessgesCount(RequestGetUnreadMessagesCount request, String uniqueId) {
JsonObject content = new JsonObject();
content.addProperty("mute", request.withMuteThreads());
AsyncMessage message = new AsyncMessage();
message.setContent(content.toString());
message.setToken(CoreConfig.token);
message.setType(ChatMessageType.Constants.ALL_UNREAD_MESSAGE_COUNT);
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 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);
}
use of com.fanap.podchat.mainmodel.AsyncMessage 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);
}
use of com.fanap.podchat.mainmodel.AsyncMessage 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);
}
Aggregations