comprodls-sdk 2.48.0 → 2.50.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.
@@ -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',
@@ -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,78 @@ 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
+ * status_active: true/false, // Optional, filter for status_active enrollments
701
+ * status_ended: true/false, // Optional, filter for status_ended enrollments
702
+ * status_expired: true/false, // Optional, filter for status_expired enrollments
703
+ * details: true/false, // Optional, includes products & meta information of classes
704
+ * bundleDetails: true/false // Optional, includes products, bundles & meta information of classes
705
+ * limit: integer, // Optional, Number of entities to be fetched
706
+ * cursor: 'cursor' // Optional, cursor to get next set of enrollments
707
+ * } options
708
+ */
709
+ function getUserClassesV2(options) {
710
+ var self = this, orgId = self.orgId, token = self.token;
711
+
712
+ // Initializing promise
713
+ var deferred = q.defer();
714
+
715
+ // Validations
716
+ var error = helpers.validations.isAuthenticated(orgId, token);
717
+
718
+ if (error) {
719
+ deferred.reject(error);
720
+ } else if (options && options.userid) {
721
+ var userId = options.userid;
722
+
723
+ // Passed all validations, Construct API url
724
+ var url = self.config.DEFAULT_HOSTS.AUTH + self.config.AUTH_API_URLS.getUserClassesV2API;
725
+ url = helpers.api.constructAPIUrl(url, { orgid: orgId, userid: userId });
726
+
727
+ // Contruct query parameters
728
+ var params = {};
729
+ if (options) {
730
+ if (options.shadow ) { params.shadow = options.shadow ; }
731
+ if (options.status_active ) { params.status_active = options.status_active ; }
732
+ if (options.status_ended ) { params.status_ended = options.status_ended ; }
733
+ if (options.status_expired ) { params.status_expired = options.status_expired ; }
734
+ if (options.details) { params.details = options.details; }
735
+ if (options.bundleDetails) { params.bundleDetails = options.bundleDetails; }
736
+ if (options.limit) { params.limit = options.limit; }
737
+ if (options.cursor) { params.cursor = options.cursor; }
738
+ }
739
+
740
+ // Setup request with URL and Params
741
+ var requestAPI = request.get(url).query(params);
742
+ if (self.traceid) { requestAPI.set('X-Amzn-Trace-Id', self.traceid); }
743
+
744
+ // Setup token in Authorization header
745
+ requestAPI = helpers.api.setupAPIToken(requestAPI, token);
746
+
747
+ // Call GET User Class-Enrollments API
748
+ requestAPI
749
+ .agent(keepaliveAgent)
750
+ .end(function(error, response) {
751
+ if (error) {
752
+ error = new DLSError(helpers.errors.ERROR_TYPES.API_ERROR, error);
753
+ deferred.reject(error);
754
+ } else {
755
+ deferred.resolve(response.body);
756
+ }
757
+ });
758
+ } else {
759
+ error = {};
760
+ error.message = error.description = 'Required parameter \'userid\' is not found in request options.';
761
+ error = new DLSError(helpers.errors.ERROR_TYPES.SDK_ERROR, error);
762
+ deferred.reject(error);
763
+ }
764
+
765
+ return deferred.promise;
766
+ }
767
+
695
768
  /**
696
769
  * options = {
697
770
  * classid: 'classid',
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "comprodls-sdk",
3
3
  "description": "comproDLS SDK for JavaScript",
4
- "version": "2.48.0",
4
+ "version": "2.50.0",
5
5
  "author": {
6
6
  "name": "Compro Technologies Private Limited",
7
7
  "url": "http://www.comprotechnologies.com/"