API Clients

In your Engine distribution, you will see an ApiClient folder. In it, you will find a library that allows native access to the Engine API, as well as dependencies. The library to include is called RusticiSoftware.Engine.Client.dll. Load the Object Browser in Visual Studio for a solution that includes the API client libraryThe Java version is SCORMEngineClient_java-1.0.jar. Your Engine release will have the API client documentation in the Documentation folder.

Example: Creating a Registration

In order to create a registration using the API client library, you could do something like this:

// adds the Basic Auth credentials to request
IAuthenticator authFilter = new HttpBasicAuthenticator("apiuser", "password");

// sets up the REST client with the correct base URI and auth details
Registrations regClient = new Registrations("http://localhost/ScormEngineInterface/api/v1/", authFilter);

// creates a learner for use with the registration
LearnerSchema learner = new LearnerSchema();
learner.Id = uniqueLearnerId;
learner.FirstName = firstName;
learner.LastName = lastName;

// creates the registration
RegistrationSchema registration = new RegistrationSchema();
registration.CourseId = courseId;
registration.Learner = learner;
registration.RegistrationId = uniqueRegistrationId;

// actually makes the call to the API
regClient.postRegistrations(registration);

// adds the Basic Auth credentials to request
ClientRequestFilter authFilter =  new BasicAuthFilter("username", "password");

// sets up the REST client with the correct base URI and auth details
Registrations regClient = new Registrations("http://localhost/ScormEngineInterface/api/v1/", authFilter);

// creates a learner for use with the registration
LearnerSchema learner = new LearnerSchema();
learner.setId(uniqueLearnerId);
learner.setFirstName(firstName);
learner.setLastName(lastName);

// creates the registration
RegistrationSchema registration = new RegistrationSchema();
registration.setCourseId(courseId);
registration.setLearner(learner);
registration.setRegistrationId(uniqueRegistrationId);

// actually makes the call to the API
regClient.postRegistrations(registration);

Parsing a Registration Postback Result Using Client Libraries

The client libraries provide a convenient way to parse a registration postback result into object. All you have to do is pass the body of the postback into RegistrationProgressPostbackHelper.ParsePostback, and it will return a deserialized postback object for you to report off of.

In this instance the code to do this is the same for both Java and C#:

//postback is a String that is returned via Engine's postback.
RegistrationSummarySchema registrationObject = RegistrationProgressPostbackHelper.ParsePostback(postback);

results matching ""

    No results matching ""