comprodls-sdk 2.90.3-development → 2.91.0-thor

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.
Files changed (42) hide show
  1. package/README.md +1 -137
  2. package/dist/comprodls-sdk.js +2917 -6291
  3. package/dist/comprodls-sdk.min.js +1 -1
  4. package/lib/comprodls.js +39 -57
  5. package/lib/config/index.js +172 -198
  6. package/lib/helpers/index.js +3 -2
  7. package/lib/helpers/lib/api/converter.js +1 -2
  8. package/lib/helpers/lib/api/index.js +19 -94
  9. package/lib/helpers/lib/errors.js +75 -80
  10. package/lib/helpers/lib/requestLayer.js +154 -0
  11. package/lib/helpers/lib/validator.js +65 -52
  12. package/lib/open_access/index.js +48 -53
  13. package/lib/services/analytics/index.js +286 -1014
  14. package/lib/services/attempts/index.js +38 -88
  15. package/lib/services/auth/index.js +324 -806
  16. package/lib/services/authextn/index.js +85 -247
  17. package/lib/services/datasyncmanager/index.js +10 -45
  18. package/lib/services/drive/index.js +20 -83
  19. package/lib/services/integrations/index.js +51 -126
  20. package/lib/services/invitations/index.js +20 -61
  21. package/lib/services/product/index.js +82 -85
  22. package/lib/services/pub/index.js +167 -235
  23. package/lib/services/pushX/index.js +195 -142
  24. package/lib/services/pushX/pubnubClientWrapper.js +399 -172
  25. package/lib/services/rules/index.js +14 -67
  26. package/lib/services/spaces/index.js +106 -289
  27. package/lib/services/spacesextn/index.js +44 -20
  28. package/lib/services/superuser/index.js +21 -36
  29. package/lib/services/taxonomy/index.js +27 -57
  30. package/lib/services/workflows/index.js +38 -97
  31. package/lib/services/xapi/index.js +7 -168
  32. package/lib/token/index.js +73 -67
  33. package/lib/token/validations.js +45 -48
  34. package/package.json +2 -3
  35. package/lib/helpers/lib/api/validations.js +0 -73
  36. package/lib/helpers/lib/utils.js +0 -24
  37. package/lib/services/activity/activity.js +0 -209
  38. package/lib/services/activity/attempt.js +0 -431
  39. package/lib/services/activity/index.js +0 -28
  40. package/lib/services/auth/classProduct.js +0 -37
  41. package/lib/services/collab/index.js +0 -468
  42. package/test.js +0 -38
@@ -31,9 +31,6 @@ var helpers = require('../../helpers');
31
31
 
32
32
  var DLSError = helpers.errors.DLSError;
33
33
 
34
- /*********************************
35
- * Setting Up Module Entry Point
36
- **********************************/
37
34
  module.exports = spaces;
38
35
 
