comprodls-sdk 2.37.0 → 2.39.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.
@@ -367,7 +367,12 @@ exports.AUTH_API_URLS = {
367
367
  createOrGetGradebookMeta: '/org/{orgId}/classes/{classId}/gradebooks',
368
368
  updateOrDeleteGradebookMeta: '/org/{orgId}/classes/{classId}/gradebooks/{gradebook_id}',
369
369
  gradebookColumns: '/org/{orgId}/classes/{classId}/gradebooks/{gradebook_id}/columns',
370
- updateGradebookColumn: '/org/{orgId}/classes/{classId}/gradebooks/{gradebook_id}/columns/{column_id}'
370
+ getAllClassesOfAComponent: '/org/{orgId}/components/{component_code}/classes',
371
+ removeAllGradebookColumnsOfAComponent: '/org/{orgId}/gradebook/columns/custom-components/{component_code}',
372
+
373
+ // Custom Components related APIs
374
+ customComponents: '/org/{orgid}/custom-components',
375
+ particularCustomComponent: '/org/{orgid}/custom-components/{custom_component_code}',
371
376
  };
372
377
 
373
378
  exports.ACTIVITY_API_URLS = {
@@ -4141,10 +4146,19 @@ function auth() {
4141
4146
  getParticularGradebookMetaOfAClass: getParticularGradebookMetaOfAClass.bind(this),
4142
4147
  getAllGradebooksMetaOfAClass: getAllGradebooksMetaOfAClass.bind(this),
4143
4148
  addGradebookColumns: addGradebookColumns.bind(this),
4144
- updateGradebookColumn: updateGradebookColumn.bind(this),
4149
+ updateMultipleGradebookColumns: updateMultipleGradebookColumns.bind(this),
4145
4150
  removeGradebookColumns: removeGradebookColumns.bind(this),
4146
4151
  getParticularColumnOfAGradebook: getParticularColumnOfAGradebook.bind(this),
4147
- getAllColumnsOfAGradebook: getAllColumnsOfAGradebook.bind(this)
4152
+ getAllColumnsOfAGradebook: getAllColumnsOfAGradebook.bind(this),
4153
+ getAllClassesOfAComponent: getAllClassesOfAComponent.bind(this),
4154
+ removeAllGradebookColumnsOfAComponent: removeAllGradebookColumnsOfAComponent.bind(this),
4155
+
4156
+ // Custom Components related APIs
4157
+ createCustomComponent: createCustomComponent.bind(this),
4158
+ updateCustomComponent: updateCustomComponent.bind(this),
4159
+ deleteCustomComponent: deleteCustomComponent.bind(this),
4160
+ getParticularCustomComponent: getParticularCustomComponent.bind(this),
4161
+ getAllCustomComponents: getAllCustomComponents.bind(this)
4148
4162
  };
4149
4163
  }
4150
4164
 
@@ -7423,20 +7437,24 @@ function addGradebookColumns(options) {
7423
7437
  options = {
7424
7438
  classid: "string", //mandatory
7425
7439
  gradebook_id: "string", //mandatory
7426
- column_id: "string", //mandatory
7427
7440
  body : {
7428
- "title": "string",
7429
- "weightage": "string",
7430
- "items": [
7441
+ "columns": [
7431
7442
  {
7432
- "item-code": "string"
7433
- }
7434
- ],
7435
- "data": {...}
7443
+ "title": "string",
7444
+ "weightage": "string",
7445
+ "items": [
7446
+ {
7447
+ "item-code": "string"
7448
+ }
7449
+ ],
7450
+ "data": {...}
7451
+ },
7452
+ {...}
7453
+ ]
7436
7454
  }
7437
7455
  }
7438
7456
  */
