Search in sources :

Example 1 with RequestCreatePublicThread

use of com.fanap.podchat.chat.thread.public_thread.RequestCreatePublicThread in project pod-chat-android-sdk by FanapSoft.

the class ThreadManager method prepareCreateThread.

public static String prepareCreateThread(RequestCreateThread request, String uniqueId, String typecode, String token) {
    JsonObject chatMessageContent = (JsonObject) App.getGson().toJsonTree(request);
    if (request instanceof RequestCreatePublicThread) {
        String uniqueName = ((RequestCreatePublicThread) request).getUniqueName();
        chatMessageContent.addProperty("uniqueName", uniqueName);
    }
    AsyncMessage chatMessage = new AsyncMessage();
    chatMessage.setContent(chatMessageContent.toString());
    chatMessage.setType(ChatMessageType.Constants.INVITATION);
    chatMessage.setToken(token);
    chatMessage.setUniqueId(uniqueId);
    chatMessage.setTokenIssuer("1");
    chatMessage.setTypeCode(Util.isNullOrEmpty(request.getTypeCode()) ? typecode : request.getTypeCode());
    String asyncContent = App.getGson().toJson(chatMessage);
    return asyncContent;
}
Also used : RequestCreatePublicThread(com.fanap.podchat.chat.thread.public_thread.RequestCreatePublicThread) AsyncMessage(com.fanap.podchat.mainmodel.AsyncMessage) JsonObject(com.google.gson.JsonObject)

Example 2 with RequestCreatePublicThread

use of com.fanap.podchat.chat.thread.public_thread.RequestCreatePublicThread in project pod-chat-android-sdk by FanapSoft.

the class ExampleUnitTest method instanceOfTest.

@Test
public void instanceOfTest() {
    RequestCreatePublicThread request = new RequestCreatePublicThread.Builder(0, new ArrayList<>(), "unique").build();
    getUniqueName(request);
}
Also used : RequestCreatePublicThread(com.fanap.podchat.chat.thread.public_thread.RequestCreatePublicThread) ArrayList(java.util.ArrayList) Test(org.junit.Test)

Example 3 with RequestCreatePublicThread

use of com.fanap.podchat.chat.thread.public_thread.RequestCreatePublicThread in project pod-chat-android-sdk by FanapSoft.

the class ExampleUnitTest method getUniqueName.

public void getUniqueName(RequestCreateThread request) {
    if (request instanceof RequestCreatePublicThread) {
        RequestCreatePublicThread pt = (RequestCreatePublicThread) request;
        Assert.assertEquals("unique", pt.getUniqueName());
    } else {
        Assert.fail("Name is Lost");
    }
}
Also used : RequestCreatePublicThread(com.fanap.podchat.chat.thread.public_thread.RequestCreatePublicThread)

Example 4 with RequestCreatePublicThread

use of com.fanap.podchat.chat.thread.public_thread.RequestCreatePublicThread in project pod-chat-android-sdk by FanapSoft.

the class ChatActivity method createPublicThread.

private void createPublicThread() {
    Invitee[] invite = new Invitee[] { new Invitee("5739", InviteType.Constants.TO_BE_USER_CONTACT_ID), new Invitee("5740", InviteType.Constants.TO_BE_USER_CONTACT_ID) };
    String metac = getMetaData();
    RequestCreatePublicThread request = new RequestCreatePublicThread.Builder(ThreadType.Constants.PUBLIC_GROUP, Arrays.asList(invite), THREAD_UNIQUE_NAME).withDescription("desc at " + new Date()).title("My Public Group 22").withImage("http://google.com").withMetadata(metac).build();
    presenter.createPublicThread(request);
}
Also used : Invitee(com.fanap.podchat.mainmodel.Invitee) RequestCreatePublicThread(com.fanap.podchat.chat.thread.public_thread.RequestCreatePublicThread) Date(java.util.Date)

Aggregations

RequestCreatePublicThread (com.fanap.podchat.chat.thread.public_thread.RequestCreatePublicThread)4 AsyncMessage (com.fanap.podchat.mainmodel.AsyncMessage)1 Invitee (com.fanap.podchat.mainmodel.Invitee)1 JsonObject (com.google.gson.JsonObject)1 ArrayList (java.util.ArrayList)1 Date (java.util.Date)1 Test (org.junit.Test)1