Search in sources :

Example 11 with RestParams

use of com.instructure.canvasapi2.builders.RestParams in project instructure-android by instructure.

the class CourseAPI method getNextPageCourseStudents.

public static void getNextPageCourseStudents(boolean forceNetwork, String nextUrl, RestBuilder adapter, StatusCallback<List<User>> callback) {
    RestParams params = new RestParams.Builder().withShouldIgnoreToken(false).withPerPageQueryParam(true).withForceReadFromNetwork(forceNetwork).build();
    callback.addCall(adapter.build(CoursesInterface.class, params).getNextPageStudents(nextUrl)).enqueue(callback);
}
Also used : RestParams(com.instructure.canvasapi2.builders.RestParams) RestBuilder(com.instructure.canvasapi2.builders.RestBuilder)

Example 12 with RestParams

use of com.instructure.canvasapi2.builders.RestParams in project instructure-android by instructure.

the class EnrollmentAPI method getNextPageEnrollments.

public static void getNextPageEnrollments(boolean forceNetwork, String nextUrl, RestBuilder adapter, StatusCallback<List<Enrollment>> callback) {
    RestParams params = new RestParams.Builder().withShouldIgnoreToken(false).withPerPageQueryParam(true).withForceReadFromNetwork(forceNetwork).build();
    callback.addCall(adapter.build(EnrollmentInterface.class, params).getNextPage(nextUrl)).enqueue(callback);
}
Also used : RestParams(com.instructure.canvasapi2.builders.RestParams) RestBuilder(com.instructure.canvasapi2.builders.RestBuilder)

Example 13 with RestParams

use of com.instructure.canvasapi2.builders.RestParams in project instructure-android by instructure.

the class ErrorReportAPI method buildInterface.

private static ErrorReportInterface buildInterface(StatusCallback<?> callback) {
    RestBuilder adapter = new RestBuilder(callback);
    RestParams params = new RestParams.Builder().withShouldIgnoreToken(true).withPerPageQueryParam(false).withForceReadFromCache(false).withForceReadFromNetwork(true).build();
    return adapter.build(ErrorReportInterface.class, params);
}
Also used : RestParams(com.instructure.canvasapi2.builders.RestParams) RestBuilder(com.instructure.canvasapi2.builders.RestBuilder)

Example 14 with RestParams

use of com.instructure.canvasapi2.builders.RestParams in project instructure-android by instructure.

the class FileFolderAPI method uploadFileSynchronousNoRedirect.

@WorkerThread
public static /* Used to manually handle the last redirect */
RemoteFile uploadFileSynchronousNoRedirect(@NonNull RestBuilder adapter, String uploadUrl, Map<String, RequestBody> uploadParams, String mimeType, File file) throws IOException {
    RestParams params = new RestParams.Builder().withShouldIgnoreToken(true).withDomain(uploadUrl).withPerPageQueryParam(false).build();
    RequestBody fileBody = RequestBody.create(MediaType.parse(mimeType), file);
    Headers headers = adapter.buildNoRedirects(FilesFoldersInterface.class, params).uploadFile(uploadParams, fileBody).execute().headers();
    String redirect = headers.get("Location");
    String newFileUrl = redirect.split("/create_success")[0];
    // POST to the redirect... according to the docs we need to do this to finalize the file upload process
    RemoteFile newFile = adapter.build(FilesFoldersInterface.class, params).postNewlyCreatedFile(redirect).execute().body();
    // We weren't receiving a url in the response from the POST to the redirect - here we grab the full file info as a work around
    FileFolder fileFolder = FileFolderManager.getFileFolderFromURLSynchronous(newFileUrl);
    newFile.setUrl(fileFolder.getUrl());
    newFile.setThumbnailUrl(fileFolder.getThumbnailUrl());
    return newFile;
}
Also used : RestParams(com.instructure.canvasapi2.builders.RestParams) Headers(okhttp3.Headers) FileFolder(com.instructure.canvasapi2.models.FileFolder) UpdateFileFolder(com.instructure.canvasapi2.models.UpdateFileFolder) RestBuilder(com.instructure.canvasapi2.builders.RestBuilder) RemoteFile(com.instructure.canvasapi2.models.RemoteFile) RequestBody(okhttp3.RequestBody) WorkerThread(android.support.annotation.WorkerThread)

Example 15 with RestParams

use of com.instructure.canvasapi2.builders.RestParams in project instructure-android by instructure.

the class FileFolderAPI method uploadFileSynchronous.

@WorkerThread
public static RemoteFile uploadFileSynchronous(@NonNull RestBuilder adapter, String uploadUrl, Map<String, RequestBody> uploadParams, String mimeType, File file) throws IOException {
    RestParams params = new RestParams.Builder().withShouldIgnoreToken(true).withDomain(uploadUrl).withPerPageQueryParam(false).build();
    RequestBody fileBody = RequestBody.create(MediaType.parse(mimeType), file);
    return adapter.build(FilesFoldersInterface.class, params).uploadFile(uploadParams, fileBody).execute().body();
}
Also used : RestParams(com.instructure.canvasapi2.builders.RestParams) RestBuilder(com.instructure.canvasapi2.builders.RestBuilder) RequestBody(okhttp3.RequestBody) WorkerThread(android.support.annotation.WorkerThread)

Aggregations

RestBuilder (com.instructure.canvasapi2.builders.RestBuilder)276 RestParams (com.instructure.canvasapi2.builders.RestParams)264 List (java.util.List)33 StatusCallback (com.instructure.canvasapi2.StatusCallback)28 ExhaustiveListCallback (com.instructure.canvasapi2.utils.ExhaustiveListCallback)25 NonNull (android.support.annotation.NonNull)23 ArrayList (java.util.ArrayList)21 LinkHeaders (com.instructure.canvasapi2.utils.LinkHeaders)20 Response (okhttp3.Response)16 ParentResponse (com.instructure.canvasapi2.models.ParentResponse)10 Conversation (com.instructure.canvasapi2.models.Conversation)7 FileFolder (com.instructure.canvasapi2.models.FileFolder)7 UpdateFileFolder (com.instructure.canvasapi2.models.UpdateFileFolder)7 Group (com.instructure.canvasapi2.models.Group)6 NotNull (org.jetbrains.annotations.NotNull)5 DiscussionTopicHeader (com.instructure.canvasapi2.models.DiscussionTopicHeader)4 ApiType (com.instructure.canvasapi2.utils.ApiType)4 Nullable (android.support.annotation.Nullable)3 WorkerThread (android.support.annotation.WorkerThread)3 Course (com.instructure.canvasapi2.models.Course)3