{"id":21959724,"url":"https://github.com/rusticisoftware/scormcloud-api-v2-client-ruby","last_synced_at":"2025-04-23T18:03:38.225Z","repository":{"id":35835222,"uuid":"177437727","full_name":"RusticiSoftware/scormcloud-api-v2-client-ruby","owner":"RusticiSoftware","description":"Swagger Generated Ruby Client for SCORM Cloud API v2","archived":false,"fork":false,"pushed_at":"2024-02-09T22:23:06.000Z","size":427,"stargazers_count":4,"open_issues_count":2,"forks_count":15,"subscribers_count":10,"default_branch":"master","last_synced_at":"2025-04-23T18:02:08.609Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Ruby","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-24T16:07:38.000Z","updated_at":"2025-01-19T22:39:01.000Z","dependencies_parsed_at":"2024-11-29T09:42:18.584Z","dependency_job_id":null,"html_url":"https://github.com/RusticiSoftware/scormcloud-api-v2-client-ruby","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RusticiSoftware%2Fscormcloud-api-v2-client-ruby","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RusticiSoftware%2Fscormcloud-api-v2-client-ruby/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RusticiSoftware%2Fscormcloud-api-v2-client-ruby/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RusticiSoftware%2Fscormcloud-api-v2-client-ruby/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/RusticiSoftware","download_url":"https://codeload.github.com/RusticiSoftware/scormcloud-api-v2-client-ruby/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:11.738Z","updated_at":"2025-04-23T18:03:38.148Z","avatar_url":"https://github.com/RusticiSoftware.png","language":"Ruby","readme":"# rustici_software_cloud_v2\n\nRusticiSoftwareCloudV2 - the Ruby gem for the SCORM Cloud Rest API\n\nREST API used for SCORM Cloud integrations.\n\nThis SDK is automatically generated by the [Swagger Codegen](https://github.com/swagger-api/swagger-codegen) project:\n\n- API version: 2.0\n- Package version: 4.0.0\n- Build package: io.swagger.codegen.languages.RubyClientCodegen\n\n## Installation\n### Gem\n[rustici_software_cloud_v2](https://rubygems.org/gems/rustici_software_cloud_v2)\n\n### Local:\nBuild the Ruby code into a gem:\n\n```shell\ngem build rustici_software_cloud_v2.gemspec\n```\n\n```shell\ngem install ./rustici_software_cloud_v2-4.0.0.gem\n```\nFor development, run `gem install --dev ./rustici_software_cloud_v2-4.0.0.gem` to install the development dependencies\n\nFinally add this to the Gemfile:\n\n    gem 'rustici_software_cloud_v2', '~\u003e 4.0.0'\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```ruby\n# Note: This code is specifically designed to not modify any existing data\ndispatch_api = RusticiSoftwareCloudV2::DispatchApi.new\nresponse = dispatch_api.update_dispatches_with_http_info(RusticiSoftwareCloudV2::UpdateDispatchSchema.new, {since: Time.now.strftime('%Y-%m-%dT%H:%M:%S.%L') + 'Z'})\nputs response[2][\"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```ruby\nrequire 'rustici_software_cloud_v2'\nrequire 'open-uri'\ninclude RusticiSoftwareCloudV2\n\n\n# ScormCloud API credentials\n# Note: These are not the same credentials used to log in to ScormCloud\nAPP_ID = 'APP_ID'\nSECRET_KEY = 'SECRET_KEY'\n\n# Sample values for data\nCOURSE_PATH = '/PATH/TO/COURSE/RunTimeAdvancedCalls_SCORM20043rdEdition.zip'\n\nCOURSE_ID = 'RB_SAMPLE_COURSE'\nLEARNER_ID = 'RB_SAMPLE_COURSE_LEARNER'\nREGISTRATION_ID = 'RB_SAMPLE_COURSE_REGISTRATION'\n\n# String used for output formatting\nOUTPUT_BORDER = \"---------------------------------------------------------\\n\\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.\ndef main()\n    RusticiSoftwareCloudV2.configure do |config|\n        # Configure HTTP basic authorization: APP_NORMAL\n        config.username = APP_ID\n        config.password = SECRET_KEY\n    end\n\n    sc = ScormCloud_Ruby_Sample.new\n\n    begin\n        # Create a course and a registration\n        course_details = sc.create_course(COURSE_ID, COURSE_PATH)\n        sc.create_registration(COURSE_ID, LEARNER_ID, REGISTRATION_ID)\n\n        # Show details of the newly imported course\n        puts 'Newly Imported Course Details: '\n        puts course_details\n\n\n\n        # Create the registration launch link\n        launch_link = sc.build_launch_link(REGISTRATION_ID)\n\n        # Show the launch link\n        puts OUTPUT_BORDER\n        puts \"Launck Link: #{launch_link}\"\n        puts 'Navigate to the url above to take the course. Hit enter once complete.'\n        gets\n\n\n\n        # Get the results for the registration\n        registration_progress = sc.get_result_for_registration(REGISTRATION_ID)\n\n        # Show details of the registration progress\n        puts OUTPUT_BORDER\n        puts 'Registration Progress: '\n        puts registration_progress\n\n\n\n        # Get information about all the courses in ScormCloud\n        course_list = sc.get_all_courses()\n\n        # Show details of the courses\n        puts OUTPUT_BORDER\n        puts 'Course List: '\n        course_list.each do |course|\n            puts course\n        end\n\n\n\n        # Get information about all the registrations in ScormCloud\n        registration_list = sc.get_all_registrations()\n\n        # Show details of the registrations\n        puts OUTPUT_BORDER\n        puts 'Registration List: '\n        registration_list.each do |registration|\n            puts registration\n        end\n\n    rescue ApiError, ArgumentError =\u003e error\n        puts error\n\n    ensure\n        # Delete all the data created by this sample\n        sc.clean_up(COURSE_ID, REGISTRATION_ID)\n\n    end\nend\n\nclass ScormCloud_Ruby_Sample\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 nil. 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    # config = Configuration.new\n    # token_request = TokenRequestSchema.new({\n    #     permissions: PermissionsSchema.new({\n    #         scopes: [ \"write:course\", \"read:course\" ]\n    #     }),\n    #     expiry: (Time.now + 2 * 60).iso8601\n    # })\n    # config.access_token = app_management_api.create_token(token_request).result\n    # course_api = CourseApi.new(ApiClient.new(config))\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 [Array\u003cString\u003e] :scopes List of permissions for calls made with the token.\n    private def configure_oauth(scopes)\n        app_management_api = ApplicationManagementApi.new\n\n        # Set permissions and expiry time of the token\n        # The expiry expected for token request must be in ISO-8601 format\n        expiry = (Time.now + 2 * 60).iso8601\n        permissions = PermissionsSchema.new({ scopes: scopes })\n\n        # Make the request to get the OAuth token\n        token_request = TokenRequestSchema.new({ permissions: permissions, expiry: expiry })\n        token_result = app_management_api.create_token(token_request)\n\n        # Set the default access token used with further API requests.\n        # To remove the token, reset config.access_token back to nil\n        # before the next call.\n        RusticiSoftwareCloudV2.configure do |config|\n            config.access_token = token_result.result\n        end\n\n        nil\n    end\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 [String] :course_id Id that will be used to identify the course.\n    # @param [String] :course_path Path to the course being uploaded.\n    # @return [CourseSchema] Detailed information about the newly uploaded course.\n    def create_course(course_id, course_path)\n        # (Optional) Further authenticate via OAuth token access\n        # configure_oauth([ \"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        course_api = CourseApi.new\n        job_id = course_api.create_upload_and_import_course_job(course_id, { file: open(course_path) })\n\n        # This call will use OAuth with the \"read:course\" scope\n        # if configured.  Otherwise the basic auth credentials will be used\n        job_result = course_api.get_import_job_status(job_id.result)\n        while job_result.status == 'RUNNING'\n            sleep(1)\n            job_result = course_api.get_import_job_status(job_id.result)\n        end\n\n        if job_result.status == 'ERROR'\n            raise ArgumentError.new('Course is not properly formatted: ' + job_result.message)\n        end\n\n        job_result.import_result.course\n    end\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 [String] :course_id Id of the course to register the learner for.\n    # @param [String] :learner_id Id that will be used to identify the learner.\n    # @param [String] :registration_id Id that will be used to identify the registration.\n    def create_registration(course_id, learner_id, registration_id)\n        # (Optional) Further authenticate via OAuth token access\n        # configure_oauth([ \"write:registration\" ])\n\n        registration_api = RegistrationApi.new\n        learner = LearnerSchema.new({ id: learner_id })\n        registration = CreateRegistrationSchema.new({ courseId: course_id, learner: learner, registrationId: registration_id })\n        registration_api.create_registration(registration)\n\n        nil\n    end\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 [String] :registration_id Id of the registration the link is being built for.\n    # @return [String] Link for the learner to launch the course.\n    def build_launch_link(registration_id)\n        # (Optional) Further authenticate via OAuth token access\n        # configure_oauth([ \"read:registration\" ])\n\n        registration_api = RegistrationApi.new\n        settings = LaunchLinkRequestSchema.new({ redirectOnExitUrl: 'Message' })\n        launch_link = registration_api.build_registration_launch_link(registration_id, settings)\n\n        launch_link.launch_link\n    end\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 [String] :registration_id Id of the registration to get results for.\n    # @return [RegistrationSchema] Detailed information about the registration's progress.\n    def get_result_for_registration(registration_id)\n        # (Optional) Further authenticate via OAuth token access\n        # configure_oauth([ \"read:registration\" ])\n\n        registration_api = RegistrationApi.new\n        progress = registration_api.get_registration_progress(registration_id)\n\n        progress\n    end\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 [Array\u003cCourseSchema\u003e] List of detailed information about all of the courses.\n    def get_all_courses()\n        # (Optional) Further authenticate via OAuth token access\n        # configure_oauth([ \"read:course\" ])\n\n        # Additional filters can be provided to this call to get a subset\n        # of all courses.\n        course_api = CourseApi.new\n        response = course_api.get_courses()\n\n        # This call is paginated, with a token provided if more results exist\n        course_list = response.courses\n        until response.more.nil?\n            response = course_api.get_courses({ more: response.more })\n            course_list += response.courses\n        end\n\n        course_list\n    end\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 [Array\u003cRegistrationSchema\u003e] List of detailed information about all of the registrations.\n    def get_all_registrations()\n        # (Optional) Further authenticate via OAuth token access\n        # configure_oauth([ \"read:registration\" ])\n\n        # Additional filters can be provided to this call to get a subset\n        # of all registrations.\n        registration_api = RegistrationApi.new\n        response = registration_api.get_registrations()\n\n        # This call is paginated, with a token provided if more results exist\n        registration_list = response.registrations\n        until response.more.nil?\n            response = registration_api.get_registrations({ more: response.more })\n            registration_list += response.registrations\n        end\n\n        registration_list\n    end\n\n    # Deletes all of the data generated by this sample.\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 [String] :course_id Id of the course to delete.\n    # @param [String] :registration_id Id of the registration to delete.\n    def clean_up(course_id, registration_id)\n        # (Optional) Further authenticate via OAuth token access\n        # configure_oauth([ \"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        course_api = CourseApi.new\n        course_api.delete_course(course_id)\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 OAuth with the \"delete:registration\" scope\n        # if configured.  Otherwise the basic auth credentials will be used\n        registration_api = RegistrationApi.new\n        registration_api.delete_registration(registration_id)\n\n        nil\n    end\nend\n\nif __FILE__ == $0\n    main\nend\n\n```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frusticisoftware%2Fscormcloud-api-v2-client-ruby","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frusticisoftware%2Fscormcloud-api-v2-client-ruby","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frusticisoftware%2Fscormcloud-api-v2-client-ruby/lists"}