{"id":21959727,"url":"https://github.com/rusticisoftware/scormcloud-api-v2-client-net","last_synced_at":"2025-04-23T18:02:00.252Z","repository":{"id":40849207,"uuid":"177436616","full_name":"RusticiSoftware/scormcloud-api-v2-client-net","owner":"RusticiSoftware","description":"Swagger Generated C# Client for SCORM Cloud API v2","archived":false,"fork":false,"pushed_at":"2024-08-29T19:35:01.000Z","size":704,"stargazers_count":10,"open_issues_count":3,"forks_count":10,"subscribers_count":9,"default_branch":"master","last_synced_at":"2025-03-30T02:11:10.302Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"C#","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-24T15:58:13.000Z","updated_at":"2025-01-19T22:34:40.000Z","dependencies_parsed_at":"2024-11-29T09:42:20.911Z","dependency_job_id":null,"html_url":"https://github.com/RusticiSoftware/scormcloud-api-v2-client-net","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-net","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RusticiSoftware%2Fscormcloud-api-v2-client-net/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RusticiSoftware%2Fscormcloud-api-v2-client-net/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RusticiSoftware%2Fscormcloud-api-v2-client-net/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/RusticiSoftware","download_url":"https://codeload.github.com/RusticiSoftware/scormcloud-api-v2-client-net/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250487526,"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:15.353Z","updated_at":"2025-04-23T18:02:00.172Z","avatar_url":"https://github.com/RusticiSoftware.png","language":"C#","readme":"# Com.RusticiSoftware.Cloud.V2 - the C# library for the SCORM Cloud Rest API\n\nREST API used for SCORM Cloud integrations.\n\nThis C# SDK is automatically generated by the [Swagger Codegen](https://github.com/swagger-api/swagger-codegen) project:\n\n- API version: 2.0\n- SDK version: 4.0.0\n- Build package: io.swagger.codegen.languages.CSharpClientCodegen\n\n## Requirements\nSupports the following frameworks:\n- .NET Framework 4.6.1 or later\n- .NET 6 or later\n\n## Installation\n### NuGet\n[Com.RusticiSoftware.Cloud.V2](https://www.nuget.org/packages/Com.RusticiSoftware.Cloud.V2/)\n\n### Local\n#### Dependencies\n- [RestSharp](https://www.nuget.org/packages/RestSharp)\n- [Newtonsoft.Json](https://www.nuget.org/packages/Newtonsoft.Json/)\n- [JsonSubTypes](https://www.nuget.org/packages/JsonSubTypes/)\n\nThe DLLs included in the package may not be the latest version. We recommend using [NuGet](https://docs.nuget.org/consume/installing-nuget) to obtain the latest version of the packages:\n```\nInstall-Package RestSharp\nInstall-Package Newtonsoft.Json\nInstall-Package JsonSubTypes\n```\n\n#### Library\nDownload the [.NET SDK](https://dotnet.microsoft.com/download) and run the following commands to generate the DLL:\n```shell\ncd src/Com.RusticiSoftware.Cloud.V2\ndotnet restore\ndotnet build\n```\n\nThen include the DLL (under the `bin` folder) in the C# project, and use the namespaces:\n```csharp\nusing Com.RusticiSoftware.Cloud.V2.Api;\nusing Com.RusticiSoftware.Cloud.V2.Client;\nusing Com.RusticiSoftware.Cloud.V2.Model;\n```\n\nTo build a NuGet package, run the following commands (will need to be in the same src/Com.RusticiSoftware.Cloud.V2 directory as before):\n```shell\ndotnet pack\n```\n\nThen, publish to a [local feed](https://docs.microsoft.com/en-us/nuget/hosting-packages/local-feeds) or [other host](https://docs.microsoft.com/en-us/nuget/hosting-packages/overview) and consume the new package via Nuget as usual.\n\n## Tips and Tricks\n**Note:** If using a version of .NET Framework \u003c 4.6, then you will need to add `System.Net.ServicePointManager.SecurityProtocol |= System.Net.SecurityProtocolType.Tls12` to your code.\nThis is because older versions of .NET Framework do not support TLS 1.2 by default, and it is the minimum TLS version we support.\n\nWorking with headers will require calling the `WithHttpInfo` version of the function. This allows for grabbing the header directly from the response object:\n```csharp\n// Note: This code is specifically designed to not modify any existing data\nDispatchApi dispatchApi = new DispatchApi();\nApiResponse\u003cobject\u003e response = dispatchApi.UpdateDispatchesWithHttpInfo(new UpdateDispatchSchema(), since: DateTime.Now);\nConsole.WriteLine(response.Headers[\"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```csharp\nusing Com.RusticiSoftware.Cloud.V2.Api;\nusing Com.RusticiSoftware.Cloud.V2.Client;\nusing Com.RusticiSoftware.Cloud.V2.Model;\nusing System;\nusing System.Collections.Generic;\nusing System.IO;\nusing System.Threading;\n\nnamespace ScormCloud_Cs_Sample\n{\n    class ScormCloud_Cs_Sample\n    {\n        // ScormCloud API credentials\n        // Note: These are not the same credentials used to log in to ScormCloud\n        const string APP_ID = \"APP_ID\";\n        const string SECRET_KEY = \"SECRET_KEY\";\n\n        // Sample values for data\n        const string COURSE_PATH = \"/PATH/TO/COURSE/RunTimeAdvancedCalls_SCORM20043rdEdition.zip\";\n\n        const string COURSE_ID = \"CS_SAMPLE_COURSE\";\n        const string LEARNER_ID = \"CS_SAMPLE_COURSE_LEARNER\";\n        const string REGISTRATION_ID = \"CS_SAMPLE_COURSE_REGISTRATION\";\n\n        // String used for output formatting\n        const string OUTPUT_BORDER = \"---------------------------------------------------------\\n\";\n\n        /// \u003csummary\u003e\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        /// \u003c/summary\u003e\n        /// \u003cremarks\u003e\n        /// All input variables used in this sample are defined up above.\n        /// \u003c/remarks\u003e\n        static void Main(string[] args)\n        {\n            // Configure HTTP basic authorization: APP_NORMAL\n            Configuration.Default.Username = APP_ID;\n            Configuration.Default.Password = SECRET_KEY;\n\n            var sc = new ScormCloud_Cs_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                Console.WriteLine(\"Newly Imported Course Details: \");\n                Console.WriteLine(courseDetails);\n\n\n\n                // Create the registration launch link\n                string launchLink = sc.BuildLaunchLink(REGISTRATION_ID);\n\n                // Show the launch link\n                Console.WriteLine(OUTPUT_BORDER);\n                Console.WriteLine($\"Launch Link: {launchLink}\");\n                Console.WriteLine(\"Navigate to the url above to take the course. Hit enter once complete.\");\n                Console.ReadLine();\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                Console.WriteLine(OUTPUT_BORDER);\n                Console.WriteLine(\"Registration Progess: \");\n                Console.WriteLine(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                Console.WriteLine(OUTPUT_BORDER);\n                Console.WriteLine(\"Course List: \");\n                foreach (CourseSchema course in courseList)\n                {\n                    Console.WriteLine(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                Console.WriteLine(OUTPUT_BORDER);\n                Console.WriteLine(\"Registration List: \");\n                foreach (RegistrationSchema registration in registrationList)\n                {\n                    Console.WriteLine(registration);\n                }\n            }\n            catch (Exception e) when (e is ApiException || e is ArgumentException)\n            {\n                Console.WriteLine(e.ToString());\n            }\n            finally\n            {\n                // Delete all the data created by this sample\n                sc.CleanUp(COURSE_ID, REGISTRATION_ID);\n            }\n        }\n\n        /// \u003csummary\u003e\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        /// \u003c/summary\u003e\n        /// \u003cparam name=\"scopes\"\u003eList of permissions for calls made with the token.\u003c/param\u003e\n        /// \u003cremarks\u003e\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        /// var courseApi = new CourseApi\n        /// {\n        ///     Configuration = new Configuration\n        ///     {\n        ///         AccessToken = applicationManagementApi.CreateToken(\n        ///             new TokenRequestSchema(\n        ///                 new PermissionsSchema(\n        ///                     new List\u003cstring\u003e { \"write:course\", \"read:course\" }\n        ///                 ),\n        ///                 DateTime.Now.AddMinutes(2)\n        ///             )\n        ///         ).Result\n        ///     }\n        /// };\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        /// \u003c/remarks\u003e\n        private void ConfigureOAuth(List\u003cstring\u003e scopes)\n        {\n            var applicationManagementApi = new ApplicationManagementApi();\n\n            // Set permissions and expiry time of the token\n            var expiry = DateTime.Now.AddMinutes(2);\n            var permissions = new PermissionsSchema(scopes);\n\n            // Make the request to get the OAuth token\n            var tokenRequest = new TokenRequestSchema(permissions, expiry);\n            StringResultSchema tokenResult = applicationManagementApi.CreateToken(tokenRequest);\n\n            // Set the default access token used with further API requests.\n            // To remove the token, reset Configuration.Default.AccessToken\n            // back to null before the next call.\n            Configuration.Default.AccessToken = tokenResult.Result;\n        }\n\n        /// \u003csummary\u003e\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        /// \u003c/summary\u003e\n        /// \u003cparam name=\"courseId\"\u003eId that will be used to identify the course.\u003c/param\u003e\n        /// \u003cparam name=\"coursePath\"\u003ePath to the course being uploaded.\u003c/param\u003e\n        /// \u003cremarks\u003e\n        /// Other methods for importing a course exist. Check the documentation\n        /// for additional ways of importing a course.\n        /// \u003c/remarks\u003e\n        /// \u003creturns\u003eDetailed information about the newly uploaded course.\u003c/returns\u003e\n        CourseSchema CreateCourse(string courseId, string coursePath)\n        {\n            // (Optional) Further authenticate via OAuth token access\n            // ConfigureOAuth(new List\u003cstring\u003e { \"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            var courseApi = new CourseApi();\n            StringResultSchema jobId = courseApi.CreateUploadAndImportCourseJob(courseId, _file: File.Open(coursePath, FileMode.Open));\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.Result);\n            while (jobResult.Status == ImportJobResultSchema.StatusEnum.RUNNING)\n            {\n                Thread.Sleep(1000);\n                jobResult = courseApi.GetImportJobStatus(jobId.Result);\n            }\n\n            if (jobResult.Status == ImportJobResultSchema.StatusEnum.ERROR)\n                throw new ArgumentException(\"Course is not properly formatted: \" + jobResult.Message);\n\n            return jobResult.ImportResult.Course;\n        }\n\n        /// \u003csummary\u003e\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        /// \u003c/summary\u003e\n        /// \u003cparam name=\"courseId\"\u003eId of the course to register the learner for.\u003c/param\u003e\n        /// \u003cparam name=\"learnerId\"\u003eId that will be used to identify the learner.\u003c/param\u003e\n        /// \u003cparam name=\"registrationId\"\u003eId that will be used to identify the registration.\u003c/param\u003e\n        void CreateRegistration(string courseId, string learnerId, string registrationId)\n        {\n            // (Optional) Further authenticate via OAuth token access\n            // ConfigureOAuth(new List\u003cstring\u003e { \"write:registration\" });\n\n            var registrationApi = new RegistrationApi();\n            var learner = new LearnerSchema(learnerId);\n            var registration = new CreateRegistrationSchema(courseId, learner, registrationId);\n            registrationApi.CreateRegistration(registration);\n        }\n\n        /// \u003csummary\u003e\n        /// Builds a url allowing the learner to access the course.\n        /// \u003c/summary\u003e\n        /// \u003cparam name=\"registrationId\"\u003eId of the registration the link is being built for.\u003c/param\u003e\n        /// \u003cremarks\u003e\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        /// \u003c/remarks\u003e\n        /// \u003creturns\u003eLink for the learner to launch the course.\u003c/returns\u003e\n        string BuildLaunchLink(string registrationId)\n        {\n            // (Optional) Further authenticate via OAuth token access\n            // ConfigureOAuth(new List\u003cstring\u003e { \"read:registration\" });\n\n            var registrationApi = new RegistrationApi();\n            var settings = new LaunchLinkRequestSchema(redirectOnExitUrl: \"Message\");\n            LaunchLinkSchema launchLink = registrationApi.BuildRegistrationLaunchLink(registrationId, settings);\n\n            return launchLink.LaunchLink;\n        }\n\n        /// \u003csummary\u003e\n        /// Gets information about the progress of the registration.\n        /// \u003c/summary\u003e\n        /// \u003cparam name=\"registrationId\"\u003eId of the registration to get results for.\u003c/param\u003e\n        /// \u003cremarks\u003e\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        /// \u003c/remarks\u003e\n        /// \u003creturns\u003eDetailed information about the registration's progress.\u003c/returns\u003e\n        RegistrationSchema GetResultForRegistration(string registrationId)\n        {\n            // (Optional) Further authenticate via OAuth token access\n            // ConfigureOAuth(new List\u003cstring\u003e { \"read:registration\" });\n\n            var registrationApi = new RegistrationApi();\n            RegistrationSchema progress = registrationApi.GetRegistrationProgress(registrationId);\n\n            return progress;\n        }\n\n        /// \u003csummary\u003e\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        /// \u003c/summary\u003e\n        /// \u003creturns\u003eList of detailed information about all of the courses.\u003c/returns\u003e\n        List\u003cCourseSchema\u003e GetAllCourses()\n        {\n            // (Optional) Further authenticate via OAuth token access\n            // ConfigureOAuth(new List\u003cstring\u003e { \"read:course\" });\n\n            // Additional filters can be provided to this call to get a subset\n            // of all courses.\n            var courseApi = new CourseApi();\n            CourseListSchema response = courseApi.GetCourses();\n\n            // This call is paginated, with a token provided if more results exist\n            List\u003cCourseSchema\u003e courseList = response.Courses;\n            while (response.More != null)\n            {\n                response = courseApi.GetCourses(more: response.More);\n                courseList.AddRange(response.Courses);\n            }\n\n            return courseList;\n        }\n\n        /// \u003csummary\u003e\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        /// \u003c/summary\u003e\n        /// \u003cremarks\u003e\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        /// \u003c/remarks\u003e\n        /// \u003creturns\u003eList of detailed information about all of the registrations.\u003c/returns\u003e\n        List\u003cRegistrationSchema\u003e GetAllRegistrations()\n        {\n            // (Optional) Further authenticate via OAuth token access\n            // ConfigureOAuth(new List\u003cstring\u003e { \"read:registration\" });\n\n            // Additional filters can be provided to this call to get a subset\n            // of all registrations.\n            var registrationApi = new RegistrationApi();\n            RegistrationListSchema response = registrationApi.GetRegistrations();\n\n            // This call is paginated, with a token provided if more results exist\n            List\u003cRegistrationSchema\u003e registrationList = response.Registrations;\n            while (response.More != null)\n            {\n                response = registrationApi.GetRegistrations(more: response.More);\n                registrationList.AddRange(response.Registrations);\n            }\n\n            return registrationList;\n        }\n\n        /// \u003csummary\u003e\n        /// Deletes all of the data generated by this sample.\n        /// \u003c/summary\u003e\n        /// \u003cparam name=\"courseId\"\u003eId of the course to delete.\u003c/param\u003e\n        /// \u003cparam name=\"registrationId\"\u003eId of the registration to delete.\u003c/param\u003e\n        /// \u003cremarks\u003e\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        /// \u003c/remarks\u003e\n        void CleanUp(string courseId, string registrationId)\n        {\n            // (Optional) Further authenticate via OAuth token access\n            // ConfigureOAuth(new List\u003cstring\u003e { \"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```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frusticisoftware%2Fscormcloud-api-v2-client-net","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frusticisoftware%2Fscormcloud-api-v2-client-net","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frusticisoftware%2Fscormcloud-api-v2-client-net/lists"}