use of com.instructure.canvasapi2.builders.RestBuilder 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);
}
use of com.instructure.canvasapi2.builders.RestBuilder 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;
}
use of com.instructure.canvasapi2.builders.RestBuilder 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();
}
use of com.instructure.canvasapi2.builders.RestBuilder in project instructure-android by instructure.
the class RecipientManager_Test method getFirstPageRecipients.
public static void getFirstPageRecipients(String searchQuery, String context, StatusCallback<List<Recipient>> callback, RestBuilder adapter, RestParams params) {
// TODO:
Response response = new Response.Builder().code(200).message("todo").protocol(Protocol.HTTP_1_0).body(ResponseBody.create(MediaType.parse("application/json"), "todo".getBytes())).addHeader("content-type", "application/json").build();
List<Recipient> items = new ArrayList<>();
retrofit2.Response<List<Recipient>> response1 = retrofit2.Response.success(items, response);
callback.onResponse(response1, new LinkHeaders(), ApiType.CACHE);
}
use of com.instructure.canvasapi2.builders.RestBuilder in project instructure-android by instructure.
the class UserManager_Test method addStudentToParentAirwolf.
public static void addStudentToParentAirwolf(String airwolfDomain, RestBuilder adapter, RestParams params, String parentId, String studentDomain, StatusCallback<ResponseBody> callback) {
adapter.setStatusCallback(callback);
Response response = new Response.Builder().code(200).message("success").protocol(Protocol.HTTP_1_0).body(ResponseBody.create(MediaType.parse("application/json"), "success".getBytes())).addHeader("content-type", "application/json").build();
retrofit2.Response response1 = retrofit2.Response.success(response);
callback.onResponse(response1, new LinkHeaders(), ApiType.API);
}
Aggregations