Search in sources :

Example 56 with LinkHeaders

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

the class QuizManager_Test method getQuizSubmissions.

public static void getQuizSubmissions(StatusCallback<QuizSubmissionResponse> callback) {
    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<QuizSubmission> quizSubmissions = new ArrayList<>();
    QuizSubmission quizSubmission = new QuizSubmission();
    quizSubmission.setQuizId(456321L);
    quizSubmissions.add(quizSubmission);
    QuizSubmissionResponse quizSubmissionResponse = new QuizSubmissionResponse();
    quizSubmissionResponse.setQuizSubmissions(quizSubmissions);
    retrofit2.Response<QuizSubmissionResponse> response1 = retrofit2.Response.success(quizSubmissionResponse, response);
    callback.onResponse(response1, new LinkHeaders(), ApiType.CACHE);
}
Also used : QuizSubmissionResponse(com.instructure.canvasapi2.models.QuizSubmissionResponse) Response(okhttp3.Response) QuizSubmissionQuestionResponse(com.instructure.canvasapi2.models.QuizSubmissionQuestionResponse) QuizSubmission(com.instructure.canvasapi2.models.QuizSubmission) LinkHeaders(com.instructure.canvasapi2.utils.LinkHeaders) ArrayList(java.util.ArrayList) QuizSubmissionResponse(com.instructure.canvasapi2.models.QuizSubmissionResponse)

Example 57 with LinkHeaders

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

the class QuizManager_Test method getQuiz.

public static void getQuiz(StatusCallback<Quiz> callback) {
    Response httpResponse = 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();
    Quiz quiz = new Quiz();
    quiz.setTitle("TEST");
    quiz.setDescription("description");
    retrofit2.Response<Quiz> response = retrofit2.Response.success(new Quiz(), httpResponse);
    callback.onResponse(response, new LinkHeaders(), ApiType.CACHE);
}
Also used : QuizSubmissionResponse(com.instructure.canvasapi2.models.QuizSubmissionResponse) Response(okhttp3.Response) QuizSubmissionQuestionResponse(com.instructure.canvasapi2.models.QuizSubmissionQuestionResponse) Quiz(com.instructure.canvasapi2.models.Quiz) LinkHeaders(com.instructure.canvasapi2.utils.LinkHeaders) Request(okhttp3.Request)

Example 58 with LinkHeaders

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

the class SubmissionManager_Test method getStudentSubmissionsForCourse.

public static void getStudentSubmissionsForCourse(long studentId, long courseId, StatusCallback<List<Submission>> callback) {
    // TODO:
    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<Submission> submissions = new ArrayList<>();
    retrofit2.Response<List<Submission>> response1 = retrofit2.Response.success(submissions, response);
    callback.onResponse(response1, new LinkHeaders(), ApiType.CACHE);
}
Also used : Response(okhttp3.Response) Submission(com.instructure.canvasapi2.models.Submission) LinkHeaders(com.instructure.canvasapi2.utils.LinkHeaders) Request(okhttp3.Request) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List)

Example 59 with LinkHeaders

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

the class ThemeManager_Test method getTheme.

public static void getTheme(final StatusCallback<CanvasTheme> callback) {
    CanvasTheme theme = new Gson().fromJson(json, CanvasTheme.class);
    retrofit2.Response<CanvasTheme> response = retrofit2.Response.success(theme);
    callback.onResponse(response, new LinkHeaders(), ApiType.CACHE);
}
Also used : LinkHeaders(com.instructure.canvasapi2.utils.LinkHeaders) Gson(com.google.gson.Gson) CanvasTheme(com.instructure.canvasapi2.models.CanvasTheme)

Example 60 with LinkHeaders

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

the class UserManager_Test method getColors.

public static void getColors(@NonNull RestBuilder adapter, @NonNull StatusCallback<CanvasColor> callback, @NonNull RestParams params) {
    adapter.setStatusCallback(callback);
    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();
    CanvasColor canvasColor = new CanvasColor();
    retrofit2.Response<CanvasColor> response1 = retrofit2.Response.success(canvasColor, response);
    callback.onResponse(response1, new LinkHeaders(), ApiType.CACHE);
}
Also used : Response(okhttp3.Response) ParentResponse(com.instructure.canvasapi2.models.ParentResponse) CanvasColor(com.instructure.canvasapi2.models.CanvasColor) LinkHeaders(com.instructure.canvasapi2.utils.LinkHeaders) RestBuilder(com.instructure.canvasapi2.builders.RestBuilder)

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