comprodls-sdk 2.34.1 → 2.34.3

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.
@@ -397,6 +397,8 @@ exports.ANALYTICS_API_URLS = {
397
397
  getClassRecordUserAggregations: '/{orgId}/class/product/user-aggregations',
398
398
  getUserClassRecentSubmissions: '/{orgId}/user/product/class/recent-submissions',
399
399
  appState: '/{orgId}/user/product/progress/state',
400
+ getUserProductAllState: '/{orgid}/user/product/progress/state/all',
401
+ updateUserProductMultiState: '/{orgid}/user/product/progress/state/multi',
400
402
 
401
403
  //AssignedPaths Related APIs
402
404
  getAllAssignedPathsOfClass: '/{orgId}/class/assigned-paths',
@@ -1974,10 +1976,14 @@ function analytics() {
1974
1976
  getUserClassRecentSubmissions: getUserClassRecentSubmissions.bind(this),
1975
1977
  getStudentsWithEvaluatedOnce: getStudentsWithEvaluatedOnce.bind(this),
1976
1978
 
1979
+ // user-state api
1977
1980
  getAppState: getAppState.bind(this),
1978
1981
  updateAppState: updateAppState.bind(this),
1979
1982
  deleteAppState: deleteAppState.bind(this),
1980
1983
 
1984
+ getUserProductAllState: getUserProductAllState.bind(this),
1985
+ updateUserProductMultiState: updateUserProductMultiState.bind(this),
1986
+
1981
1987
  getQuestionProgressByLearningObjective: getQuestionProgressByLearningObjective.bind(this),
1982
1988
 
1983
1989
  //AssignedPaths Related APIs
@@ -2628,6 +2634,115 @@ function deleteAppState(options) {
2628
2634
  return dfd.promise;
2629
2635
  }
2630
2636
 
2637
+ /** This function is used to get state of single item if itemcode is given, otherwise if the
2638
+ item code is not given then it will return state of all items and product state.
2639
+ options = {
2640
+ userid: <userid>,
2641
+ productcode: <productcode>,
2642
+ classid: <classid>, // OPTIONAL
2643
+ itemcode: <itemcode> // OPTIONAL
2644
+ model: <string> // OPTIONAL
2645
+ key: <string> // OPTIONAL
2646
+ }
2647
+ */
2648
+ function getUserProductAllState(options) {
2649
+ var self = this;
2650
+ var dfd = q.defer();
2651
+ // Validations
2652
+ var err = {};
2653
+ if(options && options.userid && options.productcode) {
2654
+ err = helpers.validations.isAuthenticated(self.orgId, self.token);
2655
+ if(err) { dfd.reject(err); }
2656
+ else {
2657
+ // Passed all validations, Construct API url
2658
+ var url = self.config.DEFAULT_HOSTS.ANALYTICS + self.config.ANALYTICS_API_URLS.getUserProductAllState;
2659
+ url = helpers.api.constructAPIUrl(url, { orgId: self.orgId });
2660
+
2661
+ var params = { userid: options.userid, productcode: options.productcode };
2662
+ if(options.classid) { params.classid = options.classid; }
2663
+ if(options.itemcode) { params.itemcode = options.itemcode; }
2664
+ if(options.model) { params.model = options.model; }
2665
+ if(options.key) { params.key = options.key; }
2666
+
2667
+ // Setup request with URL and Params
2668
+ var requestAPI = request.get(url).query(params);
2669
+
2670
+ // Setup token in Authorization header
2671
+ requestAPI = helpers.api.setupAPIToken(requestAPI, self.token);
2672
+
2673
+ // setting up traceid
2674
+ if(self.traceid) { requestAPI.set('X-Amzn-Trace-Id', self.traceid); }
2675
+
2676
+ // Call User State GET Api
2677
+ requestAPI.end(function(err, response) {
2678
+ if(err) {
2679
+ err = new DLSError(helpers.errors.ERROR_TYPES.API_ERROR, err);
2680
+ dfd.reject(err);
2681
+ }
2682
+ else { dfd.resolve(response.body); }
2683
+ });
2684
+ }
2685
+ } else {
2686
+ err.message = err.description = "Required parameters 'userid' or " +
2687
+ "'productcode' are not found in request options";
2688
+ err = new DLSError(helpers.errors.ERROR_TYPES.SDK_ERROR, err);
2689
+ dfd.reject(err);
2690
+ }
2691
+ return dfd.promise;
2692
+ }
2693
+
2694
+ /*options = {
2695
+ userid: <userid>,
2696
+ productcode: <productcode>,
2697
+ classid: <classid>, // OPTIONAL
2698
+ data: <object>,
2699
+ }*/
2700
+ function updateUserProductMultiState(options) {
2701
+ var self = this;
2702
+ var dfd = q.defer();
2703
+ // Validations
2704
+ var err = {};
2705
+ if(options && options.userid && options.productcode && options.data) {
2706
+ err = helpers.validations.isAuthenticated(self.orgId, self.token);
2707
+ if(err) { dfd.reject(err); }
2708
+ else {
2709
+ // Passed all validations, Construct API url
2710
+ var url = self.config.DEFAULT_HOSTS.ANALYTICS +
2711
+ self.config.ANALYTICS_API_URLS.updateUserProductMultiState;
2712
+ url = helpers.api.constructAPIUrl(url, { orgId: self.orgId });
2713
+
2714
+ var params = { userid: options.userid, productcode: options.productcode };
2715
+ if(options.classid) { params.classid = options.classid; }
2716
+
2717
+ // Setup request with URL and Params
2718
+ var requestAPI = request.put(url).query(params)
2719
+ .set('Content-Type', 'application/json')
2720
+ .set('Accept', 'application/json')
2721
+ .send(options.data);
2722
+
2723
+ // Setup token in Authorization header
2724
+ requestAPI = helpers.api.setupAPIToken(requestAPI, self.token);
2725
+
2726
+ // setting up traceid
2727
+ if(self.traceid) { requestAPI.set('X-Amzn-Trace-Id', self.traceid); }
2728
+
2729
+ // Call Product Timespent Api
2730
+ requestAPI.end(function(err, response) {
2731
+ if(err) {
2732
+ err = new DLSError(helpers.errors.ERROR_TYPES.API_ERROR, err);
2733
+ dfd.reject(err);
2734
+ }
2735
+ else { dfd.resolve(response); }
2736
+ });
2737
+ }
2738
+ } else {
2739
+ err.message = err.description = "Required parameters 'userid' or 'data'" +
2740
+ " or 'productcode' are not found in request options";
2741
+ err = new DLSError(helpers.errors.ERROR_TYPES.SDK_ERROR, err);
2742
+ dfd.reject(err);
2743
+ }
2744
+ return dfd.promise;
2745
+ }
2631
2746
 
2632
2747
  /**
2633
2748
  * This function returns the recent pending submissions in a Class for a Product.
@@ -3560,7 +3675,8 @@ function postProgressTimeseries(options) {
3560
3675
  dfd.reject(err);
3561
3676
  }
3562
3677
  return dfd.promise;
3563
- }
3678
+ }
3679
+
3564
3680
  },{"../../helpers":3,"agentkeepalive":38,"q":90,"superagent":133}],15:[function(require,module,exports){
3565
3681
  /*************************************************************************
3566
3682
  *