comprodls-sdk 2.12.0 → 2.12.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.
- package/.eslintrc +28 -28
- package/.npmignore +5 -0
- package/README.md +371 -371
- package/dist/comprodls-sdk.js +11493 -11471
- package/dist/comprodls-sdk.min.js +14 -14
- package/grunt/publish.js +148 -148
- package/lib/comprodls.js +146 -146
- package/lib/config/index.js +337 -337
- package/lib/helpers/index.js +29 -29
- package/lib/helpers/lib/api/converter.js +119 -119
- package/lib/helpers/lib/api/index.js +120 -120
- package/lib/helpers/lib/api/validations.js +72 -72
- package/lib/helpers/lib/errors.js +129 -129
- package/lib/helpers/lib/utils.js +23 -23
- package/lib/helpers/lib/validator.js +100 -100
- package/lib/open_access/index.js +121 -121
- package/lib/services/activity/activity.js +209 -209
- package/lib/services/activity/attempt.js +431 -431
- package/lib/services/activity/index.js +28 -28
- package/lib/services/analytics/index.js +1555 -1555
- package/lib/services/attempts/index.js +342 -342
- package/lib/services/auth/classProduct.js +37 -37
- package/lib/services/auth/index.js +2541 -2541
- package/lib/services/collab/index.js +468 -468
- package/lib/services/drive/index.js +144 -144
- package/lib/services/integrations/index.js +279 -279
- package/lib/services/invitations/index.js +313 -313
- package/lib/services/lrs/index.js +459 -459
- package/lib/services/product/index.js +267 -267
- package/lib/services/pub/index.js +407 -407
- package/lib/services/push/index.js +187 -187
- package/lib/services/push/pubnubClientWrapper.js +557 -557
- package/lib/services/push/sessionStorage.js +64 -64
- package/lib/services/pushX/index.js +190 -190
- package/lib/services/pushX/pubnubClientWrapper.js +211 -211
- package/lib/services/sisevents/index.js +113 -113
- package/lib/services/spaces/index.js +976 -929
- package/lib/services/superuser/index.js +175 -175
- package/lib/services/workflows/index.js +464 -464
- package/lib/services/xapi/index.js +232 -232
- package/lib/token/index.js +114 -114
- package/lib/token/validations.js +88 -88
- package/package-lock.json +5095 -0
- package/package.json +1 -1
- package/test.js +50 -50
- package/.vscode/launch.json +0 -23
- package/npm-debug.log.189866131 +0 -0
- package/npm-debug.log.712840116 +0 -26
|
@@ -1,929 +1,976 @@
|
|
|
1
|
-
/*************************************************************************
|
|
2
|
-
*
|
|
3
|
-
* COMPRO CONFIDENTIAL
|
|
4
|
-
* __________________
|
|
5
|
-
*
|
|
6
|
-
* [2015] - [2020] Compro Technologies Private Limited
|
|
7
|
-
* All Rights Reserved.
|
|
8
|
-
*
|
|
9
|
-
* NOTICE: All information contained herein is, and remains
|
|
10
|
-
* the property of Compro Technologies Private Limited. The
|
|
11
|
-
* intellectual and technical concepts contained herein are
|
|
12
|
-
* proprietary to Compro Technologies Private Limited and may
|
|
13
|
-
* be covered by U.S. and Foreign Patents, patents in process,
|
|
14
|
-
* and are protected by trade secret or copyright law.
|
|
15
|
-
*
|
|
16
|
-
* Dissemination of this information or reproduction of this material
|
|
17
|
-
* is strictly forbidden unless prior written permission is obtained
|
|
18
|
-
* from Compro Technologies Pvt. Ltd..
|
|
19
|
-
***************************************************************************/
|
|
20
|
-
|
|
21
|
-
/***********************************************************
|
|
22
|
-
* comproDLS SDK AUTH API Adaptor
|
|
23
|
-
* Functions for calling AUTH API.
|
|
24
|
-
************************************************************/
|
|
25
|
-
|
|
26
|
-
var q = require('q');
|
|
27
|
-
var request = require('superagent');
|
|
28
|
-
|
|
29
|
-
var helpers = require('../../helpers');
|
|
30
|
-
|
|
31
|
-
var DLSError = helpers.errors.DLSError;
|
|
32
|
-
|
|
33
|
-
/*********************************
|
|
34
|
-
* Setting Up Module Entry Point
|
|
35
|
-
**********************************/
|
|
36
|
-
module.exports = spaces;
|
|
37
|
-
|
|
38
|
-
//Auth Adaptor Contsructor
|
|
39
|
-
function spaces(accountId) {
|
|
40
|
-
this.accountId = accountId;
|
|
41
|
-
return {
|
|
42
|
-
getUserSpaces: getUserSpaces.bind(this),
|
|
43
|
-
validateSpaceCode: validateSpaceCode.bind(this),
|
|
44
|
-
validateClassCode: validateClassCode.bind(this),
|
|
45
|
-
generateSpaceCode: generateSpaceCode.bind(this),
|
|
46
|
-
changeSpaceCode: changeSpaceCode.bind(this),
|
|
47
|
-
joinInstituteSpace: joinInstituteSpace.bind(this),
|
|
48
|
-
provisionSpacesToStudent: provisionSpacesToStudent.bind(this),
|
|
49
|
-
provisionSpacesToTeacher: provisionSpacesToTeacher.bind(this),
|
|
50
|
-
provisionBulkSpaces: provisionBulkSpaces.bind(this),
|
|
51
|
-
shadowProvision: shadowProvision.bind(this),
|
|
52
|
-
entitleUserToProduct: entitleUserToProduct.bind(this),
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
if(options.
|
|
88
|
-
if(options.
|
|
89
|
-
if(options.
|
|
90
|
-
if(options.
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
err =
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
.set('
|
|
132
|
-
.
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
err =
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
.set('
|
|
178
|
-
.
|
|
179
|
-
.
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
err =
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
.set('
|
|
218
|
-
.
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
"
|
|
235
|
-
"
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
.set('
|
|
253
|
-
.
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
err =
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
.set('
|
|
299
|
-
.
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
err =
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
}
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
var
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
.set('
|
|
353
|
-
.
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
err =
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
*
|
|
376
|
-
*
|
|
377
|
-
*
|
|
378
|
-
*
|
|
379
|
-
*
|
|
380
|
-
*
|
|
381
|
-
*
|
|
382
|
-
*
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
.set('
|
|
400
|
-
.
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
err =
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
"
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
"
|
|
428
|
-
"
|
|
429
|
-
"
|
|
430
|
-
"
|
|
431
|
-
"
|
|
432
|
-
"
|
|
433
|
-
"
|
|
434
|
-
"
|
|
435
|
-
"
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
"
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
"
|
|
445
|
-
|
|
446
|
-
"
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
self.config.
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
.
|
|
473
|
-
.set('
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
err
|
|
490
|
-
err =
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
*
|
|
501
|
-
*
|
|
502
|
-
* "
|
|
503
|
-
* "
|
|
504
|
-
* "
|
|
505
|
-
* "
|
|
506
|
-
*
|
|
507
|
-
*
|
|
508
|
-
*
|
|
509
|
-
* "
|
|
510
|
-
* "
|
|
511
|
-
*
|
|
512
|
-
*
|
|
513
|
-
* "
|
|
514
|
-
* "
|
|
515
|
-
* "
|
|
516
|
-
*
|
|
517
|
-
*
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
url =
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
.
|
|
532
|
-
.set('
|
|
533
|
-
.
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
}
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
.set('
|
|
582
|
-
.
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
err
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
err =
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
options = {
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
(
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
err
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
var
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
{
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
}
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
}
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
var
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
{
|
|
810
|
-
// Passed all validations, Contruct API url
|
|
811
|
-
var url = self.config.DEFAULT_HOSTS.AUTH +
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
err =
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
function
|
|
850
|
-
var self = this;
|
|
851
|
-
// Initializing promise
|
|
852
|
-
var dfd = q.defer()
|
|
853
|
-
|
|
854
|
-
if(options && options.ext_user_id
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
if(
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
if(
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
}
|
|
1
|
+
/*************************************************************************
|
|
2
|
+
*
|
|
3
|
+
* COMPRO CONFIDENTIAL
|
|
4
|
+
* __________________
|
|
5
|
+
*
|
|
6
|
+
* [2015] - [2020] Compro Technologies Private Limited
|
|
7
|
+
* All Rights Reserved.
|
|
8
|
+
*
|
|
9
|
+
* NOTICE: All information contained herein is, and remains
|
|
10
|
+
* the property of Compro Technologies Private Limited. The
|
|
11
|
+
* intellectual and technical concepts contained herein are
|
|
12
|
+
* proprietary to Compro Technologies Private Limited and may
|
|
13
|
+
* be covered by U.S. and Foreign Patents, patents in process,
|
|
14
|
+
* and are protected by trade secret or copyright law.
|
|
15
|
+
*
|
|
16
|
+
* Dissemination of this information or reproduction of this material
|
|
17
|
+
* is strictly forbidden unless prior written permission is obtained
|
|
18
|
+
* from Compro Technologies Pvt. Ltd..
|
|
19
|
+
***************************************************************************/
|
|
20
|
+
|
|
21
|
+
/***********************************************************
|
|
22
|
+
* comproDLS SDK AUTH API Adaptor
|
|
23
|
+
* Functions for calling AUTH API.
|
|
24
|
+
************************************************************/
|
|
25
|
+
|
|
26
|
+
var q = require('q');
|
|
27
|
+
var request = require('superagent');
|
|
28
|
+
|
|
29
|
+
var helpers = require('../../helpers');
|
|
30
|
+
|
|
31
|
+
var DLSError = helpers.errors.DLSError;
|
|
32
|
+
|
|
33
|
+
/*********************************
|
|
34
|
+
* Setting Up Module Entry Point
|
|
35
|
+
**********************************/
|
|
36
|
+
module.exports = spaces;
|
|
37
|
+
|
|
38
|
+
//Auth Adaptor Contsructor
|
|
39
|
+
function spaces(accountId) {
|
|
40
|
+
this.accountId = accountId;
|
|
41
|
+
return {
|
|
42
|
+
getUserSpaces: getUserSpaces.bind(this),
|
|
43
|
+
validateSpaceCode: validateSpaceCode.bind(this),
|
|
44
|
+
validateClassCode: validateClassCode.bind(this),
|
|
45
|
+
generateSpaceCode: generateSpaceCode.bind(this),
|
|
46
|
+
changeSpaceCode: changeSpaceCode.bind(this),
|
|
47
|
+
joinInstituteSpace: joinInstituteSpace.bind(this),
|
|
48
|
+
provisionSpacesToStudent: provisionSpacesToStudent.bind(this),
|
|
49
|
+
provisionSpacesToTeacher: provisionSpacesToTeacher.bind(this),
|
|
50
|
+
provisionBulkSpaces: provisionBulkSpaces.bind(this),
|
|
51
|
+
shadowProvision: shadowProvision.bind(this),
|
|
52
|
+
entitleUserToProduct: entitleUserToProduct.bind(this),
|
|
53
|
+
unentitleUserToProduct: unentitleUserToProduct.bind(this),
|
|
54
|
+
revokeMicroEntitlementOfAUser: revokeMicroEntitlementOfAUser.bind(this),
|
|
55
|
+
microEntitleUserToProduct: microEntitleUserToProduct.bind(this),
|
|
56
|
+
enrollUserInClass: enrollUserInClass.bind(this),
|
|
57
|
+
getExtProduct: getExtProduct.bind(this),
|
|
58
|
+
getSpaceDetails: getSpaceDetails.bind(this),
|
|
59
|
+
updateUserInformation: updateUserInformation.bind(this),
|
|
60
|
+
getInvitationsByEmail: getInvitationsByEmail.bind(this)
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/*options = {
|
|
65
|
+
extuserid: 'string',
|
|
66
|
+
spaceRole: 'string', //optional
|
|
67
|
+
spaceType: 'string', //optional
|
|
68
|
+
spaceOrgContext: 'string', //optional
|
|
69
|
+
details: boolean, //optional
|
|
70
|
+
cursor: 'string' //optional
|
|
71
|
+
}*/
|
|
72
|
+
function getUserSpaces(options) {
|
|
73
|
+
var self = this;
|
|
74
|
+
// Initializing promise
|
|
75
|
+
var dfd = q.defer();
|
|
76
|
+
// Validations
|
|
77
|
+
|
|
78
|
+
if(options && options.extuserid) {
|
|
79
|
+
// Passed all validations, Contruct API url
|
|
80
|
+
var url = self.config.DEFAULT_HOSTS.AUTH +
|
|
81
|
+
self.config.AUTH_API_URLS.getUserSpaces;
|
|
82
|
+
url = helpers.api.constructAPIUrl(url, {
|
|
83
|
+
accountid: self.accountId, extuserid: options.extuserid
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
var params = {};
|
|
87
|
+
if(options.spaceRole) { params.spaceRole = options.spaceRole; }
|
|
88
|
+
if(options.spaceType) { params.spaceType = options.spaceType; }
|
|
89
|
+
if(options.spaceOrgContext) { params.spaceOrgContext = options.spaceOrgContext; }
|
|
90
|
+
if(options.details) { params.details = options.details; }
|
|
91
|
+
if(options.cursor) { params.cursor = options.cursor; }
|
|
92
|
+
|
|
93
|
+
// Setup request with URL and Params
|
|
94
|
+
var requestAPI = request.get(url).query(params);
|
|
95
|
+
if(self.traceid) { requestAPI.set('X-Amzn-Trace-Id', self.traceid); }
|
|
96
|
+
|
|
97
|
+
requestAPI.end(function(error, response) {
|
|
98
|
+
if(error) {
|
|
99
|
+
err = new DLSError(helpers.errors.ERROR_TYPES.API_ERROR, error);
|
|
100
|
+
dfd.reject(error);
|
|
101
|
+
}
|
|
102
|
+
else { dfd.resolve(response.body); }
|
|
103
|
+
});
|
|
104
|
+
} else {
|
|
105
|
+
var err = {};
|
|
106
|
+
err.message = err.description = 'extuserid not found in request options.';
|
|
107
|
+
err = new DLSError(helpers.errors.ERROR_TYPES.SDK_ERROR, err);
|
|
108
|
+
dfd.reject(err);
|
|
109
|
+
}
|
|
110
|
+
return dfd.promise;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
/*options = {
|
|
114
|
+
spaceCodeBody : {
|
|
115
|
+
space_code: 'string'
|
|
116
|
+
}
|
|
117
|
+
}*/
|
|
118
|
+
function validateSpaceCode(options) {
|
|
119
|
+
var self = this;
|
|
120
|
+
// Initializing promise
|
|
121
|
+
var dfd = q.defer();
|
|
122
|
+
|
|
123
|
+
if(options && options.spaceCodeBody && options.spaceCodeBody.space_code) {
|
|
124
|
+
// Passed all validations, Contruct API url
|
|
125
|
+
var url = self.config.DEFAULT_HOSTS.AUTH +
|
|
126
|
+
self.config.AUTH_API_URLS.validateSpaceCode;
|
|
127
|
+
url = helpers.api.constructAPIUrl(url, { accountid : self.accountId });
|
|
128
|
+
|
|
129
|
+
// Setup request with URL and Params
|
|
130
|
+
var requestAPI = request.post(url)
|
|
131
|
+
.set('Content-Type', 'application/json')
|
|
132
|
+
.set('Accept', 'application/json')
|
|
133
|
+
.send(options.spaceCodeBody);
|
|
134
|
+
if(self.traceid) { requestAPI.set('X-Amzn-Trace-Id', self.traceid); }
|
|
135
|
+
|
|
136
|
+
requestAPI.end(function(error, response) {
|
|
137
|
+
if(error) {
|
|
138
|
+
err = new DLSError(helpers.errors.ERROR_TYPES.API_ERROR, error);
|
|
139
|
+
dfd.reject(error);
|
|
140
|
+
}
|
|
141
|
+
else { dfd.resolve(response.body); }
|
|
142
|
+
});
|
|
143
|
+
} else {
|
|
144
|
+
var err = {};
|
|
145
|
+
err.message = err.description = 'spaceCodeBody or space_code not found in request options.';
|
|
146
|
+
err = new DLSError(helpers.errors.ERROR_TYPES.SDK_ERROR, err);
|
|
147
|
+
dfd.reject(err);
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
return dfd.promise;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
/*options = {
|
|
154
|
+
classCodeBody : {
|
|
155
|
+
class_code: 'string'
|
|
156
|
+
},
|
|
157
|
+
details: boolean // optional
|
|
158
|
+
}*/
|
|
159
|
+
function validateClassCode(options) {
|
|
160
|
+
var self = this;
|
|
161
|
+
// Initializing promise
|
|
162
|
+
var dfd = q.defer();
|
|
163
|
+
|
|
164
|
+
if(options && options.classCodeBody && options.classCodeBody.class_code) {
|
|
165
|
+
// Passed all validations, Contruct API url
|
|
166
|
+
var url = self.config.DEFAULT_HOSTS.AUTH +
|
|
167
|
+
self.config.AUTH_API_URLS.validateClassCode;
|
|
168
|
+
url = helpers.api.constructAPIUrl(url, { accountid : self.accountId });
|
|
169
|
+
|
|
170
|
+
var queryParams = {};
|
|
171
|
+
if (options.details) {
|
|
172
|
+
queryParams.details = options.details;
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
// Setup request with URL and Params
|
|
176
|
+
var requestAPI = request.post(url)
|
|
177
|
+
.set('Content-Type', 'application/json')
|
|
178
|
+
.set('Accept', 'application/json')
|
|
179
|
+
.query(queryParams)
|
|
180
|
+
.send(options.classCodeBody);
|
|
181
|
+
if(self.traceid) { requestAPI.set('X-Amzn-Trace-Id', self.traceid); }
|
|
182
|
+
|
|
183
|
+
requestAPI.end(function(error, response) {
|
|
184
|
+
if(error) {
|
|
185
|
+
err = new DLSError(helpers.errors.ERROR_TYPES.API_ERROR, error);
|
|
186
|
+
dfd.reject(error);
|
|
187
|
+
}
|
|
188
|
+
else { dfd.resolve(response.body); }
|
|
189
|
+
});
|
|
190
|
+
} else {
|
|
191
|
+
var err = {};
|
|
192
|
+
err.message = err.description = 'classCodeBody or class_code not found in request options.';
|
|
193
|
+
err = new DLSError(helpers.errors.ERROR_TYPES.SDK_ERROR, err);
|
|
194
|
+
dfd.reject(err);
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
return dfd.promise;
|
|
198
|
+
}
|
|
199
|
+
/* options = {
|
|
200
|
+
"ignore_words": ["string"] //optional, This is the array of all bad words to be ignored.
|
|
201
|
+
}*/
|
|
202
|
+
function generateSpaceCode(options) {
|
|
203
|
+
var self = this;
|
|
204
|
+
|
|
205
|
+
// Initializing promise
|
|
206
|
+
var dfd = q.defer();
|
|
207
|
+
|
|
208
|
+
// Passed all validations, Contruct API url
|
|
209
|
+
var url = self.config.DEFAULT_HOSTS.AUTH +
|
|
210
|
+
self.config.AUTH_API_URLS.generateSpaceCode;
|
|
211
|
+
url = helpers.api.constructAPIUrl(url, { accountid : self.accountId });
|
|
212
|
+
|
|
213
|
+
var bodyParams = {};
|
|
214
|
+
if(options.ignore_words) { bodyParams.ignore_words = options.ignore_words }
|
|
215
|
+
// Setup request with URL and Params
|
|
216
|
+
var requestAPI = request.post(url)
|
|
217
|
+
.set('Content-Type', 'application/json')
|
|
218
|
+
.set('Accept', 'application/json')
|
|
219
|
+
.send(bodyParams);
|
|
220
|
+
if(self.traceid) { requestAPI.set('X-Amzn-Trace-Id', self.traceid); }
|
|
221
|
+
|
|
222
|
+
requestAPI.end(function(error, response) {
|
|
223
|
+
if(error) {
|
|
224
|
+
err = new DLSError(helpers.errors.ERROR_TYPES.API_ERROR, error);
|
|
225
|
+
dfd.reject(error);
|
|
226
|
+
}
|
|
227
|
+
else { dfd.resolve(response); }
|
|
228
|
+
});
|
|
229
|
+
|
|
230
|
+
return dfd.promise;
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
/* options = {
|
|
234
|
+
"ext_user_id": "string", //mandatory, This is the actor to change the spacecode.
|
|
235
|
+
"ignore_words": ["string"] //optional, This is the array of all bad words to be ignored.
|
|
236
|
+
"spacecode": "string" //mandatory, This is the spacecode that needs to be changed.
|
|
237
|
+
}*/
|
|
238
|
+
function changeSpaceCode(options) {
|
|
239
|
+
var self = this;
|
|
240
|
+
// Initializing promise
|
|
241
|
+
var dfd = q.defer();
|
|
242
|
+
|
|
243
|
+
if(options && options.ext_user_id && options.spacecode) {
|
|
244
|
+
// Passed all validations, Contruct API url
|
|
245
|
+
var url = self.config.DEFAULT_HOSTS.AUTH +
|
|
246
|
+
self.config.AUTH_API_URLS.changeSpaceCode;
|
|
247
|
+
url = helpers.api.constructAPIUrl(url, { accountid : self.accountId, spacecode: options.spacecode });
|
|
248
|
+
var bodyParams = { ext_user_id: options.ext_user_id };
|
|
249
|
+
if(options.ignore_words) { bodyParams.ignore_words = options.ignore_words }
|
|
250
|
+
// Setup request with URL and Params
|
|
251
|
+
var requestAPI = request.put(url)
|
|
252
|
+
.set('Content-Type', 'application/json')
|
|
253
|
+
.set('Accept', 'application/json')
|
|
254
|
+
.send(bodyParams);
|
|
255
|
+
if(self.traceid) { requestAPI.set('X-Amzn-Trace-Id', self.traceid); }
|
|
256
|
+
|
|
257
|
+
requestAPI.end(function(error, response) {
|
|
258
|
+
if(error) {
|
|
259
|
+
err = new DLSError(helpers.errors.ERROR_TYPES.API_ERROR, error);
|
|
260
|
+
dfd.reject(error);
|
|
261
|
+
}
|
|
262
|
+
else { dfd.resolve(response); }
|
|
263
|
+
});
|
|
264
|
+
} else {
|
|
265
|
+
var err = {};
|
|
266
|
+
err.message = err.description = 'Mandatory parameter options, ext_user_id or spacecode, not found in request options.';
|
|
267
|
+
err = new DLSError(helpers.errors.ERROR_TYPES.SDK_ERROR, err);
|
|
268
|
+
dfd.reject(err);
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
return dfd.promise;
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
/*
|
|
275
|
+
ext_user_id: 'string',
|
|
276
|
+
ext_role: 'string',
|
|
277
|
+
space_code: 'string',
|
|
278
|
+
ext_email: 'string', //optional
|
|
279
|
+
ext_first_name: 'string', //optional
|
|
280
|
+
ext_last_name: 'string, //optional
|
|
281
|
+
ref_id: 'string' //optional
|
|
282
|
+
*/
|
|
283
|
+
function joinInstituteSpace(options) {
|
|
284
|
+
var self = this;
|
|
285
|
+
// Initializing promise
|
|
286
|
+
var dfd = q.defer();
|
|
287
|
+
|
|
288
|
+
if(options && options.ext_user_id &&
|
|
289
|
+
options.ext_role && options.space_code)
|
|
290
|
+
{
|
|
291
|
+
// Passed all validations, Contruct API url
|
|
292
|
+
var url = self.config.DEFAULT_HOSTS.AUTH +
|
|
293
|
+
self.config.AUTH_API_URLS.joinInstituteSpace;
|
|
294
|
+
url = helpers.api.constructAPIUrl(url, { accountid : self.accountId });
|
|
295
|
+
|
|
296
|
+
// Setup request with URL and Params
|
|
297
|
+
var requestAPI = request.post(url)
|
|
298
|
+
.set('Content-Type', 'application/json')
|
|
299
|
+
.set('Accept', 'application/json')
|
|
300
|
+
.send(options);
|
|
301
|
+
if(self.traceid) { requestAPI.set('X-Amzn-Trace-Id', self.traceid); }
|
|
302
|
+
|
|
303
|
+
requestAPI.end(function(error, response) {
|
|
304
|
+
if(error) {
|
|
305
|
+
err = new DLSError(helpers.errors.ERROR_TYPES.API_ERROR, error);
|
|
306
|
+
dfd.reject(error);
|
|
307
|
+
}
|
|
308
|
+
else { dfd.resolve(response.body); }
|
|
309
|
+
});
|
|
310
|
+
} else {
|
|
311
|
+
var err = {};
|
|
312
|
+
err.message = err.description = 'ext_user_id or ext_role or space_code not found in request options.';
|
|
313
|
+
err = new DLSError(helpers.errors.ERROR_TYPES.SDK_ERROR, err);
|
|
314
|
+
dfd.reject(err);
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
return dfd.promise;
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
/*options = {
|
|
321
|
+
ext_user_id: 'string',
|
|
322
|
+
ext_role: 'string',
|
|
323
|
+
ext_first_name: 'string',
|
|
324
|
+
ext_last_name: 'string',
|
|
325
|
+
ext_email: 'string',
|
|
326
|
+
ref_id: 'string', (optional)
|
|
327
|
+
class_code: 'string' (optional)
|
|
328
|
+
products: [{
|
|
329
|
+
productcode: 'string',
|
|
330
|
+
ext_product_id: 'string',
|
|
331
|
+
ext_product_meta: {
|
|
332
|
+
startdate: 'string',
|
|
333
|
+
enddate: 'string',
|
|
334
|
+
...
|
|
335
|
+
}
|
|
336
|
+
}]
|
|
337
|
+
}*/
|
|
338
|
+
function provisionSpacesToStudent(options) {
|
|
339
|
+
var self = this;
|
|
340
|
+
// Initializing promise
|
|
341
|
+
var dfd = q.defer();
|
|
342
|
+
var err = {};
|
|
343
|
+
if(options && options.ext_user_id && options.ext_role) {
|
|
344
|
+
|
|
345
|
+
// Passed all validations, Contruct API url
|
|
346
|
+
var url = self.config.DEFAULT_HOSTS.AUTH +
|
|
347
|
+
self.config.AUTH_API_URLS.provisionSpacesToStudent;
|
|
348
|
+
url = helpers.api.constructAPIUrl(url, { accountId : self.accountId });
|
|
349
|
+
|
|
350
|
+
// Setup request with URL and Params
|
|
351
|
+
var requestAPI = request.post(url)
|
|
352
|
+
.set('Content-Type', 'application/json')
|
|
353
|
+
.set('Accept', 'application/json')
|
|
354
|
+
.send(options);
|
|
355
|
+
if(self.traceid) { requestAPI.set('X-Amzn-Trace-Id', self.traceid); }
|
|
356
|
+
|
|
357
|
+
requestAPI.end(function(error, response) {
|
|
358
|
+
if(error) {
|
|
359
|
+
err = new DLSError(helpers.errors.ERROR_TYPES.API_ERROR, error);
|
|
360
|
+
dfd.reject(error);
|
|
361
|
+
}
|
|
362
|
+
else { dfd.resolve(response.body); }
|
|
363
|
+
});
|
|
364
|
+
}
|
|
365
|
+
else {
|
|
366
|
+
err.message = err.description = 'ext_user_id or ext_role not found in request options.';
|
|
367
|
+
err = new DLSError(helpers.errors.ERROR_TYPES.SDK_ERROR, err);
|
|
368
|
+
dfd.reject(err);
|
|
369
|
+
}
|
|
370
|
+
|
|
371
|
+
return dfd.promise;
|
|
372
|
+
}
|
|
373
|
+
|
|
374
|
+
/**
|
|
375
|
+
* This function is used to provision spaces to a user with ext_role as teacher.
|
|
376
|
+
* options = {
|
|
377
|
+
* ext_user_id: "string",
|
|
378
|
+
* ext_role: "string",
|
|
379
|
+
* ext_first_name: "string",
|
|
380
|
+
* ext_last_name: "string",
|
|
381
|
+
* ext_email: "string",
|
|
382
|
+
* ref_id: "string"
|
|
383
|
+
* };
|
|
384
|
+
*/
|
|
385
|
+
function provisionSpacesToTeacher(options) {
|
|
386
|
+
var self = this;
|
|
387
|
+
// Initializing promise
|
|
388
|
+
var dfd = q.defer();
|
|
389
|
+
|
|
390
|
+
if(options && options.ext_user_id && options.ext_role)
|
|
391
|
+
{
|
|
392
|
+
// Passed all validations, Contruct API url
|
|
393
|
+
var url = self.config.DEFAULT_HOSTS.AUTH +
|
|
394
|
+
self.config.AUTH_API_URLS.provisionSpacesToTeacher;
|
|
395
|
+
url = helpers.api.constructAPIUrl(url, { accountId : self.accountId });
|
|
396
|
+
|
|
397
|
+
// Setup request with URL and Params
|
|
398
|
+
var requestAPI = request.post(url)
|
|
399
|
+
.set('Content-Type', 'application/json')
|
|
400
|
+
.set('Accept', 'application/json')
|
|
401
|
+
.send(options);
|
|
402
|
+
if(self.traceid) { requestAPI.set('X-Amzn-Trace-Id', self.traceid); }
|
|
403
|
+
|
|
404
|
+
requestAPI.end(function(error, response) {
|
|
405
|
+
if(error) {
|
|
406
|
+
err = new DLSError(helpers.errors.ERROR_TYPES.API_ERROR, error);
|
|
407
|
+
dfd.reject(error);
|
|
408
|
+
}
|
|
409
|
+
else { dfd.resolve(response.body); }
|
|
410
|
+
});
|
|
411
|
+
} else {
|
|
412
|
+
var err = {};
|
|
413
|
+
err.message = err.description = 'Mandatory parameters [rxt_user_id, ext_role] not found in request options.';
|
|
414
|
+
err = new DLSError(helpers.errors.ERROR_TYPES.SDK_ERROR, err);
|
|
415
|
+
dfd.reject(err);
|
|
416
|
+
}
|
|
417
|
+
|
|
418
|
+
return dfd.promise;
|
|
419
|
+
}
|
|
420
|
+
|
|
421
|
+
/**
|
|
422
|
+
* options = {
|
|
423
|
+
"space_title": "string", // mandatory
|
|
424
|
+
"ext_data": {} //optional, external data(e.g. jobdata etc.)
|
|
425
|
+
"users": [ // mandatory, min: 1, max: 200
|
|
426
|
+
{
|
|
427
|
+
"ext_user_id": "string", // mandatory (it must be unique within users array)
|
|
428
|
+
"ext_parent_id": "string",
|
|
429
|
+
"ext_username": "string",
|
|
430
|
+
"ext_role": "student", // mandatory
|
|
431
|
+
"ext_email": "string",
|
|
432
|
+
"ext_first_name": "string", // mandatory
|
|
433
|
+
"ext_last_name": "string", // mandatory
|
|
434
|
+
"address": "string",
|
|
435
|
+
"rowId": "string", // mandatory (it must be unique within users array)
|
|
436
|
+
"classes": [ // optional, min: 1, max: 3
|
|
437
|
+
{
|
|
438
|
+
"classid": "string", // either of classid or class_code them must be
|
|
439
|
+
"class_code": "string" // present, classid is preferred
|
|
440
|
+
}
|
|
441
|
+
],
|
|
442
|
+
"products": [ // optional, min: 1
|
|
443
|
+
{
|
|
444
|
+
"productcode": "string", // mandatory
|
|
445
|
+
"ext_product_meta": {
|
|
446
|
+
"startdate": "epoch",
|
|
447
|
+
"enddate": "epoch" // mandatory
|
|
448
|
+
}
|
|
449
|
+
"ext_data" : {} // optional, external data (e.g., ref_id, ...)
|
|
450
|
+
}
|
|
451
|
+
]
|
|
452
|
+
}
|
|
453
|
+
]
|
|
454
|
+
}
|
|
455
|
+
*
|
|
456
|
+
*/
|
|
457
|
+
function provisionBulkSpaces(options) {
|
|
458
|
+
var self = this;
|
|
459
|
+
// Initializing promise
|
|
460
|
+
var dfd = q.defer();
|
|
461
|
+
// Validations
|
|
462
|
+
var err = helpers.validations.isAuthenticated(self.orgId, self.token);
|
|
463
|
+
if(err) { dfd.reject(err); }
|
|
464
|
+
else {
|
|
465
|
+
if(options && options.users && options.space_title) {
|
|
466
|
+
// Passed all validations, Contruct API url
|
|
467
|
+
var url = self.config.DEFAULT_HOSTS.AUTH +
|
|
468
|
+
self.config.AUTH_API_URLS.provisionBulkSpaces;
|
|
469
|
+
url = helpers.api.constructAPIUrl(url, { orgId : self.orgId });
|
|
470
|
+
|
|
471
|
+
// Setup request with URL and Params
|
|
472
|
+
var requestAPI = request.post(url)
|
|
473
|
+
.set('Content-Type', 'application/json')
|
|
474
|
+
.set('Accept', 'application/json')
|
|
475
|
+
.send(options);
|
|
476
|
+
|
|
477
|
+
if(self.traceid) { requestAPI.set('X-Amzn-Trace-Id', self.traceid); }
|
|
478
|
+
requestAPI = helpers.api.setupAPIToken(requestAPI, self.token);
|
|
479
|
+
|
|
480
|
+
requestAPI.end(function(error, response) {
|
|
481
|
+
if(error) {
|
|
482
|
+
err = new DLSError(helpers.errors.ERROR_TYPES.API_ERROR, error);
|
|
483
|
+
dfd.reject(err);
|
|
484
|
+
}
|
|
485
|
+
else { dfd.resolve(response.body); }
|
|
486
|
+
});
|
|
487
|
+
}
|
|
488
|
+
else {
|
|
489
|
+
err = {};
|
|
490
|
+
err.message = err.description = 'Mandatory parameters: space_title or users not found in request options.';
|
|
491
|
+
err = new DLSError(helpers.errors.ERROR_TYPES.SDK_ERROR, err);
|
|
492
|
+
dfd.reject(err);
|
|
493
|
+
}
|
|
494
|
+
}
|
|
495
|
+
|
|
496
|
+
return dfd.promise;
|
|
497
|
+
}
|
|
498
|
+
|
|
499
|
+
/**
|
|
500
|
+
* options = {
|
|
501
|
+
* ext_user_id: 'string', // mandatory
|
|
502
|
+
* "ext_role": "string", // mandatory
|
|
503
|
+
* "ext_first_name": "string",
|
|
504
|
+
* "ext_last_name": "string",
|
|
505
|
+
* "ext_email": "string",
|
|
506
|
+
* "address": {
|
|
507
|
+
* "country": "string"
|
|
508
|
+
* },
|
|
509
|
+
* "ref_id": "string",
|
|
510
|
+
* "ext_classid" : "string",
|
|
511
|
+
* "ext_class_meta" :
|
|
512
|
+
* {
|
|
513
|
+
* "description": "string",
|
|
514
|
+
* "title": "string", // mandatory
|
|
515
|
+
* "startdate": <epoch>, // mandatory
|
|
516
|
+
* "enddate": <epoch> // mandatory
|
|
517
|
+
* }
|
|
518
|
+
* }
|
|
519
|
+
**/
|
|
520
|
+
function shadowProvision(options) {
|
|
521
|
+
var self = this;
|
|
522
|
+
//Initializing promise
|
|
523
|
+
var dfd = q.defer(), err = {};
|
|
524
|
+
//Validations
|
|
525
|
+
if (options && options.ext_user_id && options.ext_role) {
|
|
526
|
+
//Passed all validations, Contruct API url
|
|
527
|
+
var url = self.config.DEFAULT_HOSTS.AUTH + self.config.AUTH_API_URLS.shadowProvision;
|
|
528
|
+
url = helpers.api.constructAPIUrl(url, { orgId: self.orgId });
|
|
529
|
+
|
|
530
|
+
// Setup request with URL and Params
|
|
531
|
+
var requestAPI = request.post(url)
|
|
532
|
+
.set('Content-Type', 'application/json')
|
|
533
|
+
.set('Accept', 'application/json')
|
|
534
|
+
.send(options);
|
|
535
|
+
if (self.traceid) { requestAPI.set('X-Amzn-Trace-Id', self.traceid); }
|
|
536
|
+
|
|
537
|
+
requestAPI.end(function (err, response) {
|
|
538
|
+
if (err) {
|
|
539
|
+
err = new DLSError(helpers.errors.ERROR_TYPES.API_ERROR, err);
|
|
540
|
+
dfd.reject(err);
|
|
541
|
+
}
|
|
542
|
+
else { dfd.resolve(response.body); }
|
|
543
|
+
});
|
|
544
|
+
}
|
|
545
|
+
else {
|
|
546
|
+
err.message = err.description = 'Mandatory parameters: ext_user_id or ext_role not ' +
|
|
547
|
+
'found in request options.';
|
|
548
|
+
err = new DLSError(helpers.errors.ERROR_TYPES.SDK_ERROR, err);
|
|
549
|
+
dfd.reject(err);
|
|
550
|
+
}
|
|
551
|
+
return dfd.promise;
|
|
552
|
+
}
|
|
553
|
+
|
|
554
|
+
/*options = {
|
|
555
|
+
ext_user_id: 'string',
|
|
556
|
+
ext_role: 'string',
|
|
557
|
+
ref_id: 'string', (optional)
|
|
558
|
+
productcode: 'string',
|
|
559
|
+
ext_product_id: 'string',
|
|
560
|
+
ext_product_meta: {
|
|
561
|
+
startdate: 'string',
|
|
562
|
+
enddate: 'string',
|
|
563
|
+
...
|
|
564
|
+
}
|
|
565
|
+
}*/
|
|
566
|
+
function entitleUserToProduct(options) {
|
|
567
|
+
var self = this;
|
|
568
|
+
// Initializing promise
|
|
569
|
+
var dfd = q.defer();
|
|
570
|
+
|
|
571
|
+
if(options && options.ext_user_id &&
|
|
572
|
+
options.ext_role && (options.productcode || options.ext_product_id))
|
|
573
|
+
{
|
|
574
|
+
// Passed all validations, Contruct API url
|
|
575
|
+
var url = self.config.DEFAULT_HOSTS.AUTH +
|
|
576
|
+
self.config.AUTH_API_URLS.entitleUserToProduct;
|
|
577
|
+
url = helpers.api.constructAPIUrl(url, { accountId : self.accountId });
|
|
578
|
+
|
|
579
|
+
// Setup request with URL and Params
|
|
580
|
+
var requestAPI = request.post(url)
|
|
581
|
+
.set('Content-Type', 'application/json')
|
|
582
|
+
.set('Accept', 'application/json')
|
|
583
|
+
.send(options);
|
|
584
|
+
if(self.traceid) { requestAPI.set('X-Amzn-Trace-Id', self.traceid); }
|
|
585
|
+
|
|
586
|
+
requestAPI.end(function(error, response) {
|
|
587
|
+
if(error) {
|
|
588
|
+
err = new DLSError(helpers.errors.ERROR_TYPES.API_ERROR, error);
|
|
589
|
+
dfd.reject(error);
|
|
590
|
+
}
|
|
591
|
+
else { dfd.resolve(response.body); }
|
|
592
|
+
});
|
|
593
|
+
} else {
|
|
594
|
+
var err = {};
|
|
595
|
+
err.description = 'Missing mandatory keys in request options. \'ext_user_id\', \'ext_role\' and ' +
|
|
596
|
+
'either of \'ext_product_id\' or \'productcode\' must be present.'
|
|
597
|
+
err.message = err.description;
|
|
598
|
+
err = new DLSError(helpers.errors.ERROR_TYPES.SDK_ERROR, err);
|
|
599
|
+
dfd.reject(err);
|
|
600
|
+
}
|
|
601
|
+
|
|
602
|
+
return dfd.promise;
|
|
603
|
+
}
|
|
604
|
+
|
|
605
|
+
/*options = {
|
|
606
|
+
ext_user_id: 'string',
|
|
607
|
+
ext_actor_id: 'string',
|
|
608
|
+
productcode: 'string',
|
|
609
|
+
audit: 'boolean'
|
|
610
|
+
}*/
|
|
611
|
+
function unentitleUserToProduct(options) {
|
|
612
|
+
var self = this;
|
|
613
|
+
var dfd = q.defer();
|
|
614
|
+
|
|
615
|
+
if (options && options.ext_user_id && options.productcode && options.ext_actor_id) {
|
|
616
|
+
// Passed all validations, Contruct API url
|
|
617
|
+
var url = self.config.DEFAULT_HOSTS.AUTH + self.config.AUTH_API_URLS.entitleUserToProduct;
|
|
618
|
+
url = helpers.api.constructAPIUrl(url, { accountId : self.accountId });
|
|
619
|
+
|
|
620
|
+
// Setup request with URL and Params
|
|
621
|
+
var requestAPI = request.delete(url)
|
|
622
|
+
.set('Content-Type', 'application/json')
|
|
623
|
+
.set('Accept', 'application/json')
|
|
624
|
+
.send(options);
|
|
625
|
+
|
|
626
|
+
if (self.traceid) {
|
|
627
|
+
requestAPI.set('X-Amzn-Trace-Id', self.traceid);
|
|
628
|
+
}
|
|
629
|
+
|
|
630
|
+
requestAPI.end(function(error, response) {
|
|
631
|
+
if (error) {
|
|
632
|
+
var err = new DLSError(helpers.errors.ERROR_TYPES.API_ERROR, error);
|
|
633
|
+
dfd.reject(err);
|
|
634
|
+
}
|
|
635
|
+
else {
|
|
636
|
+
dfd.resolve(response.body);
|
|
637
|
+
}
|
|
638
|
+
});
|
|
639
|
+
} else {
|
|
640
|
+
var err = {};
|
|
641
|
+
err.message = err.description = 'Missing mandatory keys in request options.' +
|
|
642
|
+
' \'ext_user_id\', \'ext_actor_id\', and \'productcode\' must be present.';
|
|
643
|
+
err = new DLSError(helpers.errors.ERROR_TYPES.SDK_ERROR, err);
|
|
644
|
+
|
|
645
|
+
dfd.reject(err);
|
|
646
|
+
}
|
|
647
|
+
|
|
648
|
+
return dfd.promise;
|
|
649
|
+
}
|
|
650
|
+
|
|
651
|
+
/* This function calls the ComproDLS API to micro entitle user to a product.
|
|
652
|
+
options = {
|
|
653
|
+
"ext_user_id": "string", // Mandatory
|
|
654
|
+
"feature_key": "string", // Mandatory
|
|
655
|
+
"feature_id": "string", // Mandatory
|
|
656
|
+
"context": "string", // Mandatory
|
|
657
|
+
"data": {}, // Optional
|
|
658
|
+
"productcode": "string", // one of productcode and ext_product_id is mandatory
|
|
659
|
+
"ext_product_id": "string",
|
|
660
|
+
"ext_entitlement_meta": { //Optional
|
|
661
|
+
"startdate": "epoch",
|
|
662
|
+
"enddate": "epoch" //mandatory, if ext_entitlement_meta provided.
|
|
663
|
+
}
|
|
664
|
+
}*/
|
|
665
|
+
function microEntitleUserToProduct(options) {
|
|
666
|
+
var self = this;
|
|
667
|
+
// Initializing promise
|
|
668
|
+
var dfd = q.defer();
|
|
669
|
+
var bValidOptions = true;
|
|
670
|
+
var err = {
|
|
671
|
+
description: '',
|
|
672
|
+
message: ''
|
|
673
|
+
};
|
|
674
|
+
|
|
675
|
+
if (!(options && options.ext_user_id && options.context && options.feature_key &&
|
|
676
|
+
options.feature_id)) {
|
|
677
|
+
bValidOptions = false;
|
|
678
|
+
err.description = 'ext_user_id or context or feature_key or feature_id ' +
|
|
679
|
+
'not found in request options. ';
|
|
680
|
+
}
|
|
681
|
+
|
|
682
|
+
if (bValidOptions && (options.productcode || options.ext_product_id)) {
|
|
683
|
+
// Passed all validations, Contruct API url
|
|
684
|
+
var url = self.config.DEFAULT_HOSTS.AUTH +
|
|
685
|
+
self.config.AUTH_API_URLS.microEntitleUserToProduct;
|
|
686
|
+
url = helpers.api.constructAPIUrl(url, { accountId : self.accountId });
|
|
687
|
+
|
|
688
|
+
// Setup request with URL and Params
|
|
689
|
+
var requestAPI = request.post(url)
|
|
690
|
+
.set('Content-Type', 'application/json')
|
|
691
|
+
.set('Accept', 'application/json')
|
|
692
|
+
.send(options);
|
|
693
|
+
if(self.traceid) { requestAPI.set('X-Amzn-Trace-Id', self.traceid); }
|
|
694
|
+
|
|
695
|
+
requestAPI.end(function(error, response) {
|
|
696
|
+
if(error) {
|
|
697
|
+
err = new DLSError(helpers.errors.ERROR_TYPES.API_ERROR, error);
|
|
698
|
+
dfd.reject(error);
|
|
699
|
+
}
|
|
700
|
+
else { dfd.resolve(response.body); }
|
|
701
|
+
});
|
|
702
|
+
} else {
|
|
703
|
+
if(!(options.productcode || options.ext_product_id)) {
|
|
704
|
+
err.description += 'Either of ext_product_id or productcode must be ' +
|
|
705
|
+
'present in request options.';
|
|
706
|
+
}
|
|
707
|
+
err.message = err.description;
|
|
708
|
+
err = new DLSError(helpers.errors.ERROR_TYPES.SDK_ERROR, err);
|
|
709
|
+
dfd.reject(err);
|
|
710
|
+
}
|
|
711
|
+
|
|
712
|
+
return dfd.promise;
|
|
713
|
+
}
|
|
714
|
+
|
|
715
|
+
/* This function calls the ComproDLS API to revoke micro entitlement of a user.
|
|
716
|
+
options = {
|
|
717
|
+
"ext_user_id": "string", // Mandatory
|
|
718
|
+
"feature_key": "string", // Mandatory
|
|
719
|
+
"context": "string", // Mandatory
|
|
720
|
+
"productcode": "string", // one of productcode and ext_product_id is mandatory
|
|
721
|
+
"ext_product_id": "string",
|
|
722
|
+
}*/
|
|
723
|
+
function revokeMicroEntitlementOfAUser(options) {
|
|
724
|
+
var self = this;
|
|
725
|
+
// Initializing promise
|
|
726
|
+
var dfd = q.defer();
|
|
727
|
+
var err = {
|
|
728
|
+
description: '',
|
|
729
|
+
message: ''
|
|
730
|
+
};
|
|
731
|
+
|
|
732
|
+
if((options && options.ext_user_id && options.context && options.feature_key &&
|
|
733
|
+
(options.productcode || options.ext_product_id))) {
|
|
734
|
+
// Passed all validations, Contruct API url
|
|
735
|
+
var url = self.config.DEFAULT_HOSTS.AUTH +
|
|
736
|
+
self.config.AUTH_API_URLS.microEntitleUserToProduct;
|
|
737
|
+
url = helpers.api.constructAPIUrl(url, { accountId : self.accountId });
|
|
738
|
+
|
|
739
|
+
// Setup request with URL and Params
|
|
740
|
+
var requestAPI = request.delete(url)
|
|
741
|
+
.set('Content-Type', 'application/json')
|
|
742
|
+
.set('Accept', 'application/json')
|
|
743
|
+
.send(options);
|
|
744
|
+
if(self.traceid) { requestAPI.set('X-Amzn-Trace-Id', self.traceid); }
|
|
745
|
+
|
|
746
|
+
requestAPI.end(function(error, response) {
|
|
747
|
+
if(error) {
|
|
748
|
+
err = new DLSError(helpers.errors.ERROR_TYPES.API_ERROR, error);
|
|
749
|
+
dfd.reject(error);
|
|
750
|
+
}
|
|
751
|
+
else { dfd.resolve(response.body); }
|
|
752
|
+
});
|
|
753
|
+
}
|
|
754
|
+
else {
|
|
755
|
+
err.description = 'ext_user_id or context or feature_key not found or is empty in request options. ' +
|
|
756
|
+
'Either productcode or ext_product_id must be provided.';
|
|
757
|
+
err.message = err.description;
|
|
758
|
+
err = new DLSError(helpers.errors.ERROR_TYPES.SDK_ERROR, err);
|
|
759
|
+
dfd.reject(err);
|
|
760
|
+
}
|
|
761
|
+
|
|
762
|
+
return dfd.promise;
|
|
763
|
+
}
|
|
764
|
+
|
|
765
|
+
/*options = {
|
|
766
|
+
ext_product_id: 'string'
|
|
767
|
+
}*/
|
|
768
|
+
function getExtProduct(options) {
|
|
769
|
+
var self = this;
|
|
770
|
+
// Initializing promise
|
|
771
|
+
var dfd = q.defer();
|
|
772
|
+
|
|
773
|
+
if(options && options.ext_product_id)
|
|
774
|
+
{
|
|
775
|
+
// Passed all validations, Contruct API url
|
|
776
|
+
var url = self.config.DEFAULT_HOSTS.AUTH +
|
|
777
|
+
self.config.AUTH_API_URLS.getExtProductAPI;
|
|
778
|
+
url = helpers.api.constructAPIUrl(url, { accountId : self.accountId, extProductId: options.ext_product_id});
|
|
779
|
+
|
|
780
|
+
// Setup request with URL and Params
|
|
781
|
+
var requestAPI = request.get(url);
|
|
782
|
+
if(self.traceid) { requestAPI.set('X-Amzn-Trace-Id', self.traceid); }
|
|
783
|
+
|
|
784
|
+
requestAPI.end(function(error, response) {
|
|
785
|
+
if(error) {
|
|
786
|
+
err = new DLSError(helpers.errors.ERROR_TYPES.API_ERROR, error);
|
|
787
|
+
dfd.reject(error);
|
|
788
|
+
}
|
|
789
|
+
else { dfd.resolve(response.body); }
|
|
790
|
+
});
|
|
791
|
+
} else {
|
|
792
|
+
var err = {};
|
|
793
|
+
err.message = err.description = 'ext_product_id not found in request options.';
|
|
794
|
+
err = new DLSError(helpers.errors.ERROR_TYPES.SDK_ERROR, err);
|
|
795
|
+
dfd.reject(err);
|
|
796
|
+
}
|
|
797
|
+
|
|
798
|
+
return dfd.promise;
|
|
799
|
+
}
|
|
800
|
+
|
|
801
|
+
/*options = {
|
|
802
|
+
spacekey: 'string'
|
|
803
|
+
}*/
|
|
804
|
+
function getSpaceDetails(options) {
|
|
805
|
+
var self = this;
|
|
806
|
+
// Initializing promise
|
|
807
|
+
var dfd = q.defer();
|
|
808
|
+
|
|
809
|
+
if(options && options.spacekey) {
|
|
810
|
+
// Passed all validations, Contruct API url
|
|
811
|
+
var url = self.config.DEFAULT_HOSTS.AUTH + self.config.AUTH_API_URLS.getSpaceDetails;
|
|
812
|
+
url = helpers.api.constructAPIUrl(url, { accountId : self.accountId, spacekey: options.spacekey});
|
|
813
|
+
|
|
814
|
+
var params = { orgid: self.orgId };
|
|
815
|
+
|
|
816
|
+
// Setup request with URL and Params
|
|
817
|
+
var requestAPI = request.get(url).query(params);
|
|
818
|
+
if(self.traceid) { requestAPI.set('X-Amzn-Trace-Id', self.traceid); }
|
|
819
|
+
|
|
820
|
+
// Setup token in Authorization header
|
|
821
|
+
requestAPI = helpers.api.setupAPIToken(requestAPI, self.token);
|
|
822
|
+
|
|
823
|
+
requestAPI.end(function(error, response) {
|
|
824
|
+
if(error) {
|
|
825
|
+
err = new DLSError(helpers.errors.ERROR_TYPES.API_ERROR, error);
|
|
826
|
+
dfd.reject(error);
|
|
827
|
+
}
|
|
828
|
+
else { dfd.resolve(response.body); }
|
|
829
|
+
});
|
|
830
|
+
} else {
|
|
831
|
+
var err = {};
|
|
832
|
+
err.message = err.description = 'spacekey not found in request options.';
|
|
833
|
+
err = new DLSError(helpers.errors.ERROR_TYPES.SDK_ERROR, err);
|
|
834
|
+
dfd.reject(err);
|
|
835
|
+
}
|
|
836
|
+
|
|
837
|
+
return dfd.promise;
|
|
838
|
+
}
|
|
839
|
+
|
|
840
|
+
/*options = {
|
|
841
|
+
ext_user_id: 'string',
|
|
842
|
+
ext_role: 'string',
|
|
843
|
+
ext_first_name: 'string',
|
|
844
|
+
ext_last_name: 'string',
|
|
845
|
+
ext_email: 'string',
|
|
846
|
+
ref_id: 'string', (optional)
|
|
847
|
+
class_code: 'string'
|
|
848
|
+
}*/
|
|
849
|
+
function enrollUserInClass(options) {
|
|
850
|
+
var self = this;
|
|
851
|
+
// Initializing promise
|
|
852
|
+
var dfd = q.defer();
|
|
853
|
+
|
|
854
|
+
if(options && options.ext_user_id &&
|
|
855
|
+
options.ext_role && options.class_code)
|
|
856
|
+
{
|
|
857
|
+
// Passed all validations, Contruct API url
|
|
858
|
+
var url = self.config.DEFAULT_HOSTS.AUTH +
|
|
859
|
+
self.config.AUTH_API_URLS.enrollUserInClass;
|
|
860
|
+
url = helpers.api.constructAPIUrl(url, { accountId : self.accountId });
|
|
861
|
+
|
|
862
|
+
// Setup request with URL and Params
|
|
863
|
+
var requestAPI = request.post(url)
|
|
864
|
+
.set('Content-Type', 'application/json')
|
|
865
|
+
.set('Accept', 'application/json')
|
|
866
|
+
.send(options);
|
|
867
|
+
if(self.traceid) { requestAPI.set('X-Amzn-Trace-Id', self.traceid); }
|
|
868
|
+
|
|
869
|
+
requestAPI.end(function(error, response) {
|
|
870
|
+
if(error) {
|
|
871
|
+
err = new DLSError(helpers.errors.ERROR_TYPES.API_ERROR, error);
|
|
872
|
+
dfd.reject(error);
|
|
873
|
+
}
|
|
874
|
+
else { dfd.resolve(response.body); }
|
|
875
|
+
});
|
|
876
|
+
} else {
|
|
877
|
+
var err = {};
|
|
878
|
+
err.message = err.description = 'ext_user_id or ext_role or class_code not found in request options.';
|
|
879
|
+
err = new DLSError(helpers.errors.ERROR_TYPES.SDK_ERROR, err);
|
|
880
|
+
dfd.reject(err);
|
|
881
|
+
}
|
|
882
|
+
|
|
883
|
+
return dfd.promise;
|
|
884
|
+
}
|
|
885
|
+
|
|
886
|
+
/**
|
|
887
|
+
* This function calls the ComproDLS API to update user information.
|
|
888
|
+
* options = {
|
|
889
|
+
* "ext_user_id": "string",
|
|
890
|
+
* "ref_id": "string", // optional
|
|
891
|
+
* "ext_email": "string", // optional
|
|
892
|
+
* "ext_first_name": "string", // optional
|
|
893
|
+
* "ext_last_name": "string" // optional
|
|
894
|
+
* };
|
|
895
|
+
*/
|
|
896
|
+
function updateUserInformation(options) {
|
|
897
|
+
var self = this;
|
|
898
|
+
// Initializing promise
|
|
899
|
+
var dfd = q.defer(), err = {};
|
|
900
|
+
|
|
901
|
+
if(options && options.ext_user_id)
|
|
902
|
+
{
|
|
903
|
+
// Passed all validations, Contruct API url
|
|
904
|
+
var url = self.config.DEFAULT_HOSTS.AUTH +
|
|
905
|
+
self.config.AUTH_API_URLS.updateUserInformation;
|
|
906
|
+
url = helpers.api.constructAPIUrl(url, { accountId : self.accountId });
|
|
907
|
+
var bodyParams = {
|
|
908
|
+
ext_user_id: options.ext_user_id
|
|
909
|
+
};
|
|
910
|
+
if(options.ref_id) { bodyParams.ref_id = options.ref_id; }
|
|
911
|
+
if(options.ext_email) { bodyParams.ext_email = options.ext_email; }
|
|
912
|
+
if(options.ext_first_name) { bodyParams.ext_first_name = options.ext_first_name; }
|
|
913
|
+
if(options.ext_last_name) { bodyParams.ext_last_name = options.ext_last_name; }
|
|
914
|
+
if(options.address) { bodyParams.address = options.address; }
|
|
915
|
+
// Setup request with URL and Params
|
|
916
|
+
var requestAPI = request.put(url)
|
|
917
|
+
.set('Content-Type', 'application/json')
|
|
918
|
+
.set('Accept', 'application/json')
|
|
919
|
+
.send(bodyParams);
|
|
920
|
+
if(self.traceid) { requestAPI.set('X-Amzn-Trace-Id', self.traceid); }
|
|
921
|
+
|
|
922
|
+
requestAPI.end(function(error, response) {
|
|
923
|
+
if(error) {
|
|
924
|
+
err = new DLSError(helpers.errors.ERROR_TYPES.API_ERROR, error);
|
|
925
|
+
dfd.reject(error);
|
|
926
|
+
}
|
|
927
|
+
else { dfd.resolve(response.body); }
|
|
928
|
+
});
|
|
929
|
+
} else {
|
|
930
|
+
err.message = err.description = 'Mandatory parameters not found in request options:' +
|
|
931
|
+
' ["ext_user_id"]';
|
|
932
|
+
err = new DLSError(helpers.errors.ERROR_TYPES.SDK_ERROR, err);
|
|
933
|
+
dfd.reject(err);
|
|
934
|
+
}
|
|
935
|
+
|
|
936
|
+
return dfd.promise;
|
|
937
|
+
}
|
|
938
|
+
|
|
939
|
+
/* options = {
|
|
940
|
+
"email": "string", // required
|
|
941
|
+
"status " : "string", // optional
|
|
942
|
+
};
|
|
943
|
+
*/
|
|
944
|
+
function getInvitationsByEmail(options) {
|
|
945
|
+
var self = this;
|
|
946
|
+
// Initializing promise
|
|
947
|
+
var dfd = q.defer();
|
|
948
|
+
var err = {};
|
|
949
|
+
if (options && options.email) {
|
|
950
|
+
|
|
951
|
+
// Passed all validations, Contruct API url
|
|
952
|
+
var url = self.config.DEFAULT_HOSTS.AUTH + self.config.AUTH_API_URLS.getInvitationsByEmail;
|
|
953
|
+
url = helpers.api.constructAPIUrl(url, { accountid: self.accountId });
|
|
954
|
+
|
|
955
|
+
var queryParam = { email: options.email };
|
|
956
|
+
if (options.status) { queryParam.status = options.status; }
|
|
957
|
+
|
|
958
|
+
// Setup request with URL and Params
|
|
959
|
+
var requestAPI = request.get(url).query(queryParam);
|
|
960
|
+
if(self.traceid) { requestAPI.set('X-Amzn-Trace-Id', self.traceid); }
|
|
961
|
+
|
|
962
|
+
requestAPI.end(function (error, response) {
|
|
963
|
+
if (error) {
|
|
964
|
+
err = new DLSError(helpers.errors.ERROR_TYPES.API_ERROR, error);
|
|
965
|
+
dfd.reject(err);
|
|
966
|
+
}
|
|
967
|
+
else { dfd.resolve(response.body); }
|
|
968
|
+
});
|
|
969
|
+
}
|
|
970
|
+
else {
|
|
971
|
+
err.message = err.description = 'email not found in request options.';
|
|
972
|
+
err = new DLSError(helpers.errors.ERROR_TYPES.SDK_ERROR, err);
|
|
973
|
+
dfd.reject(err);
|
|
974
|
+
}
|
|
975
|
+
return dfd.promise;
|
|
976
|
+
}
|