Courses module nodejs API client
import SMCourses from '@ikonintegration/mod-courses-client';
const API = new SMCourses({
//those 3 need to be provided
endpoint: SharedModules_CoursesEndpoint,
//Must be specified when using service routes
apiKey: config.examProvider.key, //API token on IDM.AppID format (generate from APIKey at https://runkit.com/gwdp/idm-appid)
//Must be specified when using admin or user routes
authorizationToken: '', -- optional, IDM JWT for shared module admins and user routes -- Accepts a function to be called async and return the token
namespace: ''
});
//Create or update user
const resp = API.user.createOrUpdateUser({
user: {
firstName: 'Gabriel', lastName: 'Pacheco',
email: 'gabriel.xx@gmail.com', id: 'IDM-ID'
}
}
);
if (!resp || resp.statusCode != 200) {
return ERROR:
} return SUCCESS;
//Enroll user into course or update user
const resp = API.course.enrollUser(userID, courseID);
if (!resp || resp.statusCode != 200) {
return ERROR:
} return SUCCESS;
//SSO
const resp = API.course.generateSSO(userID, courseID, optionalCallbackURL);
if (!resp || resp.statusCode != 200) {
return ERROR:
} return resp.body.url;
The following 2 headers must be specified in every request!
- ProviderID
- Authorization
User:
- API.user.createOrUpdateUser(userObj)
- API.user.updateUser(userObj)
Course:
- API.course.enrollUser(userID, courseID, optionalQuizID)
- API.course.unrollUser(userID, courseID, optionalQuizID)
- API.course.generateSSO(userID, courseID, callbackURL /optional/)
- API.course.getGrade(userID, courseID, gradeID)