comprodls-sdk 2.14.0 → 2.18.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 +212 -11
- package/dist/comprodls-sdk.min.js +18 -18
- package/lib/config/index.js +7 -2
- package/lib/services/analytics/index.js +46 -1
- package/lib/services/auth/index.js +64 -4
- package/lib/services/invitations/index.js +1 -0
- package/lib/services/spaces/index.js +49 -1
- package/lib/services/xapi/index.js +45 -2
- package/package.json +1 -1
- package/.vscode/launch.json +0 -24
package/dist/comprodls-sdk.js
CHANGED
|
@@ -316,6 +316,7 @@ exports.AUTH_API_URLS = {
|
|
|
316
316
|
getParticularClassAPI: '/org/{orgId}/classes/{classId}',
|
|
317
317
|
getParticularShadowClassAPI: '/org/{orgId}/shadow/classes/{extClassId}',
|
|
318
318
|
classProductAssociation: '/org/{orgId}/classes/{classId}/associate-product/{productcode}',
|
|
319
|
+
multiClassProductAssociations: '/org/{orgId}/classes/{classId}/associate-product/multi',
|
|
319
320
|
enrollUsertoClass: '/org/{orgId}/classes/{classId}/enroll-user/{userId}',
|
|
320
321
|
enrollSelftoClass: '/org/{orgId}/classes/{classId}/enroll-self',
|
|
321
322
|
enrollMultiUserstoClass: '/org/{orgId}/classes/{classId}/enroll-user/multi',
|
|
@@ -345,6 +346,7 @@ exports.AUTH_API_URLS = {
|
|
|
345
346
|
getInvitationsByEmail: '/accounts/{accountid}/invitations-by-email',
|
|
346
347
|
generateSpaceCode: '/accounts/{accountid}/space-code/generate',
|
|
347
348
|
changeSpaceCode: '/accounts/{accountid}/space-code/{spacecode}/change',
|
|
349
|
+
updateInstituteTitle: '/accounts/{accountId}/institute-spaces/{instituteSpaceCode}',
|
|
348
350
|
|
|
349
351
|
//Superuser related API
|
|
350
352
|
getAllInstitutions: '/su/accounts/{accountid}/spaces',
|
|
@@ -422,7 +424,9 @@ exports.ANALYTICS_API_URLS = {
|
|
|
422
424
|
//AssignedPaths Related APIs
|
|
423
425
|
getAllAssignedPathsOfClass: '/{orgId}/class/assigned-paths',
|
|
424
426
|
getMyAssignedPathsOfClass: '/{orgId}/user/class/assigned-paths',
|
|
425
|
-
getAssignedPathAnalytics: '/{orgId}/class/assigned-paths/aggregations'
|
|
427
|
+
getAssignedPathAnalytics: '/{orgId}/class/assigned-paths/aggregations',
|
|
428
|
+
|
|
429
|
+
getTimeseriesAnalytics: '/progress/timeseries'
|
|
426
430
|
};
|
|
427
431
|
|
|
428
432
|
exports.SISEVENTS_API_URLS = {
|
|
@@ -450,7 +454,8 @@ exports.PRODUCT_API_URLS = {
|
|
|
450
454
|
|
|
451
455
|
exports.XAPI_API_URLS = {
|
|
452
456
|
postMultiStatements: '/{orgId}/statements/multi',
|
|
453
|
-
postExternalMultiStatements: '/{orgId}/external/statements/multi'
|
|
457
|
+
postExternalMultiStatements: '/{orgId}/external/statements/multi',
|
|
458
|
+
resetUserProductProgress: '/accounts/{accountId}/progress/user/product/reset'
|
|
454
459
|
};
|
|
455
460
|
|
|
456
461
|
exports.ATTEMPTS_API_URLS = {
|
|
@@ -1982,7 +1987,9 @@ function analytics() {
|
|
|
1982
1987
|
getAllAssignedPathsOfClass: getAllAssignedPathsOfClass.bind(this),
|
|
1983
1988
|
getMyAssignedPathsOfClass: getMyAssignedPathsOfClass.bind(this),
|
|
1984
1989
|
getAssignedPathAnalytics: getAssignedPathAnalytics.bind(this),
|
|
1985
|
-
getMyParticularAssignedPathOfClass: getMyParticularAssignedPathOfClass.bind(this)
|
|
1990
|
+
getMyParticularAssignedPathOfClass: getMyParticularAssignedPathOfClass.bind(this),
|
|
1991
|
+
|
|
1992
|
+
getTimeseriesAnalytics: getTimeseriesAnalytics.bind(this)
|
|
1986
1993
|
};
|
|
1987
1994
|
}
|
|
1988
1995
|
|
|
@@ -3462,7 +3469,49 @@ function getMyParticularAssignedPathOfClass(options) {
|
|
|
3462
3469
|
}
|
|
3463
3470
|
return dfd.promise;
|
|
3464
3471
|
}
|
|
3465
|
-
|
|
3472
|
+
|
|
3473
|
+
/*
|
|
3474
|
+
options = {
|
|
3475
|
+
query: 'string', //mandatory
|
|
3476
|
+
cursor: 'string' //optional
|
|
3477
|
+
}
|
|
3478
|
+
*/
|
|
3479
|
+
function getTimeseriesAnalytics(options) {
|
|
3480
|
+
var self = this;
|
|
3481
|
+
var dfd = q.defer();
|
|
3482
|
+
var err;
|
|
3483
|
+
|
|
3484
|
+
if(options && options.query) {
|
|
3485
|
+
//Passed all validations, Construct API url
|
|
3486
|
+
var url = self.config.DEFAULT_HOSTS.ANALYTICS + self.config.ANALYTICS_API_URLS.getTimeseriesAnalytics;
|
|
3487
|
+
|
|
3488
|
+
// Contruct parameters
|
|
3489
|
+
var params = {
|
|
3490
|
+
query: options.query
|
|
3491
|
+
};
|
|
3492
|
+
|
|
3493
|
+
if(options.cursor) { params.cursor = options.cursor; }
|
|
3494
|
+
//Setup request with URL and Params
|
|
3495
|
+
var requestAPI = request.get(url).query(params);
|
|
3496
|
+
|
|
3497
|
+
if(self.traceid) { requestAPI.set('X-Amzn-Trace-Id', self.traceid); }
|
|
3498
|
+
|
|
3499
|
+
requestAPI.end(function (error, response) {
|
|
3500
|
+
if(error) {
|
|
3501
|
+
err = new DLSError(helpers.errors.ERROR_TYPES.API_ERROR, error);
|
|
3502
|
+
dfd.reject(err);
|
|
3503
|
+
}
|
|
3504
|
+
else { dfd.resolve(response.body); }
|
|
3505
|
+
});
|
|
3506
|
+
}
|
|
3507
|
+
else {
|
|
3508
|
+
err = {};
|
|
3509
|
+
err.message = err.description = 'Mandatory params query not found in request options.';
|
|
3510
|
+
err = new DLSError(helpers.errors.ERROR_TYPES.SDK_ERROR, err);
|
|
3511
|
+
dfd.reject(err);
|
|
3512
|
+
}
|
|
3513
|
+
return dfd.promise;
|
|
3514
|
+
}
|
|
3466
3515
|
},{"../../helpers":3,"q":89,"superagent":132}],15:[function(require,module,exports){
|
|
3467
3516
|
/*************************************************************************
|
|
3468
3517
|
*
|
|
@@ -3877,6 +3926,7 @@ function auth() {
|
|
|
3877
3926
|
getParticularShadowClass: getParticularShadowClass.bind(this),
|
|
3878
3927
|
createClassProductAssociation: createClassProductAssociation.bind(this),
|
|
3879
3928
|
removeClassProductAssociation: removeClassProductAssociation.bind(this),
|
|
3929
|
+
createMultiClassProductAssociations: createMultiClassProductAssociations.bind(this),
|
|
3880
3930
|
addItemsToShowcaseOfAClass: addItemsToShowcaseOfAClass.bind(this),
|
|
3881
3931
|
deleteItemsFromShowcaseOfAClass: deleteItemsFromShowcaseOfAClass.bind(this),
|
|
3882
3932
|
|
|
@@ -4874,6 +4924,62 @@ function removeClassProductAssociation(options) {
|
|
|
4874
4924
|
return dfd.promise;
|
|
4875
4925
|
}
|
|
4876
4926
|
|
|
4927
|
+
/**
|
|
4928
|
+
* This function creates multiple class-product associations.
|
|
4929
|
+
* @param options {
|
|
4930
|
+
* *classId : <string>,
|
|
4931
|
+
* *productcodes : [<string>] // Min: 1, Max: 50
|
|
4932
|
+
* }
|
|
4933
|
+
* Note: Fields marked with '*' are mandatory.
|
|
4934
|
+
*/
|
|
4935
|
+
function createMultiClassProductAssociations(options) {
|
|
4936
|
+
var deferred = q.defer();
|
|
4937
|
+
var self = this;
|
|
4938
|
+
var error = helpers.validations.isAuthenticated(self.orgId, self.token);
|
|
4939
|
+
|
|
4940
|
+
if (error) {
|
|
4941
|
+
deferred.reject(error);
|
|
4942
|
+
} else if (options && options.classId && options.productcodes) {
|
|
4943
|
+
// Passed all validations, Contruct API url
|
|
4944
|
+
var defaultHostPath = self.config.DEFAULT_HOSTS.AUTH;
|
|
4945
|
+
var bulkCPAssociationAPIPath = self.config.AUTH_API_URLS.multiClassProductAssociations;
|
|
4946
|
+
|
|
4947
|
+
var url = defaultHostPath + bulkCPAssociationAPIPath;
|
|
4948
|
+
var bodyParams = { productcodes: options.productcodes };
|
|
4949
|
+
|
|
4950
|
+
url = helpers.api.constructAPIUrl(url, { orgId: self.orgId, classId: options.classId });
|
|
4951
|
+
|
|
4952
|
+
// Setup request with URL and Params
|
|
4953
|
+
var requestAPI = request.post(url)
|
|
4954
|
+
.set('Content-Type', 'application/json')
|
|
4955
|
+
.set('Accept', 'application/json')
|
|
4956
|
+
.send(bodyParams);
|
|
4957
|
+
|
|
4958
|
+
if (self.traceid) {
|
|
4959
|
+
requestAPI.set('X-Amzn-Trace-Id', self.traceid);
|
|
4960
|
+
}
|
|
4961
|
+
|
|
4962
|
+
// Setup token in Authorization header
|
|
4963
|
+
requestAPI = helpers.api.setupAPIToken(requestAPI, self.token);
|
|
4964
|
+
|
|
4965
|
+
requestAPI.end(function(err, response) {
|
|
4966
|
+
if (err) {
|
|
4967
|
+
error = new DLSError(helpers.errors.ERROR_TYPES.API_ERROR, err);
|
|
4968
|
+
deferred.reject(error);
|
|
4969
|
+
} else {
|
|
4970
|
+
deferred.resolve(response.body);
|
|
4971
|
+
}
|
|
4972
|
+
});
|
|
4973
|
+
} else {
|
|
4974
|
+
error = {};
|
|
4975
|
+
error.message = error.description = 'Missing mandaotry fields \'classId\' or \'productcodes\' in request.';
|
|
4976
|
+
error = new DLSError(helpers.errors.ERROR_TYPES.SDK_ERROR, error);
|
|
4977
|
+
deferred.reject(error);
|
|
4978
|
+
}
|
|
4979
|
+
|
|
4980
|
+
return deferred.promise;
|
|
4981
|
+
}
|
|
4982
|
+
|
|
4877
4983
|
/*options = {
|
|
4878
4984
|
classid: 'string'
|
|
4879
4985
|
}*/
|
|
@@ -5291,8 +5397,9 @@ function encodeURLParameter(options) {
|
|
|
5291
5397
|
* title: 'class title',
|
|
5292
5398
|
* startdate: 'Epoch(Unix) timestamp in milliseconds',
|
|
5293
5399
|
* enddate: 'Epoch(Unix) timestamp in milliseconds',
|
|
5294
|
-
* description: '' // Optional field
|
|
5295
|
-
* class_ownership: 'STRICT' / 'NO_OWNER' // Default - STRICT, Optional field
|
|
5400
|
+
* description: '', // Optional field
|
|
5401
|
+
* class_ownership: 'STRICT' / 'NO_OWNER', // Default - STRICT, Optional field
|
|
5402
|
+
* ext_data: {} // Optional
|
|
5296
5403
|
* }
|
|
5297
5404
|
*/
|
|
5298
5405
|
function createClass(options) {
|
|
@@ -5352,7 +5459,8 @@ function createClass(options) {
|
|
|
5352
5459
|
// title: 'class title', //Optional field
|
|
5353
5460
|
// startdate: 'Epoch(Unix) timestamp in milliseconds', //Optional field
|
|
5354
5461
|
// enddate: 'Epoch(Unix) timestamp in milliseconds', //Optional field
|
|
5355
|
-
// description: '' //Optional field
|
|
5462
|
+
// description: '', //Optional field
|
|
5463
|
+
// ext_data: '' //Optional field
|
|
5356
5464
|
//}
|
|
5357
5465
|
function updateClass(options) {
|
|
5358
5466
|
var self = this;
|
|
@@ -5403,13 +5511,14 @@ function updateClass(options) {
|
|
|
5403
5511
|
/** options =
|
|
5404
5512
|
*{
|
|
5405
5513
|
"space_title": "string",
|
|
5406
|
-
"classes": [
|
|
5514
|
+
"classes": [
|
|
5407
5515
|
{
|
|
5408
5516
|
"title": "class tiltle",
|
|
5409
5517
|
"startdate": 'Epoch(Unix) timestamp in milliseconds',
|
|
5410
5518
|
"enddate": 'Epoch(Unix) timestamp in milliseconds',
|
|
5411
5519
|
"rowId": 'string with max limit 3 characters,
|
|
5412
5520
|
"description": "string",
|
|
5521
|
+
"ext_data": {}, // optional
|
|
5413
5522
|
"model": "STRICT",
|
|
5414
5523
|
"owner": {
|
|
5415
5524
|
"userid": "string" //Mandatory if model is 'STRICT'
|
|
@@ -7370,6 +7479,7 @@ function invitations() {
|
|
|
7370
7479
|
ext_user_id: 'string',
|
|
7371
7480
|
first_name: 'string', // required
|
|
7372
7481
|
last_name: 'string', // required
|
|
7482
|
+
ext_data: {},
|
|
7373
7483
|
rowId: 'string', // required
|
|
7374
7484
|
role: 'string' /// required
|
|
7375
7485
|
},...
|
|
@@ -9791,7 +9901,8 @@ function spaces(accountId) {
|
|
|
9791
9901
|
getExtProduct: getExtProduct.bind(this),
|
|
9792
9902
|
getSpaceDetails: getSpaceDetails.bind(this),
|
|
9793
9903
|
updateUserInformation: updateUserInformation.bind(this),
|
|
9794
|
-
getInvitationsByEmail: getInvitationsByEmail.bind(this)
|
|
9904
|
+
getInvitationsByEmail: getInvitationsByEmail.bind(this),
|
|
9905
|
+
updateInstituteTitle: updateInstituteTitle.bind(this)
|
|
9795
9906
|
};
|
|
9796
9907
|
}
|
|
9797
9908
|
|
|
@@ -10246,6 +10357,7 @@ function provisionBulkSpaces(options) {
|
|
|
10246
10357
|
* "ext_class_meta" :
|
|
10247
10358
|
* {
|
|
10248
10359
|
* "description": "string",
|
|
10360
|
+
* "ext_data": {},
|
|
10249
10361
|
* "title": "string", // mandatory
|
|
10250
10362
|
* "startdate": <epoch>, // mandatory
|
|
10251
10363
|
* "enddate": <epoch> // mandatory
|
|
@@ -10719,6 +10831,52 @@ function getInvitationsByEmail(options) {
|
|
|
10719
10831
|
}
|
|
10720
10832
|
return dfd.promise;
|
|
10721
10833
|
}
|
|
10834
|
+
|
|
10835
|
+
/**
|
|
10836
|
+
* This API is used to update an institute's space title
|
|
10837
|
+
* options = {
|
|
10838
|
+
* space_code: "", // Mandatory, space code of institute whose title is to be updated
|
|
10839
|
+
* body : {
|
|
10840
|
+
* ext_actor_id: "", // Mandatory
|
|
10841
|
+
* data: {
|
|
10842
|
+
* space_title: ""
|
|
10843
|
+
* }
|
|
10844
|
+
* }
|
|
10845
|
+
* }
|
|
10846
|
+
*/
|
|
10847
|
+
function updateInstituteTitle(options){
|
|
10848
|
+
var self = this;
|
|
10849
|
+
// Initializing promise
|
|
10850
|
+
var dfd = q.defer();
|
|
10851
|
+
var err = {};
|
|
10852
|
+
if (options && options.space_code && options.body && options.body.ext_actor_id ) {
|
|
10853
|
+
// Passed all validations, Contruct API url
|
|
10854
|
+
var url = self.config.DEFAULT_HOSTS.AUTH + self.config.AUTH_API_URLS.updateInstituteTitle;
|
|
10855
|
+
url = helpers.api.constructAPIUrl(url,
|
|
10856
|
+
{ accountId: self.accountId, instituteSpaceCode: options.space_code });
|
|
10857
|
+
|
|
10858
|
+
// Setup request with URL and Params
|
|
10859
|
+
var requestAPI = request.put(url)
|
|
10860
|
+
.set('Content-Type', 'application/json')
|
|
10861
|
+
.set('Accept', 'application/json')
|
|
10862
|
+
.send(options.body);
|
|
10863
|
+
if (self.traceid) { requestAPI.set('X-Amzn-Trace-Id', self.traceid); }
|
|
10864
|
+
|
|
10865
|
+
requestAPI.end(function (error, response) {
|
|
10866
|
+
if (error) {
|
|
10867
|
+
err = new DLSError(helpers.errors.ERROR_TYPES.API_ERROR, error);
|
|
10868
|
+
dfd.reject(err);
|
|
10869
|
+
}
|
|
10870
|
+
else { dfd.resolve(response.body); }
|
|
10871
|
+
});
|
|
10872
|
+
}
|
|
10873
|
+
else {
|
|
10874
|
+
err.message = err.description = 'space_code or ext_actor_id not found in request options.';
|
|
10875
|
+
err = new DLSError(helpers.errors.ERROR_TYPES.SDK_ERROR, err);
|
|
10876
|
+
dfd.reject(err);
|
|
10877
|
+
}
|
|
10878
|
+
return dfd.promise;
|
|
10879
|
+
}
|
|
10722
10880
|
|
|
10723
10881
|
},{"../../helpers":3,"q":89,"superagent":132}],29:[function(require,module,exports){
|
|
10724
10882
|
/*************************************************************************
|
|
@@ -11404,10 +11562,12 @@ module.exports = xapi;
|
|
|
11404
11562
|
/*********************************
|
|
11405
11563
|
* Public Function definitions
|
|
11406
11564
|
**********************************/
|
|
11407
|
-
function xapi() {
|
|
11565
|
+
function xapi(accountId) {
|
|
11566
|
+
this.accountId = accountId;
|
|
11408
11567
|
return {
|
|
11409
11568
|
postStatement: postStatements.bind(this),
|
|
11410
|
-
postExternalStatements: postExternalStatements.bind(this)
|
|
11569
|
+
postExternalStatements: postExternalStatements.bind(this),
|
|
11570
|
+
resetUserProductProgress: resetUserProductProgress.bind(this)
|
|
11411
11571
|
};
|
|
11412
11572
|
}
|
|
11413
11573
|
|
|
@@ -11596,6 +11756,47 @@ function postExternalStatements(options) {
|
|
|
11596
11756
|
});
|
|
11597
11757
|
return dfd.promise;
|
|
11598
11758
|
}
|
|
11759
|
+
|
|
11760
|
+
/*options = {
|
|
11761
|
+
userid: 'string',
|
|
11762
|
+
productcode: 'string',
|
|
11763
|
+
actorid: 'string'
|
|
11764
|
+
}*/
|
|
11765
|
+
function resetUserProductProgress(options) {
|
|
11766
|
+
var self = this;
|
|
11767
|
+
// Initializing promise
|
|
11768
|
+
var dfd = q.defer();
|
|
11769
|
+
var err = {};
|
|
11770
|
+
if(options && options.userid && options.productcode && options.actorid) {
|
|
11771
|
+
|
|
11772
|
+
// Passed all validations, Contruct API url
|
|
11773
|
+
var url = self.config.DEFAULT_HOSTS.XAPI + self.config.XAPI_API_URLS.resetUserProductProgress;
|
|
11774
|
+
url = helpers.api.constructAPIUrl(url, { accountId : self.accountId });
|
|
11775
|
+
|
|
11776
|
+
// Setup request with URL and Params
|
|
11777
|
+
var requestAPI = request.delete(url)
|
|
11778
|
+
.set('Content-Type', 'application/json')
|
|
11779
|
+
.set('Accept', 'application/json')
|
|
11780
|
+
.send(options);
|
|
11781
|
+
|
|
11782
|
+
if(self.traceid) { requestAPI.set('X-Amzn-Trace-Id', self.traceid); }
|
|
11783
|
+
|
|
11784
|
+
requestAPI.end(function(error, response) {
|
|
11785
|
+
if(error) {
|
|
11786
|
+
err = new DLSError(helpers.errors.ERROR_TYPES.API_ERROR, error);
|
|
11787
|
+
dfd.reject(err);
|
|
11788
|
+
}
|
|
11789
|
+
else { dfd.resolve(response.body); }
|
|
11790
|
+
});
|
|
11791
|
+
}
|
|
11792
|
+
else {
|
|
11793
|
+
err.message = err.description = 'userid, productcode or actorid not found in request options.';
|
|
11794
|
+
err = new DLSError(helpers.errors.ERROR_TYPES.SDK_ERROR, err);
|
|
11795
|
+
dfd.reject(err);
|
|
11796
|
+
}
|
|
11797
|
+
|
|
11798
|
+
return dfd.promise;
|
|
11799
|
+
}
|
|
11599
11800
|
|
|
11600
11801
|
},{"../../helpers":3,"q":89,"superagent":132}],32:[function(require,module,exports){
|
|
11601
11802
|
/*************************************************************************
|