Search in sources :

Example 76 with LinkHeaders

use of com.instructure.canvasapi2.utils.LinkHeaders in project instructure-android by instructure.

the class CourseManager_Test method addCourseToFavorites.

public static void addCourseToFavorites(long courseId, StatusCallback<Favorite> callback) {
    // TODO:
    Response response = new Response.Builder().request(new Request.Builder().url("https://test.com").build()).code(200).message("favorite" + " " + courseId).protocol(Protocol.HTTP_1_0).body(ResponseBody.create(MediaType.parse("application/json"), "favorite".getBytes())).addHeader("content-type", "application/json").build();
    Favorite favorite = new Favorite();
    retrofit2.Response<Favorite> response1 = retrofit2.Response.success(favorite, response);
    callback.onResponse(response1, new LinkHeaders(), ApiType.CACHE);
}
Also used : GradingPeriodResponse(com.instructure.canvasapi2.models.GradingPeriodResponse) Response(okhttp3.Response) Favorite(com.instructure.canvasapi2.models.Favorite) LinkHeaders(com.instructure.canvasapi2.utils.LinkHeaders) Request(okhttp3.Request)

Example 77 with LinkHeaders

use of com.instructure.canvasapi2.utils.LinkHeaders 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)

Example 78 with LinkHeaders

use of com.instructure.canvasapi2.utils.LinkHeaders in project instructure-android by instructure.

the class CourseNicknameManager_Test method setNickname.

public static void setNickname(long courseId, String nickname, StatusCallback<CourseNickname> callback) {
    Response response = new Response.Builder().request(new Request.Builder().url("https://test.com").build()).code(200).message("todo").protocol(Protocol.HTTP_1_0).body(ResponseBody.create(MediaType.parse("application/json"), "todo".getBytes())).addHeader("content-type", "application/json").build();
    CourseNickname courseNickname = new CourseNickname();
    courseNickname.setId(courseId);
    courseNickname.setNickname(nickname);
    retrofit2.Response<CourseNickname> response1 = retrofit2.Response.success(courseNickname, response);
    callback.onResponse(response1, new LinkHeaders(), ApiType.CACHE);
}
Also used : Response(okhttp3.Response) LinkHeaders(com.instructure.canvasapi2.utils.LinkHeaders) Request(okhttp3.Request) CourseNickname(com.instructure.canvasapi2.models.CourseNickname)

Example 79 with LinkHeaders

use of com.instructure.canvasapi2.utils.LinkHeaders in project instructure-android by instructure.

the class CourseNicknameManager_Test method deleteNickname.

public static void deleteNickname(long courseId, StatusCallback<CourseNickname> callback) {
    Response response = new Response.Builder().request(new Request.Builder().url("https://test.com").build()).code(200).message("todo").protocol(Protocol.HTTP_1_0).body(ResponseBody.create(MediaType.parse("application/json"), "todo".getBytes())).addHeader("content-type", "application/json").build();
    CourseNickname courseNickname = new CourseNickname();
    courseNickname.setId(courseId);
    retrofit2.Response<CourseNickname> response1 = retrofit2.Response.success(courseNickname, response);
    callback.onResponse(response1, new LinkHeaders(), ApiType.CACHE);
}
Also used : Response(okhttp3.Response) LinkHeaders(com.instructure.canvasapi2.utils.LinkHeaders) Request(okhttp3.Request) CourseNickname(com.instructure.canvasapi2.models.CourseNickname)

Example 80 with LinkHeaders

use of com.instructure.canvasapi2.utils.LinkHeaders in project instructure-android by instructure.

the class CourseNicknameManager_Test method getAllNicknames.

public static void getAllNicknames(StatusCallback<List<CourseNickname>> callback) {
    Response response = new Response.Builder().request(new Request.Builder().url("https://test.com").build()).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<CourseNickname> courses = new ArrayList<>();
    retrofit2.Response<List<CourseNickname>> response1 = retrofit2.Response.success(courses, response);
    callback.onResponse(response1, new LinkHeaders(), ApiType.CACHE);
}
Also used : Response(okhttp3.Response) LinkHeaders(com.instructure.canvasapi2.utils.LinkHeaders) Request(okhttp3.Request) ArrayList(java.util.ArrayList) List(java.util.List) ArrayList(java.util.ArrayList) CourseNickname(com.instructure.canvasapi2.models.CourseNickname)

Aggregations

LinkHeaders (com.instructure.canvasapi2.utils.LinkHeaders)87 Response (okhttp3.Response)57 ArrayList (java.util.ArrayList)31 Request (okhttp3.Request)27 List (java.util.List)25 RestBuilder (com.instructure.canvasapi2.builders.RestBuilder)24 ApiType (com.instructure.canvasapi2.utils.ApiType)23 Response (retrofit2.Response)15 QuizSubmissionResponse (com.instructure.canvasapi2.models.QuizSubmissionResponse)13 QuizSubmissionQuestionResponse (com.instructure.canvasapi2.models.QuizSubmissionQuestionResponse)12 ParentResponse (com.instructure.canvasapi2.models.ParentResponse)10 Conversation (com.instructure.canvasapi2.models.Conversation)9 NonNull (android.support.annotation.NonNull)8 GradingPeriodResponse (com.instructure.canvasapi2.models.GradingPeriodResponse)8 StatusCallback (com.instructure.canvasapi2.StatusCallback)7 FileFolder (com.instructure.canvasapi2.models.FileFolder)6 Submission (com.instructure.canvasapi2.models.Submission)6 Assignment (com.instructure.canvasapi2.models.Assignment)5 CourseNickname (com.instructure.canvasapi2.models.CourseNickname)5 ResponseBody (okhttp3.ResponseBody)5