Search in sources :

Example 26 with Conversation

use of com.instructure.canvasapi2.models.Conversation in project instructure-android by instructure.

the class InboxManager method getConversationsFiltered.

public static void getConversationsFiltered(InboxApi.Scope scope, String canvasContext, boolean forceNetwork, StatusCallback<List<Conversation>> callback) {
    if (isTesting() || mTesting) {
        RestBuilder adapter = new RestBuilder(callback);
        RestParams params = new RestParams.Builder().withPerPageQueryParam(true).withShouldIgnoreToken(false).withForceReadFromNetwork(forceNetwork).build();
        InboxManager_Test.getConversationsFiltered(scope, canvasContext, adapter, callback, params);
    } else {
        RestBuilder adapter = new RestBuilder(callback);
        RestParams params = new RestParams.Builder().withPerPageQueryParam(true).withShouldIgnoreToken(false).withForceReadFromNetwork(forceNetwork).build();
        InboxApi.getConversationsFiltered(scope, canvasContext, adapter, callback, params);
    }
}
Also used : RestParams(com.instructure.canvasapi2.builders.RestParams) RestBuilder(com.instructure.canvasapi2.builders.RestBuilder) RestBuilder(com.instructure.canvasapi2.builders.RestBuilder)

Example 27 with Conversation

use of com.instructure.canvasapi2.models.Conversation in project instructure-android by instructure.

the class InboxManager method starConversation.

public static void starConversation(long conversationId, boolean starred, Conversation.WorkflowState workFlowState, StatusCallback<Conversation> callback) {
    if (isTesting() || mTesting) {
        InboxManager_Test.updateConversation(conversationId, null, starred, callback);
    } else {
        RestBuilder adapter = new RestBuilder(callback);
        RestParams params = new RestParams.Builder().withShouldIgnoreToken(false).withPerPageQueryParam(false).build();
        InboxApi.updateConversation(adapter, callback, params, conversationId, workFlowState, starred);
    }
}
Also used : RestParams(com.instructure.canvasapi2.builders.RestParams) RestBuilder(com.instructure.canvasapi2.builders.RestBuilder)

Example 28 with Conversation

use of com.instructure.canvasapi2.models.Conversation in project instructure-android by instructure.

the class InboxManager method addMessageToConversationSynchronous.

@Nullable
public static Conversation addMessageToConversationSynchronous(long conversationId, String messageText, List<Long> attachmentIds) {
    if (isTesting() || mTesting) {
        // TODO
        return new Conversation();
    } else {
        RestBuilder adapter = new RestBuilder();
        RestParams params = new RestParams.Builder().withPerPageQueryParam(false).withShouldIgnoreToken(false).build();
        try {
            Response<Conversation> response = InboxApi.addMessageToConversationSynchronous(adapter, params, conversationId, messageText, attachmentIds);
            return response.isSuccessful() ? response.body() : null;
        } catch (IOException e) {
            return null;
        }
    }
}
Also used : RestParams(com.instructure.canvasapi2.builders.RestParams) Conversation(com.instructure.canvasapi2.models.Conversation) RestBuilder(com.instructure.canvasapi2.builders.RestBuilder) IOException(java.io.IOException) Nullable(android.support.annotation.Nullable)

Example 29 with Conversation

use of com.instructure.canvasapi2.models.Conversation in project instructure-android by instructure.

the class ConversationTest method getLastMessagePreview.

@Test
public void getLastMessagePreview() {
    Conversation conversation = new Conversation();
    conversation.setDeletedString("conversation deleted");
    conversation.setLastMessage("last message");
    conversation.setDeleted(false);
    assertEquals("last message", conversation.getLastMessagePreview());
}
Also used : Conversation(com.instructure.canvasapi2.models.Conversation) Test(org.junit.Test)

Example 30 with Conversation

use of com.instructure.canvasapi2.models.Conversation in project instructure-android by instructure.

the class ConversationTest method hasMedia.

@Test
public void hasMedia() {
    Conversation conversation = new Conversation();
    ArrayList<String> properties = new ArrayList<>();
    properties.add("media_objects");
    conversation.setProperties(properties);
    assertEquals(true, conversation.hasMedia());
}
Also used : ArrayList(java.util.ArrayList) Conversation(com.instructure.canvasapi2.models.Conversation) Test(org.junit.Test)

Aggregations

Conversation (com.instructure.canvasapi2.models.Conversation)28 RestBuilder (com.instructure.canvasapi2.builders.RestBuilder)20 Test (org.junit.Test)14 RestParams (com.instructure.canvasapi2.builders.RestParams)12 LinkHeaders (com.instructure.canvasapi2.utils.LinkHeaders)9 Response (okhttp3.Response)8 ArrayList (java.util.ArrayList)7 IOException (java.io.IOException)3 List (java.util.List)3 Nullable (android.support.annotation.Nullable)2 Date (java.util.Date)2 Bundle (android.os.Bundle)1 Rfc822Tokenizer (android.text.util.Rfc822Tokenizer)1 Menu (android.view.Menu)1 View (android.view.View)1 AdapterView (android.widget.AdapterView)1 ImageView (android.widget.ImageView)1 ScrollView (android.widget.ScrollView)1 TextView (android.widget.TextView)1 BindView (butterknife.BindView)1