Search in sources :

Example 1 with GradingPeriodResponse

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

the class CourseManager method getGradingPeriodsForCourse.

public static void getGradingPeriodsForCourse(StatusCallback<GradingPeriodResponse> callback, long courseId, boolean forceNetwork) {
    if (isTesting() || mTesting) {
        CourseManager_Test.getGradingPeriodsForCourse(callback, courseId);
    } else {
        RestBuilder adapter = new RestBuilder(callback);
        RestParams params = new RestParams.Builder().withShouldIgnoreToken(false).withForceReadFromNetwork(forceNetwork).build();
        CourseAPI.getGradingPeriodsForCourse(adapter, callback, params, courseId);
    }
}
Also used : RestParams(com.instructure.canvasapi2.builders.RestParams) RestBuilder(com.instructure.canvasapi2.builders.RestBuilder)

Example 2 with GradingPeriodResponse

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

the class CourseManager_Test method getGradingPeriodsForCourse.

public static void getGradingPeriodsForCourse(StatusCallback<GradingPeriodResponse> callback, long courseId) {
    // Create mock HTTP response
    Response httpResponse = new Response.Builder().request(new Request.Builder().url("https://test.com").build()).code(200).message("test").protocol(Protocol.HTTP_1_0).body(ResponseBody.create(MediaType.parse("application/json"), "test".getBytes())).addHeader("content-type", "application/json").build();
    // Create mock API response
    GradingPeriodResponse gradingPeriodResponse = new GradingPeriodResponse();
    ArrayList<GradingPeriod> gradingPeriods = new ArrayList<>();
    GradingPeriod gp1 = new GradingPeriod();
    gp1.setId(1);
    GradingPeriod gp2 = new GradingPeriod();
    gp2.setId(2);
    GradingPeriod gp3 = new GradingPeriod();
    gp3.setId(3);
    gradingPeriods.add(gp1);
    gradingPeriods.add(gp2);
    gradingPeriods.add(gp3);
    gradingPeriodResponse.setGradingPeriodList(gradingPeriods);
    retrofit2.Response<GradingPeriodResponse> response = retrofit2.Response.success(gradingPeriodResponse, httpResponse);
    callback.onResponse(response, new LinkHeaders(), ApiType.CACHE);
    callback.onFinished(ApiType.API);
}
Also used : GradingPeriodResponse(com.instructure.canvasapi2.models.GradingPeriodResponse) Response(okhttp3.Response) GradingPeriod(com.instructure.canvasapi2.models.GradingPeriod) LinkHeaders(com.instructure.canvasapi2.utils.LinkHeaders) Request(okhttp3.Request) ArrayList(java.util.ArrayList) GradingPeriodResponse(com.instructure.canvasapi2.models.GradingPeriodResponse)

Aggregations

RestBuilder (com.instructure.canvasapi2.builders.RestBuilder)1 RestParams (com.instructure.canvasapi2.builders.RestParams)1 GradingPeriod (com.instructure.canvasapi2.models.GradingPeriod)1 GradingPeriodResponse (com.instructure.canvasapi2.models.GradingPeriodResponse)1 LinkHeaders (com.instructure.canvasapi2.utils.LinkHeaders)1 ArrayList (java.util.ArrayList)1 Request (okhttp3.Request)1 Response (okhttp3.Response)1