Search in sources :

Example 76 with ChatResponse

use of com.fanap.podchat.model.ChatResponse in project pod-chat-android-sdk by FanapSoft.

the class ContactManager method prepareUpdateLastSeenResponse.

public static ChatResponse<ResultNotSeenDuration> prepareUpdateLastSeenResponse(ChatMessage message, JsonParser parser) {
    ChatResponse<ResultNotSeenDuration> response = new ChatResponse<>();
    JsonObject jsonObject = Util.objectToJson(message.getContent(), parser);
    Map<String, Long> idLastSeen = new HashMap<>();
    for (String key : jsonObject.keySet()) {
        idLastSeen.put(key, jsonObject.get(key).getAsLong());
    }
    ResultNotSeenDuration resultNotSeenDuration = new ResultNotSeenDuration();
    resultNotSeenDuration.setIdNotSeenPair(idLastSeen);
    response.setResult(resultNotSeenDuration);
    return response;
}
Also used : ResultNotSeenDuration(com.fanap.podchat.model.ResultNotSeenDuration) HashMap(java.util.HashMap) ChatResponse(com.fanap.podchat.model.ChatResponse) JsonObject(com.google.gson.JsonObject)

Example 77 with ChatResponse

use of com.fanap.podchat.model.ChatResponse in project pod-chat-android-sdk by FanapSoft.

the class PodDownloader method generatePodSpaceDownloadResult.

public static ChatResponse<ResultDownloadFile> generatePodSpaceDownloadResult(String hashCode, File cacheFile) {
    ResultDownloadFile result = new ResultDownloadFile();
    result.setFile(cacheFile);
    result.setUri(Uri.fromFile(cacheFile));
    result.setHashCode(hashCode);
    ChatResponse<ResultDownloadFile> response = new ChatResponse<>();
    response.setResult(result);
    return response;
}
Also used : ChatResponse(com.fanap.podchat.model.ChatResponse) ResultDownloadFile(com.fanap.podchat.chat.file_manager.download_file.model.ResultDownloadFile)

Example 78 with ChatResponse

use of com.fanap.podchat.model.ChatResponse in project pod-chat-android-sdk by FanapSoft.

the class PodDownloader method generateDownloadResult.

public static ChatResponse<ResultDownloadFile> generateDownloadResult(String hashCode, long id, File cacheFile) {
    ResultDownloadFile result = new ResultDownloadFile();
    result.setFile(cacheFile);
    result.setUri(Uri.fromFile(cacheFile));
    result.setHashCode(hashCode);
    result.setId(id);
    ChatResponse<ResultDownloadFile> response = new ChatResponse<>();
    response.setResult(result);
    return response;
}
Also used : ChatResponse(com.fanap.podchat.model.ChatResponse) ResultDownloadFile(com.fanap.podchat.chat.file_manager.download_file.model.ResultDownloadFile)

Example 79 with ChatResponse

use of com.fanap.podchat.model.ChatResponse in project pod-chat-android-sdk by FanapSoft.

the class AssistantManager method handleAssistantHistoryResponse.

public static ChatResponse<List<AssistantHistoryVo>> handleAssistantHistoryResponse(ChatMessage chatMessage) {
    ChatResponse<List<AssistantHistoryVo>> response = new ChatResponse<>();
    List<AssistantHistoryVo> result = App.getGson().fromJson(chatMessage.getContent(), new TypeToken<ArrayList<AssistantHistoryVo>>() {
    }.getType());
    for (AssistantHistoryVo history : result) {
        switch(history.getActionType()) {
            case AssistantActionType.REGISTER_ASSISTANT:
                history.setActionName("REGISTER_ASSISTANT");
                break;
            case AssistantActionType.ACTIVATE_ASSISTANT:
                history.setActionName("ACTIVATE_ASSISTANT");
                break;
            case AssistantActionType.DEACTIVE_ASSISTANT:
                history.setActionName("DEACTIVE_ASSISTANT");
                break;
            case AssistantActionType.BLOCK_ASSISTANT:
                history.setActionName("BLOCK_ASSISTANT");
                break;
            case AssistantActionType.UNBLOCK_ASSISTANT:
                history.setActionName("UNBLOCK_ASSISTANT");
                break;
        }
    }
    response.setResult(result);
    response.setUniqueId(chatMessage.getUniqueId());
    response.setCache(false);
    return response;
}
Also used : TypeToken(com.google.gson.reflect.TypeToken) ChatResponse(com.fanap.podchat.model.ChatResponse) ArrayList(java.util.ArrayList) List(java.util.List) AssistantHistoryVo(com.fanap.podchat.chat.assistant.model.AssistantHistoryVo)

Example 80 with ChatResponse

use of com.fanap.podchat.model.ChatResponse in project pod-chat-android-sdk by FanapSoft.

the class BotManager method handleOnBotStartedOrStopped.

public static ChatResponse<StartStopBotResult> handleOnBotStartedOrStopped(ChatMessage chatMessage) {
    ChatResponse<StartStopBotResult> response = new ChatResponse<>();
    StartStopBotResult result = new StartStopBotResult(chatMessage.getContent());
    response.setResult(result);
    response.setUniqueId(chatMessage.getUniqueId());
    response.setSubjectId(chatMessage.getSubjectId());
    return response;
}
Also used : StartStopBotResult(com.fanap.podchat.chat.bot.result_model.StartStopBotResult) ChatResponse(com.fanap.podchat.model.ChatResponse)

Aggregations

ChatResponse (com.fanap.podchat.model.ChatResponse)162 ChatListener (com.fanap.podchat.chat.ChatListener)38 Test (org.junit.Test)38 ArrayList (java.util.ArrayList)35 Thread (com.fanap.podchat.mainmodel.Thread)29 JsonSyntaxException (com.google.gson.JsonSyntaxException)29 ResultHistory (com.fanap.podchat.model.ResultHistory)28 LargeTest (android.support.test.filters.LargeTest)27 RequestThread (com.fanap.podchat.requestobject.RequestThread)27 PodChatException (com.fanap.podchat.util.PodChatException)26 MessageVO (com.fanap.podchat.mainmodel.MessageVO)25 RoomIntegrityException (com.fanap.podchat.persistance.RoomIntegrityException)23 IOException (java.io.IOException)23 JSONException (org.json.JSONException)22 ResultThreads (com.fanap.podchat.model.ResultThreads)21 RequestGetHistory (com.fanap.podchat.requestobject.RequestGetHistory)21 SentryException (io.sentry.core.protocol.SentryException)21 FlakyTest (android.support.test.filters.FlakyTest)19 MediumTest (android.support.test.filters.MediumTest)19 Activity (android.app.Activity)17