Search in sources :

Example 21 with Conversation

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

the class InboxManager method getConversationSynchronous.

public static Conversation getConversationSynchronous(long conversationId, boolean forceNetwork) {
    if (isTesting() || mTesting) {
        // TODO
        return new Conversation();
    } else {
        RestBuilder adapter = new RestBuilder();
        RestParams params = new RestParams.Builder().withPerPageQueryParam(false).withShouldIgnoreToken(false).withForceReadFromNetwork(forceNetwork).build();
        try {
            Response<Conversation> response = InboxApi.getConversationSynchronous(adapter, params, conversationId);
            return response.isSuccessful() ? response.body() : null;
        } catch (IOException e) {
            return null;
        }
    }
}
Also used : RestParams(com.instructure.canvasapi2.builders.RestParams) RestBuilder(com.instructure.canvasapi2.builders.RestBuilder) Conversation(com.instructure.canvasapi2.models.Conversation) RestBuilder(com.instructure.canvasapi2.builders.RestBuilder) IOException(java.io.IOException)

Example 22 with Conversation

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

the class InboxManager method createConversationWithAttachmentSynchronous.

@Nullable
public static List<Conversation> createConversationWithAttachmentSynchronous(String messageText, String subject, List<String> userIds, String contextId, boolean isGroup, List<Long> attachmentsIds) {
    if (isTesting() || mTesting) {
        // TODO
        return null;
    } else {
        RestBuilder adapter = new RestBuilder();
        RestParams params = new RestParams.Builder().withPerPageQueryParam(false).withShouldIgnoreToken(false).build();
        try {
            return InboxApi.createConversationWithAttachmentSynchronous(adapter, params, userIds, messageText, subject, contextId, isGroup, attachmentsIds);
        } catch (IOException e) {
            return null;
        }
    }
}
Also used : RestParams(com.instructure.canvasapi2.builders.RestParams) RestBuilder(com.instructure.canvasapi2.builders.RestBuilder) IOException(java.io.IOException) Nullable(android.support.annotation.Nullable)

Example 23 with Conversation

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

the class InboxManager method createConversation.

public static void createConversation(List<String> userIDs, String message, String subject, String contextId, long[] attachmentIds, boolean isBulk, StatusCallback<List<Conversation>> callback) {
    if (isTesting() || mTesting) {
        // todo
        RestBuilder adapter = new RestBuilder(callback);
        RestParams params = new RestParams.Builder().withPerPageQueryParam(false).withShouldIgnoreToken(false).build();
        InboxManager_Test.createConversation(adapter, params, userIDs, message, subject, contextId, isBulk, callback);
    } else {
        RestBuilder adapter = new RestBuilder(callback);
        RestParams params = new RestParams.Builder().withPerPageQueryParam(false).withShouldIgnoreToken(false).build();
        InboxApi.createConversation(adapter, params, userIDs, message, subject, contextId, attachmentIds, isBulk, callback);
    }
}
Also used : RestParams(com.instructure.canvasapi2.builders.RestParams) RestBuilder(com.instructure.canvasapi2.builders.RestBuilder)

Example 24 with Conversation

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

the class InboxManager method deleteConversation.

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

Example 25 with Conversation

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

the class InboxManager method getConversations.

public static void getConversations(InboxApi.Scope scope, 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.getConversations(scope, adapter, callback, params);
    } else {
        RestBuilder adapter = new RestBuilder(callback);
        RestParams params = new RestParams.Builder().withPerPageQueryParam(true).withShouldIgnoreToken(false).withForceReadFromNetwork(forceNetwork).build();
        InboxApi.getConversations(scope, adapter, callback, params);
    }
}
Also used : RestParams(com.instructure.canvasapi2.builders.RestParams) RestBuilder(com.instructure.canvasapi2.builders.RestBuilder) RestBuilder(com.instructure.canvasapi2.builders.RestBuilder)

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