7439
- function updateGradebookColumn(options) {
7457
+ function updateMultipleGradebookColumns(options) {
7440
7458
  // Initializing promise
7441
7459
  var deferred = q.defer();
7442
7460
  var self = this;
@@ -7447,49 +7465,42 @@ function updateGradebookColumn(options) {
7447
7465
  if(err) {
7448
7466
  deferred.reject(err);
7449
7467
  } else {
7450
- if (options && options.classid && options.gradebook_id && options.column_id && options.body) {
7451
- if (Object.keys(options.body).length !== 0) {
7452
- // Passed all validations, Contruct API url
7453
- var url = self.config.DEFAULT_HOSTS.AUTH + self.config.AUTH_API_URLS.updateGradebookColumn;
7468
+ if (options && options.classid && options.gradebook_id && options.body && options.body.columns) {
7469
+ // Passed all validations, Contruct API url
7470
+ var url = self.config.DEFAULT_HOSTS.AUTH + self.config.AUTH_API_URLS.gradebookColumns;
7454
7471
 
7455
- url = helpers.api.constructAPIUrl(url, {
7456
- orgId: self.orgId,
7457
- classId: options.classid,
7458
- gradebook_id: options.gradebook_id,
7459
- column_id: options.column_id
7460
- });
7472
+ url = helpers.api.constructAPIUrl(url, {
7473
+ orgId: self.orgId,
7474
+ classId: options.classid,
7475
+ gradebook_id: options.gradebook_id
7476
+ });
7461
7477
 
7462
- var params = options.body;
7463
- // Setup request with URL and Params
7464
- var requestAPI = request.put(url)
7465
- .set('Content-Type', 'application/json')
7466
- .set('Accept', 'application/json')
7467
- .send(params);
7478
+ var params = options.body;
7479
+ // Setup request with URL and Params
7480
+ var requestAPI = request.put(url)
7481
+ .set('Content-Type', 'application/json')
7482
+ .set('Accept', 'application/json')
7483
+ .send(params);
7468
7484
 
7469
- if (self.traceid) {
7470
- requestAPI.set('X-Amzn-Trace-Id', self.traceid);
7471
- }
7485
+ if (self.traceid) {
7486
+ requestAPI.set('X-Amzn-Trace-Id', self.traceid);
7487
+ }
7472
7488
 
7473
- //Setup token in Authorization header
7474
- requestAPI = helpers.api.setupAPIToken(requestAPI, self.token);
7489
+ //Setup token in Authorization header
7490
+ requestAPI = helpers.api.setupAPIToken(requestAPI, self.token);
7475
7491
 
7476
- requestAPI
7477
- .agent(keepaliveAgent)
7478
- .end(function(error, response) {
7479
- if (error) {
7480
- error = new DLSError(helpers.errors.ERROR_TYPES.API_ERROR, error);
7481
- deferred.reject(error);
7482
- } else {
7483
- deferred.resolve(response.body);
7484
- }
7485
- });
7486
- } else {
7487
- error.message = error.description = 'Body of the request input cannot be empty.';
7488
- error = new DLSError(helpers.errors.ERROR_TYPES.SDK_ERROR, error);
7489
- deferred.reject(error);
7490
- }
7492
+ requestAPI
7493
+ .agent(keepaliveAgent)
7494
+ .end(function(error, response) {
7495
+ if (error) {
7496
+ error = new DLSError(helpers.errors.ERROR_TYPES.API_ERROR, error);
7497
+ deferred.reject(error);
7498
+ } else {
7499
+ deferred.resolve(response.body);
7500
+ }
7501
+ });
7491
7502
  } else {
7492
- error.message = error.description = 'Mandatory params: classid, gradebook_id, column_id or body' +
7503
+ error.message = error.description = 'Mandatory params: classid, gradebook_id, body or body.columns' +
7493
7504
  ' not found in the request options.';
7494
7505
  error = new DLSError(helpers.errors.ERROR_TYPES.SDK_ERROR, error);
7495
7506
  deferred.reject(error);
@@ -7672,6 +7683,398 @@ function getAllColumnsOfAGradebook (options) {
7672
7683
  }
7673
7684
  return deferred.promise;
7674
7685
  }
7686
+
7687
+ /*
7688
+ options = {
7689
+ component_code: "string", //mandatory
7690
+ cursor: "string" //optional
7691
+ }
7692
+ */
7693
+ function getAllClassesOfAComponent (options) {
7694
+ // Initializing promise
7695
+ var deferred = q.defer();
7696
+ var self = this;
7697
+ var error = {};
7698
+
7699
+ //Validations
7700
+ var err = helpers.validations.isAuthenticated(self.orgId, self.token);
7701
+ if(err) {
7702
+ deferred.reject(err);
7703
+ } else {
7704
+ if (options && options.component_code) {
7705
+ // Passed all validations, Contruct API url
7706
+ var url = self.config.DEFAULT_HOSTS.AUTH +
7707
+ self.config.AUTH_API_URLS.getAllClassesOfAComponent;
7708
+
7709
+ url = helpers.api.constructAPIUrl(url, {
7710
+ orgId: self.orgId,
7711
+ component_code: options.component_code
7712
+ });
7713
+
7714
+ var params = {};
7715
+ if(options.cursor){ params.cursor = options.cursor; }
7716
+
7717
+ var requestAPI = request.get(url).query(params);
7718
+
7719
+ if (self.traceid) {
7720
+ requestAPI.set('X-Amzn-Trace-Id', self.traceid);
7721
+ }
7722
+
7723
+ //Setup token in Authorization header
7724
+ requestAPI = helpers.api.setupAPIToken(requestAPI, self.token);
7725
+
7726
+ requestAPI
7727
+ .agent(keepaliveAgent)
7728
+ .end(function(error, response) {
7729
+ if (error) {
7730
+ error = new DLSError(helpers.errors.ERROR_TYPES.API_ERROR, error);
7731
+ deferred.reject(error);
7732
+ } else {
7733
+ deferred.resolve(response.body);
7734
+ }
7735
+ });
7736
+ } else {
7737
+ error.message = error.description = 'Mandatory params: component_code' +
7738
+ ' not found in the request options.';
7739
+ error = new DLSError(helpers.errors.ERROR_TYPES.SDK_ERROR, error);
7740
+ deferred.reject(error);
7741
+ }
7742
+ }
7743
+ return deferred.promise;
7744
+ }
7745
+
7746
+ /*
7747
+ options = {
7748
+ component_code: "string" //mandatory
7749
+ }
7750
+ */
7751
+ function removeAllGradebookColumnsOfAComponent (options) {
7752
+ // Initializing promise
7753
+ var deferred = q.defer();
7754
+ var self = this;
7755
+ var error = {};
7756
+
7757
+ //Validations
7758
+ var err = helpers.validations.isAuthenticated(self.orgId, self.token);
7759
+ if(err) {
7760
+ deferred.reject(err);
7761
+ } else {
7762
+ if (options && options.component_code) {
7763
+ // Passed all validations, Contruct API url
7764
+ var url = self.config.DEFAULT_HOSTS.AUTH +
7765
+ self.config.AUTH_API_URLS.removeAllGradebookColumnsOfAComponent;
7766
+
7767
+ url = helpers.api.constructAPIUrl(url, {
7768
+ orgId: self.orgId,
7769
+ component_code: options.component_code
7770
+ });
7771
+
7772
+ // Setup request with URL and Params
7773
+ var requestAPI = request
7774
+ .delete(url)
7775
+ .set('Content-Type', 'application/json')
7776
+ .set('Accept', 'application/json')
7777
+ .send(options.body);
7778
+
7779
+ if (self.traceid) {
7780
+ requestAPI.set('X-Amzn-Trace-Id', self.traceid);
7781
+ }
7782
+
7783
+ //Setup token in Authorization header
7784
+ requestAPI = helpers.api.setupAPIToken(requestAPI, self.token);
7785
+
7786
+ requestAPI
7787
+ .agent(keepaliveAgent)
7788
+ .end(function(error, response) {
7789
+ if (error) {
7790
+ error = new DLSError(helpers.errors.ERROR_TYPES.API_ERROR, error);
7791
+ deferred.reject(error);
7792
+ } else {
7793
+ deferred.resolve(response.body);
7794
+ }
7795
+ });
7796
+ } else {
7797
+ error.message = error.description = 'Mandatory params: component_code' +
7798
+ ' not found in the request options.';
7799
+ error = new DLSError(helpers.errors.ERROR_TYPES.SDK_ERROR, error);
7800
+ deferred.reject(error);
7801
+ }
7802
+ }
7803
+ return deferred.promise;
7804
+ }
7805
+
7806
+ /*
7807
+ options = {
7808
+ body : {
7809
+ custom_component_code: "string", // Mandatory
7810
+ title: "string", // Mandatory
7811
+ custom_component_type: "string", // Mandatory
7812
+ scoring_type: "string",
7813
+ items: [{...}],
7814
+ data: {...}
7815
+ }
7816
+ }
7817
+ */
7818
+ function createCustomComponent(options) {
7819
+ var self = this;
7820
+
7821
+ // Initializing promise
7822
+ var deferred = q.defer();
7823
+
7824
+ // Validations
7825
+ var error = helpers.validations.isAuthenticated(self.orgId, self.token);
7826
+ if (error) {
7827
+ deferred.reject(error);
7828
+ } else {
7829
+ if (options && options.body) {
7830
+ // Passed all validations, Contruct API url
7831
+ var url = self.config.DEFAULT_HOSTS.AUTH + self.config.AUTH_API_URLS.customComponents;
7832
+ url = helpers.api.constructAPIUrl(url, { orgid: self.orgId });
7833
+
7834
+ var requestAPI = request.post(url)
7835
+ .set('Content-Type', 'application/json')
7836
+ .set('Accept', 'application/json')
7837
+ .send(options.body);
7838
+ if (self.traceid) { requestAPI.set('X-Amzn-Trace-Id', self.traceid); }
7839
+
7840
+ // Setup token in Authorization header
7841
+ requestAPI = helpers.api.setupAPIToken(requestAPI, self.token);
7842
+
7843
+ requestAPI
7844
+ .agent(keepaliveAgent)
7845
+ .end(function(error, response) {
7846
+ if (error) {
7847
+ var err = new DLSError(helpers.errors.ERROR_TYPES.API_ERROR, error);
7848
+ deferred.reject(err);
7849
+ } else {
7850
+ deferred.resolve(response.body);
7851
+ }
7852
+ });
7853
+ } else {
7854
+ var err = {};
7855
+ err.message = err.description = 'Mandatory param - \'body\' not found in request options.';
7856
+ err = new DLSError(helpers.errors.ERROR_TYPES.SDK_ERROR, err);
7857
+ deferred.reject(err);
7858
+ }
7859
+ }
7860
+
7861
+ return deferred.promise;
7862
+ }
7863
+
7864
+ /*
7865
+ options = {
7866
+ custom_component_code: "string", // Mandatory
7867
+ body : {
7868
+ title: "string",
7869
+ custom_component_type: "string",
7870
+ items: [{...}],
7871
+ data: {...}
7872
+ }
7873
+ }
7874
+ */
7875
+ function updateCustomComponent(options) {
7876
+ var self = this;
7877
+
7878
+ // Initializing promise
7879
+ var deferred = q.defer();
7880
+
7881
+ // Validations
7882
+ var error = helpers.validations.isAuthenticated(self.orgId, self.token);
7883
+ if (error) {
7884
+ deferred.reject(error);
7885
+ } else {
7886
+ if (options && options.custom_component_code && options.body) {
7887
+ if (Object.keys(options.body).length === 0) {
7888
+ error.message = error.description = 'Mandatory params: \'custom_component_code\' or \'body\' not found in the request options.';
7889
+ error = new DLSError(helpers.errors.ERROR_TYPES.SDK_ERROR, error);
7890
+ deferred.reject(error);
7891
+ } else {
7892
+ // Passed all validations, Contruct API url
7893
+ var url = self.config.DEFAULT_HOSTS.AUTH + self.config.AUTH_API_URLS.particularCustomComponent;
7894
+ url = helpers.api.constructAPIUrl(url, {
7895
+ orgid: self.orgId, custom_component_code: options.custom_component_code
7896
+ });
7897
+
7898
+ // Setup request with URL and Params
7899
+ var params = options.body;
7900
+ var requestAPI = request.put(url)
7901
+ .set('Content-Type', 'application/json')
7902
+ .set('Accept', 'application/json')
7903
+ .send(params);
7904
+ if (self.traceid) { requestAPI.set('X-Amzn-Trace-Id', self.traceid); }
7905
+
7906
+ // Setup token in Authorization header
7907
+ requestAPI = helpers.api.setupAPIToken(requestAPI, self.token);
7908
+
7909
+ requestAPI
7910
+ .agent(keepaliveAgent)
7911
+ .end(function(error, response) {
7912
+ if (error) {
7913
+ error = new DLSError(helpers.errors.ERROR_TYPES.API_ERROR, error);
7914
+ deferred.reject(error);
7915
+ } else {
7916
+ deferred.resolve(response.body);
7917
+ }
7918
+ });
7919
+ }
7920
+ } else {
7921
+ error = {};
7922
+ error.message = error.description = 'Mandatory params: \'custom_component_code\' or \'body\' not found in the request options.';
7923
+ error = new DLSError(helpers.errors.ERROR_TYPES.SDK_ERROR, error);
7924
+ deferred.reject(error);
7925
+ }
7926
+ }
7927
+
7928
+ return deferred.promise;
7929
+ }
7930
+
7931
+ /*
7932
+ options = {
7933
+ custom_component_code: "string", // Mandatory
7934
+ }
7935
+ */
7936
+ function deleteCustomComponent(options) {
7937
+ var self = this;
7938
+
7939
+ // Initializing promise
7940
+ var deferred = q.defer();
7941
+
7942
+ // Validations
7943
+ var error = helpers.validations.isAuthenticated(self.orgId, self.token);
7944
+ if (error) {
7945
+ deferred.reject(error);
7946
+ } else {
7947
+ if (options && options.custom_component_code) {
7948
+ // Passed all validations, Contruct API url
7949
+ var url = self.config.DEFAULT_HOSTS.AUTH + self.config.AUTH_API_URLS.particularCustomComponent;
7950
+ url = helpers.api.constructAPIUrl(url, {
7951
+ orgid: self.orgId, custom_component_code: options.custom_component_code
7952
+ });
7953
+
7954
+ // Setup request with URL and Params
7955
+ var requestAPI = request.delete(url);
7956
+ if (self.traceid) { requestAPI.set('X-Amzn-Trace-Id', self.traceid); }
7957
+
7958
+ // Setup token in Authorization header
7959
+ requestAPI = helpers.api.setupAPIToken(requestAPI, self.token);
7960
+
7961
+ requestAPI
7962
+ .agent(keepaliveAgent)
7963
+ .end(function (error, response) {
7964
+ if (error) {
7965
+ var err = new DLSError(helpers.errors.ERROR_TYPES.API_ERROR, error);
7966
+ deferred.reject(err);
7967
+ } else {
7968
+ deferred.resolve(response.body);
7969
+ }
7970
+ });
7971
+ } else {
7972
+ var err = {};
7973
+ err.message = err.description = 'Mandatory params - \'custom_component_code\' not found in request options.';
7974
+ err = new DLSError(helpers.errors.ERROR_TYPES.SDK_ERROR, err);
7975
+ deferred.reject(err);
7976
+ }
7977
+ }
7978
+
7979
+ return deferred.promise;
7980
+ }
7981
+
7982
+ /*
7983
+ options = {
7984
+ custom_component_code: "string", // Mandatory
7985
+ }
7986
+ */
7987
+ function getParticularCustomComponent(options) {
7988
+ var self = this;
7989
+
7990
+ // Initializing promise
7991
+ var deferred = q.defer();
7992
+
7993
+ // Validations
7994
+ var err = helpers.validations.isAuthenticated(self.orgId, self.token);
7995
+ if (err) {
7996
+ deferred.reject(err);
7997
+ } else {
7998
+ if (options && options.custom_component_code) {
7999
+ // Passed all validations, Contruct API url
8000
+ var url = self.config.DEFAULT_HOSTS.AUTH + self.config.AUTH_API_URLS.particularCustomComponent;
8001
+
8002
+ url = helpers.api.constructAPIUrl(url, {
8003
+ orgid: self.orgId, custom_component_code: options.custom_component_code
8004
+ });
8005
+
8006
+ // Setup request with URL and Params
8007
+ var requestAPI = request.get(url);
8008
+ if (self.traceid) { requestAPI.set('X-Amzn-Trace-Id', self.traceid); }
8009
+
8010
+ // Setup token in Authorization header
8011
+ requestAPI = helpers.api.setupAPIToken(requestAPI, self.token);
8012
+
8013
+ requestAPI
8014
+ .agent(keepaliveAgent)
8015
+ .end(function(error, response) {
8016
+ if (error) {
8017
+ error = new DLSError(helpers.errors.ERROR_TYPES.API_ERROR, error);
8018
+ deferred.reject(error);
8019
+ } else {
8020
+ deferred.resolve(response.body);
8021
+ }
8022
+ });
8023
+ } else {
8024
+ var error = {};
8025
+ error.message = error.description = 'Mandatory params: \'custom_component_code\' not found in request options.';
8026
+ error = new DLSError(helpers.errors.ERROR_TYPES.SDK_ERROR, error);
8027
+ deferred.reject(error);
8028
+ }
8029
+ }
8030
+
8031
+ return deferred.promise;
8032
+ }
8033
+
8034
+ /*
8035
+ options = {
8036
+ cursor: "string"
8037
+ }
8038
+ */
8039
+ function getAllCustomComponents(options) {
8040
+ var self = this;
8041
+
8042
+ // Initializing promise
8043
+ var deferred = q.defer();
8044
+
8045
+ // Validations
8046
+ var error = helpers.validations.isAuthenticated(self.orgId, self.token);
8047
+ if (error) {
8048
+ deferred.reject(error);
8049
+ } else {
8050
+ // Passed all validations, Contruct API url
8051
+ var url = self.config.DEFAULT_HOSTS.AUTH + self.config.AUTH_API_URLS.customComponents;
8052
+ url = helpers.api.constructAPIUrl(url, { orgid: self.orgId });
8053
+
8054
+ // Setup request with URL and Params
8055
+ var params = {};
8056
+ if (options.cursor) { params.cursor = options.cursor; }
8057
+
8058
+ var requestAPI = request.get(url).query(params);
8059
+ if (self.traceid) { requestAPI.set('X-Amzn-Trace-Id', self.traceid); }
8060
+
8061
+ // Setup token in Authorization header
8062
+ requestAPI = helpers.api.setupAPIToken(requestAPI, self.token);
8063
+
8064
+ requestAPI
8065
+ .agent(keepaliveAgent)
8066
+ .end(function(error, response) {
8067
+ if (error) {
8068
+ error = new DLSError(helpers.errors.ERROR_TYPES.API_ERROR, error);
8069
+ deferred.reject(error);
8070
+ } else {
8071
+ deferred.resolve(response.body);
8072
+ }
8073
+ });
8074
+ }
8075
+
8076
+ return deferred.promise;
8077
+ }
7675
8078
 
7676
8079
  },{"../../helpers":3,"../../helpers/lib/api/converter":4,"agentkeepalive":38,"q":91,"superagent":134}],17:[function(require,module,exports){
7677
8080
  /*************************************************************************