39
36
  var keepaliveAgent = new Agent({
@@ -70,14 +67,10 @@ function spaces(accountId) {
70
67
  };
71
68
  }
72
69
 
73
- /*options = {
74
- extuserid: 'string',
75
- spaceRole: 'string', //optional
76
- spaceType: 'string', //optional
77
- spaceOrgContext: 'string', //optional
78
- details: boolean, //optional
79
- cursor: 'string' //optional
80
- }*/
70
+ /**
71
+ * Wiki Link for SDK params
72
+ * https://github.com/comprodls/comprodls-sdk-js/wiki/18_Spaces-Adapter#getuserspacesparams
73
+ */
81
74
  function getUserSpaces(options) {
82
75
  var self = this;
83
76
  // Initializing promise
@@ -119,11 +112,10 @@ function getUserSpaces(options) {
119
112
  return dfd.promise;
120
113
  }
121
114
 
122
- /*options = {
123
- spaceCodeBody : {
124
- space_code: 'string'
125
- }
126
- }*/
115
+ /**
116
+ * Wiki Link for SDK params
117
+ * https://github.com/comprodls/comprodls-sdk-js/wiki/18_Spaces-Adapter#validatespacecodeparams
118
+ */
127
119
  function validateSpaceCode(options) {
128
120
  var self = this;
129
121
  // Initializing promise
@@ -159,12 +151,10 @@ function validateSpaceCode(options) {
159
151
  return dfd.promise;
160
152
  }
161
153
 
162
- /*options = {
163
- classCodeBody : {
164
- class_code: 'string'
165
- },
166
- details: boolean // optional
167
- }*/
154
+ /**
155
+ * Wiki Link for SDK params
156
+ * https://github.com/comprodls/comprodls-sdk-js/wiki/18_Spaces-Adapter#validateclasscodeparams
157
+ */
168
158
  function validateClassCode(options) {
169
159
  var self = this;
170
160
  // Initializing promise
@@ -205,9 +195,11 @@ function validateClassCode(options) {
205
195
 
206
196
  return dfd.promise;
207
197
  }
208
- /* options = {
209
- "ignore_words": ["string"] //optional, This is the array of all bad words to be ignored.
210
- }*/
198
+
199
+ /**
200
+ * Wiki Link for SDK params
201
+ * https://github.com/comprodls/comprodls-sdk-js/wiki/18_Spaces-Adapter#generatespacecodeparams
202
+ */
211
203
  function generateSpaceCode(options) {
212
204
  var self = this;
213
205
 
@@ -220,7 +212,7 @@ function generateSpaceCode(options) {
220
212
  url = helpers.api.constructAPIUrl(url, { accountid : self.accountId });
221
213
 
222
214
  var bodyParams = {};
223
- if(options.ignore_words) { bodyParams.ignore_words = options.ignore_words }
215
+ if(options.ignore_words) { bodyParams.ignore_words = options.ignore_words; }
224
216
  // Setup request with URL and Params
225
217
  var requestAPI = request.post(url)
226
218
  .set('Content-Type', 'application/json')
@@ -239,11 +231,10 @@ function generateSpaceCode(options) {
239
231
  return dfd.promise;
240
232
  }
241
233
 
242
- /* options = {
243
- "ext_user_id": "string", //mandatory, This is the actor to change the spacecode.
244
- "ignore_words": ["string"] //optional, This is the array of all bad words to be ignored.
245
- "spacecode": "string" //mandatory, This is the spacecode that needs to be changed.
246
- }*/
234
+ /**
235
+ * Wiki Link for SDK params
236
+ * https://github.com/comprodls/comprodls-sdk-js/wiki/18_Spaces-Adapter#changespacecodeparams
237
+ */
247
238
  function changeSpaceCode(options) {
248
239
  var self = this;
249
240
  // Initializing promise
@@ -255,7 +246,7 @@ function changeSpaceCode(options) {
255
246
  self.config.AUTH_API_URLS.changeSpaceCode;
256
247
  url = helpers.api.constructAPIUrl(url, { accountid : self.accountId, spacecode: options.spacecode });
257
248
  var bodyParams = { ext_user_id: options.ext_user_id };
258
- if(options.ignore_words) { bodyParams.ignore_words = options.ignore_words }
249
+ if(options.ignore_words) { bodyParams.ignore_words = options.ignore_words; }
259
250
  // Setup request with URL and Params
260
251
  var requestAPI = request.put(url)
261
252
  .set('Content-Type', 'application/json')
@@ -280,15 +271,10 @@ function changeSpaceCode(options) {
280
271
  return dfd.promise;
281
272
  }
282
273
 
283
- /*
284
- ext_user_id: 'string',
285
- ext_role: 'string',
286
- space_code: 'string',
287
- ext_email: 'string', //optional
288
- ext_first_name: 'string', //optional
289
- ext_last_name: 'string, //optional
290
- ref_id: 'string' //optional
291
- */
274
+ /**
275
+ * Wiki Link for SDK params
276
+ * https://github.com/comprodls/comprodls-sdk-js/wiki/18_Spaces-Adapter#joininstitutespaceparams
277
+ */
292
278
  function joinInstituteSpace(options) {
293
279
  var self = this;
294
280
  // Initializing promise
@@ -326,26 +312,10 @@ function joinInstituteSpace(options) {
326
312
  return dfd.promise;
327
313
  }
328
314
 
329
- /*options = {
330
- ext_user_id: 'string',
331
- ext_actor_id: 'string', (optional)
332
- ext_role: 'string',
333
- ext_first_name: 'string',
334
- ext_last_name: 'string',
335
- ext_email: 'string',
336
- ref_id: 'string', (optional)
337
- class_code: 'string' (optional)
338
- products: [{
339
- productcode: 'string',
340
- ext_product_id: 'string',
341
- ext_product_meta: {
342
- startdate: 'string',
343
- enddate: 'string',
344
- ...
345
- },
346
- ext_data: {}
347
- }]
348
- }*/
315
+ /**
316
+ * Wiki Link for SDK params
317
+ * https://github.com/comprodls/comprodls-sdk-js/wiki/18_Spaces-Adapter#provisionspacestostudentparams
318
+ */
349
319
  function provisionSpacesToStudent(options) {
350
320
  var self = this;
351
321
  // Initializing promise
@@ -383,15 +353,8 @@ function provisionSpacesToStudent(options) {
383
353
  }
384
354
 
385
355
  /**
386
- * This function is used to provision spaces to a user with ext_role as teacher.
387
- * options = {
388
- * ext_user_id: "string",
389
- * ext_role: "string",
390
- * ext_first_name: "string",
391
- * ext_last_name: "string",
392
- * ext_email: "string",
393
- * ref_id: "string"
394
- * };
356
+ * Wiki Link for SDK params
357
+ * https://github.com/comprodls/comprodls-sdk-js/wiki/18_Spaces-Adapter#provisionspacestoteacherparams
395
358
  */
396
359
  function provisionSpacesToTeacher(options) {
397
360
  var self = this;
@@ -430,40 +393,8 @@ function provisionSpacesToTeacher(options) {
430
393
  }
431
394
 
432
395
  /**
433
- * options = {
434
- "space_title": "string", // mandatory
435
- "ext_data": {} //optional, external data(e.g. jobdata etc.)
436
- "users": [ // mandatory, min: 1, max: 200
437
- {
438
- "ext_user_id": "string", // mandatory (it must be unique within users array)
439
- "ext_parent_id": "string",
440
- "ext_username": "string",
441
- "ext_role": "student", // mandatory
442
- "ext_email": "string",
443
- "ext_first_name": "string", // mandatory
444
- "ext_last_name": "string", // mandatory
445
- "address": "string",
446
- "rowId": "string", // mandatory (it must be unique within users array)
447
- "classes": [ // optional, min: 1, max: 3
448
- {
449
- "classid": "string", // either of classid or class_code them must be
450
- "class_code": "string" // present, classid is preferred
451
- }
452
- ],
453
- "products": [ // optional, min: 1
454
- {
455
- "productcode": "string", // mandatory
456
- "ext_product_meta": {
457
- "startdate": "epoch",
458
- "enddate": "epoch" // mandatory
459
- }
460
- "ext_data" : {} // optional, external data (e.g., ref_id, ...)
461
- }
462
- ]
463
- }
464
- ]
465
- }
466
- *
396
+ * Wiki Link for SDK params
397
+ * https://github.com/comprodls/comprodls-sdk-js/wiki/18_Spaces-Adapter#provisionbulkspacesparams
467
398
  */
468
399
  function provisionBulkSpaces(options) {
469
400
  var self = this;
@@ -508,52 +439,8 @@ function provisionBulkSpaces(options) {
508
439
  }
509
440
 
510
441
  /**
511
- * @param {
512
- * *ext_user_id: 'string',
513
- * *ext_role": 'string',
514
- * ext_first_name: 'string',
515
- * ext_last_name: 'string',
516
- * ext_email: 'string',
517
- * address: {
518
- * country:'string'
519
- * },
520
- * ref_id: 'string',
521
- * ext_classid : 'string',
522
- * ext_class_meta : {
523
- * *title: 'string',
524
- * *startdate: <epoch>,
525
- * *enddate: <epoch>,
526
- * description: 'string',
527
- * ext_data: {},
528
- * limits: {
529
- * *los: 0,
530
- * *students: 0
531
- * }
532
- * },
533
- * checkLimits: {
534
- * student: 0,
535
- * teacher: 0
536
- * },
537
- * clone_settings: {
538
- * *src_ext_classid: 'string',
539
- * products: boolean,
540
- * assigned_paths: boolean,
541
- * ext_assigned_path_id_rule: 'string' //enum: ['SRC_ID']
542
- * advanced: {
543
- * assigned_paths: [ //length > 0 if assigned_paths flag is true
544
- * {
545
- * *ext_assignedpathid: 'string',
546
- * *assigned_path_id: 'string',
547
- * startdate: 0,
548
- * *duedate: 0
549
- * },
550
- * ],
551
- * products: [
552
- * { *productcode: 'string' },
553
- * ]
554
- * }
555
- * }
556
- * }
442
+ * Wiki Link for SDK params
443
+ * https://github.com/comprodls/comprodls-sdk-js/wiki/18_Spaces-Adapter#shadowprovisionparams
557
444
  */
558
445
  function shadowProvision(options) {
559
446
  var self = this;
@@ -591,21 +478,10 @@ function shadowProvision(options) {
591
478
  return dfd.promise;
592
479
  }
593
480
 
594
- /*options = {
595
- ext_user_id: 'string',
596
- ext_actor_id: 'string',
597
- ext_role: 'string',
598
- ref_id: 'string', (optional)
599
- productcode: 'string',
600
- ext_product_id: 'string',
601
- ext_product_meta: {
602
- startdate: 'string',
603
- enddate: 'string',
604
- ...
605
- },
606
- ext_data: {},
607
- audit: boolean
608
- }*/
481
+ /**
482
+ * Wiki Link for SDK params
483
+ * https://github.com/comprodls/comprodls-sdk-js/wiki/18_Spaces-Adapter#entitleusertoproductparams
484
+ */
609
485
  function entitleUserToProduct(options) {
610
486
  var self = this;
611
487
  // Initializing promise
@@ -636,7 +512,7 @@ function entitleUserToProduct(options) {
636
512
  } else {
637
513
  var err = {};
638
514
  err.description = 'Missing mandatory keys in request options. \'ext_user_id\', \'ext_role\' and ' +
639
- 'either of \'ext_product_id\' or \'productcode\' must be present.'
515
+ 'either of \'ext_product_id\' or \'productcode\' must be present.';
640
516
  err.message = err.description;
641
517
  err = new DLSError(helpers.errors.ERROR_TYPES.SDK_ERROR, err);
642
518
  dfd.reject(err);
@@ -645,12 +521,10 @@ function entitleUserToProduct(options) {
645
521
  return dfd.promise;
646
522
  }
647
523
 
648
- /*options = {
649
- ext_user_id: 'string',
650
- ext_actor_id: 'string',
651
- productcode: 'string',
652
- audit: 'boolean'
653
- }*/
524
+ /**
525
+ * Wiki Link for SDK params
526
+ * https://github.com/comprodls/comprodls-sdk-js/wiki/18_Spaces-Adapter#unentitleusertoproductparams
527
+ */
654
528
  function unentitleUserToProduct(options) {
655
529
  var self = this;
656
530
  var dfd = q.defer();
@@ -693,22 +567,10 @@ function unentitleUserToProduct(options) {
693
567
  return dfd.promise;
694
568
  }
695
569
 
696
- /* This function calls the ComproDLS API to micro entitle user to a product.
697
- options = {
698
- "ext_user_id": "string", // Mandatory
699
- "ext_actor_id": "string", // Optional
700
- "feature_key": "string", // Mandatory
701
- "feature_id": "string", // Mandatory
702
- "context": "string", // Mandatory
703
- "data": {}, // Optional
704
- "productcode": "string", // one of productcode and ext_product_id is mandatory
705
- "ext_product_id": "string",
706
- "ext_entitlement_meta": { //Optional
707
- "startdate": "epoch",
708
- "enddate": "epoch" //mandatory, if ext_entitlement_meta provided.
709
- },
710
- "audit": boolean // Optional
711
- }*/
570
+ /**
571
+ * Wiki Link for SDK params
572
+ * https://github.com/comprodls/comprodls-sdk-js/wiki/18_Spaces-Adapter#microentitleusertoproductparams
573
+ */
712
574
  function microEntitleUserToProduct(options) {
713
575
  var self = this;
714
576
  // Initializing promise
@@ -759,30 +621,10 @@ function microEntitleUserToProduct(options) {
759
621
  return dfd.promise;
760
622
  }
761
623
 
762
- /* This function calls the ComproDLS API to micro entitle user to product.
763
- options = {
764
- "micro-entitlements": [{ // Mandatory, Min: 1
765
- "ext_user_id": "string", // Mandatory
766
-
767
- "productcode": "string",
768
- "ext_product_id": "string",
769
-
770
- "context": "string",
771
- "feature_key": "string",
772
- "feature_id": "string",,
773
- "data": {},
774
- "ext_entitlement_meta": {
775
- "startdate": 0,
776
- "enddate": 0
777
- },
778
-
779
- "ext_actor_id": "string", // Mandatory if 'audit' is true
780
- "audit": true
781
- },
782
-
783
- ]
784
- }
785
- */
624
+ /**
625
+ * Wiki Link for SDK params
626
+ * https://github.com/comprodls/comprodls-sdk-js/wiki/18_Spaces-Adapter#bulkmicroentitleproducttouserparams
627
+ */
786
628
  function bulkMicroEntitleProductToUser(options) {
787
629
  var self = this;
788
630
  // Initializing promise
@@ -812,7 +654,7 @@ function bulkMicroEntitleProductToUser(options) {
812
654
  } else {
813
655
  var err = {};
814
656
  err.description = 'Missing mandatory keys in request options.' +
815
- ' \'micro-entitlements\' must be present.'
657
+ ' \'micro-entitlements\' must be present.';
816
658
  err.message = err.description;
817
659
  err = new DLSError(helpers.errors.ERROR_TYPES.SDK_ERROR, err);
818
660
  dfd.reject(err);
@@ -821,16 +663,10 @@ function bulkMicroEntitleProductToUser(options) {
821
663
  return dfd.promise;
822
664
  }
823
665
 
824
- /* This function calls the ComproDLS API to revoke micro entitlement of a user.
825
- options = {
826
- "ext_user_id": "string", // Mandatory
827
- "ext_actor_id": "string", // Mandatory
828
- "feature_key": "string", // Mandatory
829
- "context": "string", // Mandatory
830
- "productcode": "string", // one of productcode and ext_product_id is mandatory
831
- "ext_product_id": "string",
832
- "audit": boolean // Mandatory
833
- }*/
666
+ /**
667
+ * Wiki Link for SDK params
668
+ * https://github.com/comprodls/comprodls-sdk-js/wiki/18_Spaces-Adapter#revokemicroentitlementofauserparams
669
+ */
834
670
  function revokeMicroEntitlementOfAUser(options) {
835
671
  var self = this;
836
672
  // Initializing promise
@@ -875,9 +711,10 @@ function revokeMicroEntitlementOfAUser(options) {
875
711
  return dfd.promise;
876
712
  }
877
713
 
878
- /*options = {
879
- ext_product_id: 'string'
880
- }*/
714
+ /**
715
+ * Wiki Link for SDK params
716
+ * https://github.com/comprodls/comprodls-sdk-js/wiki/18_Spaces-Adapter#getextproductparams
717
+ */
881
718
  function getExtProduct(options) {
882
719
  var self = this;
883
720
  // Initializing promise
@@ -911,9 +748,10 @@ function getExtProduct(options) {
911
748
  return dfd.promise;
912
749
  }
913
750
 
914
- /*options = {
915
- spacekey: 'string'
916
- }*/
751
+ /**
752
+ * Wiki Link for SDK params
753
+ * https://github.com/comprodls/comprodls-sdk-js/wiki/18_Spaces-Adapter#getspacedetailsparams
754
+ */
917
755
  function getSpaceDetails(options) {
918
756
  var self = this;
919
757
  // Initializing promise
@@ -950,15 +788,10 @@ function getSpaceDetails(options) {
950
788
  return dfd.promise;
951
789
  }
952
790
 
953
- /*options = {
954
- ext_user_id: 'string',
955
- ext_role: 'string',
956
- ext_first_name: 'string',
957
- ext_last_name: 'string',
958
- ext_email: 'string',
959
- ref_id: 'string', (optional)
960
- class_code: 'string'
961
- }*/
791
+ /**
792
+ * Wiki Link for SDK params
793
+ * https://github.com/comprodls/comprodls-sdk-js/wiki/18_Spaces-Adapter#enrolluserinclassparams
794
+ */
962
795
  function enrollUserInClass(options) {
963
796
  var self = this;
964
797
  // Initializing promise
@@ -997,14 +830,8 @@ function enrollUserInClass(options) {
997
830
  }
998
831
 
999
832
  /**
1000
- * This function calls the ComproDLS API to update user information.
1001
- * options = {
1002
- * "ext_user_id": "string",
1003
- * "ref_id": "string", // optional
1004
- * "ext_email": "string", // optional
1005
- * "ext_first_name": "string", // optional
1006
- * "ext_last_name": "string" // optional
1007
- * };
833
+ * Wiki Link for SDK params
834
+ * https://github.com/comprodls/comprodls-sdk-js/wiki/18_Spaces-Adapter#updateuserinformationparams
1008
835
  */
1009
836
  function updateUserInformation(options) {
1010
837
  var self = this;
@@ -1050,9 +877,8 @@ function updateUserInformation(options) {
1050
877
  }
1051
878
 
1052
879
  /**
1053
- * This function is used to update the visibility (hide/unhide) a particular user-space of a user.
1054
- * @param {*extuserid, *spacekey, *body: { *visibility }} options
1055
- * @returns {promise}
880
+ * Wiki Link for SDK params
881
+ * https://github.com/comprodls/comprodls-sdk-js/wiki/18_Spaces-Adapter#updateuserspaceparams
1056
882
  */
1057
883
  function updateUserSpace(options) {
1058
884
  var self = this;
@@ -1096,56 +922,47 @@ function updateUserSpace(options) {
1096
922
  return deferred.promise;
1097
923
  }
1098
924
 
1099
- /* options = {
1100
- "email": "string", // required
1101
- "status " : "string", // optional
1102
- };
1103
- */
925
+ /**
926
+ * Wiki Link for SDK params
927
+ * https://github.com/comprodls/comprodls-sdk-js/wiki/18_Spaces-Adapter#getinvitationsbyemailparams
928
+ */
1104
929
  function getInvitationsByEmail(options) {
1105
- var self = this;
1106
- // Initializing promise
1107
- var dfd = q.defer();
1108
- var err = {};
1109
- if (options && options.email) {
930
+ var self = this;
931
+ // Initializing promise
932
+ var dfd = q.defer();
933
+ var err = {};
934
+ if (options && options.email) {
1110
935
 
1111
- // Passed all validations, Contruct API url
1112
- var url = self.config.DEFAULT_HOSTS.AUTH + self.config.AUTH_API_URLS.getInvitationsByEmail;
1113
- url = helpers.api.constructAPIUrl(url, { accountid: self.accountId });
936
+ // Passed all validations, Contruct API url
937
+ var url = self.config.DEFAULT_HOSTS.AUTH + self.config.AUTH_API_URLS.getInvitationsByEmail;
938
+ url = helpers.api.constructAPIUrl(url, { accountid: self.accountId });
1114
939
 
1115
- var queryParam = { email: options.email };
1116
- if (options.status) { queryParam.status = options.status; }
940
+ var queryParam = { email: options.email };
941
+ if (options.status) { queryParam.status = options.status; }
1117
942
 
1118
- // Setup request with URL and Params
943
+ // Setup request with URL and Params
1119
944
  var requestAPI = request.get(url).query(queryParam);
1120
945
  if(self.traceid) { requestAPI.set('X-Amzn-Trace-Id', self.traceid); }
1121
946
 
1122
- requestAPI.end(function (error, response) {
1123
- if (error) {
1124
- err = new DLSError(helpers.errors.ERROR_TYPES.API_ERROR, error);
1125
- dfd.reject(err);
1126
- }
1127
- else { dfd.resolve(response.body); }
1128
- });
1129
- }
1130
- else {
1131
- err.message = err.description = 'email not found in request options.';
1132
- err = new DLSError(helpers.errors.ERROR_TYPES.SDK_ERROR, err);
1133
- dfd.reject(err);
1134
- }
1135
- return dfd.promise;
947
+ requestAPI.end(function (error, response) {
948
+ if (error) {
949
+ err = new DLSError(helpers.errors.ERROR_TYPES.API_ERROR, error);
950
+ dfd.reject(err);
951
+ }
952
+ else { dfd.resolve(response.body); }
953
+ });
954
+ }
955
+ else {
956
+ err.message = err.description = 'email not found in request options.';
957
+ err = new DLSError(helpers.errors.ERROR_TYPES.SDK_ERROR, err);
958
+ dfd.reject(err);
959
+ }
960
+ return dfd.promise;
1136
961
  }
1137
962
 
1138
963
  /**
1139
- * This API is used to update an institute's space title
1140
- * options = {
1141
- * space_code: "", // Mandatory, space code of institute whose title is to be updated
1142
- * body : {
1143
- * ext_actor_id: "", // Mandatory
1144
- * data: {
1145
- * space_title: ""
1146
- * }
1147
- * }
1148
- * }
964
+ * Wiki Link for SDK params
965
+ * https://github.com/comprodls/comprodls-sdk-js/wiki/18_Spaces-Adapter#updateinstitutetitleparams
1149
966
  */
1150
967
  function updateInstituteTitle(options){
1151
968
  var self = this;
@@ -30,9 +30,6 @@ var Agent = require('agentkeepalive');
30
30
  var helpers = require('../../helpers');
31
31
  var DLSError = helpers.errors.DLSError;
32
32
 
33
- /*********************************
34
- * Setting Up Module Entry Point
35
- **********************************/
36
33
  module.exports = spacesextn;
37
34
 
38
35
  var keepaliveAgent = new Agent({
@@ -44,27 +41,14 @@ var keepaliveAgent = new Agent({
44
41
  function spacesextn(accountId) {
45
42
  this.accountId = accountId;
46
43
  return {
47
- entitleBulkUsersToProducts: entitleBulkUsersToProducts.bind(this)
44
+ entitleBulkUsersToProducts: entitleBulkUsersToProducts.bind(this),
45
+ setupUser: setupUser.bind(this)
48
46
  };
49
47
  }
50
48
 
51
49
  /**
52
- * @param {
53
- * *users: [{
54
- * *ext_user_id: 'string',
55
- * ext_role: 'string',
56
- * *products: [{
57
- * *productcode: 'string',
58
- * ext_entitlement_meta: {
59
- * start_date: <epoch>,
60
- * *end_date: <epoch>
61
- * },
62
- * ext_data : {},
63
- * *action: 'string'
64
- * }]
65
- * }],
66
- * *ext_actor_id: 'string'
67
- * } options
50
+ * Wiki Link for SDK params
51
+ * https://github.com/comprodls/comprodls-sdk-js/wiki/22_Integrations-Adapter#entitlebulkuserstoproductsparams
68
52
  */
69
53
  function entitleBulkUsersToProducts(options) {
70
54
  var self = this;
@@ -105,3 +89,43 @@ function entitleBulkUsersToProducts(options) {
105
89
  return dfd.promise;
106
90
  }
107
91
 
92
+ /**
93
+ * Wiki Link for SDK params
94
+ * https://github.com/comprodls/comprodls-sdk-js/wiki/22_Integrations-Adapter#setupuserparams
95
+ */
96
+ function setupUser(options) {
97
+ var self = this;
98
+ //Initializing promise
99
+ var deferred = q.defer();
100
+
101
+ if (options && options.ext_user_id && options.workflow_type) {
102
+ //Passed all validations, Contruct API url
103
+ var url = self.config.DEFAULT_HOSTS.AUTHEXTN + self.config.AUTHEXTN_API_URLS.setupUser;
104
+ url = helpers.api.constructAPIUrl(url, { accountId: self.accountId });
105
+
106
+ var requestAPI = request.post(url)
107
+ .set('Content-Type', 'application/json')
108
+ .set('Accept', 'application/json')
109
+ .send(options);
110
+
111
+ if (self.traceid) { requestAPI.set('X-Amzn-Trace-Id', self.traceid); }
112
+
113
+ requestAPI
114
+ .agent(keepaliveAgent)
115
+ .end(function(err, res) {
116
+ if (err) {
117
+ err = new DLSError(helpers.errors.ERROR_TYPES.API_ERROR, err);
118
+ deferred.reject(err);
119
+ } else {
120
+ deferred.resolve(res.body);
121
+ }
122
+ });
123
+ } else {
124
+ var err = {};
125
+ err.message = err.description = 'Mandatory field \'ext_user_id\' or \'workflow_type\' not found '+
126
+ 'in the request options.';
127
+ err = new DLSError(helpers.errors.ERROR_TYPES.SDK_ERROR, err);
128
+ deferred.reject(err);
129
+ }
130
+ return deferred.promise;
131
+ }