Search in sources :

Example 6 with CourseNickname

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

the class CourseNicknameManager method setCourseNickname.

public static void setCourseNickname(long courseId, String nickname, StatusCallback<CourseNickname> callback) {
    if (isTesting() || mTesting) {
        CourseNicknameManager_Test.setNickname(courseId, nickname, callback);
    } else {
        RestBuilder adapter = new RestBuilder(callback);
        RestParams params = new RestParams.Builder().withPerPageQueryParam(false).withShouldIgnoreToken(false).withForceReadFromNetwork(true).build();
        if (nickname.isEmpty()) {
            CourseNicknameAPI.deleteNickname(courseId, adapter, callback, params);
        } else {
            CourseNicknameAPI.setNickname(courseId, nickname, adapter, callback, params);
        }
    }
}
Also used : RestParams(com.instructure.canvasapi2.builders.RestParams) RestBuilder(com.instructure.canvasapi2.builders.RestBuilder) RestBuilder(com.instructure.canvasapi2.builders.RestBuilder)

Example 7 with CourseNickname

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

the class CourseNicknameManager method deleteAllNicknames.

public static void deleteAllNicknames(final StatusCallback<CourseNickname> callback) {
    if (isTesting() || mTesting) {
        CourseNicknameManager_Test.deleteAllNicknames(callback);
    } else {
        RestBuilder adapter = new RestBuilder(callback);
        RestParams params = new RestParams.Builder().withPerPageQueryParam(true).withShouldIgnoreToken(false).build();
        CourseNicknameAPI.deleteAllNicknames(adapter, callback, params);
    }
}
Also used : RestParams(com.instructure.canvasapi2.builders.RestParams) RestBuilder(com.instructure.canvasapi2.builders.RestBuilder)

Example 8 with CourseNickname

use of com.instructure.canvasapi2.models.CourseNickname 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 9 with CourseNickname

use of com.instructure.canvasapi2.models.CourseNickname 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 10 with CourseNickname

use of com.instructure.canvasapi2.models.CourseNickname 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

RestBuilder (com.instructure.canvasapi2.builders.RestBuilder)5 RestParams (com.instructure.canvasapi2.builders.RestParams)5 CourseNickname (com.instructure.canvasapi2.models.CourseNickname)5 LinkHeaders (com.instructure.canvasapi2.utils.LinkHeaders)5 Request (okhttp3.Request)5 Response (okhttp3.Response)5 ArrayList (java.util.ArrayList)1 List (java.util.List)1