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,389 +1,389 @@
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 attempts Adaptor
23
- * Functions for calling attempts.
24
- ************************************************************/
25
-
26
- var q = require('q');
27
- var request = require('superagent');
28
-
29
- var helpers = require('../../helpers');
30
- var DLSError = helpers.errors.DLSError;
31
-
32
- module.exports = attempts;
33
-
34
- // Attempts Adaptor Constructor
35
- function attempts() {
36
- return {
37
- getUserAllAttemptsForActivity: getUserAllAttemptsForActivity.bind(this),
38
- createUserAttemptForActivity: createUserAttemptForActivity.bind(this),
39
- getUserAttemptStatsForActivity: getUserAttemptStatsForActivity.bind(this),
40
- getUserAttemptForActivity: getUserAttemptForActivity.bind(this),
41
- getUserFirstAttemptForActivity: getUserFirstAttemptForActivity.bind(this),
42
- getUserLastAttemptForActivity: getUserLastAttemptForActivity.bind(this),
43
- updateUserAttemptForActivity: updateUserAttemptForActivity.bind(this),
44
- getUserActivityMeta: getUserActivityMeta.bind(this)
45
- };
46
- }
47
-
48
- /*********************************
49
- * Public Function definitions
50
- **********************************/
51
-
52
- /**
53
- * Wiki Link for SDK params
54
- * https://github.com/comprodls/comprodls-sdk-js/wiki/23_Attempts-Adapter#getuserallattemptsforactivityparams
55
- */
56
- function getUserAllAttemptsForActivity(options) {
57
- var self = this;
58
- var dfd = q.defer();
59
- var err;
60
-
61
- if(options && options.userid && options.activityid) {
62
- //Passed all validations, Construct API url
63
- var url = self.config.DEFAULT_HOSTS.ATTEMPTS + self.config.ATTEMPTS_API_URLS.userAttempts;
64
- url = helpers.api.constructAPIUrl(url, { orgId: self.orgId, userId: options.userid, activityId: options.activityid });
65
-
66
- // Contruct parameters
67
- var params = {};
68
- if(options.allorgs) { params.allorgs = options.allorgs; }
69
- if(options.classid) { params.classid = options.classid; }
70
- if(options.assignmentid) { params.assignmentid = options.assignmentid; }
71
- if(options.productcode) { params.productcode = options.productcode; }
72
- if(options.cursor) { params.cursor = options.cursor; }
73
- if(options.limit) { params.limit = options.limit; }
74
- if(options.sortOrder) { params.sortOrder = options.sortOrder; }
75
-
76
- //Setup request with URL and Params
77
- var requestAPI = request.get(url).query(params);
78
-
79
- if(self.traceid) { requestAPI.set('X-Amzn-Trace-Id', self.traceid); }
80
-
81
- requestAPI.end(function (err, response) {
82
- if (err) {
83
- err = new DLSError(helpers.errors.ERROR_TYPES.API_ERROR, err);
84
- dfd.reject(err);
85
- }
86
- else { dfd.resolve(response.body); }
87
- });
88
- }
89
- else {
90
- err = {};
91
- err.message = err.description = 'Mandatory params - userid or activityid ' +
92
- 'not found in request options.';
93
- err = new DLSError(helpers.errors.ERROR_TYPES.SDK_ERROR, err);
94
- dfd.reject(err);
95
- }
96
- return dfd.promise;
97
- }
98
-
99
- /**
100
- * Wiki Link for SDK params
101
- * https://github.com/comprodls/comprodls-sdk-js/wiki/23_Attempts-Adapter#createuserattemptforactivityparams
102
- */
103
- function createUserAttemptForActivity(options) {
104
- var self = this;
105
- var dfd = q.defer();
106
- var err;
107
-
108
- if(options && options.userid && options.activityid && options.body) {
109
- //Passed all validations, Construct API url
110
- var url = self.config.DEFAULT_HOSTS.ATTEMPTS + self.config.ATTEMPTS_API_URLS.userAttempts;
111
- url = helpers.api.constructAPIUrl(url, { orgId: self.orgId, userId: options.userid, activityId: options.activityid });
112
-
113
- //Setup request with URL and Body
114
- var requestAPI = request.post(url).send(options.body);
115
-
116
- if(self.traceid) { requestAPI.set('X-Amzn-Trace-Id', self.traceid); }
117
-
118
- requestAPI.end(function (err, response) {
119
- if (err) {
120
- err = new DLSError(helpers.errors.ERROR_TYPES.API_ERROR, err);
121
- dfd.reject(err);
122
- }
123
- else { dfd.resolve(response.body); }
124
- });
125
- }
126
- else {
127
- err = {};
128
- err.message = err.description = 'Mandatory params - userid or activityid or body ' +
129
- 'not found in request options.';
130
- err = new DLSError(helpers.errors.ERROR_TYPES.SDK_ERROR, err);
131
- dfd.reject(err);
132
- }
133
- return dfd.promise;
134
- }
135
-
136
- /**
137
- * Wiki Link for SDK params
138
- * https://github.com/comprodls/comprodls-sdk-js/wiki/23_Attempts-Adapter#getuserattemptstatsforactivityparams
139
- */
140
- function getUserAttemptStatsForActivity(options) {
141
- var self = this;
142
- var dfd = q.defer();
143
- var err;
144
-
145
- if(options && options.userid && options.activityid) {
146
- //Passed all validations, Construct API url
147
- var url = self.config.DEFAULT_HOSTS.ATTEMPTS + self.config.ATTEMPTS_API_URLS.getUserAttemptStatsForActivity;
148
- url = helpers.api.constructAPIUrl(url, { orgId: self.orgId, userId: options.userid, activityId: options.activityid });
149
-
150
- // Contruct parameters
151
- var params = {};
152
- if(options.allorgs) { params.allorgs = options.allorgs; }
153
- if(options.classid) { params.classid = options.classid; }
154
- if(options.assignmentid) { params.assignmentid = options.assignmentid; }
155
-
156
- //Setup request with URL and Params
157
- var requestAPI = request.get(url).query(params);
158
-
159
- if(self.traceid) { requestAPI.set('X-Amzn-Trace-Id', self.traceid); }
160
-
161
- requestAPI.end(function (err, response) {
162
- if (err) {
163
- err = new DLSError(helpers.errors.ERROR_TYPES.API_ERROR, err);
164
- dfd.reject(err);
165
- }
166
- else { dfd.resolve(response.body); }
167
- });
168
- }
169
- else {
170
- err = {};
171
- err.message = err.description = 'Mandatory params - userid or activityid ' +
172
- 'not found in request options.';
173
- err = new DLSError(helpers.errors.ERROR_TYPES.SDK_ERROR, err);
174
- dfd.reject(err);
175
- }
176
- return dfd.promise;
177
- }
178
-
179
- /**
180
- * Wiki Link for SDK params
181
- * https://github.com/comprodls/comprodls-sdk-js/wiki/23_Attempts-Adapter#getuserattemptforactivityparams
182
- */
183
- function getUserAttemptForActivity(options) {
184
- var self = this;
185
- var dfd = q.defer();
186
- var err;
187
-
188
- if(options && options.userid && options.activityid && options.attemptid) {
189
- //Passed all validations, Construct API url
190
- var url = self.config.DEFAULT_HOSTS.ATTEMPTS + self.config.ATTEMPTS_API_URLS.getUserAttemptForActivity;
191
- url = helpers.api.constructAPIUrl(url, { orgId: self.orgId, userId: options.userid, activityId: options.activityid,
192
- attemptId: options.attemptid });
193
-
194
- // Contruct parameters
195
- var params = {};
196
- if(options.details) { params.details = options.details; }
197
-
198
- //Setup request with URL and Params
199
- var requestAPI = request.get(url).query(params);
200
-
201
- if(self.traceid) { requestAPI.set('X-Amzn-Trace-Id', self.traceid); }
202
-
203
- requestAPI.end(function (err, response) {
204
- if (err) {
205
- err = new DLSError(helpers.errors.ERROR_TYPES.API_ERROR, err);
206
- dfd.reject(err);
207
- }
208
- else { dfd.resolve(response.body); }
209
- });
210
- }
211
- else {
212
- err = {};
213
- err.message = err.description = 'Mandatory params - userid or activityid or attemptid ' +
214
- 'not found in request options.';
215
- err = new DLSError(helpers.errors.ERROR_TYPES.SDK_ERROR, err);
216
- dfd.reject(err);
217
- }
218
- return dfd.promise;
219
- }
220
-
221
- /**
222
- * Wiki Link for SDK params
223
- * https://github.com/comprodls/comprodls-sdk-js/wiki/23_Attempts-Adapter#getuserfirstattemptforactivityparams
224
- */
225
- function getUserFirstAttemptForActivity(options) {
226
- var self = this;
227
- var dfd = q.defer();
228
- var err;
229
-
230
- if(options && options.userid && options.activityid) {
231
- //Passed all validations, Construct API url
232
- var url = self.config.DEFAULT_HOSTS.ATTEMPTS + self.config.ATTEMPTS_API_URLS.getUserFirstAttemptForActivity;
233
- url = helpers.api.constructAPIUrl(url, { orgId: self.orgId, userId: options.userid, activityId: options.activityid });
234
-
235
- // Contruct parameters
236
- var params = {};
237
- if(options.details) { params.details = options.details; }
238
- if(options.classid) { params.classid = options.classid; }
239
- if(options.assignmentid) { params.assignmentid = options.assignmentid; }
240
-
241
- //Setup request with URL and Params
242
- var requestAPI = request.get(url).query(params);
243
-
244
- if(self.traceid) { requestAPI.set('X-Amzn-Trace-Id', self.traceid); }
245
-
246
- requestAPI.end(function (err, response) {
247
- if (err) {
248
- err = new DLSError(helpers.errors.ERROR_TYPES.API_ERROR, err);
249
- dfd.reject(err);
250
- }
251
- else { dfd.resolve(response.body); }
252
- });
253
- }
254
- else {
255
- err = {};
256
- err.message = err.description = 'Mandatory params - userid or activityid ' +
257
- 'not found in request options.';
258
- err = new DLSError(helpers.errors.ERROR_TYPES.SDK_ERROR, err);
259
- dfd.reject(err);
260
- }
261
- return dfd.promise;
262
- }
263
-
264
- /**
265
- * Wiki Link for SDK params
266
- * https://github.com/comprodls/comprodls-sdk-js/wiki/23_Attempts-Adapter#getuserlastattemptforactivityparams
267
- */
268
- function getUserLastAttemptForActivity(options) {
269
- var self = this;
270
- var dfd = q.defer();
271
- var err;
272
-
273
- if(options && options.userid && options.activityid) {
274
- //Passed all validations, Construct API url
275
- var url = self.config.DEFAULT_HOSTS.ATTEMPTS + self.config.ATTEMPTS_API_URLS.getUserLastAttemptForActivity;
276
- url = helpers.api.constructAPIUrl(url, { orgId: self.orgId, userId: options.userid, activityId: options.activityid });
277
-
278
- // Contruct parameters
279
- var params = {};
280
- if(options.details) { params.details = options.details; }
281
- if(options.classid) { params.classid = options.classid; }
282
- if(options.assignmentid) { params.assignmentid = options.assignmentid; }
283
-
284
- //Setup request with URL and Params
285
- var requestAPI = request.get(url).query(params);
286
- console.log(url, params, requestAPI);
287
- if(self.traceid) { requestAPI.set('X-Amzn-Trace-Id', self.traceid); }
288
-
289
- requestAPI.end(function (err, response) {
290
- if (err) {
291
- err = new DLSError(helpers.errors.ERROR_TYPES.API_ERROR, err);
292
- dfd.reject(err);
293
- }
294
- else { dfd.resolve(response.body); }
295
- });
296
- }
297
- else {
298
- err = {};
299
- err.message = err.description = 'Mandatory params - userid or activityid ' +
300
- 'not found in request options.';
301
- err = new DLSError(helpers.errors.ERROR_TYPES.SDK_ERROR, err);
302
- dfd.reject(err);
303
- }
304
- return dfd.promise;
305
- }
306
-
307
- /**
308
- * Wiki Link for SDK params
309
- * https://github.com/comprodls/comprodls-sdk-js/wiki/23_Attempts-Adapter#updateuserattemptforactivityparams
310
- */
311
- function updateUserAttemptForActivity(options) {
312
- var self = this;
313
- var dfd = q.defer();
314
- var err;
315
-
316
- if(options && options.userid && options.activityid && options.attemptid && options.body) {
317
- //Passed all validations, Construct API url
318
- var url = self.config.DEFAULT_HOSTS.ATTEMPTS + self.config.ATTEMPTS_API_URLS.getUserAttemptForActivity;
319
- url = helpers.api.constructAPIUrl(url, { orgId: self.orgId, userId: options.userid, activityId: options.activityid,
320
- attemptId: options.attemptid });
321
-
322
- var params = options.body;
323
- //Setup request with URL and Params
324
- var requestAPI = request.put(url)
325
- .set('Content-Type', 'application/json')
326
- .set('Accept', 'application/json')
327
- .send(params);
328
-
329
- if(self.traceid) { requestAPI.set('X-Amzn-Trace-Id', self.traceid); }
330
-
331
- requestAPI.end(function (err, response) {
332
- if (err) {
333
- err = new DLSError(helpers.errors.ERROR_TYPES.API_ERROR, err);
334
- dfd.reject(err);
335
- }
336
- else { dfd.resolve(response.body); }
337
- });
338
- }
339
- else {
340
- err = {};
341
- err.message = err.description = 'Mandatory params - userid or activityid or attemptid or body ' +
342
- 'not found in request options.';
343
- err = new DLSError(helpers.errors.ERROR_TYPES.SDK_ERROR, err);
344
- dfd.reject(err);
345
- }
346
- return dfd.promise;
347
- }
348
-
349
- /**
350
- * Wiki Link for SDK params
351
- * https://github.com/comprodls/comprodls-sdk-js/wiki/23_Attempts-Adapter#getuseractivitymetaparams
352
- */
353
- function getUserActivityMeta(options) {
354
- var self = this;
355
- var dfd = q.defer();
356
- var err;
357
-
358
- if(options && options.userid && options.activityid) {
359
- //Passed all validations, Construct API url
360
- var url = self.config.DEFAULT_HOSTS.ATTEMPTS + self.config.ATTEMPTS_API_URLS.getUserActivityMeta;
361
- url = helpers.api.constructAPIUrl(url, { orgId: self.orgId, userId: options.userid, activityId: options.activityid });
362
-
363
- // Contruct parameters
364
- var params = {};
365
- if(options.classid) { params.classid = options.classid; }
366
- if(options.assignmentid) { params.assignmentid = options.assignmentid; }
367
-
368
- //Setup request with URL and Params
369
- var requestAPI = request.get(url).query(params);
370
-
371
- if(self.traceid) { requestAPI.set('X-Amzn-Trace-Id', self.traceid); }
372
-
373
- requestAPI.end(function (err, response) {
374
- if (err) {
375
- err = new DLSError(helpers.errors.ERROR_TYPES.API_ERROR, err);
376
- dfd.reject(err);
377
- }
378
- else { dfd.resolve(response.body); }
379
- });
380
- }
381
- else {
382
- err = {};
383
- err.message = err.description = 'Mandatory params - userid or activityid ' +
384
- 'not found in request options.';
385
- err = new DLSError(helpers.errors.ERROR_TYPES.SDK_ERROR, err);
386
- dfd.reject(err);
387
- }
388
- return dfd.promise;
389
- }
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 attempts Adaptor
23
+ * Functions for calling attempts.
24
+ ************************************************************/
25
+
26
+ var q = require('q');
27
+ var request = require('superagent');
28
+
29
+ var helpers = require('../../helpers');
30
+ var DLSError = helpers.errors.DLSError;
31
+
32
+ module.exports = attempts;
33
+
34
+ // Attempts Adaptor Constructor
35
+ function attempts() {
36
+ return {
37
+ getUserAllAttemptsForActivity: getUserAllAttemptsForActivity.bind(this),
38
+ createUserAttemptForActivity: createUserAttemptForActivity.bind(this),
39
+ getUserAttemptStatsForActivity: getUserAttemptStatsForActivity.bind(this),
40
+ getUserAttemptForActivity: getUserAttemptForActivity.bind(this),
41
+ getUserFirstAttemptForActivity: getUserFirstAttemptForActivity.bind(this),
42
+ getUserLastAttemptForActivity: getUserLastAttemptForActivity.bind(this),
43
+ updateUserAttemptForActivity: updateUserAttemptForActivity.bind(this),
44
+ getUserActivityMeta: getUserActivityMeta.bind(this)
45
+ };
46
+ }
47
+
48
+ /*********************************
49
+ * Public Function definitions
50
+ **********************************/
51
+
52
+ /**
53
+ * Wiki Link for SDK params
54
+ * https://github.com/comprodls/comprodls-sdk-js/wiki/23_Attempts-Adapter#getuserallattemptsforactivityparams
55
+ */
56
+ function getUserAllAttemptsForActivity(options) {
57
+ var self = this;
58
+ var dfd = q.defer();
59
+ var err;
60
+
61
+ if(options && options.userid && options.activityid) {
62
+ //Passed all validations, Construct API url
63
+ var url = self.config.DEFAULT_HOSTS.ATTEMPTS + self.config.ATTEMPTS_API_URLS.userAttempts;
64
+ url = helpers.api.constructAPIUrl(url, { orgId: self.orgId, userId: options.userid, activityId: options.activityid });
65
+
66
+ // Contruct parameters
67
+ var params = {};
68
+ if(options.allorgs) { params.allorgs = options.allorgs; }
69
+ if(options.classid) { params.classid = options.classid; }
70
+ if(options.assignmentid) { params.assignmentid = options.assignmentid; }
71
+ if(options.productcode) { params.productcode = options.productcode; }
72
+ if(options.cursor) { params.cursor = options.cursor; }
73
+ if(options.limit) { params.limit = options.limit; }
74
+ if(options.sortOrder) { params.sortOrder = options.sortOrder; }
75
+
76
+ //Setup request with URL and Params
77
+ var requestAPI = request.get(url).query(params);
78
+
79
+ if(self.traceid) { requestAPI.set('X-Amzn-Trace-Id', self.traceid); }
80
+
81
+ requestAPI.end(function (err, response) {
82
+ if (err) {
83
+ err = new DLSError(helpers.errors.ERROR_TYPES.API_ERROR, err);
84
+ dfd.reject(err);
85
+ }
86
+ else { dfd.resolve(response.body); }
87
+ });
88
+ }
89
+ else {
90
+ err = {};
91
+ err.message = err.description = 'Mandatory params - userid or activityid ' +
92
+ 'not found in request options.';
93
+ err = new DLSError(helpers.errors.ERROR_TYPES.SDK_ERROR, err);
94
+ dfd.reject(err);
95
+ }
96
+ return dfd.promise;
97
+ }
98
+
99
+ /**
100
+ * Wiki Link for SDK params
101
+ * https://github.com/comprodls/comprodls-sdk-js/wiki/23_Attempts-Adapter#createuserattemptforactivityparams
102
+ */
103
+ function createUserAttemptForActivity(options) {
104
+ var self = this;
105
+ var dfd = q.defer();
106
+ var err;
107
+
108
+ if(options && options.userid && options.activityid && options.body) {
109
+ //Passed all validations, Construct API url
110
+ var url = self.config.DEFAULT_HOSTS.ATTEMPTS + self.config.ATTEMPTS_API_URLS.userAttempts;
111
+ url = helpers.api.constructAPIUrl(url, { orgId: self.orgId, userId: options.userid, activityId: options.activityid });
112
+
113
+ //Setup request with URL and Body
114
+ var requestAPI = request.post(url).send(options.body);
115
+
116
+ if(self.traceid) { requestAPI.set('X-Amzn-Trace-Id', self.traceid); }
117
+
118
+ requestAPI.end(function (err, response) {
119
+ if (err) {
120
+ err = new DLSError(helpers.errors.ERROR_TYPES.API_ERROR, err);
121
+ dfd.reject(err);
122
+ }
123
+ else { dfd.resolve(response.body); }
124
+ });
125
+ }
126
+ else {
127
+ err = {};
128
+ err.message = err.description = 'Mandatory params - userid or activityid or body ' +
129
+ 'not found in request options.';
130
+ err = new DLSError(helpers.errors.ERROR_TYPES.SDK_ERROR, err);
131
+ dfd.reject(err);
132
+ }
133
+ return dfd.promise;
134
+ }
135
+
136
+ /**
137
+ * Wiki Link for SDK params
138
+ * https://github.com/comprodls/comprodls-sdk-js/wiki/23_Attempts-Adapter#getuserattemptstatsforactivityparams
139
+ */
140
+ function getUserAttemptStatsForActivity(options) {
141
+ var self = this;
142
+ var dfd = q.defer();
143
+ var err;
144
+
145
+ if(options && options.userid && options.activityid) {
146
+ //Passed all validations, Construct API url
147
+ var url = self.config.DEFAULT_HOSTS.ATTEMPTS + self.config.ATTEMPTS_API_URLS.getUserAttemptStatsForActivity;
148
+ url = helpers.api.constructAPIUrl(url, { orgId: self.orgId, userId: options.userid, activityId: options.activityid });
149
+
150
+ // Contruct parameters
151
+ var params = {};
152
+ if(options.allorgs) { params.allorgs = options.allorgs; }
153
+ if(options.classid) { params.classid = options.classid; }
154
+ if(options.assignmentid) { params.assignmentid = options.assignmentid; }
155
+
156
+ //Setup request with URL and Params
157
+ var requestAPI = request.get(url).query(params);
158
+
159
+ if(self.traceid) { requestAPI.set('X-Amzn-Trace-Id', self.traceid); }
160
+
161
+ requestAPI.end(function (err, response) {
162
+ if (err) {
163
+ err = new DLSError(helpers.errors.ERROR_TYPES.API_ERROR, err);
164
+ dfd.reject(err);
165
+ }
166
+ else { dfd.resolve(response.body); }
167
+ });
168
+ }
169
+ else {
170
+ err = {};
171
+ err.message = err.description = 'Mandatory params - userid or activityid ' +
172
+ 'not found in request options.';
173
+ err = new DLSError(helpers.errors.ERROR_TYPES.SDK_ERROR, err);
174
+ dfd.reject(err);
175
+ }
176
+ return dfd.promise;
177
+ }
178
+
179
+ /**
180
+ * Wiki Link for SDK params
181
+ * https://github.com/comprodls/comprodls-sdk-js/wiki/23_Attempts-Adapter#getuserattemptforactivityparams
182
+ */
183
+ function getUserAttemptForActivity(options) {
184
+ var self = this;
185
+ var dfd = q.defer();
186
+ var err;
187
+
188
+ if(options && options.userid && options.activityid && options.attemptid) {
189
+ //Passed all validations, Construct API url
190
+ var url = self.config.DEFAULT_HOSTS.ATTEMPTS + self.config.ATTEMPTS_API_URLS.getUserAttemptForActivity;
191
+ url = helpers.api.constructAPIUrl(url, { orgId: self.orgId, userId: options.userid, activityId: options.activityid,
192
+ attemptId: options.attemptid });
193
+
194
+ // Contruct parameters
195
+ var params = {};
196
+ if(options.details) { params.details = options.details; }
197
+
198
+ //Setup request with URL and Params
199
+ var requestAPI = request.get(url).query(params);
200
+
201
+ if(self.traceid) { requestAPI.set('X-Amzn-Trace-Id', self.traceid); }
202
+
203
+ requestAPI.end(function (err, response) {
204
+ if (err) {
205
+ err = new DLSError(helpers.errors.ERROR_TYPES.API_ERROR, err);
206
+ dfd.reject(err);
207
+ }
208
+ else { dfd.resolve(response.body); }
209
+ });
210
+ }
211
+ else {
212
+ err = {};
213
+ err.message = err.description = 'Mandatory params - userid or activityid or attemptid ' +
214
+ 'not found in request options.';
215
+ err = new DLSError(helpers.errors.ERROR_TYPES.SDK_ERROR, err);
216
+ dfd.reject(err);
217
+ }
218
+ return dfd.promise;
219
+ }
220
+
221
+ /**
222
+ * Wiki Link for SDK params
223
+ * https://github.com/comprodls/comprodls-sdk-js/wiki/23_Attempts-Adapter#getuserfirstattemptforactivityparams
224
+ */
225
+ function getUserFirstAttemptForActivity(options) {
226
+ var self = this;
227
+ var dfd = q.defer();
228
+ var err;
229
+
230
+ if(options && options.userid && options.activityid) {
231
+ //Passed all validations, Construct API url
232
+ var url = self.config.DEFAULT_HOSTS.ATTEMPTS + self.config.ATTEMPTS_API_URLS.getUserFirstAttemptForActivity;
233
+ url = helpers.api.constructAPIUrl(url, { orgId: self.orgId, userId: options.userid, activityId: options.activityid });
234
+
235
+ // Contruct parameters
236
+ var params = {};
237
+ if(options.details) { params.details = options.details; }
238
+ if(options.classid) { params.classid = options.classid; }
239
+ if(options.assignmentid) { params.assignmentid = options.assignmentid; }
240
+
241
+ //Setup request with URL and Params
242
+ var requestAPI = request.get(url).query(params);
243
+
244
+ if(self.traceid) { requestAPI.set('X-Amzn-Trace-Id', self.traceid); }
245
+
246
+ requestAPI.end(function (err, response) {
247
+ if (err) {
248
+ err = new DLSError(helpers.errors.ERROR_TYPES.API_ERROR, err);
249
+ dfd.reject(err);
250
+ }
251
+ else { dfd.resolve(response.body); }
252
+ });
253
+ }
254
+ else {
255
+ err = {};
256
+ err.message = err.description = 'Mandatory params - userid or activityid ' +
257
+ 'not found in request options.';
258
+ err = new DLSError(helpers.errors.ERROR_TYPES.SDK_ERROR, err);
259
+ dfd.reject(err);
260
+ }
261
+ return dfd.promise;
262
+ }
263
+
264
+ /**
265
+ * Wiki Link for SDK params
266
+ * https://github.com/comprodls/comprodls-sdk-js/wiki/23_Attempts-Adapter#getuserlastattemptforactivityparams
267
+ */
268
+ function getUserLastAttemptForActivity(options) {
269
+ var self = this;
270
+ var dfd = q.defer();
271
+ var err;
272
+
273
+ if(options && options.userid && options.activityid) {
274
+ //Passed all validations, Construct API url
275
+ var url = self.config.DEFAULT_HOSTS.ATTEMPTS + self.config.ATTEMPTS_API_URLS.getUserLastAttemptForActivity;
276
+ url = helpers.api.constructAPIUrl(url, { orgId: self.orgId, userId: options.userid, activityId: options.activityid });
277
+
278
+ // Contruct parameters
279
+ var params = {};
280
+ if(options.details) { params.details = options.details; }
281
+ if(options.classid) { params.classid = options.classid; }
282
+ if(options.assignmentid) { params.assignmentid = options.assignmentid; }
283
+
284
+ //Setup request with URL and Params
285
+ var requestAPI = request.get(url).query(params);
286
+ console.log(url, params, requestAPI);
287
+ if(self.traceid) { requestAPI.set('X-Amzn-Trace-Id', self.traceid); }
288
+
289
+ requestAPI.end(function (err, response) {
290
+ if (err) {
291
+ err = new DLSError(helpers.errors.ERROR_TYPES.API_ERROR, err);
292
+ dfd.reject(err);
293
+ }
294
+ else { dfd.resolve(response.body); }
295
+ });
296
+ }
297
+ else {
298
+ err = {};
299
+ err.message = err.description = 'Mandatory params - userid or activityid ' +
300
+ 'not found in request options.';
301
+ err = new DLSError(helpers.errors.ERROR_TYPES.SDK_ERROR, err);
302
+ dfd.reject(err);
303
+ }
304
+ return dfd.promise;
305
+ }
306
+
307
+ /**
308
+ * Wiki Link for SDK params
309
+ * https://github.com/comprodls/comprodls-sdk-js/wiki/23_Attempts-Adapter#updateuserattemptforactivityparams
310
+ */
311
+ function updateUserAttemptForActivity(options) {
312
+ var self = this;
313
+ var dfd = q.defer();
314
+ var err;
315
+
316
+ if(options && options.userid && options.activityid && options.attemptid && options.body) {
317
+ //Passed all validations, Construct API url
318
+ var url = self.config.DEFAULT_HOSTS.ATTEMPTS + self.config.ATTEMPTS_API_URLS.getUserAttemptForActivity;
319
+ url = helpers.api.constructAPIUrl(url, { orgId: self.orgId, userId: options.userid, activityId: options.activityid,
320
+ attemptId: options.attemptid });
321
+
322
+ var params = options.body;
323
+ //Setup request with URL and Params
324
+ var requestAPI = request.put(url)
325
+ .set('Content-Type', 'application/json')
326
+ .set('Accept', 'application/json')
327
+ .send(params);
328
+
329
+ if(self.traceid) { requestAPI.set('X-Amzn-Trace-Id', self.traceid); }
330
+
331
+ requestAPI.end(function (err, response) {
332
+ if (err) {
333
+ err = new DLSError(helpers.errors.ERROR_TYPES.API_ERROR, err);
334
+ dfd.reject(err);
335
+ }
336
+ else { dfd.resolve(response.body); }
337
+ });
338
+ }
339
+ else {
340
+ err = {};
341
+ err.message = err.description = 'Mandatory params - userid or activityid or attemptid or body ' +
342
+ 'not found in request options.';
343
+ err = new DLSError(helpers.errors.ERROR_TYPES.SDK_ERROR, err);
344
+ dfd.reject(err);
345
+ }
346
+ return dfd.promise;
347
+ }
348
+
349
+ /**
350
+ * Wiki Link for SDK params
351
+ * https://github.com/comprodls/comprodls-sdk-js/wiki/23_Attempts-Adapter#getuseractivitymetaparams
352
+ */
353
+ function getUserActivityMeta(options) {
354
+ var self = this;
355
+ var dfd = q.defer();
356
+ var err;
357
+
358
+ if(options && options.userid && options.activityid) {
359
+ //Passed all validations, Construct API url
360
+ var url = self.config.DEFAULT_HOSTS.ATTEMPTS + self.config.ATTEMPTS_API_URLS.getUserActivityMeta;
361
+ url = helpers.api.constructAPIUrl(url, { orgId: self.orgId, userId: options.userid, activityId: options.activityid });
362
+
363
+ // Contruct parameters
364
+ var params = {};
365
+ if(options.classid) { params.classid = options.classid; }
366
+ if(options.assignmentid) { params.assignmentid = options.assignmentid; }
367
+
368
+ //Setup request with URL and Params
369
+ var requestAPI = request.get(url).query(params);
370
+
371
+ if(self.traceid) { requestAPI.set('X-Amzn-Trace-Id', self.traceid); }
372
+
373
+ requestAPI.end(function (err, response) {
374
+ if (err) {
375
+ err = new DLSError(helpers.errors.ERROR_TYPES.API_ERROR, err);
376
+ dfd.reject(err);
377
+ }
378
+ else { dfd.resolve(response.body); }
379
+ });
380
+ }
381
+ else {
382
+ err = {};
383
+ err.message = err.description = 'Mandatory params - userid or activityid ' +
384
+ 'not found in request options.';
385
+ err = new DLSError(helpers.errors.ERROR_TYPES.SDK_ERROR, err);
386
+ dfd.reject(err);
387
+ }
388
+ return dfd.promise;
389
+ }