comprodls-sdk 2.123.2-security → 2.123.4-oidc-poc.2

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 (36) hide show
  1. package/.eslintrc +28 -28
  2. package/.github/workflows/npm-publish.yml +76 -0
  3. package/README.md +235 -235
  4. package/dist/comprodls-sdk.js +13543 -13543
  5. package/docs/npm-oidc-publishing-runbook.md +229 -0
  6. package/lib/comprodls.js +132 -132
  7. package/lib/config/index.js +356 -356
  8. package/lib/helpers/index.js +31 -31
  9. package/lib/helpers/lib/api/converter.js +129 -129
  10. package/lib/helpers/lib/api/index.js +46 -46
  11. package/lib/helpers/lib/errors.js +122 -122
  12. package/lib/helpers/lib/requestLayer.js +154 -154
  13. package/lib/helpers/lib/validator.js +192 -192
  14. package/lib/open_access/index.js +116 -116
  15. package/lib/services/analytics/index.js +1365 -1365
  16. package/lib/services/attempts/index.js +389 -389
  17. package/lib/services/auth/index.js +3708 -3708
  18. package/lib/services/authextn/index.js +1032 -1032
  19. package/lib/services/datasyncmanager/index.js +275 -275
  20. package/lib/services/drive/index.js +270 -270
  21. package/lib/services/integrations/index.js +525 -525
  22. package/lib/services/invitations/index.js +282 -282
  23. package/lib/services/product/index.js +343 -343
  24. package/lib/services/pub/index.js +530 -530
  25. package/lib/services/pushX/index.js +251 -251
  26. package/lib/services/pushX/pubnubClientWrapper.js +438 -438
  27. package/lib/services/rules/index.js +416 -416
  28. package/lib/services/spaces/index.js +999 -999
  29. package/lib/services/spacesextn/index.js +131 -131
  30. package/lib/services/superuser/index.js +160 -160
  31. package/lib/services/taxonomy/index.js +405 -405
  32. package/lib/services/workflows/index.js +406 -406
  33. package/lib/services/xapi/index.js +114 -114
  34. package/lib/token/index.js +120 -120
  35. package/lib/token/validations.js +85 -85
  36. package/package.json +5 -1
