comprodls-sdk 2.47.0 → 2.49.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 +632 -580
- package/dist/comprodls-sdk.min.js +17 -20
- package/lib/config/index.js +1 -0
- package/lib/services/analytics/index.js +6 -3
- package/lib/services/auth/index.js +67 -0
- package/package.json +1 -1
package/lib/config/index.js
CHANGED
|
@@ -131,6 +131,7 @@ exports.AUTH_API_URLS = {
|
|
|
131
131
|
getSettingsField: '/org/{orgId}/settings/{field}',
|
|
132
132
|
getClassUsersAPI: '/org/{orgId}/class/{classId}/users',
|
|
133
133
|
getUserClassesAPI: '/org/{orgId}/users/{userId}/classes',
|
|
134
|
+
getUserClassesV2API: '/org/{orgid}/users/{userid}/class-enrollments',
|
|
134
135
|
getAllJobs: '/accounts/{accountId}/ext-users/{extUserId}/jobs',
|
|
135
136
|
getJob: '/accounts/{accountId}/ext-users/{extUserId}/jobs/{jobId}',
|
|
136
137
|
getAllClassesAPI: '/org/{orgId}/classes',
|
|
@@ -1633,7 +1633,8 @@ function getMyAssignedPathsOfClass(options) {
|
|
|
1633
1633
|
/* options = {
|
|
1634
1634
|
"classid": "string", // required
|
|
1635
1635
|
"userid" : "string", // required
|
|
1636
|
-
"assignedPathId" : "string",
|
|
1636
|
+
"assignedPathId" : "string",
|
|
1637
|
+
"ext_assignedpathid": "string",
|
|
1637
1638
|
"progress" : "true/false",
|
|
1638
1639
|
"group" : "true/false"
|
|
1639
1640
|
};
|
|
@@ -1645,7 +1646,7 @@ function getMyParticularAssignedPathOfClass(options) {
|
|
|
1645
1646
|
var err = helpers.validations.isAuthenticated(self.orgId, self.token);
|
|
1646
1647
|
if(err) { dfd.reject(err); }
|
|
1647
1648
|
else {
|
|
1648
|
-
if(options && options.classid && options.userid
|
|
1649
|
+
if(options && options.classid && options.userid ) {
|
|
1649
1650
|
|
|
1650
1651
|
// Passed all validations, Contruct API url
|
|
1651
1652
|
var url = self.config.DEFAULT_HOSTS.ANALYTICS + self.config.ANALYTICS_API_URLS.getMyAssignedPathsOfClass;
|
|
@@ -1657,6 +1658,8 @@ function getMyParticularAssignedPathOfClass(options) {
|
|
|
1657
1658
|
|
|
1658
1659
|
if(options.progress) { queryParams.progress = options.progress; }
|
|
1659
1660
|
if(options.group) { queryParams.group = options.group; }
|
|
1661
|
+
if(options.assignedpathid) { queryParams.assignedpathid = options.assignedpathid; }
|
|
1662
|
+
if(options.ext_assignedpathid) {queryParams.ext_assignedpathid = options.ext_assignedpathid;}
|
|
1660
1663
|
|
|
1661
1664
|
// Setup request with URL and Params
|
|
1662
1665
|
var requestAPI = request.get(url).query(queryParams);
|
|
@@ -1676,7 +1679,7 @@ function getMyParticularAssignedPathOfClass(options) {
|
|
|
1676
1679
|
}
|
|
1677
1680
|
else {
|
|
1678
1681
|
err = {};
|
|
1679
|
-
err.message = err.description = 'Mandatory params - classid, userid
|
|
1682
|
+
err.message = err.description = 'Mandatory params - classid, userid not found in ' +
|
|
1680
1683
|
'request options.';
|
|
1681
1684
|
err = new DLSError(helpers.errors.ERROR_TYPES.SDK_ERROR, err);
|
|
1682
1685
|
dfd.reject(err);
|
|
@@ -53,6 +53,7 @@ function auth() {
|
|
|
53
53
|
deleteUserProfile: deleteUserProfile.bind(this),
|
|
54
54
|
updateUserRole: updateUserRole.bind(this),
|
|
55
55
|
getUserClasses: getUserClasses.bind(this),
|
|
56
|
+
getUserClassesV2: getUserClassesV2.bind(this),
|
|
56
57
|
getClassUsers: getClassUsers.bind(this),
|
|
57
58
|
enrollUsertoClass: enrollUsertoClass.bind(this),
|
|
58
59
|
enrollSelftoClass: enrollSelftoClass.bind(this),
|
|
@@ -692,6 +693,72 @@ function getUserClasses(options) {
|
|
|
692
693
|
return dfd.promise;
|
|
693
694
|
}
|
|
694
695
|
|
|
696
|
+
/**
|
|
697
|
+
* @param {
|
|
698
|
+
* userid: 'uuid or username', // Mandatory
|
|
699
|
+
* shadow: true/false, // Optional, filter shadow enrollments
|
|
700
|
+
* details: true/false, // Optional, includes products & meta information of classes
|
|
701
|
+
* bundleDetails: true/false // Optional, includes products, bundles & meta information of classes
|
|
702
|
+
* limit: integer, // Optional, Number of entities to be fetched
|
|
703
|
+
* cursor: 'cursor' // Optional, cursor to get next set of enrollments
|
|
704
|
+
* } options
|
|
705
|
+
*/
|
|
706
|
+
function getUserClassesV2(options) {
|
|
707
|
+
var self = this, orgId = self.orgId, token = self.token;
|
|
708
|
+
|
|
709
|
+
// Initializing promise
|
|
710
|
+
var deferred = q.defer();
|
|
711
|
+
|
|
712
|
+
// Validations
|
|
713
|
+
var error = helpers.validations.isAuthenticated(orgId, token);
|
|
714
|
+
|
|
715
|
+
if (error) {
|
|
716
|
+
deferred.reject(error);
|
|
717
|
+
} else if (options && options.userid) {
|
|
718
|
+
var userId = options.userid;
|
|
719
|
+
|
|
720
|
+
// Passed all validations, Construct API url
|
|
721
|
+
var url = self.config.DEFAULT_HOSTS.AUTH + self.config.AUTH_API_URLS.getUserClassesV2API;
|
|
722
|
+
url = helpers.api.constructAPIUrl(url, { orgid: orgId, userid: userId });
|
|
723
|
+
|
|
724
|
+
// Contruct parameters
|
|
725
|
+
var params = {};
|
|
726
|
+
if (options) {
|
|
727
|
+
if (options.shadow ) { params.shadow = options.shadow ; }
|
|
728
|
+
if (options.details) { params.details = options.details; }
|
|
729
|
+
if (options.bundleDetails) { params.bundleDetails = options.bundleDetails; }
|
|
730
|
+
if (options.limit) { params.limit = options.limit; }
|
|
731
|
+
if (options.cursor) { params.cursor = options.cursor; }
|
|
732
|
+
}
|
|
733
|
+
|
|
734
|
+
// Setup request with URL and Params
|
|
735
|
+
var requestAPI = request.get(url).query(params);
|
|
736
|
+
if (self.traceid) { requestAPI.set('X-Amzn-Trace-Id', self.traceid); }
|
|
737
|
+
|
|
738
|
+
// Setup token in Authorization header
|
|
739
|
+
requestAPI = helpers.api.setupAPIToken(requestAPI, token);
|
|
740
|
+
|
|
741
|
+
// Call GET User Class-Enrollments API
|
|
742
|
+
requestAPI
|
|
743
|
+
.agent(keepaliveAgent)
|
|
744
|
+
.end(function(error, response) {
|
|
745
|
+
if (error) {
|
|
746
|
+
error = new DLSError(helpers.errors.ERROR_TYPES.API_ERROR, error);
|
|
747
|
+
deferred.reject(error);
|
|
748
|
+
} else {
|
|
749
|
+
deferred.resolve(response.body);
|
|
750
|
+
}
|
|
751
|
+
});
|
|
752
|
+
} else {
|
|
753
|
+
error = {};
|
|
754
|
+
error.message = error.description = 'Required parameter \'userid\' is not found in request options.';
|
|
755
|
+
error = new DLSError(helpers.errors.ERROR_TYPES.SDK_ERROR, error);
|
|
756
|
+
deferred.reject(error);
|
|
757
|
+
}
|
|
758
|
+
|
|
759
|
+
return deferred.promise;
|
|
760
|
+
}
|
|
761
|
+
|
|
695
762
|
/**
|
|
696
763
|
* options = {
|
|
697
764
|
* classid: 'classid',
|