{"id":21959726,"url":"https://github.com/rusticisoftware/scormcloud-api-v2-client-java","last_synced_at":"2025-04-23T18:02:37.534Z","repository":{"id":36262480,"uuid":"177372364","full_name":"RusticiSoftware/scormcloud-api-v2-client-java","owner":"RusticiSoftware","description":"Swagger Generated Java Client for SCORM Cloud API v2","archived":false,"fork":false,"pushed_at":"2024-02-09T22:23:40.000Z","size":711,"stargazers_count":5,"open_issues_count":1,"forks_count":2,"subscribers_count":10,"default_branch":"master","last_synced_at":"2025-04-23T18:02:05.842Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/RusticiSoftware.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-03-24T04:55:27.000Z","updated_at":"2025-01-19T22:36:44.000Z","dependencies_parsed_at":"2023-12-13T23:24:13.420Z","dependency_job_id":"49ddfc59-6d35-482e-9b78-804a7a384f97","html_url":"https://github.com/RusticiSoftware/scormcloud-api-v2-client-java","commit_stats":null,"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RusticiSoftware%2Fscormcloud-api-v2-client-java","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RusticiSoftware%2Fscormcloud-api-v2-client-java/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RusticiSoftware%2Fscormcloud-api-v2-client-java/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RusticiSoftware%2Fscormcloud-api-v2-client-java/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/RusticiSoftware","download_url":"https://codeload.github.com/RusticiSoftware/scormcloud-api-v2-client-java/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250487530,"owners_count":21438612,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-29T09:32:13.716Z","updated_at":"2025-04-23T18:02:37.465Z","avatar_url":"https://github.com/RusticiSoftware.png","language":"Java","readme":"# scormcloud-api-v2-client\n\nSCORM Cloud Rest API\n- API version: 2.0\n    - Build date: 2023-12-14T11:28:58.809-06:00\n\nREST API used for SCORM Cloud integrations.\n\n\n*Automatically generated by the [Swagger Codegen](https://github.com/swagger-api/swagger-codegen)*\n\n## Requirements\n\nBuilding the API client library requires:\n1. Java 1.7+\n2. Maven/Gradle\n\n## Installation\n### Maven\n[scormcloud-api-v2-client](https://mvnrepository.com/artifact/com.rusticisoftware.cloud.v2.client/scormcloud-api-v2-client)\n\n### Local\nTo install the API client library to your local Maven repository, simply execute:\n\n```shell\nmvn clean install\n```\n\nTo deploy it to a remote Maven repository instead, configure the settings of the repository and execute:\n\n```shell\nmvn clean deploy\n```\n\nRefer to the [OSSRH Guide](http://central.sonatype.org/pages/ossrh-guide.html) for more information.\n\n#### Maven users\n\nAdd this dependency to your project's POM:\n\n```xml\n\u003cdependency\u003e\n    \u003cgroupId\u003ecom.rusticisoftware.cloud.v2.client\u003c/groupId\u003e\n    \u003cartifactId\u003escormcloud-api-v2-client\u003c/artifactId\u003e\n    \u003cversion\u003e4.0.0\u003c/version\u003e\n    \u003cscope\u003ecompile\u003c/scope\u003e\n\u003c/dependency\u003e\n```\n\n#### Gradle users\n\nAdd this dependency to your project's build file:\n\n```groovy\ncompile \"com.rusticisoftware.cloud.v2.client:scormcloud-api-v2-client:4.0.0\"\n```\n\n#### Others\n\nAt first generate the JAR by executing:\n\n```shell\nmvn clean package\n```\n\nThen manually install the following JARs:\n\n* `target/scormcloud-api-v2-client-4.0.0.jar`\n* `target/lib/*.jar`\n\n## Tips and Tricks\nWorking with headers will require calling the `WithHttpInfo` version of the function. This allows for grabbing the header directly from the response object:\n```java\n// Note: This code is specifically designed to not modify any existing data\nDispatchApi dispatchApi = new DispatchApi();\nApiResponse\u003cVoid\u003e response = dispatchApi.updateDispatchesWithHttpInfo(new UpdateDispatchSchema(), null, OffsetDateTime.now(), null, null, null, null, null);\nSystem.out.println(response.getHeaders().get(\"X-Total-Count\"));\n```\n\n## Changelog:\nCheck the [changelog](https://cloud.scorm.com/docs/v2/reference/changelog/) for details of what has changed.\n\n## Sample Code\n```java\nimport com.rusticisoftware.cloud.v2.client.ApiClient;\nimport com.rusticisoftware.cloud.v2.client.ApiException;\nimport com.rusticisoftware.cloud.v2.client.Configuration;\nimport com.rusticisoftware.cloud.v2.client.api.ApplicationManagementApi;\nimport com.rusticisoftware.cloud.v2.client.api.CourseApi;\nimport com.rusticisoftware.cloud.v2.client.api.RegistrationApi;\nimport com.rusticisoftware.cloud.v2.client.auth.HttpBasicAuth;\nimport com.rusticisoftware.cloud.v2.client.auth.OAuth;\nimport com.rusticisoftware.cloud.v2.client.model.*;\n\nimport java.io.File;\nimport java.io.IOException;\nimport java.time.OffsetDateTime;\nimport java.util.Arrays;\nimport java.util.Collections;\nimport java.util.List;\n\npublic class ScormCloud_Java_Sample {\n\n    // ScormCloud API credentials\n    // Note: These are not the same credentials used to log in to ScormCloud\n    final static String APP_ID = \"APP_ID\";\n    final static String SECRET_KEY = \"SECRET_KEY\";\n\n    // Sample values for data\n    final static String COURSE_PATH = \"/PATH/TO/COURSE/RunTimeAdvancedCalls_SCORM20043rdEdition.zip\";\n\n    final static String COURSE_ID = \"JAVA_SAMPLE_COURSE\";\n    final static String LEARNER_ID = \"JAVA_SAMPLE_COURSE_LEARNER\";\n    final static String REGISTRATION_ID = \"JAVA_SAMPLE_COURSE_REGISTRATION\";\n\n    // String used for output formatting\n    final static String OUTPUT_BORDER = \"---------------------------------------------------------\\n\";\n\n    /**\n     * This sample will consist of:\n     * 1. Creating a course.\n     * 2. Registering a learner for the course.\n     * 3. Building a link for the learner to take the course.\n     * 4. Getting the learner's progress after having taken the course.\n     * 5. Viewing all courses and registrations.\n     * 6. Deleting all of the data created via this sample.\n     *\n     * All input variables used in this sample are defined up above.\n     */\n    public static void main(String[] args) throws ApiException {\n        // Configure HTTP basic authorization: APP_NORMAL\n        HttpBasicAuth APP_NORMAL = (HttpBasicAuth) Configuration.getDefaultApiClient().getAuthentication(\"APP_NORMAL\");\n        APP_NORMAL.setUsername(APP_ID);\n        APP_NORMAL.setPassword(SECRET_KEY);\n\n        ScormCloud_Java_Sample sc = new ScormCloud_Java_Sample();\n\n        try\n        {\n            // Create a course and a registration\n            CourseSchema courseDetails = sc.createCourse(COURSE_ID, COURSE_PATH);\n            sc.createRegistration(COURSE_ID, LEARNER_ID, REGISTRATION_ID);\n\n            // Show details of the newly imported course\n            System.out.println(\"Newly Imported Course Details: \");\n            System.out.println(courseDetails);\n\n\n\n            // Create the registration launch link\n            String launchLink = sc.buildLaunchLink(REGISTRATION_ID);\n\n            // Show the launch link\n            System.out.println(OUTPUT_BORDER);\n            System.out.printf(\"Launch Link: %s%n\", launchLink);\n            System.out.println(\"Navigate to the url above to take the course. Hit enter once complete.\");\n            try {\n                System.in.read();\n            } catch (IOException e) {\n                e.printStackTrace();\n            }\n\n\n\n            // Get the results for the registration\n            RegistrationSchema registrationProgress = sc.getResultForRegistration(REGISTRATION_ID);\n\n            // Show details of the registration progress\n            System.out.println(OUTPUT_BORDER);\n            System.out.println(\"Registration Progress: \");\n            System.out.println(registrationProgress);\n\n\n\n            // Get information about all the courses in ScormCloud\n            List\u003cCourseSchema\u003e courseList = sc.getAllCourses();\n\n            // Show details of the courses\n            System.out.println(OUTPUT_BORDER);\n            System.out.println(\"Course List: \");\n            for (CourseSchema course: courseList)\n            {\n                System.out.println(course);\n            }\n\n\n\n            // Get information about all the registrations in ScormCloud\n            List\u003cRegistrationSchema\u003e registrationList = sc.getAllRegistrations();\n\n            // Show details of the registrations\n            System.out.println(OUTPUT_BORDER);\n            System.out.println(\"Registration List: \");\n            for (RegistrationSchema registration: registrationList)\n            {\n                System.out.println(registration);\n            }\n        } catch (ApiException | IllegalArgumentException e) {\n            System.out.println(e.toString());\n        } finally {\n            // Delete all the data created by this sample\n            sc.cleanUp(COURSE_ID, REGISTRATION_ID);\n        }\n    }\n\n    /**\n     * Sets the default OAuth token passed with all calls to the API.\n     *\n     * If a token is created with limited scope (i.e. read:registration),\n     * calls that require a different permission set will error. Either a\n     * new token needs to be generated with the correct scope, or the\n     * default access token can be reset to null. This would cause the\n     * request to be made with basic auth credentials (appId/ secret key)\n     * instead.\n     *\n     * Additionally, you could create a new configuration object and set\n     * the token on that object instead of the default access token. This\n     * configuration would then be passed into the Api object:\n     *\n     * ApiClient apiClient = new ApiClient();\n     * TokenRequestSchema tokenRequest = new TokenRequestSchema()\n     *         .permissions(new PermissionsSchema().scopes(Arrays.asList(\"write:course\", \"read:course\")))\n     *         .expiry(OffsetDateTime.now().plusMinutes(2));\n     * apiClient.setAccessToken(applicationManagementApi.createToken(tokenRequest).getResult());\n     * CourseApi courseApi = new CourseApi(apiClient);\n     *\n     * Any calls that would use this CourseApi instance would then have the\n     * write:course and read:course permissions passed automatically, but\n     * other instances would be unaffected and continue to use other means\n     * of authorization.\n     *\n     * @param scopes List of permissions for calls made with the token.\n     */\n    private void configureOAuth(List\u003cString\u003e scopes) throws ApiException {\n        ApplicationManagementApi appManagementApi = new ApplicationManagementApi();\n\n        // Set permissions and expiry time of the token\n        OffsetDateTime expiry = OffsetDateTime.now().plusMinutes(2);\n        PermissionsSchema permissions = new PermissionsSchema()\n                .scopes(scopes);\n\n        // Make the request to get the OAuth token\n        TokenRequestSchema tokenRequest = new TokenRequestSchema()\n                .expiry(expiry)\n                .permissions(permissions);\n        StringResultSchema tokenResult = appManagementApi.createToken(tokenRequest);\n\n        // Set the default access token used with further API requests.\n        // To remove the token, reset the accessToken of\n        // Configuration.getDefaultApiClient().getAuthentication(\"OAUTH\")\n        // back to null before the next call.\n        OAuth OAUTH = (OAuth) Configuration.getDefaultApiClient().getAuthentication(\"OAUTH\");\n        OAUTH.setAccessToken(tokenResult.getResult());\n    }\n\n    /**\n     * Creates a course by uploading the course from your local machine.\n     * Courses are a package of content for a learner to consume.\n     *\n     * Other methods for importing a course exist. Check the documentation\n     * for additional ways of importing a course.\n     *\n     * @param courseId Id that will be used to identify the course.\n     * @param coursePath Path to the course being uploaded.\n     * @return Detailed information about the newly uploaded course.\n     */\n    public CourseSchema createCourse(String courseId, String coursePath) throws ApiException {\n        // (Optional) Further authenticate via OAuth token access\n        // configureOAuth(Arrays.asList(\"write:course\", \"read:course\"));\n\n        // This call will use OAuth with the \"write:course\" scope\n        // if configured.  Otherwise the basic auth credentials will be used\n        CourseApi courseApi = new CourseApi();\n        StringResultSchema jobId = courseApi.createUploadAndImportCourseJob(courseId, null, null, null, null, new File(coursePath));\n\n        // This call will use OAuth with the \"read:course\" scope\n        // if configured.  Otherwise the basic auth credentials will be used\n        ImportJobResultSchema jobResult = courseApi.getImportJobStatus(jobId.getResult());\n        while (jobResult.getStatus() == ImportJobResultSchema.StatusEnum.RUNNING) {\n            try {\n                Thread.sleep(1000);\n            } catch (InterruptedException ignored) {\n                Thread.currentThread().interrupt();\n            }\n\n            jobResult = courseApi.getImportJobStatus(jobId.getResult());\n        }\n\n        if (jobResult.getStatus() == ImportJobResultSchema.StatusEnum.ERROR)\n            throw new IllegalArgumentException(\"Course is not properly formatted: \" + jobResult.getMessage());\n\n        return jobResult.getImportResult().getCourse();\n    }\n\n    /**\n     * Creates a registration allowing the learner to consume the course\n     * content. A registration is the link between a learner and a single\n     * course.\n     *\n     * @param courseId Id of the course to register the learner for.\n     * @param learnerId Id that will be used to identify the learner.\n     * @param registrationId Id that will be used to identify the registration.\n     */\n    public void createRegistration(String courseId, String learnerId, String registrationId) throws ApiException {\n        // (Optional) Further authenticate via OAuth token access\n        // configureOAuth(Collections.singletonList(\"write:registration\"));\n\n        RegistrationApi registrationApi = new RegistrationApi();\n        LearnerSchema learner = new LearnerSchema()\n                .id(learnerId);\n        CreateRegistrationSchema registration = new CreateRegistrationSchema()\n                .courseId(courseId)\n                .learner(learner)\n                .registrationId(registrationId);\n        registrationApi.createRegistration(registration, null);\n    }\n\n    /**\n     * Builds a url allowing the learner to access the course.\n     *\n     * This sample will build the launch link and print it out. It will then\n     * pause and wait for user input, allowing you to navigate to the course\n     * to generate sample learner progress. Once this step has been reached,\n     * hitting the enter key will continue program execution.\n     *\n     * @param registrationId Id of the registration the link is being built for.\n     * @return Link for the learner to launch the course.\n     */\n    public String buildLaunchLink(String registrationId) throws ApiException {\n        // (Optional) Further authenticate via OAuth token access\n        // configureOAuth(Collections.singletonList(\"read:registration\"));\n\n        RegistrationApi registrationApi = new RegistrationApi();\n        LaunchLinkRequestSchema settings = new LaunchLinkRequestSchema()\n                .redirectOnExitUrl(\"Message\");\n        LaunchLinkSchema launchLink = registrationApi.buildRegistrationLaunchLink(registrationId, settings);\n\n        return launchLink.getLaunchLink();\n    }\n\n    /**\n     * Gets information about the progress of the registration.\n     *\n     * For the most up-to-date results, you should implement our postback\n     * mechanism. The basic premise is that any update to the registration\n     * would cause us to send the updated results to your system.\n     *\n     * More details can be found in the documentation:\n     * https://cloud.scorm.com/docs/v2/guides/postback/\n     *\n     * @param registrationId Id of the registration to get results for.\n     * @return Detailed information about the registration's progress.\n     */\n    public RegistrationSchema getResultForRegistration(String registrationId) throws ApiException {\n        // (Optional) Further authenticate via OAuth token access\n        // configureOAuth(Collections.singletonList(\"read:registration\"));\n\n        RegistrationApi registrationApi = new RegistrationApi();\n        RegistrationSchema progress = registrationApi.getRegistrationProgress(registrationId, null, null, null);\n\n        return progress;\n    }\n\n    /**\n     * Gets information about all courses. The result received from the API\n     * call is a paginated list, meaning that additional calls are required\n     * to retrieve all the information from the API. This has already been\n     * accounted for in the sample.\n     *\n     * @return List of detailed information about all of the courses.\n     */\n    public List\u003cCourseSchema\u003e getAllCourses() throws ApiException {\n        // (Optional) Further authenticate via OAuth token access\n        // configureOAuth(Collections.singletonList(\"read:course\"));\n\n        // Additional filters can be provided to this call to get a subset\n        // of all courses.\n        CourseApi courseApi = new CourseApi();\n        CourseListSchema response = courseApi.getCourses(null, null, null, null, null, null, null, null, null, null, null);\n\n        // This call is paginated, with a token provided if more results exist\n        List\u003cCourseSchema\u003e courseList = response.getCourses();\n        while (response.getMore() != null)\n        {\n            response = courseApi.getCourses(null, null, null, null, null, null, null, response.getMore(), null, null, null);\n            courseList.addAll(response.getCourses());\n        }\n\n        return courseList;\n    }\n\n    /**\n     * Gets information about the registration progress for all\n     * registrations. The result received from the API call is a paginated\n     * list, meaning that additional calls are required to retrieve all the\n     * information from the API. This has already been accounted for in the\n     * sample.\n     *\n     * This call can be quite time-consuming and tedious with lots of\n     * registrations. If you find yourself making lots of calls to this\n     * endpoint, it might be worthwhile to look into registration postbacks.\n     *\n     * More details can be found in the documentation:\n     * https://cloud.scorm.com/docs/v2/guides/postback/\n     *\n     * @return List of detailed information about all of the registrations.\n     */\n    public List\u003cRegistrationSchema\u003e getAllRegistrations() throws ApiException {\n        // (Optional) Further authenticate via OAuth token access\n        // configureOAuth(Collections.singletonList(\"read:registration\"));\n\n        // Additional filters can be provided to this call to get a subset\n        // of all registrations.\n        RegistrationApi registrationApi = new RegistrationApi();\n        RegistrationListSchema response = registrationApi.getRegistrations(null, null, null, null, null, null, null, null, null, null, null, null, null, null);\n\n        // This call is paginated, with a token provided if more results exist\n        List\u003cRegistrationSchema\u003e registrationList = response.getRegistrations();\n        while (response.getMore() != null)\n        {\n            response = registrationApi.getRegistrations(null, null, null, null, null, null, null, null, null, response.getMore(), null, null, null, null);\n            registrationList.addAll(response.getRegistrations());\n        }\n\n        return registrationList;\n    }\n\n    /**\n     * Deletes all of the data generated by this sample.\n     *\n     * This code is run even if the program has errored out, providing a\n     * \"clean slate\" for every run of this sample.\n     *\n     * It is not necessary to delete registrations if the course\n     * they belong to has been deleted. Deleting the course will\n     * automatically queue deletion of all registrations associated with\n     * the course. There will be a delay between when the course is deleted\n     * and when the registrations for the course have been removed. The\n     * registration deletion has been handled here to prevent scenarios\n     * where the registration hasn't been deleted yet by the time the\n     * sample has been rerun.\n     *\n     * @param courseId Id of the course to delete.\n     * @param registrationId Id of the registration to delete.\n     */\n    public void cleanUp(String courseId, String registrationId) throws ApiException {\n        // (Optional) Further authenticate via OAuth token access\n        // configureOAuth(Arrays.asList(\"delete:course\", \"delete:registration\"));\n\n        // This call will use OAuth with the \"delete:course\" scope\n        // if configured.  Otherwise the basic auth credentials will be used\n        CourseApi courseApi = new CourseApi();\n        courseApi.deleteCourse(courseId);\n\n        // The code below is to prevent race conditions if the\n        // sample is run in quick successions.\n\n        // This call will use OAuth2 with the \"delete:registration\" scope\n        // if configured.  Otherwise the basic auth credentials will be used.\n        RegistrationApi registrationApi = new RegistrationApi();\n        registrationApi.deleteRegistration(registrationId);\n    }\n}\n\n```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frusticisoftware%2Fscormcloud-api-v2-client-java","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frusticisoftware%2Fscormcloud-api-v2-client-java","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frusticisoftware%2Fscormcloud-api-v2-client-java/lists"}