comprodls-sdk 2.15.0 → 2.19.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/comprodls-sdk.js +517 -330
- package/dist/comprodls-sdk.min.js +18 -18
- package/lib/config/index.js +4 -1
- package/lib/services/auth/index.js +71 -5
- package/lib/services/invitations/index.js +11 -1
- package/lib/services/spaces/index.js +49 -1
- package/lib/services/xapi/index.js +45 -2
- package/package.json +1 -1
package/lib/config/index.js
CHANGED
|
@@ -167,6 +167,7 @@ exports.AUTH_API_URLS = {
|
|
|
167
167
|
getParticularClassAPI: '/org/{orgId}/classes/{classId}',
|
|
168
168
|
getParticularShadowClassAPI: '/org/{orgId}/shadow/classes/{extClassId}',
|
|
169
169
|
classProductAssociation: '/org/{orgId}/classes/{classId}/associate-product/{productcode}',
|
|
170
|
+
multiClassProductAssociations: '/org/{orgId}/classes/{classId}/associate-product/multi',
|
|
170
171
|
enrollUsertoClass: '/org/{orgId}/classes/{classId}/enroll-user/{userId}',
|
|
171
172
|
enrollSelftoClass: '/org/{orgId}/classes/{classId}/enroll-self',
|
|
172
173
|
enrollMultiUserstoClass: '/org/{orgId}/classes/{classId}/enroll-user/multi',
|
|
@@ -196,6 +197,7 @@ exports.AUTH_API_URLS = {
|
|
|
196
197
|
getInvitationsByEmail: '/accounts/{accountid}/invitations-by-email',
|
|
197
198
|
generateSpaceCode: '/accounts/{accountid}/space-code/generate',
|
|
198
199
|
changeSpaceCode: '/accounts/{accountid}/space-code/{spacecode}/change',
|
|
200
|
+
updateInstituteTitle: '/accounts/{accountId}/institute-spaces/{instituteSpaceCode}',
|
|
199
201
|
|
|
200
202
|
//Superuser related API
|
|
201
203
|
getAllInstitutions: '/su/accounts/{accountid}/spaces',
|
|
@@ -303,7 +305,8 @@ exports.PRODUCT_API_URLS = {
|
|
|
303
305
|
|
|
304
306
|
exports.XAPI_API_URLS = {
|
|
305
307
|
postMultiStatements: '/{orgId}/statements/multi',
|
|
306
|
-
postExternalMultiStatements: '/{orgId}/external/statements/multi'
|
|
308
|
+
postExternalMultiStatements: '/{orgId}/external/statements/multi',
|
|
309
|
+
resetUserProductProgress: '/accounts/{accountId}/progress/user/product/reset'
|
|
307
310
|
};
|
|
308
311
|
|
|
309
312
|
exports.ATTEMPTS_API_URLS = {
|
|
@@ -67,6 +67,7 @@ function auth() {
|
|
|
67
67
|
getParticularShadowClass: getParticularShadowClass.bind(this),
|
|
68
68
|
createClassProductAssociation: createClassProductAssociation.bind(this),
|
|
69
69
|
removeClassProductAssociation: removeClassProductAssociation.bind(this),
|
|
70
|
+
createMultiClassProductAssociations: createMultiClassProductAssociations.bind(this),
|
|
70
71
|
addItemsToShowcaseOfAClass: addItemsToShowcaseOfAClass.bind(this),
|
|
71
72
|
deleteItemsFromShowcaseOfAClass: deleteItemsFromShowcaseOfAClass.bind(this),
|
|
72
73
|
|
|
@@ -1064,6 +1065,62 @@ function removeClassProductAssociation(options) {
|
|
|
1064
1065
|
return dfd.promise;
|
|
1065
1066
|
}
|
|
1066
1067
|
|
|
1068
|
+
/**
|
|
1069
|
+
* This function creates multiple class-product associations.
|
|
1070
|
+
* @param options {
|
|
1071
|
+
* *classId : <string>,
|
|
1072
|
+
* *productcodes : [<string>] // Min: 1, Max: 50
|
|
1073
|
+
* }
|
|
1074
|
+
* Note: Fields marked with '*' are mandatory.
|
|
1075
|
+
*/
|
|
1076
|
+
function createMultiClassProductAssociations(options) {
|
|
1077
|
+
var deferred = q.defer();
|
|
1078
|
+
var self = this;
|
|
1079
|
+
var error = helpers.validations.isAuthenticated(self.orgId, self.token);
|
|
1080
|
+
|
|
1081
|
+
if (error) {
|
|
1082
|
+
deferred.reject(error);
|
|
1083
|
+
} else if (options && options.classId && options.productcodes) {
|
|
1084
|
+
// Passed all validations, Contruct API url
|
|
1085
|
+
var defaultHostPath = self.config.DEFAULT_HOSTS.AUTH;
|
|
1086
|
+
var bulkCPAssociationAPIPath = self.config.AUTH_API_URLS.multiClassProductAssociations;
|
|
1087
|
+
|
|
1088
|
+
var url = defaultHostPath + bulkCPAssociationAPIPath;
|
|
1089
|
+
var bodyParams = { productcodes: options.productcodes };
|
|
1090
|
+
|
|
1091
|
+
url = helpers.api.constructAPIUrl(url, { orgId: self.orgId, classId: options.classId });
|
|
1092
|
+
|
|
1093
|
+
// Setup request with URL and Params
|
|
1094
|
+
var requestAPI = request.post(url)
|
|
1095
|
+
.set('Content-Type', 'application/json')
|
|
1096
|
+
.set('Accept', 'application/json')
|
|
1097
|
+
.send(bodyParams);
|
|
1098
|
+
|
|
1099
|
+
if (self.traceid) {
|
|
1100
|
+
requestAPI.set('X-Amzn-Trace-Id', self.traceid);
|
|
1101
|
+
}
|
|
1102
|
+
|
|
1103
|
+
// Setup token in Authorization header
|
|
1104
|
+
requestAPI = helpers.api.setupAPIToken(requestAPI, self.token);
|
|
1105
|
+
|
|
1106
|
+
requestAPI.end(function(err, response) {
|
|
1107
|
+
if (err) {
|
|
1108
|
+
error = new DLSError(helpers.errors.ERROR_TYPES.API_ERROR, err);
|
|
1109
|
+
deferred.reject(error);
|
|
1110
|
+
} else {
|
|
1111
|
+
deferred.resolve(response.body);
|
|
1112
|
+
}
|
|
1113
|
+
});
|
|
1114
|
+
} else {
|
|
1115
|
+
error = {};
|
|
1116
|
+
error.message = error.description = 'Missing mandaotry fields \'classId\' or \'productcodes\' in request.';
|
|
1117
|
+
error = new DLSError(helpers.errors.ERROR_TYPES.SDK_ERROR, error);
|
|
1118
|
+
deferred.reject(error);
|
|
1119
|
+
}
|
|
1120
|
+
|
|
1121
|
+
return deferred.promise;
|
|
1122
|
+
}
|
|
1123
|
+
|
|
1067
1124
|
/*options = {
|
|
1068
1125
|
classid: 'string'
|
|
1069
1126
|
}*/
|
|
@@ -1257,6 +1314,7 @@ function enrollUsertoClass(options) {
|
|
|
1257
1314
|
|
|
1258
1315
|
//options = {
|
|
1259
1316
|
// classid: '', //Class Id
|
|
1317
|
+
// classrole: ''
|
|
1260
1318
|
//};
|
|
1261
1319
|
function enrollSelftoClass(options) {
|
|
1262
1320
|
var self = this;
|
|
@@ -1277,8 +1335,13 @@ function enrollSelftoClass(options) {
|
|
|
1277
1335
|
classId: options.classid
|
|
1278
1336
|
});
|
|
1279
1337
|
|
|
1338
|
+
var params = { classrole: options.classrole };
|
|
1280
1339
|
//Setup request with URL and Params
|
|
1281
|
-
var requestAPI = request.post(url)
|
|
1340
|
+
var requestAPI = request.post(url)
|
|
1341
|
+
.set('Content-Type', 'application/json')
|
|
1342
|
+
.set('Accept', 'application/json')
|
|
1343
|
+
.send(params);
|
|
1344
|
+
|
|
1282
1345
|
if(self.traceid) { requestAPI.set('X-Amzn-Trace-Id', self.traceid); }
|
|
1283
1346
|
|
|
1284
1347
|
//Setup token in Authorization header
|
|
@@ -1481,8 +1544,9 @@ function encodeURLParameter(options) {
|
|
|
1481
1544
|
* title: 'class title',
|
|
1482
1545
|
* startdate: 'Epoch(Unix) timestamp in milliseconds',
|
|
1483
1546
|
* enddate: 'Epoch(Unix) timestamp in milliseconds',
|
|
1484
|
-
* description: '' // Optional field
|
|
1485
|
-
* class_ownership: 'STRICT' / 'NO_OWNER' // Default - STRICT, Optional field
|
|
1547
|
+
* description: '', // Optional field
|
|
1548
|
+
* class_ownership: 'STRICT' / 'NO_OWNER', // Default - STRICT, Optional field
|
|
1549
|
+
* ext_data: {} // Optional
|
|
1486
1550
|
* }
|
|
1487
1551
|
*/
|
|
1488
1552
|
function createClass(options) {
|
|
@@ -1542,7 +1606,8 @@ function createClass(options) {
|
|
|
1542
1606
|
// title: 'class title', //Optional field
|
|
1543
1607
|
// startdate: 'Epoch(Unix) timestamp in milliseconds', //Optional field
|
|
1544
1608
|
// enddate: 'Epoch(Unix) timestamp in milliseconds', //Optional field
|
|
1545
|
-
// description: '' //Optional field
|
|
1609
|
+
// description: '', //Optional field
|
|
1610
|
+
// ext_data: '' //Optional field
|
|
1546
1611
|
//}
|
|
1547
1612
|
function updateClass(options) {
|
|
1548
1613
|
var self = this;
|
|
@@ -1593,13 +1658,14 @@ function updateClass(options) {
|
|
|
1593
1658
|
/** options =
|
|
1594
1659
|
*{
|
|
1595
1660
|
"space_title": "string",
|
|
1596
|
-
"classes": [
|
|
1661
|
+
"classes": [
|
|
1597
1662
|
{
|
|
1598
1663
|
"title": "class tiltle",
|
|
1599
1664
|
"startdate": 'Epoch(Unix) timestamp in milliseconds',
|
|
1600
1665
|
"enddate": 'Epoch(Unix) timestamp in milliseconds',
|
|
1601
1666
|
"rowId": 'string with max limit 3 characters,
|
|
1602
1667
|
"description": "string",
|
|
1668
|
+
"ext_data": {}, // optional
|
|
1603
1669
|
"model": "STRICT",
|
|
1604
1670
|
"owner": {
|
|
1605
1671
|
"userid": "string" //Mandatory if model is 'STRICT'
|
|
@@ -51,9 +51,18 @@ function invitations() {
|
|
|
51
51
|
context: 'string', // required
|
|
52
52
|
created: 'string', // required
|
|
53
53
|
space_title: 'string',
|
|
54
|
-
class_enrollment: {
|
|
54
|
+
class_enrollment: {
|
|
55
|
+
classid: 'string', // required. Correlated with context
|
|
56
|
+
class_role: 'string', // optional
|
|
57
|
+
inviter_email: 'string' // optional
|
|
58
|
+
},
|
|
55
59
|
invitation_data: [
|
|
56
60
|
{
|
|
61
|
+
class_enrollment : { // optional, will override the outer context
|
|
62
|
+
classid: 'string' // required. Correlated with context
|
|
63
|
+
class_role: 'string', // optional
|
|
64
|
+
inviter_email: 'string' // optional
|
|
65
|
+
},
|
|
57
66
|
email: 'string', // required
|
|
58
67
|
dls_account_status: 'string',
|
|
59
68
|
ext_account_status: 'string',
|
|
@@ -61,6 +70,7 @@ function invitations() {
|
|
|
61
70
|
ext_user_id: 'string',
|
|
62
71
|
first_name: 'string', // required
|
|
63
72
|
last_name: 'string', // required
|
|
73
|
+
ext_data: {},
|
|
64
74
|
rowId: 'string', // required
|
|
65
75
|
role: 'string' /// required
|
|
66
76
|
},...
|
|
@@ -57,7 +57,8 @@ function spaces(accountId) {
|
|
|
57
57
|
getExtProduct: getExtProduct.bind(this),
|
|
58
58
|
getSpaceDetails: getSpaceDetails.bind(this),
|
|
59
59
|
updateUserInformation: updateUserInformation.bind(this),
|
|
60
|
-
getInvitationsByEmail: getInvitationsByEmail.bind(this)
|
|
60
|
+
getInvitationsByEmail: getInvitationsByEmail.bind(this),
|
|
61
|
+
updateInstituteTitle: updateInstituteTitle.bind(this)
|
|
61
62
|
};
|
|
62
63
|
}
|
|
63
64
|
|
|
@@ -512,6 +513,7 @@ function provisionBulkSpaces(options) {
|
|
|
512
513
|
* "ext_class_meta" :
|
|
513
514
|
* {
|
|
514
515
|
* "description": "string",
|
|
516
|
+
* "ext_data": {},
|
|
515
517
|
* "title": "string", // mandatory
|
|
516
518
|
* "startdate": <epoch>, // mandatory
|
|
517
519
|
* "enddate": <epoch> // mandatory
|
|
@@ -985,3 +987,49 @@ function getInvitationsByEmail(options) {
|
|
|
985
987
|
}
|
|
986
988
|
return dfd.promise;
|
|
987
989
|
}
|
|
990
|
+
|
|
991
|
+
/**
|
|
992
|
+
* This API is used to update an institute's space title
|
|
993
|
+
* options = {
|
|
994
|
+
* space_code: "", // Mandatory, space code of institute whose title is to be updated
|
|
995
|
+
* body : {
|
|
996
|
+
* ext_actor_id: "", // Mandatory
|
|
997
|
+
* data: {
|
|
998
|
+
* space_title: ""
|
|
999
|
+
* }
|
|
1000
|
+
* }
|
|
1001
|
+
* }
|
|
1002
|
+
*/
|
|
1003
|
+
function updateInstituteTitle(options){
|
|
1004
|
+
var self = this;
|
|
1005
|
+
// Initializing promise
|
|
1006
|
+
var dfd = q.defer();
|
|
1007
|
+
var err = {};
|
|
1008
|
+
if (options && options.space_code && options.body && options.body.ext_actor_id ) {
|
|
1009
|
+
// Passed all validations, Contruct API url
|
|
1010
|
+
var url = self.config.DEFAULT_HOSTS.AUTH + self.config.AUTH_API_URLS.updateInstituteTitle;
|
|
1011
|
+
url = helpers.api.constructAPIUrl(url,
|
|
1012
|
+
{ accountId: self.accountId, instituteSpaceCode: options.space_code });
|
|
1013
|
+
|
|
1014
|
+
// Setup request with URL and Params
|
|
1015
|
+
var requestAPI = request.put(url)
|
|
1016
|
+
.set('Content-Type', 'application/json')
|
|
1017
|
+
.set('Accept', 'application/json')
|
|
1018
|
+
.send(options.body);
|
|
1019
|
+
if (self.traceid) { requestAPI.set('X-Amzn-Trace-Id', self.traceid); }
|
|
1020
|
+
|
|
1021
|
+
requestAPI.end(function (error, response) {
|
|
1022
|
+
if (error) {
|
|
1023
|
+
err = new DLSError(helpers.errors.ERROR_TYPES.API_ERROR, error);
|
|
1024
|
+
dfd.reject(err);
|
|
1025
|
+
}
|
|
1026
|
+
else { dfd.resolve(response.body); }
|
|
1027
|
+
});
|
|
1028
|
+
}
|
|
1029
|
+
else {
|
|
1030
|
+
err.message = err.description = 'space_code or ext_actor_id not found in request options.';
|
|
1031
|
+
err = new DLSError(helpers.errors.ERROR_TYPES.SDK_ERROR, err);
|
|
1032
|
+
dfd.reject(err);
|
|
1033
|
+
}
|
|
1034
|
+
return dfd.promise;
|
|
1035
|
+
}
|
|
@@ -38,10 +38,12 @@ module.exports = xapi;
|
|
|
38
38
|
/*********************************
|
|
39
39
|
* Public Function definitions
|
|
40
40
|
**********************************/
|
|
41
|
-
function xapi() {
|
|
41
|
+
function xapi(accountId) {
|
|
42
|
+
this.accountId = accountId;
|
|
42
43
|
return {
|
|
43
44
|
postStatement: postStatements.bind(this),
|
|
44
|
-
postExternalStatements: postExternalStatements.bind(this)
|
|
45
|
+
postExternalStatements: postExternalStatements.bind(this),
|
|
46
|
+
resetUserProductProgress: resetUserProductProgress.bind(this)
|
|
45
47
|
};
|
|
46
48
|
}
|
|
47
49
|
|
|
@@ -230,3 +232,44 @@ function postExternalStatements(options) {
|
|
|
230
232
|
});
|
|
231
233
|
return dfd.promise;
|
|
232
234
|
}
|
|
235
|
+
|
|
236
|
+
/*options = {
|
|
237
|
+
userid: 'string',
|
|
238
|
+
productcode: 'string',
|
|
239
|
+
actorid: 'string'
|
|
240
|
+
}*/
|
|
241
|
+
function resetUserProductProgress(options) {
|
|
242
|
+
var self = this;
|
|
243
|
+
// Initializing promise
|
|
244
|
+
var dfd = q.defer();
|
|
245
|
+
var err = {};
|
|
246
|
+
if(options && options.userid && options.productcode && options.actorid) {
|
|
247
|
+
|
|
248
|
+
// Passed all validations, Contruct API url
|
|
249
|
+
var url = self.config.DEFAULT_HOSTS.XAPI + self.config.XAPI_API_URLS.resetUserProductProgress;
|
|
250
|
+
url = helpers.api.constructAPIUrl(url, { accountId : self.accountId });
|
|
251
|
+
|
|
252
|
+
// Setup request with URL and Params
|
|
253
|
+
var requestAPI = request.delete(url)
|
|
254
|
+
.set('Content-Type', 'application/json')
|
|
255
|
+
.set('Accept', 'application/json')
|
|
256
|
+
.send(options);
|
|
257
|
+
|
|
258
|
+
if(self.traceid) { requestAPI.set('X-Amzn-Trace-Id', self.traceid); }
|
|
259
|
+
|
|
260
|
+
requestAPI.end(function(error, response) {
|
|
261
|
+
if(error) {
|
|
262
|
+
err = new DLSError(helpers.errors.ERROR_TYPES.API_ERROR, error);
|
|
263
|
+
dfd.reject(err);
|
|
264
|
+
}
|
|
265
|
+
else { dfd.resolve(response.body); }
|
|
266
|
+
});
|
|
267
|
+
}
|
|
268
|
+
else {
|
|
269
|
+
err.message = err.description = 'userid, productcode or actorid not found in request options.';
|
|
270
|
+
err = new DLSError(helpers.errors.ERROR_TYPES.SDK_ERROR, err);
|
|
271
|
+
dfd.reject(err);
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
return dfd.promise;
|
|
275
|
+
}
|