use of com.instructure.canvasapi2.builders.RestBuilder in project instructure-android by instructure.
the class AnnouncementManager method getAnnouncements.
/**
* Get announcements for the given context codes and date range. Currently this only works for
* courses. All non-course context codes will be ignored.
* @param contextCodes List of context_codes to retrieve announcements for (for example,
* course_123). Only courses are presently supported and all non-course
* context codes will be ignored.
* @param startDate Only return announcements posted since the start_date (inclusive). May be null,
* defaults to 14 days ago. The value should be formatted as: yyyy-mm-dd
* or ISO 8601 YYYY-MM-DDTHH:MM:SSZ.
* @param endDate Only return announcements posted before the end_date (inclusive). May be null,
* defaults to 28 days from start_date. The value should be formatted as: yyyy-mm-dd
* or ISO 8601 YYYY-MM-DDTHH:MM:SSZ. Announcements scheduled for future posting
* will only be returned to course administrators.
* @param forceNetwork Force network
* @param callback StatusCallback
*/
public static void getAnnouncements(@NonNull List<String> contextCodes, String startDate, String endDate, boolean forceNetwork, @NonNull StatusCallback<List<DiscussionTopicHeader>> callback) {
// Use only course context codes
ArrayList<String> courseContextCodes = new ArrayList<>();
for (String code : contextCodes) {
if (code != null && code.startsWith("course")) {
courseContextCodes.add(code);
}
}
// noinspection PointlessBooleanExpression
if (isTesting() || mTesting) {
AnnouncementManager_Test.getAnnouncements(courseContextCodes, startDate, endDate, callback);
} else {
RestBuilder adapter = new RestBuilder(callback);
RestParams params = new RestParams.Builder().withForceReadFromNetwork(forceNetwork).build();
AnnouncementAPI.getAnnouncements(courseContextCodes, startDate, endDate, adapter, callback, params);
}
}
use of com.instructure.canvasapi2.builders.RestBuilder in project instructure-android by instructure.
the class AnnouncementManager method getAllAnnouncements.
public static void getAllAnnouncements(@NonNull CanvasContext canvasContext, boolean forceNetwork, StatusCallback<List<DiscussionTopicHeader>> callback) {
if (isTesting() || mTesting) {
// TODO:
} else {
final RestBuilder adapter = new RestBuilder(callback);
final RestParams params = new RestParams.Builder().withForceReadFromNetwork(forceNetwork).withPerPageQueryParam(true).build();
StatusCallback<List<DiscussionTopicHeader>> depaginatedCallback = new ExhaustiveListCallback<DiscussionTopicHeader>(callback) {
@Override
public void getNextPage(@NotNull StatusCallback<List<DiscussionTopicHeader>> callback, @NotNull String nextUrl, boolean isCached) {
AnnouncementAPI.getNextPage(nextUrl, adapter, callback, params);
}
};
adapter.setStatusCallback(depaginatedCallback);
AnnouncementAPI.getFirstPageAnnouncements(canvasContext, adapter, depaginatedCallback, params);
}
}
use of com.instructure.canvasapi2.builders.RestBuilder in project instructure-android by instructure.
the class AnnouncementManager method getAnnouncements.
public static void getAnnouncements(@NonNull CanvasContext canvasContext, boolean forceNetwork, StatusCallback<List<DiscussionTopicHeader>> callback) {
if (isTesting() || mTesting) {
AnnouncementManager_Test.getAnnouncements(canvasContext, callback);
} else {
RestBuilder adapter = new RestBuilder(callback);
RestParams params = new RestParams.Builder().withPerPageQueryParam(true).withShouldIgnoreToken(false).withForceReadFromNetwork(forceNetwork).build();
AnnouncementAPI.getAnnouncements(canvasContext, adapter, callback, params);
}
}
use of com.instructure.canvasapi2.builders.RestBuilder in project instructure-android by instructure.
the class AssignmentManager method deleteAssignment.
public static void deleteAssignment(long courseId, Assignment assignment, final StatusCallback<Assignment> callback) {
if (isTesting() || mTesting) {
AssignmentManager_Test.deleteAssignment(assignment, callback);
} else {
RestBuilder adapter = new RestBuilder(callback);
RestParams params = new RestParams.Builder().withPerPageQueryParam(true).withShouldIgnoreToken(false).build();
AssignmentAPI.deleteAssignment(courseId, assignment.getId(), adapter, callback, params);
}
}
use of com.instructure.canvasapi2.builders.RestBuilder in project instructure-android by instructure.
the class AssignmentManager method getAssignmentGroup.
public static void getAssignmentGroup(long courseId, long assignmentGroupId, boolean forceNetwork, StatusCallback<AssignmentGroup> callback) {
if (isTesting() || mTesting) {
AssignmentManager_Test.getAssignmentGroup(courseId, assignmentGroupId, callback);
} else {
RestBuilder adapter = new RestBuilder(callback);
RestParams params = new RestParams.Builder().withPerPageQueryParam(true).withShouldIgnoreToken(false).withForceReadFromNetwork(forceNetwork).build();
AssignmentAPI.getAssignmentGroup(courseId, assignmentGroupId, adapter, callback, params);
}
}
Aggregations