comprodls-sdk 2.107.0 → 2.108.0-thor.1

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.
@@ -289,6 +289,7 @@ exports.AUTH_API_URLS = {
289
289
  validateSpaceCode: '/accounts/{accountid}/space-code/validate',
290
290
  validateClassCode: '/accounts/{accountid}/class-code/validate',
291
291
  joinInstituteSpace: '/accounts/{accountid}/join-institute-space',
292
+ provisionStudentInInstitutionalSpace: '/accounts/{accountid}/student/join-institute-space',
292
293
  provisionSpacesToStudent: '/accounts/{accountId}/student/provision-spaces',
293
294
  provisionSpacesToTeacher: '/accounts/{accountId}/teacher/provision-spaces',
294
295
  shadowProvision: '/org/{orgId}/shadow-provision',
@@ -371,6 +372,7 @@ exports.AUTHEXTN_API_URLS = {
371
372
 
372
373
  //Space related API
373
374
  entitleBulkUsersToProducts: '/accounts/{accountid}/entitle-users/bulk',
375
+ deleteUserAccount : '/accounts/{accountid}/ext-users/{ext_user_id}',
374
376
 
375
377
  // Assigned Path APIs
376
378
  userAssignedPaths: '/org/{orgid}/classes/{classid}/assigned-paths/{assignedpathid}/enroll-user/multi',
@@ -731,7 +733,9 @@ function setupAPIToken(request, token) {
731
733
  var ERROR_TYPES = {
732
734
  API_ERROR: 'API_ERROR',
733
735
  SDK_ERROR: 'SDK_ERROR',
734
- CHANNEL_SUBSCRIPTION: 'CHANNEL_SUBSCRIPTION'
736
+ CHANNEL_SUBSCRIPTION: 'CHANNEL_SUBSCRIPTION',
737
+ UNEXPECTED_ERROR: 'UNEXPECTED_ERROR',
738
+ POLLING_INITIATION: 'POLLING_INITIATION'
735
739
  };
736
740
 
737
741
  var ERROR_CATEGORY = {
@@ -11300,39 +11304,45 @@ function changeSpaceCode(options) {
11300
11304
  */
11301
11305
  function joinInstituteSpace(options) {
11302
11306
  var self = this;
11303
- // Initializing promise
11304
- var dfd = q.defer();
11305
-
11306
- if(options && options.ext_user_id &&
11307
- options.ext_role && options.space_code)
11308
- {
11309
- // Passed all validations, Contruct API url
11310
- var url = self.config.DEFAULT_HOSTS.AUTH +
11311
- self.config.AUTH_API_URLS.joinInstituteSpace;
11312
- url = helpers.api.constructAPIUrl(url, { accountid : self.accountId });
11313
11307
 
11314
- // Setup request with URL and Params
11315
- var requestAPI = request.post(url)
11316
- .set('Content-Type', 'application/json')
11317
- .set('Accept', 'application/json')
11318
- .send(options);
11319
- if(self.traceid) { requestAPI.set('X-Amzn-Trace-Id', self.traceid); }
11308
+ return new Promise(function(resolve, reject) {
11309
+ if (options && options.ext_user_id && options.ext_role) {
11310
+ // Passed all validations, Contruct API url
11320
11311
 
11321
- requestAPI.end(function(error, response) {
11322
- if(error) {
11323
- err = new DLSError(helpers.errors.ERROR_TYPES.API_ERROR, error);
11324
- dfd.reject(err);
11312
+ var url;
11313
+ if (options.ext_role === 'student') {
11314
+ url = self.config.DEFAULT_HOSTS.AUTH +
11315
+ self.config.AUTH_API_URLS.provisionStudentInInstitutionalSpace;
11325
11316
  }
11326
- else { dfd.resolve(response.body); }
11327
- });
11328
- } else {
11329
- var err = {};
11330
- err.message = err.description = 'ext_user_id or ext_role or space_code not found in request options.';
11331
- err = new DLSError(helpers.errors.ERROR_TYPES.SDK_ERROR, err);
11332
- dfd.reject(err);
11333
- }
11317
+ else {
11318
+ url = self.config.DEFAULT_HOSTS.AUTH + self.config.AUTH_API_URLS.joinInstituteSpace;
11319
+ }
11320
+ url = helpers.api.constructAPIUrl(url, { accountid : self.accountId });
11334
11321
 
11335
- return dfd.promise;
11322
+ // Setup request with URL and Params
11323
+ var requestAPI = request.post(url)
11324
+ .set('Content-Type', 'application/json')
11325
+ .set('Accept', 'application/json');
11326
+ if(self.traceid) { requestAPI.set('X-Amzn-Trace-Id', self.traceid); }
11327
+
11328
+ requestAPI
11329
+ .send(options)
11330
+ .agent(keepaliveAgent)
11331
+ .end(function(error, response) {
11332
+ if (error) {
11333
+ var err = new DLSError(helpers.errors.ERROR_TYPES.API_ERROR, error);
11334
+ reject(err);
11335
+ }
11336
+ else { resolve(response.body); }
11337
+ });
11338
+ } else {
11339
+ var err = {};
11340
+ err.message = err.description = 'ext_user_id or ext_role not found' +
11341
+ ' in request options.';
11342
+ err = new DLSError(helpers.errors.ERROR_TYPES.SDK_ERROR, err);
11343
+ reject(err);
11344
+ }
11345
+ });
11336
11346
  }
11337
11347
 
11338
11348
  /**
@@ -11872,6 +11882,7 @@ function updateUserInformation(options) {
11872
11882
  };
11873
11883
  if(options.ref_id) { bodyParams.ref_id = options.ref_id; }
11874
11884
  if(options.ext_email) { bodyParams.ext_email = options.ext_email; }
11885
+ if(options.ext_username) { bodyParams.ext_username = options.ext_username; }
11875
11886
  if(options.ext_first_name) { bodyParams.ext_first_name = options.ext_first_name; }
11876
11887
  if(options.ext_last_name) { bodyParams.ext_last_name = options.ext_last_name; }
11877
11888
  if(options.address) { bodyParams.address = options.address; }
@@ -12066,7 +12077,8 @@ function spacesextn(accountId) {
12066
12077
  this.accountId = accountId;
12067
12078
  return {
12068
12079
  entitleBulkUsersToProducts: entitleBulkUsersToProducts.bind(this),
12069
- setupUser: setupUser.bind(this)
12080
+ setupUser: setupUser.bind(this),
12081
+ deleteUserAccount : deleteUserAccount.bind(this)
12070
12082
  };
12071
12083
  }
12072
12084
 
@@ -12153,6 +12165,50 @@ function setupUser(options) {
12153
12165
  }
12154
12166
  return deferred.promise;
12155
12167
  }
12168
+
12169
+ /**
12170
+ * Wiki Link for SDK params
12171
+ * https://github.com/comprodls/comprodls-sdk-js/wiki/04_AUTH-Adapter#getuserprofileparams
12172
+ */
12173
+ function deleteUserAccount(options) {
12174
+ var self = this;
12175
+ return new Promise(function(resolve, reject) {
12176
+
12177
+ if (options.ext_user_id && options.body) {
12178
+ //Passed all validations, Contruct API url
12179
+ var url = self.config.DEFAULT_HOSTS.AUTHEXTN +
12180
+ self.config.AUTHEXTN_API_URLS.deleteUserAccount;
12181
+ url = helpers.api.constructAPIUrl(url, {
12182
+ accountid: self.accountId,
12183
+ ext_user_id: options.ext_user_id,
12184
+ });
12185
+
12186
+ // Setup request
12187
+ var requestAPI = request.delete(url)
12188
+ .set('Content-Type', 'application/json')
12189
+ .set('Accept', 'application/json');
12190
+ if (self.traceid) { requestAPI.set('X-Amzn-Trace-Id', self.traceid); }
12191
+
12192
+ requestAPI
12193
+ .send(options.body)
12194
+ .agent(keepaliveAgent)
12195
+ .end(function(error, response) {
12196
+ if (error) {
12197
+ var err = new DLSError(helpers.errors.ERROR_TYPES.API_ERROR, error);
12198
+ reject(err);
12199
+ } else {
12200
+ resolve(response.body);
12201
+ }
12202
+ });
12203
+ } else {
12204
+ var err = {};
12205
+ err.description = 'Mandatory field \'ext_user_id\' or \'body\' in request options.';
12206
+ err.message = err.description;
12207
+ err = new DLSError(helpers.errors.ERROR_TYPES.SDK_ERROR, err);
12208
+ reject(err);
12209
+ }
12210
+ });
12211
+ }
12156
12212
 
12157
12213
  },{"../../helpers":3,"agentkeepalive":31,"q":36,"superagent":39}],25:[function(require,module,exports){
12158
12214
  /*************************************************************************
@@ -12184,6 +12240,7 @@ var q = require('q');
12184
12240
  var request = require('superagent');
12185
12241
 
12186
12242
  var helpers = require('../../helpers');
12243
+ var requestLayer = require('../../helpers/lib/requestLayer');
12187
12244
 
12188
12245
  var DLSError = helpers.errors.DLSError;
12189
12246
 
@@ -12205,34 +12262,32 @@ function superuser(accountId) {
12205
12262
  */
12206
12263
  function getAllInstitutions(options) {
12207
12264
  var self = this;
12208
- // Initializing promise
12209
- var dfd = q.defer();
12210
12265
 
12211
- var url = self.config.DEFAULT_HOSTS.AUTH +
12212
- self.config.AUTH_API_URLS.getAllInstitutions;
12213
- url = helpers.api.constructAPIUrl(url, { accountid : self.accountId });
12266
+ var url = helpers.api.constructAPIUrl(
12267
+ self.config.DEFAULT_HOSTS.AUTH + self.config.AUTH_API_URLS.getAllInstitutions,
12268
+ { accountid : self.accountId }
12269
+ );
12214
12270
 
12215
12271
  var params = {};
12216
- if(options) {
12217
- if(options.lookup) { params.lookup = options.lookup; }
12218
- if(options.cursor) { params.cursor = options.cursor; }
12219
- if(options.limit) { params.limit = options.limit; }
12272
+ if (options) {
12273
+ if (options.lookup) { params.lookup = options.lookup; }
12274
+ if (options.cursor) { params.cursor = options.cursor; }
12275
+ if (options.start) { params.start = options.start; }
12276
+ if (options.end) { params.end = options.end; }
12220
12277
  }
12221
12278
 
12222
- //Setup request with URL and Params
12223
- var requestAPI = request.get(url).query(params);
12224
- if(self.traceid) { requestAPI.set('X-Amzn-Trace-Id', self.traceid); }
12225
-
12226
- requestAPI.end(function(err, response) {
12227
- if(err) {
12228
- err = new DLSError(helpers.errors.ERROR_TYPES.API_ERROR, err);
12229
- dfd.reject(err);
12230
- } else {
12231
- dfd.resolve(response.body);
12232
- }
12279
+ // Prepare request parameters & execute request
12280
+ var reqOptions = {
12281
+ params: params,
12282
+ headers: { traceid: self.traceid }
12283
+ };
12284
+ return requestLayer.get(url, reqOptions)
12285
+ .then(function (response) {
12286
+ return response.body;
12287
+ })
12288
+ .catch(function (err) {
12289
+ throw new DLSError(helpers.errors.ERROR_TYPES.API_ERROR, err);
12233
12290
  });
12234
-
12235
- return dfd.promise;
12236
12291
  }
12237
12292
 
12238
12293
  /**
@@ -12316,7 +12371,7 @@ function provisionSpacesToSuperAdmin(options) {
12316
12371
  return dfd.promise;
12317
12372
  }
12318
12373
 
12319
- },{"../../helpers":3,"q":36,"superagent":39}],26:[function(require,module,exports){
12374
+ },{"../../helpers":3,"../../helpers/lib/requestLayer":7,"q":36,"superagent":39}],26:[function(require,module,exports){
12320
12375
  /*************************************************************************
12321
12376
  *
12322
12377
  * COMPRO CONFIDENTIAL