@@ -1,1365 +1,1365 @@
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 Analytics API Adaptor
23
- * Functions for calling Analytics API.
24
- ************************************************************/
25
-
26
- var q = require('q');
27
- var request = require('superagent');
28
- var Agent = require('agentkeepalive');
29
-
30
- var helpers = require('../../helpers');
31
- var DLSError = helpers.errors.DLSError;
32
-
33
- module.exports = analytics;
34
-
35
- var keepaliveAgent = new Agent({
36
- timeout: 60000,
37
- freeSocketTimeout: 30000
38
- });
39
-
40
- //Analytics Adaptor Constructor
41
- function analytics() {
42
- return {
43
- getOrgAnalyticsStat: getOrgAnalyticsStat.bind(this),
44
-
45
- getClassProductRecentPendingSubmissions: getClassProductRecentPendingSubmissions.bind(this),
46
- getClassRecordUserAggregations: getClassRecordUserAggregations.bind(this),
47
- getClassRecord: getClassRecord.bind(this),
48
- getClassRecordItemAggregations: getClassRecordItemAggregations.bind(this),
49
- getShowcaseRecordOfAClass: getShowcaseRecordOfAClass.bind(this),
50
-
51
- getGroupRecord: getGroupRecord.bind(this),
52
- getClassGroupsRecentPendingSubmissions: getClassGroupsRecentPendingSubmissions.bind(this),
53
- getGroupsWithEvaluatedOnce: getGroupsWithEvaluatedOnce.bind(this),
54
-
55
- getUserProductAnalytics: getUserProductAnalytics.bind(this),
56
- getExternalDataForUserAnalyticItem: getExternalDataForUserAnalyticItem.bind(this),
57
- getUserClassRecentSubmissions: getUserClassRecentSubmissions.bind(this),
58
- getStudentsWithEvaluatedOnce: getStudentsWithEvaluatedOnce.bind(this),
59
-
60
- //AssignedPaths Related APIs
61
- getAllAssignedPathsOfClass: getAllAssignedPathsOfClass.bind(this),
62
- getMyAssignedPathsOfClass: getMyAssignedPathsOfClass.bind(this),
63
- getUserAssignedPathsOfClass: getUserAssignedPathsOfClass.bind(this),
64
- getAssignedPathAnalytics: getAssignedPathAnalytics.bind(this),
65
- getMyParticularAssignedPathOfClass: getMyParticularAssignedPathOfClass.bind(this),
66
- getParticularAssignedPathOfClass: getParticularAssignedPathOfClass.bind(this),
67
-
68
- getTimeseriesAnalytics: getTimeseriesAnalytics.bind(this),
69
- postProgressTimeseries: postProgressTimeseries.bind(this),
70
-
71
- //ClassCustomComponentRecord Related APIs
72
- getClassCustomComponentRecord: getClassCustomComponentRecord.bind(this),
73
- getClassCustomComponentUserSubmission: getClassCustomComponentUserSubmission.bind(this),
74
-
75
- //CrossProductAggregation Related APIs
76
- getCrossProductAggregation: getCrossProductAggregation.bind(this)
77
- };
78
- }
79
-
80
- /*********************************
81
- * Public Function definitions
82
- **********************************/
83
-
84
- /**
85
- * Wiki Link for SDK params
86
- * https://github.com/comprodls/comprodls-sdk-js/wiki/06_ANALYTICS-Adapter#getorganalyticsstatparams
87
- */
88
- function getOrgAnalyticsStat(options) {
89
- var self = this;
90
-
91
- //Initializing promise
92
- var dfd = q.defer();
93
- //Validations
94
- var err = {};
95
- if(options && options.type) {
96
- err = helpers.validations.isAuthenticated(self.orgId, self.token);
97
- if(err) { dfd.reject(err); }
98
- else {
99
- err = {};
100
- var allowedAnalyticsDataType = ['users', 'classes'];
101
- if(allowedAnalyticsDataType.indexOf(options.type) > -1) {
102
- //Passed all validations, Construct API url
103
- var url = self.config.DEFAULT_HOSTS['ANALYTICS'] +
104
- self.config.ANALYTICS_API_URLS.getOrgAnalyticsStat;
105
- url = helpers.api.constructAPIUrl(url, {
106
- orgId: self.orgId, type: options.type
107
- });
108
-
109
- var params = {};
110
- if(options) {
111
- if(options.range) { params.range = options.range; }
112
- if(options.start) { params.start = options.start; }
113
- if(options.end) { params.end = options.end; }
114
- if(options.role) { params.role = options.role; }
115
- if(options.shadow) { params.shadow = options.shadow; }
116
- }
117
-
118
- //Setup request with URL and Params
119
- var requestAPI = request.get(url).query(params);
120
-
121
- //Setup token in Authorization header
122
- requestAPI = helpers.api.setupAPIToken(requestAPI, self.token);
123
-
124
- // setting up traceid
125
- if(self.traceid) { requestAPI.set('X-Amzn-Trace-Id', self.traceid); }
126
-
127
- //Call Product Timespent Api
128
- requestAPI.end(function(err, response) {
129
- if(err) {
130
- err = new DLSError(helpers.errors.ERROR_TYPES.API_ERROR, err);
131
- dfd.reject(err);
132
- }
133
- else { dfd.resolve(response.body); }
134
- });
135
- } else {
136
- err.message = err.description = 'Type: ' + options.type + ' is not supported';
137
- err = new DLSError(helpers.errors.ERROR_TYPES.SDK_ERROR, err);
138
- dfd.reject(err);
139
- }
140
- }
141
- } else {
142
- err.message = err.description = 'type not found in request options';
143
- err = new DLSError(helpers.errors.ERROR_TYPES.SDK_ERROR, err);
144
- dfd.reject(err);
145
- }
146
-
147
- return dfd.promise;
148
- }
149
-
150
- /**
151
- * Wiki Link for SDK params
152
- * https://github.com/comprodls/comprodls-sdk-js/wiki/06_ANALYTICS-Adapter#getuserproductanalyticsparams
153
- */
154
- function getUserProductAnalytics(options) {
155
- var self = this;
156
-
157
- //Initializing promise
158
- var dfd = q.defer();
159
- //Validations
160
- var err = {};
161
- if(options && options.type && options.userid && options.productcode) {
162
- err = helpers.validations.isAuthenticated(self.orgId, self.token);
163
- if(err) { dfd.reject(err); }
164
- else {
165
- var supportedType = ['items', 'summary'];
166
- //Passed all validations, Construct API url
167
- var url = self.config.DEFAULT_HOSTS['ANALYTICS'];
168
-
169
- if(supportedType.indexOf(options.type) > -1) {
170
- switch(options.type) {
171
- case 'items':
172
- url += self.config.ANALYTICS_API_URLS.getAnalyticProductItems;
173
- break;
174
- case 'summary':
175
- url += self.config.ANALYTICS_API_URLS.getAnalyticProductSummary;
176
- break;
177
- }
178
- url = helpers.api.constructAPIUrl(url, { orgId: self.orgId });
179
-
180
- var params = { userid: options.userid, productcode: options.productcode };
181
-
182
- if(options.classid) { params.classid = options.classid; }
183
- if(options.itemcode) { params.itemcode = options.itemcode; }
184
- if(options.metrics) { params.metrics = options.metrics; }
185
- if(options.history) { params.history = options.history; }
186
- if(options.group) { params.group = options.group; }
187
- if(options.externalData) { params.externalData = options.externalData; }
188
- if(options.expiredView && options.type === 'items') { params.expiredView = options.expiredView; }
189
-
190
- //Setup request with URL and Params
191
- var requestAPI = request.get(url).query(params);
192
-
193
- //Setup token in Authorization header
194
- requestAPI = helpers.api.setupAPIToken(requestAPI, self.token);
195
-
196
- // setting up traceid
197
- if(self.traceid) { requestAPI.set('X-Amzn-Trace-Id', self.traceid); }
198
-
199
- //Call Product Timespent Api
200
- requestAPI.end(function(err, response) {
201
- if(err) {
202
- err = new DLSError(helpers.errors.ERROR_TYPES.API_ERROR, err);
203
- dfd.reject(err);
204
- }
205
- else { dfd.resolve(response.body); }
206
- });
207
- } else {
208
- err.message = err.description = options.type + " is not a valid value of option 'type'";
209
- err = new DLSError(helpers.errors.ERROR_TYPES.SDK_ERROR, err);
210
- dfd.reject(err);
211
- }
212
- }
213
- } else {
214
- err.message = err.description = "Required parameter 'type' or 'userid' or " +
215
- "'productcode' not found in request options";
216
- err = new DLSError(helpers.errors.ERROR_TYPES.SDK_ERROR, err);
217
- dfd.reject(err);
218
- }
219
-
220
- return dfd.promise;
221
- }
222
-
223
- /**
224
- * Wiki Link for SDK params
225
- * https://github.com/comprodls/comprodls-sdk-js/wiki/06_ANALYTICS-Adapter#getexternaldataforuseranalyticitemparams
226
- */
227
- function getExternalDataForUserAnalyticItem(options) {
228
- var self = this;
229
- var dfd = q.defer();
230
- // Validations
231
- var err = {};
232
- if(options && options.ext_user_id && options.productcode && options.itemcode &&
233
- (options.submission_order || options.ext_link_id) && options.part) {
234
- err = helpers.validations.isAuthenticated(self.orgId, self.token);
235
- if(err) { dfd.reject(err); }
236
- else {
237
- // Passed all validations, Construct API url
238
- var url = self.config.DEFAULT_HOSTS.ANALYTICS +
239
- self.config.ANALYTICS_API_URLS.getExternalDataForUserAnalyticItem;
240
- url = helpers.api.constructAPIUrl(url, { orgId: self.orgId });
241
-
242
- var params = {
243
- ext_user_id: options.ext_user_id,
244
- productcode: options.productcode,
245
- itemcode: options.itemcode,
246
- part: options.part
247
- };
248
-
249
- if(options.submission_order) { params.submission_order = options.submission_order; }
250
- if(options.ext_link_id) { params.ext_link_id = options.ext_link_id; }
251
- if(options.classid) { params.classid = options.classid; }
252
-
253
- // Setup request with URL and Params
254
- var requestAPI = request.get(url).query(params);
255
-
256
- // Setup token in Authorization header
257
- requestAPI = helpers.api.setupAPIToken(requestAPI, self.token);
258
-
259
- // setting up traceid
260
- if(self.traceid) { requestAPI.set('X-Amzn-Trace-Id', self.traceid); }
261
-
262
- // Call Product Timespent Api
263
- requestAPI.end(function(err, response) {
264
- if(err) {
265
- err = new DLSError(helpers.errors.ERROR_TYPES.API_ERROR, err);
266
- dfd.reject(err);
267
- }
268
- else { dfd.resolve(response.body); }
269
- });
270
- }
271
- } else {
272
- err.message = err.description = "Required parameters 'ext_user_id' or 'productcode' or 'itemcode'" +
273
- " or (either 'submission_order' OR 'ext_link_id') or 'part'are not found in request options";
274
- err = new DLSError(helpers.errors.ERROR_TYPES.SDK_ERROR, err);
275
- dfd.reject(err);
276
- }
277
- return dfd.promise;
278
- }
279
-
280
- /**
281
- * Wiki Link for SDK params
282
- * https://github.com/comprodls/comprodls-sdk-js/wiki/06_ANALYTICS-Adapter#getuserclassrecentsubmissionsparams
283
- */
284
- function getUserClassRecentSubmissions(options) {
285
- var self = this;
286
- var dfd = q.defer(), err = {};
287
-
288
- if(options && options.classid && options.productcode && options.userid) {
289
- err = helpers.validations.isAuthenticated(self.orgId, self.token);
290
- if(err) { dfd.reject(err); }
291
- else {
292
- // Passed all validations, Constructing URL
293
- var url = self.config.DEFAULT_HOSTS['ANALYTICS'] +
294
- self.config.ANALYTICS_API_URLS.getUserClassRecentSubmissions;
295
- url = helpers.api.constructAPIUrl(url, { orgId: self.orgId });
296
-
297
- // Setup Query Params
298
- var queryParams = {
299
- userid: options.userid,
300
- classid: options.classid,
301
- productcode: options.productcode
302
- };
303
-
304
- if(options.gradingStatus) { queryParams.gradingStatus = options.gradingStatus; }
305
-
306
- // Setup Request with url and params
307
- var requestAPI = request.get(url).query(queryParams);
308
- // Setup token in Authorization Header
309
- requestAPI = helpers.api.setupAPIToken(requestAPI, self.token);
310
-
311
- // setting up traceid
312
- if(self.traceid) { requestAPI.set('X-Amzn-Trace-Id', self.traceid); }
313
-
314
- // Call GET Class Product Recent Pending Submissions
315
- requestAPI.end(function(error, response) {
316
- if(error) {
317
- err = new DLSError(helpers.errors.ERROR_TYPES.API_ERROR, error);
318
- dfd.reject(err);
319
- } else {
320
- dfd.resolve(response.body);
321
- }
322
- });
323
- }
324
- }
325
- else {
326
- err.message = err.description = 'Mandatory parameters ["classid", "productcode", "userid"]' +
327
- ' not found in request options.';
328
- err = new DLSError(helpers.errors.ERROR_TYPES.SDK_ERROR, err);
329
- dfd.reject(err);
330
- }
331
-
332
- return dfd.promise;
333
- }
334
-
335
- /**
336
- * Wiki Link for SDK params
337
- * https://github.com/comprodls/comprodls-sdk-js/wiki/06_ANALYTICS-Adapter#getstudentswithevaluatedonceparams
338
- */
339
- function getStudentsWithEvaluatedOnce(options) {
340
- var self = this, err = {};
341
- //Initializing promise
342
- var dfd = q.defer();
343
- if(options && options.classid && options.productcode) {
344
- //Validations
345
- err = helpers.validations.isAuthenticated(self.orgId, self.token);
346
- if(err) { dfd.reject(err); }
347
- else {
348
- // Passed all validations, Construct API url
349
- var url = self.config.DEFAULT_HOSTS['ANALYTICS'] +
350
- self.config.ANALYTICS_API_URLS.getStudentsWithEvaluatedOnce;
351
- url = helpers.api.constructAPIUrl(url, { orgId: self.orgId });
352
-
353
- // Setup params
354
- var params = {
355
- classid: options.classid,
356
- productcode: options.productcode
357
- };
358
- // Setup request with URL and Params
359
- var requestAPI = request.get(url).query(params);
360
- // Setup token in Authorization header
361
- requestAPI = helpers.api.setupAPIToken(requestAPI, self.token);
362
-
363
- // setting up traceid
364
- if(self.traceid) { requestAPI.set('X-Amzn-Trace-Id', self.traceid); }
365
-
366
- requestAPI.end(function(error, response) {
367
- if(error) {
368
- err = new DLSError(helpers.errors.ERROR_TYPES.API_ERROR, error);
369
- dfd.reject(err);
370
- }
371
- else { dfd.resolve(response.body); }
372
- });
373
- }
374
- } else {
375
- err.message = err.description = 'Required parameter classid or ' +
376
- 'productcode not found in request options.';
377
- err = new DLSError(helpers.errors.ERROR_TYPES.SDK_ERROR, err);
378
- dfd.reject(err);
379
- }
380
- return dfd.promise;
381
- }
382
-
383
- /**
384
- * Wiki Link for SDK params
385
- * https://github.com/comprodls/comprodls-sdk-js/wiki/06_ANALYTICS-Adapter#getclassproductrecentpendingsubmissionsparams
386
- */
387
- function getClassProductRecentPendingSubmissions(options) {
388
- var self = this;
389
- var dfd = q.defer(), err = {};
390
-
391
- if(options && options.classid && options.productcode) {
392
- err = helpers.validations.isAuthenticated(self.orgId, self.token);
393
- if(err) { dfd.reject(err); }
394
- else {
395
- // Passed all validations, Constructing URL
396
- var url = self.config.DEFAULT_HOSTS['ANALYTICS'] +
397
- self.config.ANALYTICS_API_URLS.getClassProductRecentPendingSubmissions;
398
- url = helpers.api.constructAPIUrl(url, { orgId: self.orgId });
399
-
400
- // Setup Query Params
401
- var queryParams = {
402
- classid: options.classid,
403
- productcode: options.productcode
404
- };
405
-
406
- if(options.details) { queryParams.details = options.details; }
407
- if(options.limit) { queryParams.limit = options.limit; }
408
-
409
- // Setup Request with url and params
410
- var requestAPI = request.get(url).query(queryParams);
411
- // Setup token in Authorization Header
412
- requestAPI = helpers.api.setupAPIToken(requestAPI, self.token);
413
- // Call GET Class Product Recent Pending Submissions
414
-
415
- // setting up traceid
416
- if(self.traceid) { requestAPI.set('X-Amzn-Trace-Id', self.traceid); }
417
-
418
- requestAPI.end(function(error, response) {
419
- if(error) {
420
- err = new DLSError(helpers.errors.ERROR_TYPES.API_ERROR, error);
421
- dfd.reject(err);
422
- } else {
423
- dfd.resolve(response.body);
424
- }
425
- });
426
- }
427
- }
428
- else {
429
- err.message = err.description = 'Mandatory parameters ["classid", "productcode"] not found in ' +
430
- 'request options.';
431
- err = new DLSError(helpers.errors.ERROR_TYPES.SDK_ERROR, err);
432
- dfd.reject(err);
433
- }
434
-
435
- return dfd.promise;
436
- }
437
-
438
- /**
439
- * Wiki Link for SDK params
440
- * https://github.com/comprodls/comprodls-sdk-js/wiki/06_ANALYTICS-Adapter#getclassrecordparams
441
- */
442
- function getClassRecord(options) {
443
- var self = this;
444
-
445
- //Initializing DFD
446
- var dfd = q.defer(), err = {};
447
-
448
- // Validations
449
- if(options && options.classid && options.productcode) {
450
- err = helpers.validations.isAuthenticated(self.orgId, self.token);
451
- if(err){ dfd.reject(err); }
452
- else {
453
- // Passed all validations, Constructing URL
454
- var url = self.config.DEFAULT_HOSTS['ANALYTICS'] + self.config.ANALYTICS_API_URLS.getClassRecord;
455
- url = helpers.api.constructAPIUrl(url, { orgId: self.orgId });
456
-
457
- // Setup Query Params
458
- var queryParams = {
459
- classid: options.classid,
460
- productcode: options.productcode,
461
- userids: options.userids,
462
- includeContext: options.includeContext
463
- };
464
-
465
- // Setup Request with url and params
466
- var requestAPI = request.get(url).query(queryParams);
467
- // Setup token in Authorization Header
468
- requestAPI = helpers.api.setupAPIToken(requestAPI, self.token);
469
-
470
- // setting up traceid
471
- if(self.traceid) { requestAPI.set('X-Amzn-Trace-Id', self.traceid); }
472
-
473
- // Call GET GET CLASS RECORD ITEM
474
- requestAPI.end(function(error, response) {
475
- if(error) {
476
- err = new DLSError(helpers.errors.ERROR_TYPES.API_ERROR, error);
477
- dfd.reject(err);
478
- } else { dfd.resolve(response.body); }
479
- });
480
- }
481
- } else {
482
- err.message = err.description = 'Required parameter classid or ' +
483
- 'productcode not found in request options.';
484
- err = new DLSError(helpers.errors.ERROR_TYPES.SDK_ERROR, err);
485
- dfd.reject(err);
486
- }
487
- return dfd.promise;
488
- }
489
-
490
- /**
491
- * Wiki Link for SDK params
492
- * https://github.com/comprodls/comprodls-sdk-js/wiki/06_ANALYTICS-Adapter#getclassrecorditemaggregationsparams
493
- */
494
- function getClassRecordItemAggregations(options) {
495
- var self = this;
496
-
497
- //Initializing DFD
498
- var dfd = q.defer(), err = {};
499
-
500
- // Validations
501
- if(options && options.classid && options.productcode) {
502
- err = helpers.validations.isAuthenticated(self.orgId, self.token);
503
- if(err){ dfd.reject(err); }
504
- else {
505
- // Passed all validations, Constructing URL
506
- var url = self.config.DEFAULT_HOSTS['ANALYTICS'] + self.config.ANALYTICS_API_URLS.getClassRecordItemAggregations;
507
- url = helpers.api.constructAPIUrl(url, { orgId: self.orgId });
508
-
509
- // Setup Query Params
510
- var queryParams = {
511
- classid: options.classid,
512
- productcode: options.productcode,
513
- 'item-code': options['item-code']
514
- };
515
-
516
- // Setup Request with url and params
517
- var requestAPI = request.get(url).query(queryParams);
518
- // Setup token in Authorization Header
519
- requestAPI = helpers.api.setupAPIToken(requestAPI, self.token);
520
-
521
- // setting up traceid
522
- if(self.traceid) { requestAPI.set('X-Amzn-Trace-Id', self.traceid); }
523
-
524
- // Call GET GET CLASS RECORD ITEM
525
- requestAPI.end(function(error, response) {
526
- if(error) {
527
- err = new DLSError(helpers.errors.ERROR_TYPES.API_ERROR, error);
528
- dfd.reject(err);
529
- } else {
530
- dfd.resolve(response.body);
531
- }
532
- });
533
- }
534
- } else {
535
- err.message = err.description = 'Required parameter classid or ' +
536
- 'productcode not found in request options.';
537
- err = new DLSError(helpers.errors.ERROR_TYPES.SDK_ERROR, err);
538
- dfd.reject(err);
539
- }
540
- return dfd.promise;
541
- }
542
-
543
- /**
544
- * Wiki Link for SDK params
545
- * https://github.com/comprodls/comprodls-sdk-js/wiki/06_ANALYTICS-Adapter#getshowcaserecordofaclassparams
546
- */
547
- function getShowcaseRecordOfAClass(options) {
548
- var self = this;
549
-
550
- //Initializing DFD
551
- var dfd = q.defer(), err = {};
552
-
553
- // Validations
554
- if(options && options.classid) {
555
- err = helpers.validations.isAuthenticated(self.orgId, self.token);
556
- if(err){ dfd.reject(err); }
557
- else {
558
- // Passed all validations, Constructing URL
559
- var url = self.config.DEFAULT_HOSTS['ANALYTICS'] + self.config.ANALYTICS_API_URLS.getShowcaseRecordOfAClass;
560
- url = helpers.api.constructAPIUrl(url, { orgId: self.orgId });
561
-
562
- // Setup Query Params
563
- var queryParams = {
564
- classid: options.classid
565
- };
566
-
567
- if(options.productcode) { queryParams.productcode = options.productcode; }
568
- if(options.groupid) { queryParams.groupid = options.groupid; }
569
- if(options['item-code']) { queryParams['item-code'] = options['item-code']; }
570
- if(options.id) { queryParams.id = options.id; }
571
-
572
- // Setup Request with url and params
573
- var requestAPI = request.get(url).query(queryParams);
574
- // Setup token in Authorization Header
575
- requestAPI = helpers.api.setupAPIToken(requestAPI, self.token);
576
-
577
- // setting up traceid
578
- if(self.traceid) { requestAPI.set('X-Amzn-Trace-Id', self.traceid); }
579
-
580
- // Call GET GET CLASS RECORD ITEM
581
- requestAPI.end(function(error, response) {
582
- if(error) {
583
- err = new DLSError(helpers.errors.ERROR_TYPES.API_ERROR, error);
584
- dfd.reject(err);
585
- } else {
586
- dfd.resolve(response.body);
587
- }
588
- });
589
- }
590
- } else {
591
- err.message = err.description = 'Required parameter classid not found in request options.';
592
- err = new DLSError(helpers.errors.ERROR_TYPES.SDK_ERROR, err);
593
- dfd.reject(err);
594
- }
595
- return dfd.promise;
596
- }
597
-
598
- /**
599
- * Wiki Link for SDK params
600
- * https://github.com/comprodls/comprodls-sdk-js/wiki/06_ANALYTICS-Adapter#getgrouprecordparams
601
- */
602
- function getGroupRecord(options) {
603
- var self = this;
604
-
605
- //Initializing DFD
606
- var dfd = q.defer(), err = {};
607
-
608
- // Validations
609
- if(options && options.classid && options.productcode && options.groupid) {
610
- err = helpers.validations.isAuthenticated(self.orgId, self.token);
611
- if(err){ dfd.reject(err); }
612
- else {
613
- // Passed all validations, Constructing URL
614
- var url = self.config.DEFAULT_HOSTS['ANALYTICS'] + self.config.ANALYTICS_API_URLS.getGroupRecord;
615
- url = helpers.api.constructAPIUrl(url, { orgId: self.orgId });
616
-
617
- // Setup Query Params
618
- var queryParams = {
619
- classid: options.classid,
620
- productcode: options.productcode,
621
- groupid: options.groupid
622
- };
623
-
624
- if(options.itemcode) { queryParams.itemcode = options.itemcode; }
625
- if(options.history) { queryParams.history = options.history; }
626
-
627
- // Setup Request with url and params
628
- var requestAPI = request.get(url).query(queryParams);
629
- // Setup token in Authorization Header
630
- requestAPI = helpers.api.setupAPIToken(requestAPI, self.token);
631
-
632
- // setting up traceid
633
- if(self.traceid) { requestAPI.set('X-Amzn-Trace-Id', self.traceid); }
634
-
635
- // Call GET GET GROUP RECORD ITEM
636
- requestAPI.end(function(error, response) {
637
- if(error) {
638
- err = new DLSError(helpers.errors.ERROR_TYPES.API_ERROR, error);
639
- dfd.reject(err);
640
- } else {
641
- dfd.resolve(response.body);
642
- }
643
- });
644
- }
645
- } else {
646
- err.message = err.description = 'Required parameter classid or ' +
647
- 'productcode or groupid not found in request options.';
648
- err = new DLSError(helpers.errors.ERROR_TYPES.SDK_ERROR, err);
649
- dfd.reject(err);
650
- }
651
- return dfd.promise;
652
- }
653
-
654
- /**
655
- * Wiki Link for SDK params
656
- * https://github.com/comprodls/comprodls-sdk-js/wiki/06_ANALYTICS-Adapter#getclassgroupsrecentpendingsubmissionsparams
657
- */
658
- function getClassGroupsRecentPendingSubmissions(options) {
659
- var self = this;
660
- var dfd = q.defer(), err = {};
661
-
662
- if(options && options.classid && options.productcode) {
663
- err = helpers.validations.isAuthenticated(self.orgId, self.token);
664
- if(err) { dfd.reject(err); }
665
- else {
666
- // Passed all validations, Constructing URL
667
- var url = self.config.DEFAULT_HOSTS['ANALYTICS'] +
668
- self.config.ANALYTICS_API_URLS.getClassGroupsRecentPendingSubmissions;
669
- url = helpers.api.constructAPIUrl(url, { orgId: self.orgId });
670
-
671
- // Setup Query Params
672
- var queryParams = {
673
- classid: options.classid,
674
- productcode: options.productcode
675
- };
676
-
677
- if(options.details) { queryParams.details = options.details; }
678
- if(options.limit) { queryParams.limit = options.limit; }
679
-
680
- // Setup Request with url and params
681
- var requestAPI = request.get(url).query(queryParams);
682
- // Setup token in Authorization Header
683
- requestAPI = helpers.api.setupAPIToken(requestAPI, self.token);
684
-
685
- // setting up traceid
686
- if(self.traceid) { requestAPI.set('X-Amzn-Trace-Id', self.traceid); }
687
-
688
- // Call GET Class Product Recent Pending Submissions of all groups
689
- requestAPI.end(function(error, response) {
690
- if(error) {
691
- err = new DLSError(helpers.errors.ERROR_TYPES.API_ERROR, error);
692
- dfd.reject(err);
693
- } else {
694
- dfd.resolve(response.body);
695
- }
696
- });
697
- }
698
- }
699
- else {
700
- err.message = err.description = 'Mandatory parameters ["classid", "productcode"] not found in ' +
701
- 'request options.';
702
- err = new DLSError(helpers.errors.ERROR_TYPES.SDK_ERROR, err);
703
- dfd.reject(err);
704
- }
705
-
706
- return dfd.promise;
707
- }
708
-
709
- /**
710
- * Wiki Link for SDK params
711
- * https://github.com/comprodls/comprodls-sdk-js/wiki/06_ANALYTICS-Adapter#getgroupswithevaluatedonceparams
712
- */
713
- function getGroupsWithEvaluatedOnce(options) {
714
- var self = this, err = {};
715
- //Initializing promise
716
- var dfd = q.defer();
717
- if(options && options.classid && options.productcode) {
718
- //Validations
719
- err = helpers.validations.isAuthenticated(self.orgId, self.token);
720
- if(err) { dfd.reject(err); }
721
- else {
722
- // Passed all validations, Construct API url
723
- var url = self.config.DEFAULT_HOSTS['ANALYTICS'] +
724
- self.config.ANALYTICS_API_URLS.getGroupsWithEvaluatedOnce;
725
- url = helpers.api.constructAPIUrl(url, { orgId: self.orgId });
726
-
727
- // Setup params
728
- var params = {
729
- classid: options.classid,
730
- productcode: options.productcode
731
- };
732
- // Setup request with URL and Params
733
- var requestAPI = request.get(url).query(params);
734
- // Setup token in Authorization header
735
- requestAPI = helpers.api.setupAPIToken(requestAPI, self.token);
736
-
737
- // setting up traceid
738
- if(self.traceid) { requestAPI.set('X-Amzn-Trace-Id', self.traceid); }
739
-
740
- requestAPI.end(function(error, response) {
741
- if(error) {
742
- err = new DLSError(helpers.errors.ERROR_TYPES.API_ERROR, error);
743
- dfd.reject(err);
744
- }
745
- else { dfd.resolve(response.body); }
746
- });
747
- }
748
- } else {
749
- err.message = err.description = 'Required parameter classid or ' +
750
- 'productcode not found in request options.';
751
- err = new DLSError(helpers.errors.ERROR_TYPES.SDK_ERROR, err);
752
- dfd.reject(err);
753
- }
754
- return dfd.promise;
755
- }
756
-
757
- /**
758
- * Wiki Link for SDK params
759
- * https://github.com/comprodls/comprodls-sdk-js/wiki/06_ANALYTICS-Adapter#getclassrecorduseraggregationsparams
760
- */
761
- function getClassRecordUserAggregations(options) {
762
- var self = this, err = {};
763
- //Initializing promise
764
- var dfd = q.defer();
765
- if(options && options.classid && options.productcode) {
766
- //Validations
767
- err = helpers.validations.isAuthenticated(self.orgId, self.token);
768
- if(err) { dfd.reject(err); }
769
- else {
770
- // Passed all validations, Construct API url
771
- var url = self.config.DEFAULT_HOSTS['ANALYTICS'] +
772
- self.config.ANALYTICS_API_URLS.getClassRecordUserAggregations;
773
- url = helpers.api.constructAPIUrl(url, { orgId: self.orgId });
774
-
775
- // Setup params
776
- var params = {
777
- classid: options.classid,
778
- productcode: options.productcode,
779
- userid: options.userid
780
- };
781
- // Setup request with URL and Params
782
- var requestAPI = request.get(url).query(params);
783
- // Setup token in Authorization header
784
- requestAPI = helpers.api.setupAPIToken(requestAPI, self.token);
785
-
786
- // setting up traceid
787
- if(self.traceid) { requestAPI.set('X-Amzn-Trace-Id', self.traceid); }
788
-
789
- requestAPI.end(function(error, response) {
790
- if(error) {
791
- err = new DLSError(helpers.errors.ERROR_TYPES.API_ERROR, error);
792
- dfd.reject(err);
793
- }
794
- else { dfd.resolve(response.body); }
795
- });
796
- }
797
- } else {
798
- err.message = err.description = 'Required parameter classid or ' +
799
- 'productcode not found in request options.';
800
- err = new DLSError(helpers.errors.ERROR_TYPES.SDK_ERROR, err);
801
- dfd.reject(err);
802
- }
803
- return dfd.promise;
804
- }
805
-
806
- /**
807
- * Wiki Link for SDK params
808
- * https://github.com/comprodls/comprodls-sdk-js/wiki/06_ANALYTICS-Adapter#getallassignedpathsofclassparams
809
- */
810
- function getAllAssignedPathsOfClass(options) {
811
- var self = this;
812
- // Initializing promise
813
- var dfd = q.defer();
814
- var err = helpers.validations.isAuthenticated(self.orgId, self.token);
815
- if(err) { dfd.reject(err); }
816
- else {
817
- if(options && options.classid) {
818
-
819
- // Passed all validations, Contruct API url
820
- var url = self.config.DEFAULT_HOSTS.ANALYTICS + self.config.ANALYTICS_API_URLS.getAllAssignedPathsOfClass;
821
- url = helpers.api.constructAPIUrl(url, { orgId: self.orgId });
822
-
823
- var queryParams = {
824
- classid: options.classid,
825
- status_not_started: options.status_not_started,
826
- status_active: options.status_active,
827
- status_expired: options.status_expired,
828
- limit: options.limit,
829
- cursor: options.cursor
830
- };
831
-
832
- // Setup request with URL and Params
833
- var requestAPI = request.get(url).query(queryParams);
834
-
835
- //Setup token in Authorization header
836
- requestAPI = helpers.api.setupAPIToken(requestAPI, self.token);
837
-
838
- // setting up traceid
839
- if(self.traceid) { requestAPI.set('X-Amzn-Trace-Id', self.traceid); }
840
-
841
- requestAPI
842
- .agent(keepaliveAgent)
843
- .end(function (error, response) {
844
- if(error) {
845
- err = new DLSError(helpers.errors.ERROR_TYPES.API_ERROR, error);
846
- dfd.reject(err);
847
- }
848
- else { dfd.resolve(response.body); }
849
- });
850
- }
851
- else {
852
- err = {};
853
- err.message = err.description = 'Mandatory param - classid not found in request options.';
854
- err = new DLSError(helpers.errors.ERROR_TYPES.SDK_ERROR, err);
855
- dfd.reject(err);
856
- }
857
- }
858
- return dfd.promise;
859
- }
860
-
861
- /**
862
- * Wiki Link for SDK params
863
- * https://github.com/comprodls/comprodls-sdk-js/wiki/06_ANALYTICS-Adapter#getassignedpathanalyticsparams
864
- */
865
- function getAssignedPathAnalytics(options) {
866
- var self = this;
867
- // Initializing promise
868
- var dfd = q.defer();
869
- var err = helpers.validations.isAuthenticated(self.orgId, self.token);
870
- if(err) { dfd.reject(err); }
871
- else {
872
- if(options && options.classid && options.productcode) {
873
- // Passed all validations, Contruct API url
874
- var url = self.config.DEFAULT_HOSTS.ANALYTICS + self.config.ANALYTICS_API_URLS.getAssignedPathAnalytics;
875
- url = helpers.api.constructAPIUrl(url, { orgId: self.orgId });
876
-
877
- var queryParams = {
878
- classid: options.classid,
879
- assignedpathid: options.assignedPathId,
880
- ext_assignedpathid: options.ext_assignedpathid,
881
- productcode: options.productcode
882
- };
883
- // Setup request with URL and Params
884
- var requestAPI = request.get(url).query(queryParams);
885
-
886
- //Setup token in Authorization header
887
- requestAPI = helpers.api.setupAPIToken(requestAPI, self.token);
888
-
889
- // setting up traceid
890
- if(self.traceid) { requestAPI.set('X-Amzn-Trace-Id', self.traceid); }
891
-
892
- requestAPI.end(function (error, response) {
893
- if(error) {
894
- err = new DLSError(helpers.errors.ERROR_TYPES.API_ERROR, error);
895
- dfd.reject(err);
896
- }
897
- else { dfd.resolve(response.body); }
898
- });
899
- }
900
- else {
901
- err = {};
902
- err.message = err.description = 'Mandatory params - classid or productcode not found in request options.';
903
- err = new DLSError(helpers.errors.ERROR_TYPES.SDK_ERROR, err);
904
- dfd.reject(err);
905
- }
906
- }
907
- return dfd.promise;
908
- }
909
-
910
- /**
911
- * Wiki Link for SDK params
912
- * https://github.com/comprodls/comprodls-sdk-js/wiki/06_ANALYTICS-Adapter#getmyassignedpathsofclassparams
913
- */
914
- function getMyAssignedPathsOfClass(options) {
915
- var self = this;
916
- // Initializing promise
917
- var dfd = q.defer();
918
- var err = helpers.validations.isAuthenticated(self.orgId, self.token);
919
- if(err) { dfd.reject(err); }
920
- else {
921
- if(options && options.classid && options.userid ) {
922
-
923
- // Passed all validations, Contruct API url
924
- var url = self.config.DEFAULT_HOSTS.ANALYTICS + self.config.ANALYTICS_API_URLS.getMyAssignedPathsOfClass;
925
- url = helpers.api.constructAPIUrl(url, { orgId: self.orgId });
926
- var queryParams = { userid: options.userid, classid: options.classid };
927
- if(options.progress) { queryParams.progress = options.progress; }
928
- if(options.group) { queryParams.group = options.group; }
929
- if(options.expiredView) { queryParams.expiredView = options.expiredView; }
930
- if(options.status_not_started) { queryParams.status_not_started = options.status_not_started; }
931
- if(options.status_active) { queryParams.status_active = options.status_active; }
932
- if(options.status_expired) { queryParams.status_expired = options.status_expired; }
933
-
934
- // Setup request with URL and Params
935
- var requestAPI = request.get(url).query(queryParams);
936
- //Setup token in Authorization header
937
- requestAPI = helpers.api.setupAPIToken(requestAPI, self.token);
938
-
939
- // setting up traceid
940
- if(self.traceid) { requestAPI.set('X-Amzn-Trace-Id', self.traceid); }
941
-
942
- requestAPI
943
- .agent(keepaliveAgent)
944
- .end(function (error, response) {
945
- if(error) {
946
- err = new DLSError(helpers.errors.ERROR_TYPES.API_ERROR, error);
947
- dfd.reject(err);
948
- }
949
- else { dfd.resolve(response.body); }
950
- });
951
- }
952
- else {
953
- err = {};
954
- err.message = err.description = 'Mandatory params - classid, userid not found in ' +
955
- 'request options.';
956
- err = new DLSError(helpers.errors.ERROR_TYPES.SDK_ERROR, err);
957
- dfd.reject(err);
958
- }
959
- }
960
- return dfd.promise;
961
- }
962
-
963
- /**
964
- * Wiki Link for SDK params
965
- * https://github.com/comprodls/comprodls-sdk-js/wiki/06_ANALYTICS-Adapter#getuserassignedpathsofclassparams
966
- */
967
- function getUserAssignedPathsOfClass(options) {
968
- var self = this;
969
- // Initializing promise
970
- var dfd = q.defer();
971
- var err = helpers.validations.isAuthenticated(self.orgId, self.token);
972
- if(err) { dfd.reject(err); }
973
- else {
974
- if(options && options.classid && options.userid ) {
975
-
976
- // Passed all validations, Contruct API url
977
- var url = self.config.DEFAULT_HOSTS.ANALYTICS + self.config.ANALYTICS_API_URLS.getMyAssignedPathsOfClass;
978
- url = helpers.api.constructAPIUrl(url, { orgId: self.orgId });
979
-
980
- var queryParams = { userid: options.userid, classid: options.classid };
981
- if(options.progress) { queryParams.progress = options.progress; }
982
- if(options.group) { queryParams.group = options.group; }
983
- if(options.expiredView) { queryParams.expiredView = options.expiredView; }
984
- if(options.status_not_started) { queryParams.status_not_started = options.status_not_started; }
985
- if(options.status_active) { queryParams.status_active = options.status_active; }
986
- if(options.status_expired) { queryParams.status_expired = options.status_expired; }
987
-
988
- // Setup request with URL and Params
989
- var requestAPI = request.get(url).query(queryParams);
990
- //Setup token in Authorization header
991
- requestAPI = helpers.api.setupAPIToken(requestAPI, self.token);
992
-
993
- // setting up traceid
994
- if(self.traceid) { requestAPI.set('X-Amzn-Trace-Id', self.traceid); }
995
-
996
- requestAPI
997
- .agent(keepaliveAgent)
998
- .end(function (error, response) {
999
- if(error) {
1000
- err = new DLSError(helpers.errors.ERROR_TYPES.API_ERROR, error);
1001
- dfd.reject(err);
1002
- }
1003
- else { dfd.resolve(response.body); }
1004
- });
1005
- }
1006
- else {
1007
- err = {};
1008
- err.message = err.description = 'Mandatory params - classid, userid not found in ' +
1009
- 'request options.';
1010
- err = new DLSError(helpers.errors.ERROR_TYPES.SDK_ERROR, err);
1011
- dfd.reject(err);
1012
- }
1013
- }
1014
- return dfd.promise;
1015
- }
1016
-
1017
- /**
1018
- * Wiki Link for SDK params
1019
- * https://github.com/comprodls/comprodls-sdk-js/wiki/06_ANALYTICS-Adapter#getmyparticularassignedpathofclassparams
1020
- */
1021
- function getMyParticularAssignedPathOfClass(options) {
1022
- var self = this;
1023
- // Initializing promise
1024
- var dfd = q.defer();
1025
- var err = helpers.validations.isAuthenticated(self.orgId, self.token);
1026
- if(err) { dfd.reject(err); }
1027
- else {
1028
- if(options && options.classid && options.userid ) {
1029
-
1030
- // Passed all validations, Contruct API url
1031
- var url = self.config.DEFAULT_HOSTS.ANALYTICS + self.config.ANALYTICS_API_URLS.getMyAssignedPathsOfClass;
1032
- url = helpers.api.constructAPIUrl(url, { orgId: self.orgId });
1033
-
1034
- var queryParams = {
1035
- assignedpathid: options.assignedPathId, classid: options.classid, userid: options.userid
1036
- };
1037
-
1038
- if(options.progress) { queryParams.progress = options.progress; }
1039
- if(options.group) { queryParams.group = options.group; }
1040
- if(options.assignedpathid) { queryParams.assignedpathid = options.assignedpathid; }
1041
- if(options.ext_assignedpathid) {queryParams.ext_assignedpathid = options.ext_assignedpathid;}
1042
- if(options.expiredView) { queryParams.expiredView = options.expiredView; }
1043
-
1044
- // Setup request with URL and Params
1045
- var requestAPI = request.get(url).query(queryParams);
1046
- //Setup token in Authorization header
1047
- requestAPI = helpers.api.setupAPIToken(requestAPI, self.token);
1048
-
1049
- // setting up traceid
1050
- if(self.traceid) { requestAPI.set('X-Amzn-Trace-Id', self.traceid); }
1051
-
1052
- requestAPI.end(function (error, response) {
1053
- if(error) {
1054
- err = new DLSError(helpers.errors.ERROR_TYPES.API_ERROR, error);
1055
- dfd.reject(err);
1056
- }
1057
- else { dfd.resolve(response.body); }
1058
- });
1059
- }
1060
- else {
1061
- err = {};
1062
- err.message = err.description = 'Mandatory params - classid, userid not found in ' +
1063
- 'request options.';
1064
- err = new DLSError(helpers.errors.ERROR_TYPES.SDK_ERROR, err);
1065
- dfd.reject(err);
1066
- }
1067
- }
1068
- return dfd.promise;
1069
- }
1070
-
1071
- /**
1072
- * Wiki Link for SDK params
1073
- * https://github.com/comprodls/comprodls-sdk-js/wiki/06_ANALYTICS-Adapter#getparticularassignedpathofclassparams
1074
- */
1075
- function getParticularAssignedPathOfClass(options) {
1076
- var self = this;
1077
- // Initializing promise
1078
- var dfd = q.defer();
1079
- var err = helpers.validations.isAuthenticated(self.orgId, self.token);
1080
- if(err) { dfd.reject(err); }
1081
- else {
1082
- if(options && options.classid && (options.assignedpathid || options.ext_assignedpathid)) {
1083
-
1084
- // Passed all validations, Contruct API url
1085
- var url = self.config.DEFAULT_HOSTS.ANALYTICS +
1086
- self.config.ANALYTICS_API_URLS.getAllAssignedPathsOfClass;
1087
- url = helpers.api.constructAPIUrl(url, { orgId: self.orgId });
1088
-
1089
- var queryParams = { classid: options.classid };
1090
- if(options.assignedpathid) { queryParams.assignedpathid = options.assignedpathid; }
1091
- if(options.ext_assignedpathid) {queryParams.ext_assignedpathid = options.ext_assignedpathid;}
1092
-
1093
- // Setup request with URL and Params
1094
- var requestAPI = request.get(url).query(queryParams);
1095
-
1096
- // Setup token in Authorization header
1097
- requestAPI = helpers.api.setupAPIToken(requestAPI, self.token);
1098
-
1099
- // Setting up traceid
1100
- if(self.traceid) { requestAPI.set('X-Amzn-Trace-Id', self.traceid); }
1101
-
1102
- requestAPI
1103
- .agent(keepaliveAgent)
1104
- .end(function (error, response) {
1105
- if(error) {
1106
- err = new DLSError(helpers.errors.ERROR_TYPES.API_ERROR, error);
1107
- dfd.reject(err);
1108
- }
1109
- else { dfd.resolve(response.body.entities[0]); }
1110
- });
1111
- }
1112
- else {
1113
- err = {};
1114
- err.message = err.description = 'Mandatory params - \'classid\', ' +
1115
- '\'assignedpathid\'/\'ext_assignedpathid\' not found in request options.';
1116
- err = new DLSError(helpers.errors.ERROR_TYPES.SDK_ERROR, err);
1117
- dfd.reject(err);
1118
- }
1119
- }
1120
- return dfd.promise;
1121
- }
1122
-
1123
- /**
1124
- * Wiki Link for SDK params
1125
- * https://github.com/comprodls/comprodls-sdk-js/wiki/06_ANALYTICS-Adapter#gettimeseriesanalyticsparams
1126
- */
1127
- function getTimeseriesAnalytics(options) {
1128
- var self = this;
1129
- var dfd = q.defer();
1130
- var err;
1131
-
1132
- if(options && options.query) {
1133
- //Passed all validations, Construct API url
1134
- var url = self.config.DEFAULT_HOSTS.ANALYTICS + self.config.ANALYTICS_API_URLS.timeseriesAnalytics;
1135
-
1136
- // Contruct parameters
1137
- var params = {
1138
- query: options.query
1139
- };
1140
-
1141
- if(options.cursor) { params.cursor = options.cursor; }
1142
- //Setup request with URL and Params
1143
- var requestAPI = request.get(url).query(params);
1144
-
1145
- if(self.traceid) { requestAPI.set('X-Amzn-Trace-Id', self.traceid); }
1146
-
1147
- requestAPI
1148
- .agent(keepaliveAgent)
1149
- .end(function (error, response) {
1150
- if(error) {
1151
- err = new DLSError(helpers.errors.ERROR_TYPES.API_ERROR, error);
1152
- dfd.reject(err);
1153
- }
1154
- else { dfd.resolve(response.body); }
1155
- });
1156
- }
1157
- else {
1158
- err = {};
1159
- err.message = err.description = 'Mandatory params query not found in request options.';
1160
- err = new DLSError(helpers.errors.ERROR_TYPES.SDK_ERROR, err);
1161
- dfd.reject(err);
1162
- }
1163
- return dfd.promise;
1164
- }
1165
-
1166
- /**
1167
- * Wiki Link for SDK params
1168
- * https://github.com/comprodls/comprodls-sdk-js/wiki/06_ANALYTICS-Adapter#postprogresstimeseriesparams
1169
- */
1170
- function postProgressTimeseries(options) {
1171
- var self = this;
1172
- var dfd = q.defer();
1173
- var err;
1174
-
1175
- if(options && options.body && options.body.query) {
1176
- //Passed all validations, Construct API url
1177
- var url = self.config.DEFAULT_HOSTS.ANALYTICS + self.config.ANALYTICS_API_URLS.timeseriesAnalytics;
1178
-
1179
- //Setup request with URL and Params
1180
- var requestAPI = request.post(url).send(options.body);
1181
-
1182
- if(options.cursor) {
1183
- var params = { cursor: options.cursor };
1184
- requestAPI.query(params);
1185
- };
1186
-
1187
- if(self.traceid) { requestAPI.set('X-Amzn-Trace-Id', self.traceid); }
1188
-
1189
- requestAPI
1190
- .agent(keepaliveAgent)
1191
- .end(function (error, response) {
1192
- if(error) {
1193
- err = new DLSError(helpers.errors.ERROR_TYPES.API_ERROR, error);
1194
- dfd.reject(err);
1195
- }
1196
- else { dfd.resolve(response.body); }
1197
- });
1198
- }
1199
- else {
1200
- err = {};
1201
- err.message = err.description = 'Mandatory options.body.query not found in request options.';
1202
- err = new DLSError(helpers.errors.ERROR_TYPES.SDK_ERROR, err);
1203
- dfd.reject(err);
1204
- }
1205
- return dfd.promise;
1206
- }
1207
-
1208
- /**
1209
- * Wiki Link for SDK params
1210
- * https://github.com/comprodls/comprodls-sdk-js/wiki/06_ANALYTICS-Adapter#getclasscustomcomponentrecordparams
1211
- */
1212
- function getClassCustomComponentRecord(options) {
1213
- var self = this;
1214
-
1215
- //Initializing DFD
1216
- var dfd = q.defer(), err = {};
1217
-
1218
- // Validations
1219
- if(options && options.classid) {
1220
- err = helpers.validations.isAuthenticated(self.orgId, self.token);
1221
- if(err){ dfd.reject(err); }
1222
- else {
1223
- // Passed all validations, Constructing URL
1224
- var url = self.config.DEFAULT_HOSTS['ANALYTICS'] + self.config.ANALYTICS_API_URLS.getClassCustomComponentRecord;
1225
- url = helpers.api.constructAPIUrl(url, { orgId: self.orgId });
1226
-
1227
- // Setup Query Params
1228
- var queryParams = {
1229
- classid: options.classid
1230
- };
1231
-
1232
- if(options['custom_component_code']) {
1233
- queryParams['custom_component_code'] = options['custom_component_code'];
1234
- }
1235
-
1236
- // Setup Request with url and params
1237
- var requestAPI = request.get(url).query(queryParams);
1238
- // Setup token in Authorization Header
1239
- requestAPI = helpers.api.setupAPIToken(requestAPI, self.token);
1240
-
1241
- // setting up traceid
1242
- if(self.traceid) { requestAPI.set('X-Amzn-Trace-Id', self.traceid); }
1243
-
1244
- // Call GET CLASS CUSTOM COMPONENT RECORD ITEM
1245
- requestAPI.end(function(error, response) {
1246
- if(error) {
1247
- err = new DLSError(helpers.errors.ERROR_TYPES.API_ERROR, error);
1248
- err.message = error.response.res.text;
1249
- dfd.reject(err);
1250
- } else {
1251
- dfd.resolve(response.body);
1252
- }
1253
- });
1254
- }
1255
- } else {
1256
- err.message = err.description = 'Required parameter classid not found in request options.';
1257
- err = new DLSError(helpers.errors.ERROR_TYPES.SDK_ERROR, err);
1258
- dfd.reject(err);
1259
- }
1260
- return dfd.promise;
1261
- }
1262
-
1263
- /**
1264
- * Wiki Link for SDK params
1265
- * https://github.com/comprodls/comprodls-sdk-js/wiki/06_ANALYTICS-Adapter#getclasscustomcomponentusersubmissionparams
1266
- */
1267
- function getClassCustomComponentUserSubmission(options) {
1268
- var self = this;
1269
-
1270
- //Initializing DFD
1271
- var dfd = q.defer(), err = {};
1272
-
1273
- // Validations
1274
- if(options && options.classid && options['custom_component_code'] &&
1275
- options.userid && options['item_code']) {
1276
- err = helpers.validations.isAuthenticated(self.orgId, self.token);
1277
- if(err){ dfd.reject(err); }
1278
- else {
1279
- // Passed all validations, Constructing URL
1280
- var url = self.config.DEFAULT_HOSTS['ANALYTICS'] + self.config.ANALYTICS_API_URLS.getClassCustomComponentUserSubmission;
1281
- url = helpers.api.constructAPIUrl(url, { orgId: self.orgId });
1282
-
1283
- // Setup Query Params
1284
- var queryParams = {
1285
- classid: options.classid,
1286
- userid: options.userid,
1287
- 'custom_component_code': options['custom_component_code'],
1288
- 'item_code': options['item_code']
1289
- };
1290
-
1291
- // Setup Request with url and params
1292
- var requestAPI = request.get(url).query(queryParams);
1293
- // Setup token in Authorization Header
1294
- requestAPI = helpers.api.setupAPIToken(requestAPI, self.token);
1295
-
1296
- // setting up traceid
1297
- if(self.traceid) { requestAPI.set('X-Amzn-Trace-Id', self.traceid); }
1298
-
1299
- // Call GET CLASS CUSTOM COMPONENT SUBMISSION OF A USER ON AN ITEM
1300
- requestAPI.end(function(error, response) {
1301
- if(error) {
1302
- err = new DLSError(helpers.errors.ERROR_TYPES.API_ERROR, error);
1303
- err.message = error.response.res.text;
1304
- dfd.reject(err);
1305
- } else {
1306
- dfd.resolve(response.body);
1307
- }
1308
- });
1309
- }
1310
- } else {
1311
- err.message = err.description = 'Required parameter classid or ' +
1312
- 'custom-component-code or ' + 'userid or ' + 'item-code not found in request options.';
1313
- err = new DLSError(helpers.errors.ERROR_TYPES.SDK_ERROR, err);
1314
- dfd.reject(err);
1315
- }
1316
- return dfd.promise;
1317
- }
1318
-
1319
- /**
1320
- * Wiki Link for SDK params
1321
- * https://github.com/comprodls/comprodls-sdk-js/wiki/06_ANALYTICS-Adapter#getcrossproductaggregationparams
1322
- */
1323
- function getCrossProductAggregation(options) {
1324
- var self = this;
1325
-
1326
- //Initializing DFD
1327
- var dfd = q.defer(), err = {};
1328
-
1329
- // Validations
1330
- if(options && options.classid) {
1331
- err = helpers.validations.isAuthenticated(self.orgId, self.token);
1332
- if(err){ dfd.reject(err); }
1333
- else {
1334
- // Passed all validations, Constructing URL
1335
- var url = self.config.DEFAULT_HOSTS['ANALYTICS'] + self.config.ANALYTICS_API_URLS.getCrossProductAggregation;
1336
- url = helpers.api.constructAPIUrl(url, { orgId: self.orgId });
1337
-
1338
- // Setup Query Params
1339
- var queryParams = { classid: options.classid };
1340
-
1341
- if(options.userid) { queryParams.userid = options.userid; }
1342
-
1343
- // Setup Request with url and params
1344
- var requestAPI = request.get(url).query(queryParams);
1345
- // Setup token in Authorization Header
1346
- requestAPI = helpers.api.setupAPIToken(requestAPI, self.token);
1347
-
1348
- // setting up traceid
1349
- if(self.traceid) { requestAPI.set('X-Amzn-Trace-Id', self.traceid); }
1350
-
1351
- // Call GET CROSS PRODUCT AGGREGATION RECORD FOR A CLASS
1352
- requestAPI.end(function(error, response) {
1353
- if(error) {
1354
- err = new DLSError(helpers.errors.ERROR_TYPES.API_ERROR, error);
1355
- dfd.reject(err);
1356
- } else { dfd.resolve(response.body); }
1357
- });
1358
- }
1359
- } else {
1360
- err.message = err.description = 'Required parameter classid not found in request options.';
1361
- err = new DLSError(helpers.errors.ERROR_TYPES.SDK_ERROR, err);
1362
- dfd.reject(err);
1363
- }
1364
- return dfd.promise;
1365
- }
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 Analytics API Adaptor
23
+ * Functions for calling Analytics API.
24
+ ************************************************************/
25
+
26
+ var q = require('q');
27
+ var request = require('superagent');
28
+ var Agent = require('agentkeepalive');
29
+
30
+ var helpers = require('../../helpers');
31
+ var DLSError = helpers.errors.DLSError;
32
+
33
+ module.exports = analytics;
34
+
35
+ var keepaliveAgent = new Agent({
36
+ timeout: 60000,
37
+ freeSocketTimeout: 30000
38
+ });
39
+
40
+ //Analytics Adaptor Constructor
41
+ function analytics() {
42
+ return {
43
+ getOrgAnalyticsStat: getOrgAnalyticsStat.bind(this),
44
+
45
+ getClassProductRecentPendingSubmissions: getClassProductRecentPendingSubmissions.bind(this),
46
+ getClassRecordUserAggregations: getClassRecordUserAggregations.bind(this),
47
+ getClassRecord: getClassRecord.bind(this),
48
+ getClassRecordItemAggregations: getClassRecordItemAggregations.bind(this),
49
+ getShowcaseRecordOfAClass: getShowcaseRecordOfAClass.bind(this),
50
+
51
+ getGroupRecord: getGroupRecord.bind(this),
52
+ getClassGroupsRecentPendingSubmissions: getClassGroupsRecentPendingSubmissions.bind(this),
53
+ getGroupsWithEvaluatedOnce: getGroupsWithEvaluatedOnce.bind(this),
54
+
55
+ getUserProductAnalytics: getUserProductAnalytics.bind(this),
56
+ getExternalDataForUserAnalyticItem: getExternalDataForUserAnalyticItem.bind(this),
57
+ getUserClassRecentSubmissions: getUserClassRecentSubmissions.bind(this),
58
+ getStudentsWithEvaluatedOnce: getStudentsWithEvaluatedOnce.bind(this),
59
+
60
+ //AssignedPaths Related APIs
61
+ getAllAssignedPathsOfClass: getAllAssignedPathsOfClass.bind(this),
62
+ getMyAssignedPathsOfClass: getMyAssignedPathsOfClass.bind(this),
63
+ getUserAssignedPathsOfClass: getUserAssignedPathsOfClass.bind(this),
64
+ getAssignedPathAnalytics: getAssignedPathAnalytics.bind(this),
65
+ getMyParticularAssignedPathOfClass: getMyParticularAssignedPathOfClass.bind(this),
66
+ getParticularAssignedPathOfClass: getParticularAssignedPathOfClass.bind(this),
67
+
68
+ getTimeseriesAnalytics: getTimeseriesAnalytics.bind(this),
69
+ postProgressTimeseries: postProgressTimeseries.bind(this),
70
+
71
+ //ClassCustomComponentRecord Related APIs
72
+ getClassCustomComponentRecord: getClassCustomComponentRecord.bind(this),
73
+ getClassCustomComponentUserSubmission: getClassCustomComponentUserSubmission.bind(this),
74
+
75
+ //CrossProductAggregation Related APIs
76
+ getCrossProductAggregation: getCrossProductAggregation.bind(this)
77
+ };
78
+ }
79
+
80
+ /*********************************
81
+ * Public Function definitions
82
+ **********************************/
83
+
84
+ /**
85
+ * Wiki Link for SDK params
86
+ * https://github.com/comprodls/comprodls-sdk-js/wiki/06_ANALYTICS-Adapter#getorganalyticsstatparams
87
+ */
88
+ function getOrgAnalyticsStat(options) {
89
+ var self = this;
90
+
91
+ //Initializing promise
92
+ var dfd = q.defer();
93
+ //Validations
94
+ var err = {};
95
+ if(options && options.type) {
96
+ err = helpers.validations.isAuthenticated(self.orgId, self.token);
97
+ if(err) { dfd.reject(err); }
98
+ else {
99
+ err = {};
100
+ var allowedAnalyticsDataType = ['users', 'classes'];
101
+ if(allowedAnalyticsDataType.indexOf(options.type) > -1) {
102
+ //Passed all validations, Construct API url
103
+ var url = self.config.DEFAULT_HOSTS['ANALYTICS'] +
104
+ self.config.ANALYTICS_API_URLS.getOrgAnalyticsStat;
105
+ url = helpers.api.constructAPIUrl(url, {
106
+ orgId: self.orgId, type: options.type
107
+ });
108
+
109
+ var params = {};
110
+ if(options) {
111
+ if(options.range) { params.range = options.range; }
112
+ if(options.start) { params.start = options.start; }
113
+ if(options.end) { params.end = options.end; }
114
+ if(options.role) { params.role = options.role; }
115
+ if(options.shadow) { params.shadow = options.shadow; }
116
+ }
117
+
118
+ //Setup request with URL and Params
119
+ var requestAPI = request.get(url).query(params);
120
+
121
+ //Setup token in Authorization header
122
+ requestAPI = helpers.api.setupAPIToken(requestAPI, self.token);
123
+
124
+ // setting up traceid
125
+ if(self.traceid) { requestAPI.set('X-Amzn-Trace-Id', self.traceid); }
126
+
127
+ //Call Product Timespent Api
128
+ requestAPI.end(function(err, response) {
129
+ if(err) {
130
+ err = new DLSError(helpers.errors.ERROR_TYPES.API_ERROR, err);
131
+ dfd.reject(err);
132
+ }
133
+ else { dfd.resolve(response.body); }
134
+ });
135
+ } else {
136
+ err.message = err.description = 'Type: ' + options.type + ' is not supported';
137
+ err = new DLSError(helpers.errors.ERROR_TYPES.SDK_ERROR, err);
138
+ dfd.reject(err);
139
+ }
140
+ }
141
+ } else {
142
+ err.message = err.description = 'type not found in request options';
143
+ err = new DLSError(helpers.errors.ERROR_TYPES.SDK_ERROR, err);
144
+ dfd.reject(err);
145
+ }
146
+
147
+ return dfd.promise;
148
+ }
149
+
150
+ /**
151
+ * Wiki Link for SDK params
152
+ * https://github.com/comprodls/comprodls-sdk-js/wiki/06_ANALYTICS-Adapter#getuserproductanalyticsparams
153
+ */
154
+ function getUserProductAnalytics(options) {
155
+ var self = this;
156
+
157
+ //Initializing promise
158
+ var dfd = q.defer();
159
+ //Validations
160
+ var err = {};
161
+ if(options && options.type && options.userid && options.productcode) {
162
+ err = helpers.validations.isAuthenticated(self.orgId, self.token);
163
+ if(err) { dfd.reject(err); }
164
+ else {
165
+ var supportedType = ['items', 'summary'];
166
+ //Passed all validations, Construct API url
167
+ var url = self.config.DEFAULT_HOSTS['ANALYTICS'];
168
+
169
+ if(supportedType.indexOf(options.type) > -1) {
170
+ switch(options.type) {
171
+ case 'items':
172
+ url += self.config.ANALYTICS_API_URLS.getAnalyticProductItems;
173
+ break;
174
+ case 'summary':
175
+ url += self.config.ANALYTICS_API_URLS.getAnalyticProductSummary;
176
+ break;
177
+ }
178
+ url = helpers.api.constructAPIUrl(url, { orgId: self.orgId });
179
+
180
+ var params = { userid: options.userid, productcode: options.productcode };
181
+
182
+ if(options.classid) { params.classid = options.classid; }
183
+ if(options.itemcode) { params.itemcode = options.itemcode; }
184
+ if(options.metrics) { params.metrics = options.metrics; }
185
+ if(options.history) { params.history = options.history; }
186
+ if(options.group) { params.group = options.group; }
187
+ if(options.externalData) { params.externalData = options.externalData; }
188
+ if(options.expiredView && options.type === 'items') { params.expiredView = options.expiredView; }
189
+
190
+ //Setup request with URL and Params
191
+ var requestAPI = request.get(url).query(params);
192
+
193
+ //Setup token in Authorization header
194
+ requestAPI = helpers.api.setupAPIToken(requestAPI, self.token);
195
+
196
+ // setting up traceid
197
+ if(self.traceid) { requestAPI.set('X-Amzn-Trace-Id', self.traceid); }
198
+
199
+ //Call Product Timespent Api
200
+ requestAPI.end(function(err, response) {
201
+ if(err) {
202
+ err = new DLSError(helpers.errors.ERROR_TYPES.API_ERROR, err);
203
+ dfd.reject(err);
204
+ }
205
+ else { dfd.resolve(response.body); }
206
+ });
207
+ } else {
208
+ err.message = err.description = options.type + " is not a valid value of option 'type'";
209
+ err = new DLSError(helpers.errors.ERROR_TYPES.SDK_ERROR, err);
210
+ dfd.reject(err);
211
+ }
212
+ }
213
+ } else {
214
+ err.message = err.description = "Required parameter 'type' or 'userid' or " +
215
+ "'productcode' not found in request options";
216
+ err = new DLSError(helpers.errors.ERROR_TYPES.SDK_ERROR, err);
217
+ dfd.reject(err);
218
+ }
219
+
220
+ return dfd.promise;
221
+ }
222
+
223
+ /**
224
+ * Wiki Link for SDK params
225
+ * https://github.com/comprodls/comprodls-sdk-js/wiki/06_ANALYTICS-Adapter#getexternaldataforuseranalyticitemparams
226
+ */
227
+ function getExternalDataForUserAnalyticItem(options) {
228
+ var self = this;
229
+ var dfd = q.defer();
230
+ // Validations
231
+ var err = {};
232
+ if(options && options.ext_user_id && options.productcode && options.itemcode &&
233
+ (options.submission_order || options.ext_link_id) && options.part) {
234
+ err = helpers.validations.isAuthenticated(self.orgId, self.token);
235
+ if(err) { dfd.reject(err); }
236
+ else {
237
+ // Passed all validations, Construct API url
238
+ var url = self.config.DEFAULT_HOSTS.ANALYTICS +
239
+ self.config.ANALYTICS_API_URLS.getExternalDataForUserAnalyticItem;
240
+ url = helpers.api.constructAPIUrl(url, { orgId: self.orgId });
241
+
242
+ var params = {
243
+ ext_user_id: options.ext_user_id,
244
+ productcode: options.productcode,
245
+ itemcode: options.itemcode,
246
+ part: options.part
247
+ };
248
+
249
+ if(options.submission_order) { params.submission_order = options.submission_order; }
250
+ if(options.ext_link_id) { params.ext_link_id = options.ext_link_id; }
251
+ if(options.classid) { params.classid = options.classid; }
252
+
253
+ // Setup request with URL and Params
254
+ var requestAPI = request.get(url).query(params);
255
+
256
+ // Setup token in Authorization header
257
+ requestAPI = helpers.api.setupAPIToken(requestAPI, self.token);
258
+
259
+ // setting up traceid
260
+ if(self.traceid) { requestAPI.set('X-Amzn-Trace-Id', self.traceid); }
261
+
262
+ // Call Product Timespent Api
263
+ requestAPI.end(function(err, response) {
264
+ if(err) {
265
+ err = new DLSError(helpers.errors.ERROR_TYPES.API_ERROR, err);
266
+ dfd.reject(err);
267
+ }
268
+ else { dfd.resolve(response.body); }
269
+ });
270
+ }
271
+ } else {
272
+ err.message = err.description = "Required parameters 'ext_user_id' or 'productcode' or 'itemcode'" +
273
+ " or (either 'submission_order' OR 'ext_link_id') or 'part'are not found in request options";
274
+ err = new DLSError(helpers.errors.ERROR_TYPES.SDK_ERROR, err);
275
+ dfd.reject(err);
276
+ }
277
+ return dfd.promise;
278
+ }
279
+
280
+ /**
281
+ * Wiki Link for SDK params
282
+ * https://github.com/comprodls/comprodls-sdk-js/wiki/06_ANALYTICS-Adapter#getuserclassrecentsubmissionsparams
283
+ */
284
+ function getUserClassRecentSubmissions(options) {
285
+ var self = this;
286
+ var dfd = q.defer(), err = {};
287
+
288
+ if(options && options.classid && options.productcode && options.userid) {
289
+ err = helpers.validations.isAuthenticated(self.orgId, self.token);
290
+ if(err) { dfd.reject(err); }
291
+ else {
292
+ // Passed all validations, Constructing URL
293
+ var url = self.config.DEFAULT_HOSTS['ANALYTICS'] +
294
+ self.config.ANALYTICS_API_URLS.getUserClassRecentSubmissions;
295
+ url = helpers.api.constructAPIUrl(url, { orgId: self.orgId });
296
+
297
+ // Setup Query Params
298
+ var queryParams = {
299
+ userid: options.userid,
300
+ classid: options.classid,
301
+ productcode: options.productcode
302
+ };
303
+
304
+ if(options.gradingStatus) { queryParams.gradingStatus = options.gradingStatus; }
305
+
306
+ // Setup Request with url and params
307
+ var requestAPI = request.get(url).query(queryParams);
308
+ // Setup token in Authorization Header
309
+ requestAPI = helpers.api.setupAPIToken(requestAPI, self.token);
310
+
311
+ // setting up traceid
312
+ if(self.traceid) { requestAPI.set('X-Amzn-Trace-Id', self.traceid); }
313
+
314
+ // Call GET Class Product Recent Pending Submissions
315
+ requestAPI.end(function(error, response) {
316
+ if(error) {
317
+ err = new DLSError(helpers.errors.ERROR_TYPES.API_ERROR, error);
318
+ dfd.reject(err);
319
+ } else {
320
+ dfd.resolve(response.body);
321
+ }
322
+ });
323
+ }
324
+ }
325
+ else {
326
+ err.message = err.description = 'Mandatory parameters ["classid", "productcode", "userid"]' +
327
+ ' not found in request options.';
328
+ err = new DLSError(helpers.errors.ERROR_TYPES.SDK_ERROR, err);
329
+ dfd.reject(err);
330
+ }
331
+
332
+ return dfd.promise;
333
+ }
334
+
335
+ /**
336
+ * Wiki Link for SDK params
337
+ * https://github.com/comprodls/comprodls-sdk-js/wiki/06_ANALYTICS-Adapter#getstudentswithevaluatedonceparams
338
+ */
339
+ function getStudentsWithEvaluatedOnce(options) {
340
+ var self = this, err = {};
341
+ //Initializing promise
342
+ var dfd = q.defer();
343
+ if(options && options.classid && options.productcode) {
344
+ //Validations
345
+ err = helpers.validations.isAuthenticated(self.orgId, self.token);
346
+ if(err) { dfd.reject(err); }
347
+ else {
348
+ // Passed all validations, Construct API url
349
+ var url = self.config.DEFAULT_HOSTS['ANALYTICS'] +
350
+ self.config.ANALYTICS_API_URLS.getStudentsWithEvaluatedOnce;
351
+ url = helpers.api.constructAPIUrl(url, { orgId: self.orgId });
352
+
353
+ // Setup params
354
+ var params = {
355
+ classid: options.classid,
356
+ productcode: options.productcode
357
+ };
358
+ // Setup request with URL and Params
359
+ var requestAPI = request.get(url).query(params);
360
+ // Setup token in Authorization header
361
+ requestAPI = helpers.api.setupAPIToken(requestAPI, self.token);
362
+
363
+ // setting up traceid
364
+ if(self.traceid) { requestAPI.set('X-Amzn-Trace-Id', self.traceid); }
365
+
366
+ requestAPI.end(function(error, response) {
367
+ if(error) {
368
+ err = new DLSError(helpers.errors.ERROR_TYPES.API_ERROR, error);
369
+ dfd.reject(err);
370
+ }
371
+ else { dfd.resolve(response.body); }
372
+ });
373
+ }
374
+ } else {
375
+ err.message = err.description = 'Required parameter classid or ' +
376
+ 'productcode not found in request options.';
377
+ err = new DLSError(helpers.errors.ERROR_TYPES.SDK_ERROR, err);
378
+ dfd.reject(err);
379
+ }
380
+ return dfd.promise;
381
+ }
382
+
383
+ /**
384
+ * Wiki Link for SDK params
385
+ * https://github.com/comprodls/comprodls-sdk-js/wiki/06_ANALYTICS-Adapter#getclassproductrecentpendingsubmissionsparams
386
+ */
387
+ function getClassProductRecentPendingSubmissions(options) {
388
+ var self = this;
389
+ var dfd = q.defer(), err = {};
390
+
391
+ if(options && options.classid && options.productcode) {
392
+ err = helpers.validations.isAuthenticated(self.orgId, self.token);
393
+ if(err) { dfd.reject(err); }
394
+ else {
395
+ // Passed all validations, Constructing URL
396
+ var url = self.config.DEFAULT_HOSTS['ANALYTICS'] +
397
+ self.config.ANALYTICS_API_URLS.getClassProductRecentPendingSubmissions;
398
+ url = helpers.api.constructAPIUrl(url, { orgId: self.orgId });
399
+
400
+ // Setup Query Params
401
+ var queryParams = {
402
+ classid: options.classid,
403
+ productcode: options.productcode
404
+ };
405
+
406
+ if(options.details) { queryParams.details = options.details; }
407
+ if(options.limit) { queryParams.limit = options.limit; }
408
+
409
+ // Setup Request with url and params
410
+ var requestAPI = request.get(url).query(queryParams);
411
+ // Setup token in Authorization Header
412
+ requestAPI = helpers.api.setupAPIToken(requestAPI, self.token);
413
+ // Call GET Class Product Recent Pending Submissions
414
+
415
+ // setting up traceid
416
+ if(self.traceid) { requestAPI.set('X-Amzn-Trace-Id', self.traceid); }
417
+
418
+ requestAPI.end(function(error, response) {
419
+ if(error) {
420
+ err = new DLSError(helpers.errors.ERROR_TYPES.API_ERROR, error);
421
+ dfd.reject(err);
422
+ } else {
423
+ dfd.resolve(response.body);
424
+ }
425
+ });
426
+ }
427
+ }
428
+ else {
429
+ err.message = err.description = 'Mandatory parameters ["classid", "productcode"] not found in ' +
430
+ 'request options.';
431
+ err = new DLSError(helpers.errors.ERROR_TYPES.SDK_ERROR, err);
432
+ dfd.reject(err);
433
+ }
434
+
435
+ return dfd.promise;
436
+ }
437
+
438
+ /**
439
+ * Wiki Link for SDK params
440
+ * https://github.com/comprodls/comprodls-sdk-js/wiki/06_ANALYTICS-Adapter#getclassrecordparams
441
+ */
442
+ function getClassRecord(options) {
443
+ var self = this;
444
+
445
+ //Initializing DFD
446
+ var dfd = q.defer(), err = {};
447
+
448
+ // Validations
449
+ if(options && options.classid && options.productcode) {
450
+ err = helpers.validations.isAuthenticated(self.orgId, self.token);
451
+ if(err){ dfd.reject(err); }
452
+ else {
453
+ // Passed all validations, Constructing URL
454
+ var url = self.config.DEFAULT_HOSTS['ANALYTICS'] + self.config.ANALYTICS_API_URLS.getClassRecord;
455
+ url = helpers.api.constructAPIUrl(url, { orgId: self.orgId });
456
+
457
+ // Setup Query Params
458
+ var queryParams = {
459
+ classid: options.classid,
460
+ productcode: options.productcode,
461
+ userids: options.userids,
462
+ includeContext: options.includeContext
463
+ };
464
+
465
+ // Setup Request with url and params
466
+ var requestAPI = request.get(url).query(queryParams);
467
+ // Setup token in Authorization Header
468
+ requestAPI = helpers.api.setupAPIToken(requestAPI, self.token);
469
+
470
+ // setting up traceid
471
+ if(self.traceid) { requestAPI.set('X-Amzn-Trace-Id', self.traceid); }
472
+
473
+ // Call GET GET CLASS RECORD ITEM
474
+ requestAPI.end(function(error, response) {
475
+ if(error) {
476
+ err = new DLSError(helpers.errors.ERROR_TYPES.API_ERROR, error);
477
+ dfd.reject(err);
478
+ } else { dfd.resolve(response.body); }
479
+ });
480
+ }
481
+ } else {
482
+ err.message = err.description = 'Required parameter classid or ' +
483
+ 'productcode not found in request options.';
484
+ err = new DLSError(helpers.errors.ERROR_TYPES.SDK_ERROR, err);
485
+ dfd.reject(err);
486
+ }
487
+ return dfd.promise;
488
+ }
489
+
490
+ /**
491
+ * Wiki Link for SDK params
492
+ * https://github.com/comprodls/comprodls-sdk-js/wiki/06_ANALYTICS-Adapter#getclassrecorditemaggregationsparams
493
+ */
494
+ function getClassRecordItemAggregations(options) {
495
+ var self = this;
496
+
497
+ //Initializing DFD
498
+ var dfd = q.defer(), err = {};
499
+
500
+ // Validations
501
+ if(options && options.classid && options.productcode) {
502
+ err = helpers.validations.isAuthenticated(self.orgId, self.token);
503
+ if(err){ dfd.reject(err); }
504
+ else {
505
+ // Passed all validations, Constructing URL
506
+ var url = self.config.DEFAULT_HOSTS['ANALYTICS'] + self.config.ANALYTICS_API_URLS.getClassRecordItemAggregations;
507
+ url = helpers.api.constructAPIUrl(url, { orgId: self.orgId });
508
+
509
+ // Setup Query Params
510
+ var queryParams = {
511
+ classid: options.classid,
512
+ productcode: options.productcode,
513
+ 'item-code': options['item-code']
514
+ };
515
+
516
+ // Setup Request with url and params
517
+ var requestAPI = request.get(url).query(queryParams);
518
+ // Setup token in Authorization Header
519
+ requestAPI = helpers.api.setupAPIToken(requestAPI, self.token);
520
+
521
+ // setting up traceid
522
+ if(self.traceid) { requestAPI.set('X-Amzn-Trace-Id', self.traceid); }
523
+
524
+ // Call GET GET CLASS RECORD ITEM
525
+ requestAPI.end(function(error, response) {
526
+ if(error) {
527
+ err = new DLSError(helpers.errors.ERROR_TYPES.API_ERROR, error);
528
+ dfd.reject(err);
529
+ } else {
530
+ dfd.resolve(response.body);
531
+ }
532
+ });
533
+ }
534
+ } else {
535
+ err.message = err.description = 'Required parameter classid or ' +
536
+ 'productcode not found in request options.';
537
+ err = new DLSError(helpers.errors.ERROR_TYPES.SDK_ERROR, err);
538
+ dfd.reject(err);
539
+ }
540
+ return dfd.promise;
541
+ }
542
+
543
+ /**
544
+ * Wiki Link for SDK params
545
+ * https://github.com/comprodls/comprodls-sdk-js/wiki/06_ANALYTICS-Adapter#getshowcaserecordofaclassparams
546
+ */
547
+ function getShowcaseRecordOfAClass(options) {
548
+ var self = this;
549
+
550
+ //Initializing DFD
551
+ var dfd = q.defer(), err = {};
552
+
553
+ // Validations
554
+ if(options && options.classid) {
555
+ err = helpers.validations.isAuthenticated(self.orgId, self.token);
556
+ if(err){ dfd.reject(err); }
557
+ else {
558
+ // Passed all validations, Constructing URL
559
+ var url = self.config.DEFAULT_HOSTS['ANALYTICS'] + self.config.ANALYTICS_API_URLS.getShowcaseRecordOfAClass;
560
+ url = helpers.api.constructAPIUrl(url, { orgId: self.orgId });
561
+
562
+ // Setup Query Params
563
+ var queryParams = {
564
+ classid: options.classid
565
+ };
566
+
567
+ if(options.productcode) { queryParams.productcode = options.productcode; }
568
+ if(options.groupid) { queryParams.groupid = options.groupid; }
569
+ if(options['item-code']) { queryParams['item-code'] = options['item-code']; }
570
+ if(options.id) { queryParams.id = options.id; }
571
+
572
+ // Setup Request with url and params
573
+ var requestAPI = request.get(url).query(queryParams);
574
+ // Setup token in Authorization Header
575
+ requestAPI = helpers.api.setupAPIToken(requestAPI, self.token);
576
+
577
+ // setting up traceid
578
+ if(self.traceid) { requestAPI.set('X-Amzn-Trace-Id', self.traceid); }
579
+
580
+ // Call GET GET CLASS RECORD ITEM
581
+ requestAPI.end(function(error, response) {
582
+ if(error) {
583
+ err = new DLSError(helpers.errors.ERROR_TYPES.API_ERROR, error);
584
+ dfd.reject(err);
585
+ } else {
586
+ dfd.resolve(response.body);
587
+ }
588
+ });
589
+ }
590
+ } else {
591
+ err.message = err.description = 'Required parameter classid not found in request options.';
592
+ err = new DLSError(helpers.errors.ERROR_TYPES.SDK_ERROR, err);
593
+ dfd.reject(err);
594
+ }
595
+ return dfd.promise;
596
+ }
597
+
598
+ /**
599
+ * Wiki Link for SDK params
600
+ * https://github.com/comprodls/comprodls-sdk-js/wiki/06_ANALYTICS-Adapter#getgrouprecordparams
601
+ */
602
+ function getGroupRecord(options) {
603
+ var self = this;
604
+
605
+ //Initializing DFD
606
+ var dfd = q.defer(), err = {};
607
+
608
+ // Validations
609
+ if(options && options.classid && options.productcode && options.groupid) {
610
+ err = helpers.validations.isAuthenticated(self.orgId, self.token);
611
+ if(err){ dfd.reject(err); }
612
+ else {
613
+ // Passed all validations, Constructing URL
614
+ var url = self.config.DEFAULT_HOSTS['ANALYTICS'] + self.config.ANALYTICS_API_URLS.getGroupRecord;
615
+ url = helpers.api.constructAPIUrl(url, { orgId: self.orgId });
616
+
617
+ // Setup Query Params
618
+ var queryParams = {
619
+ classid: options.classid,
620
+ productcode: options.productcode,
621
+ groupid: options.groupid
622
+ };
623
+
624
+ if(options.itemcode) { queryParams.itemcode = options.itemcode; }
625
+ if(options.history) { queryParams.history = options.history; }
626
+
627
+ // Setup Request with url and params
628
+ var requestAPI = request.get(url).query(queryParams);
629
+ // Setup token in Authorization Header
630
+ requestAPI = helpers.api.setupAPIToken(requestAPI, self.token);
631
+
632
+ // setting up traceid
633
+ if(self.traceid) { requestAPI.set('X-Amzn-Trace-Id', self.traceid); }
634
+
635
+ // Call GET GET GROUP RECORD ITEM
636
+ requestAPI.end(function(error, response) {
637
+ if(error) {
638
+ err = new DLSError(helpers.errors.ERROR_TYPES.API_ERROR, error);
639
+ dfd.reject(err);
640
+ } else {
641
+ dfd.resolve(response.body);
642
+ }
643
+ });
644
+ }
645
+ } else {
646
+ err.message = err.description = 'Required parameter classid or ' +
647
+ 'productcode or groupid not found in request options.';
648
+ err = new DLSError(helpers.errors.ERROR_TYPES.SDK_ERROR, err);
649
+ dfd.reject(err);
650
+ }
651
+ return dfd.promise;
652
+ }
653
+
654
+ /**
655
+ * Wiki Link for SDK params
656
+ * https://github.com/comprodls/comprodls-sdk-js/wiki/06_ANALYTICS-Adapter#getclassgroupsrecentpendingsubmissionsparams
657
+ */
658
+ function getClassGroupsRecentPendingSubmissions(options) {
659
+ var self = this;
660
+ var dfd = q.defer(), err = {};
661
+
662
+ if(options && options.classid && options.productcode) {
663
+ err = helpers.validations.isAuthenticated(self.orgId, self.token);
664
+ if(err) { dfd.reject(err); }
665
+ else {
666
+ // Passed all validations, Constructing URL
667
+ var url = self.config.DEFAULT_HOSTS['ANALYTICS'] +
668
+ self.config.ANALYTICS_API_URLS.getClassGroupsRecentPendingSubmissions;
669
+ url = helpers.api.constructAPIUrl(url, { orgId: self.orgId });
670
+
671
+ // Setup Query Params
672
+ var queryParams = {
673
+ classid: options.classid,
674
+ productcode: options.productcode
675
+ };
676
+
677
+ if(options.details) { queryParams.details = options.details; }
678
+ if(options.limit) { queryParams.limit = options.limit; }
679
+
680
+ // Setup Request with url and params
681
+ var requestAPI = request.get(url).query(queryParams);
682
+ // Setup token in Authorization Header
683
+ requestAPI = helpers.api.setupAPIToken(requestAPI, self.token);
684
+
685
+ // setting up traceid
686
+ if(self.traceid) { requestAPI.set('X-Amzn-Trace-Id', self.traceid); }
687
+
688
+ // Call GET Class Product Recent Pending Submissions of all groups
689
+ requestAPI.end(function(error, response) {
690
+ if(error) {
691
+ err = new DLSError(helpers.errors.ERROR_TYPES.API_ERROR, error);
692
+ dfd.reject(err);
693
+ } else {
694
+ dfd.resolve(response.body);
695
+ }
696
+ });
697
+ }
698
+ }
699
+ else {
700
+ err.message = err.description = 'Mandatory parameters ["classid", "productcode"] not found in ' +
701
+ 'request options.';
702
+ err = new DLSError(helpers.errors.ERROR_TYPES.SDK_ERROR, err);
703
+ dfd.reject(err);
704
+ }
705
+
706
+ return dfd.promise;
707
+ }
708
+
709
+ /**
710
+ * Wiki Link for SDK params
711
+ * https://github.com/comprodls/comprodls-sdk-js/wiki/06_ANALYTICS-Adapter#getgroupswithevaluatedonceparams
712
+ */
713
+ function getGroupsWithEvaluatedOnce(options) {
714
+ var self = this, err = {};
715
+ //Initializing promise
716
+ var dfd = q.defer();
717
+ if(options && options.classid && options.productcode) {
718
+ //Validations
719
+ err = helpers.validations.isAuthenticated(self.orgId, self.token);
720
+ if(err) { dfd.reject(err); }
721
+ else {
722
+ // Passed all validations, Construct API url
723
+ var url = self.config.DEFAULT_HOSTS['ANALYTICS'] +
724
+ self.config.ANALYTICS_API_URLS.getGroupsWithEvaluatedOnce;
725
+ url = helpers.api.constructAPIUrl(url, { orgId: self.orgId });
726
+
727
+ // Setup params
728
+ var params = {
729
+ classid: options.classid,
730
+ productcode: options.productcode
731
+ };
732
+ // Setup request with URL and Params
733
+ var requestAPI = request.get(url).query(params);
734
+ // Setup token in Authorization header
735
+ requestAPI = helpers.api.setupAPIToken(requestAPI, self.token);
736
+
737
+ // setting up traceid
738
+ if(self.traceid) { requestAPI.set('X-Amzn-Trace-Id', self.traceid); }
739
+
740
+ requestAPI.end(function(error, response) {
741
+ if(error) {
742
+ err = new DLSError(helpers.errors.ERROR_TYPES.API_ERROR, error);
743
+ dfd.reject(err);
744
+ }
745
+ else { dfd.resolve(response.body); }
746
+ });
747
+ }
748
+ } else {
749
+ err.message = err.description = 'Required parameter classid or ' +
750
+ 'productcode not found in request options.';
751
+ err = new DLSError(helpers.errors.ERROR_TYPES.SDK_ERROR, err);
752
+ dfd.reject(err);
753
+ }
754
+ return dfd.promise;
755
+ }
756
+
757
+ /**
758
+ * Wiki Link for SDK params
759
+ * https://github.com/comprodls/comprodls-sdk-js/wiki/06_ANALYTICS-Adapter#getclassrecorduseraggregationsparams
760
+ */
761
+ function getClassRecordUserAggregations(options) {
762
+ var self = this, err = {};
763
+ //Initializing promise
764
+ var dfd = q.defer();
765
+ if(options && options.classid && options.productcode) {
766
+ //Validations
767
+ err = helpers.validations.isAuthenticated(self.orgId, self.token);
768
+ if(err) { dfd.reject(err); }
769
+ else {
770
+ // Passed all validations, Construct API url
771
+ var url = self.config.DEFAULT_HOSTS['ANALYTICS'] +
772
+ self.config.ANALYTICS_API_URLS.getClassRecordUserAggregations;
773
+ url = helpers.api.constructAPIUrl(url, { orgId: self.orgId });
774
+
775
+ // Setup params
776
+ var params = {
777
+ classid: options.classid,
778
+ productcode: options.productcode,
779
+ userid: options.userid
780
+ };
781
+ // Setup request with URL and Params
782
+ var requestAPI = request.get(url).query(params);
783
+ // Setup token in Authorization header
784
+ requestAPI = helpers.api.setupAPIToken(requestAPI, self.token);
785
+
786
+ // setting up traceid
787
+ if(self.traceid) { requestAPI.set('X-Amzn-Trace-Id', self.traceid); }
788
+
789
+ requestAPI.end(function(error, response) {
790
+ if(error) {
791
+ err = new DLSError(helpers.errors.ERROR_TYPES.API_ERROR, error);
792
+ dfd.reject(err);
793
+ }
794
+ else { dfd.resolve(response.body); }
795
+ });
796
+ }
797
+ } else {
798
+ err.message = err.description = 'Required parameter classid or ' +
799
+ 'productcode not found in request options.';
800
+ err = new DLSError(helpers.errors.ERROR_TYPES.SDK_ERROR, err);
801
+ dfd.reject(err);
802
+ }
803
+ return dfd.promise;
804
+ }
805
+
806
+ /**
807
+ * Wiki Link for SDK params
808
+ * https://github.com/comprodls/comprodls-sdk-js/wiki/06_ANALYTICS-Adapter#getallassignedpathsofclassparams
809
+ */
810
+ function getAllAssignedPathsOfClass(options) {
811
+ var self = this;
812
+ // Initializing promise
813
+ var dfd = q.defer();
814
+ var err = helpers.validations.isAuthenticated(self.orgId, self.token);
815
+ if(err) { dfd.reject(err); }
816
+ else {
817
+ if(options && options.classid) {
818
+
819
+ // Passed all validations, Contruct API url
820
+ var url = self.config.DEFAULT_HOSTS.ANALYTICS + self.config.ANALYTICS_API_URLS.getAllAssignedPathsOfClass;
821
+ url = helpers.api.constructAPIUrl(url, { orgId: self.orgId });
822
+
823
+ var queryParams = {
824
+ classid: options.classid,
825
+ status_not_started: options.status_not_started,
826
+ status_active: options.status_active,
827
+ status_expired: options.status_expired,
828
+ limit: options.limit,
829
+ cursor: options.cursor
830
+ };
831
+
832
+ // Setup request with URL and Params
833
+ var requestAPI = request.get(url).query(queryParams);
834
+
835
+ //Setup token in Authorization header
836
+ requestAPI = helpers.api.setupAPIToken(requestAPI, self.token);
837
+
838
+ // setting up traceid
839
+ if(self.traceid) { requestAPI.set('X-Amzn-Trace-Id', self.traceid); }
840
+
841
+ requestAPI
842
+ .agent(keepaliveAgent)
843
+ .end(function (error, response) {
844
+ if(error) {
845
+ err = new DLSError(helpers.errors.ERROR_TYPES.API_ERROR, error);
846
+ dfd.reject(err);
847
+ }
848
+ else { dfd.resolve(response.body); }
849
+ });
850
+ }
851
+ else {
852
+ err = {};
853
+ err.message = err.description = 'Mandatory param - classid not found in request options.';
854
+ err = new DLSError(helpers.errors.ERROR_TYPES.SDK_ERROR, err);
855
+ dfd.reject(err);
856
+ }
857
+ }
858
+ return dfd.promise;
859
+ }
860
+
861
+ /**
862
+ * Wiki Link for SDK params
863
+ * https://github.com/comprodls/comprodls-sdk-js/wiki/06_ANALYTICS-Adapter#getassignedpathanalyticsparams
864
+ */
865
+ function getAssignedPathAnalytics(options) {
866
+ var self = this;
867
+ // Initializing promise
868
+ var dfd = q.defer();
869
+ var err = helpers.validations.isAuthenticated(self.orgId, self.token);
870
+ if(err) { dfd.reject(err); }
871
+ else {
872
+ if(options && options.classid && options.productcode) {
873
+ // Passed all validations, Contruct API url
874
+ var url = self.config.DEFAULT_HOSTS.ANALYTICS + self.config.ANALYTICS_API_URLS.getAssignedPathAnalytics;
875
+ url = helpers.api.constructAPIUrl(url, { orgId: self.orgId });
876
+
877
+ var queryParams = {
878
+ classid: options.classid,
879
+ assignedpathid: options.assignedPathId,
880
+ ext_assignedpathid: options.ext_assignedpathid,
881
+ productcode: options.productcode
882
+ };
883
+ // Setup request with URL and Params
884
+ var requestAPI = request.get(url).query(queryParams);
885
+
886
+ //Setup token in Authorization header
887
+ requestAPI = helpers.api.setupAPIToken(requestAPI, self.token);
888
+
889
+ // setting up traceid
890
+ if(self.traceid) { requestAPI.set('X-Amzn-Trace-Id', self.traceid); }
891
+
892
+ requestAPI.end(function (error, response) {
893
+ if(error) {
894
+ err = new DLSError(helpers.errors.ERROR_TYPES.API_ERROR, error);
895
+ dfd.reject(err);
896
+ }
897
+ else { dfd.resolve(response.body); }
898
+ });
899
+ }
900
+ else {
901
+ err = {};
902
+ err.message = err.description = 'Mandatory params - classid or productcode not found in request options.';
903
+ err = new DLSError(helpers.errors.ERROR_TYPES.SDK_ERROR, err);
904
+ dfd.reject(err);
905
+ }
906
+ }
907
+ return dfd.promise;
908
+ }
909
+
910
+ /**
911
+ * Wiki Link for SDK params
912
+ * https://github.com/comprodls/comprodls-sdk-js/wiki/06_ANALYTICS-Adapter#getmyassignedpathsofclassparams
913
+ */
914
+ function getMyAssignedPathsOfClass(options) {
915
+ var self = this;
916
+ // Initializing promise
917
+ var dfd = q.defer();
918
+ var err = helpers.validations.isAuthenticated(self.orgId, self.token);
919
+ if(err) { dfd.reject(err); }
920
+ else {
921
+ if(options && options.classid && options.userid ) {
922
+
923
+ // Passed all validations, Contruct API url
924
+ var url = self.config.DEFAULT_HOSTS.ANALYTICS + self.config.ANALYTICS_API_URLS.getMyAssignedPathsOfClass;
925
+ url = helpers.api.constructAPIUrl(url, { orgId: self.orgId });
926
+ var queryParams = { userid: options.userid, classid: options.classid };
927
+ if(options.progress) { queryParams.progress = options.progress; }
928
+ if(options.group) { queryParams.group = options.group; }
929
+ if(options.expiredView) { queryParams.expiredView = options.expiredView; }
930
+ if(options.status_not_started) { queryParams.status_not_started = options.status_not_started; }
931
+ if(options.status_active) { queryParams.status_active = options.status_active; }
932
+ if(options.status_expired) { queryParams.status_expired = options.status_expired; }
933
+
934
+ // Setup request with URL and Params
935
+ var requestAPI = request.get(url).query(queryParams);
936
+ //Setup token in Authorization header
937
+ requestAPI = helpers.api.setupAPIToken(requestAPI, self.token);
938
+
939
+ // setting up traceid
940
+ if(self.traceid) { requestAPI.set('X-Amzn-Trace-Id', self.traceid); }
941
+
942
+ requestAPI
943
+ .agent(keepaliveAgent)
944
+ .end(function (error, response) {
945
+ if(error) {
946
+ err = new DLSError(helpers.errors.ERROR_TYPES.API_ERROR, error);
947
+ dfd.reject(err);
948
+ }
949
+ else { dfd.resolve(response.body); }
950
+ });
951
+ }
952
+ else {
953
+ err = {};
954
+ err.message = err.description = 'Mandatory params - classid, userid not found in ' +
955
+ 'request options.';
956
+ err = new DLSError(helpers.errors.ERROR_TYPES.SDK_ERROR, err);
957
+ dfd.reject(err);
958
+ }
959
+ }
960
+ return dfd.promise;
961
+ }
962
+
963
+ /**
964
+ * Wiki Link for SDK params
965
+ * https://github.com/comprodls/comprodls-sdk-js/wiki/06_ANALYTICS-Adapter#getuserassignedpathsofclassparams
966
+ */
967
+ function getUserAssignedPathsOfClass(options) {
968
+ var self = this;
969
+ // Initializing promise
970
+ var dfd = q.defer();
971
+ var err = helpers.validations.isAuthenticated(self.orgId, self.token);
972
+ if(err) { dfd.reject(err); }
973
+ else {
974
+ if(options && options.classid && options.userid ) {
975
+
976
+ // Passed all validations, Contruct API url
977
+ var url = self.config.DEFAULT_HOSTS.ANALYTICS + self.config.ANALYTICS_API_URLS.getMyAssignedPathsOfClass;
978
+ url = helpers.api.constructAPIUrl(url, { orgId: self.orgId });
979
+
980
+ var queryParams = { userid: options.userid, classid: options.classid };
981
+ if(options.progress) { queryParams.progress = options.progress; }
982
+ if(options.group) { queryParams.group = options.group; }
983
+ if(options.expiredView) { queryParams.expiredView = options.expiredView; }
984
+ if(options.status_not_started) { queryParams.status_not_started = options.status_not_started; }
985
+ if(options.status_active) { queryParams.status_active = options.status_active; }
986
+ if(options.status_expired) { queryParams.status_expired = options.status_expired; }
987
+
988
+ // Setup request with URL and Params
989
+ var requestAPI = request.get(url).query(queryParams);
990
+ //Setup token in Authorization header
991
+ requestAPI = helpers.api.setupAPIToken(requestAPI, self.token);
992
+
993
+ // setting up traceid
994
+ if(self.traceid) { requestAPI.set('X-Amzn-Trace-Id', self.traceid); }
995
+
996
+ requestAPI
997
+ .agent(keepaliveAgent)
998
+ .end(function (error, response) {
999
+ if(error) {
1000
+ err = new DLSError(helpers.errors.ERROR_TYPES.API_ERROR, error);
1001
+ dfd.reject(err);
1002
+ }
1003
+ else { dfd.resolve(response.body); }
1004
+ });
1005
+ }
1006
+ else {
1007
+ err = {};
1008
+ err.message = err.description = 'Mandatory params - classid, userid not found in ' +
1009
+ 'request options.';
1010
+ err = new DLSError(helpers.errors.ERROR_TYPES.SDK_ERROR, err);
1011
+ dfd.reject(err);
1012
+ }
1013
+ }
1014
+ return dfd.promise;
1015
+ }
1016
+
1017
+ /**
1018
+ * Wiki Link for SDK params
1019
+ * https://github.com/comprodls/comprodls-sdk-js/wiki/06_ANALYTICS-Adapter#getmyparticularassignedpathofclassparams
1020
+ */
1021
+ function getMyParticularAssignedPathOfClass(options) {
1022
+ var self = this;
1023
+ // Initializing promise
1024
+ var dfd = q.defer();
1025
+ var err = helpers.validations.isAuthenticated(self.orgId, self.token);
1026
+ if(err) { dfd.reject(err); }
1027
+ else {
1028
+ if(options && options.classid && options.userid ) {
1029
+
1030
+ // Passed all validations, Contruct API url
1031
+ var url = self.config.DEFAULT_HOSTS.ANALYTICS + self.config.ANALYTICS_API_URLS.getMyAssignedPathsOfClass;
1032
+ url = helpers.api.constructAPIUrl(url, { orgId: self.orgId });
1033
+
1034
+ var queryParams = {
1035
+ assignedpathid: options.assignedPathId, classid: options.classid, userid: options.userid
1036
+ };
1037
+
1038
+ if(options.progress) { queryParams.progress = options.progress; }
1039
+ if(options.group) { queryParams.group = options.group; }
1040
+ if(options.assignedpathid) { queryParams.assignedpathid = options.assignedpathid; }
1041
+ if(options.ext_assignedpathid) {queryParams.ext_assignedpathid = options.ext_assignedpathid;}
1042
+ if(options.expiredView) { queryParams.expiredView = options.expiredView; }
1043
+
1044
+ // Setup request with URL and Params
1045
+ var requestAPI = request.get(url).query(queryParams);
1046
+ //Setup token in Authorization header
1047
+ requestAPI = helpers.api.setupAPIToken(requestAPI, self.token);
1048
+
1049
+ // setting up traceid
1050
+ if(self.traceid) { requestAPI.set('X-Amzn-Trace-Id', self.traceid); }
1051
+
1052
+ requestAPI.end(function (error, response) {
1053
+ if(error) {
1054
+ err = new DLSError(helpers.errors.ERROR_TYPES.API_ERROR, error);
1055
+ dfd.reject(err);
1056
+ }
1057
+ else { dfd.resolve(response.body); }
1058
+ });
1059
+ }
1060
+ else {
1061
+ err = {};
1062
+ err.message = err.description = 'Mandatory params - classid, userid not found in ' +
1063
+ 'request options.';
1064
+ err = new DLSError(helpers.errors.ERROR_TYPES.SDK_ERROR, err);
1065
+ dfd.reject(err);
1066
+ }
1067
+ }
1068
+ return dfd.promise;
1069
+ }
1070
+
1071
+ /**
1072
+ * Wiki Link for SDK params
1073
+ * https://github.com/comprodls/comprodls-sdk-js/wiki/06_ANALYTICS-Adapter#getparticularassignedpathofclassparams
1074
+ */
1075
+ function getParticularAssignedPathOfClass(options) {
1076
+ var self = this;
1077
+ // Initializing promise
1078
+ var dfd = q.defer();
1079
+ var err = helpers.validations.isAuthenticated(self.orgId, self.token);
1080
+ if(err) { dfd.reject(err); }
1081
+ else {
1082
+ if(options && options.classid && (options.assignedpathid || options.ext_assignedpathid)) {
1083
+
1084
+ // Passed all validations, Contruct API url
1085
+ var url = self.config.DEFAULT_HOSTS.ANALYTICS +
1086
+ self.config.ANALYTICS_API_URLS.getAllAssignedPathsOfClass;
1087
+ url = helpers.api.constructAPIUrl(url, { orgId: self.orgId });
1088
+
1089
+ var queryParams = { classid: options.classid };
1090
+ if(options.assignedpathid) { queryParams.assignedpathid = options.assignedpathid; }
1091
+ if(options.ext_assignedpathid) {queryParams.ext_assignedpathid = options.ext_assignedpathid;}
1092
+
1093
+ // Setup request with URL and Params
1094
+ var requestAPI = request.get(url).query(queryParams);
1095
+
1096
+ // Setup token in Authorization header
1097
+ requestAPI = helpers.api.setupAPIToken(requestAPI, self.token);
1098
+
1099
+ // Setting up traceid
1100
+ if(self.traceid) { requestAPI.set('X-Amzn-Trace-Id', self.traceid); }
1101
+
1102
+ requestAPI
1103
+ .agent(keepaliveAgent)
1104
+ .end(function (error, response) {
1105
+ if(error) {
1106
+ err = new DLSError(helpers.errors.ERROR_TYPES.API_ERROR, error);
1107
+ dfd.reject(err);
1108
+ }
1109
+ else { dfd.resolve(response.body.entities[0]); }
1110
+ });
1111
+ }
1112
+ else {
1113
+ err = {};
1114
+ err.message = err.description = 'Mandatory params - \'classid\', ' +
1115
+ '\'assignedpathid\'/\'ext_assignedpathid\' not found in request options.';
1116
+ err = new DLSError(helpers.errors.ERROR_TYPES.SDK_ERROR, err);
1117
+ dfd.reject(err);
1118
+ }
1119
+ }
1120
+ return dfd.promise;
1121
+ }
1122
+
1123
+ /**
1124
+ * Wiki Link for SDK params
1125
+ * https://github.com/comprodls/comprodls-sdk-js/wiki/06_ANALYTICS-Adapter#gettimeseriesanalyticsparams
1126
+ */
1127
+ function getTimeseriesAnalytics(options) {
1128
+ var self = this;
1129
+ var dfd = q.defer();
1130
+ var err;
1131
+
1132
+ if(options && options.query) {
1133
+ //Passed all validations, Construct API url
1134
+ var url = self.config.DEFAULT_HOSTS.ANALYTICS + self.config.ANALYTICS_API_URLS.timeseriesAnalytics;
1135
+
1136
+ // Contruct parameters
1137
+ var params = {
1138
+ query: options.query
1139
+ };
1140
+
1141
+ if(options.cursor) { params.cursor = options.cursor; }
1142
+ //Setup request with URL and Params
1143
+ var requestAPI = request.get(url).query(params);
1144
+
1145
+ if(self.traceid) { requestAPI.set('X-Amzn-Trace-Id', self.traceid); }
1146
+
1147
+ requestAPI
1148
+ .agent(keepaliveAgent)
1149
+ .end(function (error, response) {
1150
+ if(error) {
1151
+ err = new DLSError(helpers.errors.ERROR_TYPES.API_ERROR, error);
1152
+ dfd.reject(err);
1153
+ }
1154
+ else { dfd.resolve(response.body); }
1155
+ });
1156
+ }
1157
+ else {
1158
+ err = {};
1159
+ err.message = err.description = 'Mandatory params query not found in request options.';
1160
+ err = new DLSError(helpers.errors.ERROR_TYPES.SDK_ERROR, err);
1161
+ dfd.reject(err);
1162
+ }
1163
+ return dfd.promise;
1164
+ }
1165
+
1166
+ /**
1167
+ * Wiki Link for SDK params
1168
+ * https://github.com/comprodls/comprodls-sdk-js/wiki/06_ANALYTICS-Adapter#postprogresstimeseriesparams
1169
+ */
1170
+ function postProgressTimeseries(options) {
1171
+ var self = this;
1172
+ var dfd = q.defer();
1173
+ var err;
1174
+
1175
+ if(options && options.body && options.body.query) {
1176
+ //Passed all validations, Construct API url
1177
+ var url = self.config.DEFAULT_HOSTS.ANALYTICS + self.config.ANALYTICS_API_URLS.timeseriesAnalytics;
1178
+
1179
+ //Setup request with URL and Params
1180
+ var requestAPI = request.post(url).send(options.body);
1181
+
1182
+ if(options.cursor) {
1183
+ var params = { cursor: options.cursor };
1184
+ requestAPI.query(params);
1185
+ };
1186
+
1187
+ if(self.traceid) { requestAPI.set('X-Amzn-Trace-Id', self.traceid); }
1188
+
1189
+ requestAPI
1190
+ .agent(keepaliveAgent)
1191
+ .end(function (error, response) {
1192
+ if(error) {
1193
+ err = new DLSError(helpers.errors.ERROR_TYPES.API_ERROR, error);
1194
+ dfd.reject(err);
1195
+ }
1196
+ else { dfd.resolve(response.body); }
1197
+ });
1198
+ }
1199
+ else {
1200
+ err = {};
1201
+ err.message = err.description = 'Mandatory options.body.query not found in request options.';
1202
+ err = new DLSError(helpers.errors.ERROR_TYPES.SDK_ERROR, err);
1203
+ dfd.reject(err);
1204
+ }
1205
+ return dfd.promise;
1206
+ }
1207
+
1208
+ /**
1209
+ * Wiki Link for SDK params
1210
+ * https://github.com/comprodls/comprodls-sdk-js/wiki/06_ANALYTICS-Adapter#getclasscustomcomponentrecordparams
1211
+ */
1212
+ function getClassCustomComponentRecord(options) {
1213
+ var self = this;
1214
+
1215
+ //Initializing DFD
1216
+ var dfd = q.defer(), err = {};
1217
+
1218
+ // Validations
1219
+ if(options && options.classid) {
1220
+ err = helpers.validations.isAuthenticated(self.orgId, self.token);
1221
+ if(err){ dfd.reject(err); }
1222
+ else {
1223
+ // Passed all validations, Constructing URL
1224
+ var url = self.config.DEFAULT_HOSTS['ANALYTICS'] + self.config.ANALYTICS_API_URLS.getClassCustomComponentRecord;
1225
+ url = helpers.api.constructAPIUrl(url, { orgId: self.orgId });
1226
+
1227
+ // Setup Query Params
1228
+ var queryParams = {
1229
+ classid: options.classid
1230
+ };
1231
+
1232
+ if(options['custom_component_code']) {
1233
+ queryParams['custom_component_code'] = options['custom_component_code'];
1234
+ }
1235
+
1236
+ // Setup Request with url and params
1237
+ var requestAPI = request.get(url).query(queryParams);
1238
+ // Setup token in Authorization Header
1239
+ requestAPI = helpers.api.setupAPIToken(requestAPI, self.token);
1240
+
1241
+ // setting up traceid
1242
+ if(self.traceid) { requestAPI.set('X-Amzn-Trace-Id', self.traceid); }
1243
+
1244
+ // Call GET CLASS CUSTOM COMPONENT RECORD ITEM
1245
+ requestAPI.end(function(error, response) {
1246
+ if(error) {
1247
+ err = new DLSError(helpers.errors.ERROR_TYPES.API_ERROR, error);
1248
+ err.message = error.response.res.text;
1249
+ dfd.reject(err);
1250
+ } else {
1251
+ dfd.resolve(response.body);
1252
+ }
1253
+ });
1254
+ }
1255
+ } else {
1256
+ err.message = err.description = 'Required parameter classid not found in request options.';
1257
+ err = new DLSError(helpers.errors.ERROR_TYPES.SDK_ERROR, err);
1258
+ dfd.reject(err);
1259
+ }
1260
+ return dfd.promise;
1261
+ }
1262
+
1263
+ /**
1264
+ * Wiki Link for SDK params
1265
+ * https://github.com/comprodls/comprodls-sdk-js/wiki/06_ANALYTICS-Adapter#getclasscustomcomponentusersubmissionparams
1266
+ */
1267
+ function getClassCustomComponentUserSubmission(options) {
1268
+ var self = this;
1269
+
1270
+ //Initializing DFD
1271
+ var dfd = q.defer(), err = {};
1272
+
1273
+ // Validations
1274
+ if(options && options.classid && options['custom_component_code'] &&
1275
+ options.userid && options['item_code']) {
1276
+ err = helpers.validations.isAuthenticated(self.orgId, self.token);
1277
+ if(err){ dfd.reject(err); }
1278
+ else {
1279
+ // Passed all validations, Constructing URL
1280
+ var url = self.config.DEFAULT_HOSTS['ANALYTICS'] + self.config.ANALYTICS_API_URLS.getClassCustomComponentUserSubmission;
1281
+ url = helpers.api.constructAPIUrl(url, { orgId: self.orgId });
1282
+
1283
+ // Setup Query Params
1284
+ var queryParams = {
1285
+ classid: options.classid,
1286
+ userid: options.userid,
1287
+ 'custom_component_code': options['custom_component_code'],
1288
+ 'item_code': options['item_code']
1289
+ };
1290
+
1291
+ // Setup Request with url and params
1292
+ var requestAPI = request.get(url).query(queryParams);
1293
+ // Setup token in Authorization Header
1294
+ requestAPI = helpers.api.setupAPIToken(requestAPI, self.token);
1295
+
1296
+ // setting up traceid
1297
+ if(self.traceid) { requestAPI.set('X-Amzn-Trace-Id', self.traceid); }
1298
+
1299
+ // Call GET CLASS CUSTOM COMPONENT SUBMISSION OF A USER ON AN ITEM
1300
+ requestAPI.end(function(error, response) {
1301
+ if(error) {
1302
+ err = new DLSError(helpers.errors.ERROR_TYPES.API_ERROR, error);
1303
+ err.message = error.response.res.text;
1304
+ dfd.reject(err);
1305
+ } else {
1306
+ dfd.resolve(response.body);
1307
+ }
1308
+ });
1309
+ }
1310
+ } else {
1311
+ err.message = err.description = 'Required parameter classid or ' +
1312
+ 'custom-component-code or ' + 'userid or ' + 'item-code not found in request options.';
1313
+ err = new DLSError(helpers.errors.ERROR_TYPES.SDK_ERROR, err);
1314
+ dfd.reject(err);
1315
+ }
1316
+ return dfd.promise;
1317
+ }
1318
+
1319
+ /**
1320
+ * Wiki Link for SDK params
1321
+ * https://github.com/comprodls/comprodls-sdk-js/wiki/06_ANALYTICS-Adapter#getcrossproductaggregationparams
1322
+ */
1323
+ function getCrossProductAggregation(options) {
1324
+ var self = this;
1325
+
1326
+ //Initializing DFD
1327
+ var dfd = q.defer(), err = {};
1328
+
1329
+ // Validations
1330
+ if(options && options.classid) {
1331
+ err = helpers.validations.isAuthenticated(self.orgId, self.token);
1332
+ if(err){ dfd.reject(err); }
1333
+ else {
1334
+ // Passed all validations, Constructing URL
1335
+ var url = self.config.DEFAULT_HOSTS['ANALYTICS'] + self.config.ANALYTICS_API_URLS.getCrossProductAggregation;
1336
+ url = helpers.api.constructAPIUrl(url, { orgId: self.orgId });
1337
+
1338
+ // Setup Query Params
1339
+ var queryParams = { classid: options.classid };
1340
+
1341
+ if(options.userid) { queryParams.userid = options.userid; }
1342
+
1343
+ // Setup Request with url and params
1344
+ var requestAPI = request.get(url).query(queryParams);
1345
+ // Setup token in Authorization Header
1346
+ requestAPI = helpers.api.setupAPIToken(requestAPI, self.token);
1347
+
1348
+ // setting up traceid
1349
+ if(self.traceid) { requestAPI.set('X-Amzn-Trace-Id', self.traceid); }
1350
+
1351
+ // Call GET CROSS PRODUCT AGGREGATION RECORD FOR A CLASS
1352
+ requestAPI.end(function(error, response) {
1353
+ if(error) {
1354
+ err = new DLSError(helpers.errors.ERROR_TYPES.API_ERROR, error);
1355
+ dfd.reject(err);
1356
+ } else { dfd.resolve(response.body); }
1357
+ });
1358
+ }
1359
+ } else {
1360
+ err.message = err.description = 'Required parameter classid not found in request options.';
1361
+ err = new DLSError(helpers.errors.ERROR_TYPES.SDK_ERROR, err);
1362
+ dfd.reject(err);
1363
+ }
1364
+ return dfd.promise;
1365
+ }