comprodls-sdk 2.12.0 → 2.12.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (48) hide show
  1. package/.eslintrc +28 -28
  2. package/.npmignore +5 -0
  3. package/README.md +371 -371
  4. package/dist/comprodls-sdk.js +11493 -11471
  5. package/dist/comprodls-sdk.min.js +14 -14
  6. package/grunt/publish.js +148 -148
  7. package/lib/comprodls.js +146 -146
  8. package/lib/config/index.js +337 -337
  9. package/lib/helpers/index.js +29 -29
  10. package/lib/helpers/lib/api/converter.js +119 -119
  11. package/lib/helpers/lib/api/index.js +120 -120
  12. package/lib/helpers/lib/api/validations.js +72 -72
  13. package/lib/helpers/lib/errors.js +129 -129
  14. package/lib/helpers/lib/utils.js +23 -23
  15. package/lib/helpers/lib/validator.js +100 -100
  16. package/lib/open_access/index.js +121 -121
  17. package/lib/services/activity/activity.js +209 -209
  18. package/lib/services/activity/attempt.js +431 -431
  19. package/lib/services/activity/index.js +28 -28
  20. package/lib/services/analytics/index.js +1555 -1555
  21. package/lib/services/attempts/index.js +342 -342
  22. package/lib/services/auth/classProduct.js +37 -37
  23. package/lib/services/auth/index.js +2541 -2541
  24. package/lib/services/collab/index.js +468 -468
  25. package/lib/services/drive/index.js +144 -144
  26. package/lib/services/integrations/index.js +279 -279
  27. package/lib/services/invitations/index.js +313 -313
  28. package/lib/services/lrs/index.js +459 -459
  29. package/lib/services/product/index.js +267 -267
  30. package/lib/services/pub/index.js +407 -407
  31. package/lib/services/push/index.js +187 -187
  32. package/lib/services/push/pubnubClientWrapper.js +557 -557
  33. package/lib/services/push/sessionStorage.js +64 -64
  34. package/lib/services/pushX/index.js +190 -190
  35. package/lib/services/pushX/pubnubClientWrapper.js +211 -211
  36. package/lib/services/sisevents/index.js +113 -113
  37. package/lib/services/spaces/index.js +976 -929
  38. package/lib/services/superuser/index.js +175 -175
  39. package/lib/services/workflows/index.js +464 -464
  40. package/lib/services/xapi/index.js +232 -232
  41. package/lib/token/index.js +114 -114
  42. package/lib/token/validations.js +88 -88
  43. package/package-lock.json +5095 -0
  44. package/package.json +1 -1
  45. package/test.js +50 -50
  46. package/.vscode/launch.json +0 -23
  47. package/npm-debug.log.189866131 +0 -0
  48. package/npm-debug.log.712840116 +0 -26
@@ -1,465 +1,465 @@
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
- * comproDLS SDK Open Access Manager Module
22
- * Provides Open Access functions for the SDK
23
- ************************************************************/
24
- var q = require('q');
25
- var request = require('superagent');
26
- var helpers = require('./../../helpers');
27
- var DLSError = helpers.errors.DLSError;
28
-
29
- /*************************************
30
- * Setting up Exports/Public functions
31
- *************************************/
32
-
33
- module.exports = workflows;
34
-
35
- //Workflows Adaptor Constructor
36
- function workflows(accountId) {
37
- this.accountId = accountId;
38
- return {
39
- createWorkflow: createWorkflow.bind(this),
40
- getAllWorkflow: getAllWorkflow.bind(this),
41
- getAllWorkflowOfAUser: getAllWorkflowOfAUser.bind(this),
42
- getAWorkflow: getAWorkflow.bind(this),
43
- acceptAWorkflow: acceptAWorkflow.bind(this),
44
- processAWorkflow: processAWorkflow.bind(this),
45
- revokeAWorkflow: revokeAWorkflow.bind(this),
46
- completeAWorkflow: completeAWorkflow.bind(this),
47
- updateWorkflowRequest: updateWorkflowRequest.bind(this)
48
- }
49
- }
50
-
51
- /*********************************
52
- * Public Function definitions
53
- **********************************/
54
- /**
55
- * options={
56
- "ext_user_id": "string", //mandatory
57
- "workflow_type": "institution_request", //mandatory
58
- "institution_request": {
59
- "address": {
60
- "city": "string",
61
- "country": "string",
62
- "street1": "string",
63
- "street2": "string",
64
- "street3": "string",
65
- "house_no": "string",
66
- "post_code": "string"
67
- },
68
- "display_name": "string",
69
- "school_key": "string"
70
- }
71
- }
72
- */
73
- function createWorkflow(options) {
74
- var self = this;
75
- // Initializing promise
76
- var dfd = q.defer();
77
- // Validations
78
-
79
- if(options && options.ext_user_id && options.workflow_type) {
80
- // Passed all validations, Contruct API url
81
- var url = self.config.DEFAULT_HOSTS.AUTH +
82
- self.config.AUTH_API_URLS.workflows;
83
- url = helpers.api.constructAPIUrl(url, {
84
- accountid: self.accountId
85
- });
86
-
87
- // Setup request with URL and Params
88
- var requestAPI = request.post(url)
89
- .set('Content-Type', 'application/json')
90
- .set('Accept', 'application/json')
91
- .send(options)
92
-
93
- if(self.traceid) { requestAPI.set('X-Amzn-Trace-Id', self.traceid); }
94
-
95
- requestAPI.end(function(error, response) {
96
- if(error) {
97
- err = new DLSError(helpers.errors.ERROR_TYPES.API_ERROR, error);
98
- dfd.reject(error);
99
- }
100
- else { dfd.resolve(response.body); }
101
- });
102
- } else {
103
- var err = {};
104
- err.message = err.description = 'ext_user_id or workflow_type not found in request options.';
105
- err = new DLSError(helpers.errors.ERROR_TYPES.SDK_ERROR, err);
106
- dfd.reject(err);
107
- }
108
- return dfd.promise;
109
- }
110
-
111
- /* options = {
112
- "workflow_type": "string", // required
113
- "status" : "string", // required
114
- "start": "string" //epoch
115
- "end": "string" //epoch
116
- "cursor" : "string"
117
- };
118
- */
119
- function getAllWorkflow(options) {
120
- var self = this;
121
- // Initializing promise
122
- var dfd = q.defer();
123
- if(options && options.workflow_type && options.status ) {
124
-
125
- // Passed all validations, Contruct API url
126
- var url = self.config.DEFAULT_HOSTS.AUTH + self.config.AUTH_API_URLS.workflows;
127
- url = helpers.api.constructAPIUrl(url,{ accountid: self.accountId });
128
- var queryParams = { workflow_type: options.workflow_type, status: options.status };
129
- if(options.start) { queryParams.start = options.start; }
130
- if(options.end) { queryParams.end = options.end; }
131
- if(options.cursor) { queryParams.cursor = options.cursor; }
132
-
133
-
134
- // Setup request with URL and Params
135
- var requestAPI = request.get(url).query(queryParams);
136
- if(self.traceid) { requestAPI.set('X-Amzn-Trace-Id', self.traceid); }
137
-
138
- requestAPI.end(function (error, response) {
139
- if(error) {
140
- err = new DLSError(helpers.errors.ERROR_TYPES.API_ERROR, error);
141
- dfd.reject(err);
142
- }
143
- else { dfd.resolve(response.body); }
144
- });
145
- }
146
- else {
147
- err = {};
148
- err.message = err.description = 'Mandatory params - workflow_type, status not found in ' +
149
- 'request options.';
150
- err = new DLSError(helpers.errors.ERROR_TYPES.SDK_ERROR, err);
151
- dfd.reject(err);
152
- }
153
- return dfd.promise;
154
- }
155
-
156
- /* options = {
157
- "workflow_type": "string", // required
158
- "status" : "string", // required
159
- "ext_user_id": "string" //required
160
- "start": "string" //epoch
161
- "end": "string" //epoch
162
- "cursor" : "string"
163
- };
164
- */
165
- function getAllWorkflowOfAUser(options) {
166
- var self = this;
167
- // Initializing promise
168
- var dfd = q.defer();
169
- if(options && options.workflow_type && options.status && options.ext_user_id) {
170
-
171
- // Passed all validations, Contruct API url
172
- var url = self.config.DEFAULT_HOSTS.AUTH + self.config.AUTH_API_URLS.getAllWorkflowOfAUser;
173
- url = helpers.api.constructAPIUrl(url,{ accountid: self.accountId });
174
- var queryParams = { workflow_type: options.workflow_type, status: options.status, ext_user_id: options.ext_user_id };
175
- if(options.start) { queryParams.start = options.start; }
176
- if(options.end) { queryParams.end = options.end; }
177
- if(options.cursor) { queryParams.cursor = options.cursor; }
178
-
179
-
180
- // Setup request with URL and Params
181
- var requestAPI = request.get(url).query(queryParams);
182
- if(self.traceid) { requestAPI.set('X-Amzn-Trace-Id', self.traceid); }
183
-
184
- requestAPI.end(function (error, response) {
185
- if(error) {
186
- err = new DLSError(helpers.errors.ERROR_TYPES.API_ERROR, error);
187
- dfd.reject(err);
188
- }
189
- else { dfd.resolve(response.body); }
190
- });
191
- }
192
- else {
193
- err = {};
194
- err.message = err.description = 'Mandatory params - workflow_type, status, ext_user_id not found in ' +
195
- 'request options.';
196
- err = new DLSError(helpers.errors.ERROR_TYPES.SDK_ERROR, err);
197
- dfd.reject(err);
198
- }
199
- return dfd.promise;
200
- }
201
-
202
- /* options = {
203
- "workflowid": "string", // required
204
- "context_id" : "string", // required
205
- };
206
- */
207
- function getAWorkflow(options) {
208
- var self = this;
209
- // Initializing promise
210
- var dfd = q.defer();
211
- if(options && options.workflowid && options.context_id ) {
212
-
213
- // Passed all validations, Contruct API url
214
- var url = self.config.DEFAULT_HOSTS.AUTH + self.config.AUTH_API_URLS.getAWorkflow;
215
- url = helpers.api.constructAPIUrl(url,{ accountid: self.accountId, workflowid: options.workflowid });
216
-
217
- var queryParams = { context_id: options.context_id };
218
-
219
-
220
- // Setup request with URL
221
- var requestAPI = request.get(url).query(queryParams);
222
- if(self.traceid) { requestAPI.set('X-Amzn-Trace-Id', self.traceid); }
223
-
224
- requestAPI.end(function (error, response) {
225
- if(error) {
226
- err = new DLSError(helpers.errors.ERROR_TYPES.API_ERROR, error);
227
- dfd.reject(err);
228
- }
229
- else { dfd.resolve(response.body); }
230
- });
231
- }
232
- else {
233
- err = {};
234
- err.message = err.description = 'Mandatory params - workflow_type, status not found in ' +
235
- 'request options.';
236
- err = new DLSError(helpers.errors.ERROR_TYPES.SDK_ERROR, err);
237
- dfd.reject(err);
238
- }
239
- return dfd.promise;
240
- }
241
-
242
- /* options = {
243
- "workflowid": "string", // required
244
- "body" : { // required
245
- "context_id": "string" // required
246
- }
247
- };
248
- */
249
- function acceptAWorkflow(options) {
250
- var self = this;
251
- // Initializing promise
252
- var dfd = q.defer();
253
- if(options && options.workflowid && options.body && options.body.context_id ) {
254
-
255
- // Passed all validations, Contruct API url
256
- var url = self.config.DEFAULT_HOSTS.AUTH + self.config.AUTH_API_URLS.acceptAWorkflow;
257
- url = helpers.api.constructAPIUrl(url,{ accountid: self.accountId, workflowid: options.workflowid });
258
-
259
- var params = options.body;
260
- // Setup request with URL
261
- var requestAPI = request.put(url).send(params);
262
- if(self.traceid) { requestAPI.set('X-Amzn-Trace-Id', self.traceid); }
263
- requestAPI.end(function (error, response) {
264
- if(error) {
265
- err = new DLSError(helpers.errors.ERROR_TYPES.API_ERROR, error);
266
- dfd.reject(err);
267
- }
268
- else { dfd.resolve(response); }
269
- });
270
- }
271
- else {
272
- err = {};
273
- err.message = err.description = 'Mandatory params - workflowid, body or body.context_id not found in ' +
274
- 'request options.';
275
- err = new DLSError(helpers.errors.ERROR_TYPES.SDK_ERROR, err);
276
- dfd.reject(err);
277
- }
278
- return dfd.promise;
279
- }
280
-
281
- /* options = {
282
- "workflowid": "string", // required
283
- "body" : { // required
284
- "context_id": "string", // required
285
- "org_id": "string", // required
286
- }
287
- };
288
- */
289
- function processAWorkflow(options) {
290
- var self = this;
291
- // Initializing promise
292
- var dfd = q.defer();
293
- if(options && options.workflowid && options.body && options.body.context_id &&
294
- options.body.org_id) {
295
-
296
- // Passed all validations, Contruct API url
297
- var url = self.config.DEFAULT_HOSTS.AUTH + self.config.AUTH_API_URLS.processAWorkflow;
298
- url = helpers.api.constructAPIUrl(url,{ accountid: self.accountId, workflowid: options.workflowid });
299
-
300
- var params = options.body;
301
- // Setup request with URL
302
- var requestAPI = request.put(url).send(params);
303
- if(self.traceid) { requestAPI.set('X-Amzn-Trace-Id', self.traceid); }
304
-
305
- requestAPI.end(function (error, response) {
306
- if(error) {
307
- err = new DLSError(helpers.errors.ERROR_TYPES.API_ERROR, error);
308
- dfd.reject(err);
309
- }
310
- else { dfd.resolve(response); }
311
- });
312
- }
313
- else {
314
- err = {};
315
- err.message = err.description = 'Mandatory params - workflowid, body, body.context_id, body.org_id' +
316
- ' in request options.';
317
- err = new DLSError(helpers.errors.ERROR_TYPES.SDK_ERROR, err);
318
- dfd.reject(err);
319
- }
320
- return dfd.promise;
321
- }
322
-
323
- /* options = {
324
- "workflowid": "string", // required
325
- "body" : { // required
326
- "context_id": "string" // required
327
- }
328
- };
329
- */
330
- function revokeAWorkflow(options) {
331
- var self = this;
332
- // Initializing promise
333
- var dfd = q.defer();
334
- if(options && options.workflowid && options.body && options.body.context_id ) {
335
-
336
- // Passed all validations, Contruct API url
337
- var url = self.config.DEFAULT_HOSTS.AUTH + self.config.AUTH_API_URLS.revokeAWorkflow;
338
- url = helpers.api.constructAPIUrl(url,{ accountid: self.accountId, workflowid: options.workflowid });
339
-
340
- var params = options.body;
341
-
342
-
343
- // Setup request with URL
344
- var requestAPI = request.put(url).send(params);
345
- if(self.traceid) { requestAPI.set('X-Amzn-Trace-Id', self.traceid); }
346
-
347
- requestAPI.end(function (error, response) {
348
- if(error) {
349
- err = new DLSError(helpers.errors.ERROR_TYPES.API_ERROR, error);
350
- dfd.reject(err);
351
- }
352
- else { dfd.resolve(response); }
353
- });
354
- }
355
- else {
356
- err = {};
357
- err.message = err.description = 'Mandatory params - workflowid, body or body.context_id not found in ' +
358
- 'request options.';
359
- err = new DLSError(helpers.errors.ERROR_TYPES.SDK_ERROR, err);
360
- dfd.reject(err);
361
- }
362
- return dfd.promise;
363
- }
364
-
365
- /* options = {
366
- "workflowid": "string", // required
367
- "body" : { // required
368
- "context_id": "string" // required
369
- }
370
- };
371
- */
372
- function completeAWorkflow(options) {
373
- var self = this;
374
- // Initializing promise
375
- var dfd = q.defer();
376
- if(options && options.workflowid && options.body && options.body.context_id ) {
377
-
378
- // Passed all validations, Contruct API url
379
- var url = self.config.DEFAULT_HOSTS.AUTH + self.config.AUTH_API_URLS.completeAWorkflow;
380
- url = helpers.api.constructAPIUrl(url,{ accountid: self.accountId, workflowid: options.workflowid });
381
-
382
- var params = options.body;
383
-
384
-
385
- // Setup request with URL
386
- var requestAPI = request.put(url).send(params);
387
- if(self.traceid) { requestAPI.set('X-Amzn-Trace-Id', self.traceid); }
388
-
389
- requestAPI.end(function (error, response) {
390
- if(error) {
391
- err = new DLSError(helpers.errors.ERROR_TYPES.API_ERROR, error);
392
- dfd.reject(err);
393
- }
394
- else { dfd.resolve(response); }
395
- });
396
- }
397
- else {
398
- err = {};
399
- err.message = err.description = 'Mandatory params - workflowid, body or body.context_id not found in ' +
400
- 'request options.';
401
- err = new DLSError(helpers.errors.ERROR_TYPES.SDK_ERROR, err);
402
- dfd.reject(err);
403
- }
404
- return dfd.promise;
405
- }
406
-
407
- /**
408
- * options={
409
- * "context_id": "string", //mandatory
410
- * "body": {
411
- "ext_user_id": "string", //mandatory
412
- "workflow_type": "institution_request", //mandatory
413
- "institution_request": {
414
- "address": {
415
- "city": "string",
416
- "country": "string",
417
- "street1": "string",
418
- "street2": "string",
419
- "street3": "string",
420
- "house_no": "string",
421
- "post_code": "string"
422
- },
423
- "display_name": "string",
424
- "school_key": "string"
425
- }
426
- }
427
- }
428
- */
429
- function updateWorkflowRequest(options) {
430
- var self = this;
431
- // Initializing promise
432
- var dfd = q.defer();
433
- // Validations
434
-
435
- if(options && options.context_id && options.body.ext_user_id && options.body.workflow_type && options.workflowid) {
436
- // Passed all validations, Contruct API url
437
- var url = self.config.DEFAULT_HOSTS.AUTH +
438
- self.config.AUTH_API_URLS.getAWorkflow;
439
- url = helpers.api.constructAPIUrl(url, {
440
- accountid: self.accountId, workflowid: options.workflowid
441
- });
442
- var queryParams = { context_id: options.context_id };
443
-
444
- // Setup request with URL and Params
445
- var requestAPI = request.put(url)
446
- .set('Content-Type', 'application/json')
447
- .set('Accept', 'application/json').query(queryParams)
448
- .send(options.body)
449
-
450
- if(self.traceid) { requestAPI.set('X-Amzn-Trace-Id', self.traceid); }
451
- requestAPI.end(function(error, response) {
452
- if(error) {
453
- err = new DLSError(helpers.errors.ERROR_TYPES.API_ERROR, error);
454
- dfd.reject(error);
455
- }
456
- else { dfd.resolve(response); }
457
- });
458
- } else {
459
- var err = {};
460
- err.message = err.description = 'context_id or ext_user_id or workflow_type or workflowid not found in request options.';
461
- err = new DLSError(helpers.errors.ERROR_TYPES.SDK_ERROR, err);
462
- dfd.reject(err);
463
- }
464
- return dfd.promise;
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
+ * comproDLS SDK Open Access Manager Module
22
+ * Provides Open Access functions for the SDK
23
+ ************************************************************/
24
+ var q = require('q');
25
+ var request = require('superagent');
26
+ var helpers = require('./../../helpers');
27
+ var DLSError = helpers.errors.DLSError;
28
+
29
+ /*************************************
30
+ * Setting up Exports/Public functions
31
+ *************************************/
32
+
33
+ module.exports = workflows;
34
+
35
+ //Workflows Adaptor Constructor
36
+ function workflows(accountId) {
37
+ this.accountId = accountId;
38
+ return {
39
+ createWorkflow: createWorkflow.bind(this),
40
+ getAllWorkflow: getAllWorkflow.bind(this),
41
+ getAllWorkflowOfAUser: getAllWorkflowOfAUser.bind(this),
42
+ getAWorkflow: getAWorkflow.bind(this),
43
+ acceptAWorkflow: acceptAWorkflow.bind(this),
44
+ processAWorkflow: processAWorkflow.bind(this),
45
+ revokeAWorkflow: revokeAWorkflow.bind(this),
46
+ completeAWorkflow: completeAWorkflow.bind(this),
47
+ updateWorkflowRequest: updateWorkflowRequest.bind(this)
48
+ }
49
+ }
50
+
51
+ /*********************************
52
+ * Public Function definitions
53
+ **********************************/
54
+ /**
55
+ * options={
56
+ "ext_user_id": "string", //mandatory
57
+ "workflow_type": "institution_request", //mandatory
58
+ "institution_request": {
59
+ "address": {
60
+ "city": "string",
61
+ "country": "string",
62
+ "street1": "string",
63
+ "street2": "string",
64
+ "street3": "string",
65
+ "house_no": "string",
66
+ "post_code": "string"
67
+ },
68
+ "display_name": "string",
69
+ "school_key": "string"
70
+ }
71
+ }
72
+ */
73
+ function createWorkflow(options) {
74
+ var self = this;
75
+ // Initializing promise
76
+ var dfd = q.defer();
77
+ // Validations
78
+
79
+ if(options && options.ext_user_id && options.workflow_type) {
80
+ // Passed all validations, Contruct API url
81
+ var url = self.config.DEFAULT_HOSTS.AUTH +
82
+ self.config.AUTH_API_URLS.workflows;
83
+ url = helpers.api.constructAPIUrl(url, {
84
+ accountid: self.accountId
85
+ });
86
+
87
+ // Setup request with URL and Params
88
+ var requestAPI = request.post(url)
89
+ .set('Content-Type', 'application/json')
90
+ .set('Accept', 'application/json')
91
+ .send(options)
92
+
93
+ if(self.traceid) { requestAPI.set('X-Amzn-Trace-Id', self.traceid); }
94
+
95
+ requestAPI.end(function(error, response) {
96
+ if(error) {
97
+ err = new DLSError(helpers.errors.ERROR_TYPES.API_ERROR, error);
98
+ dfd.reject(error);
99
+ }
100
+ else { dfd.resolve(response.body); }
101
+ });
102
+ } else {
103
+ var err = {};
104
+ err.message = err.description = 'ext_user_id or workflow_type not found in request options.';
105
+ err = new DLSError(helpers.errors.ERROR_TYPES.SDK_ERROR, err);
106
+ dfd.reject(err);
107
+ }
108
+ return dfd.promise;
109
+ }
110
+
111
+ /* options = {
112
+ "workflow_type": "string", // required
113
+ "status" : "string", // required
114
+ "start": "string" //epoch
115
+ "end": "string" //epoch
116
+ "cursor" : "string"
117
+ };
118
+ */
119
+ function getAllWorkflow(options) {
120
+ var self = this;
121
+ // Initializing promise
122
+ var dfd = q.defer();
123
+ if(options && options.workflow_type && options.status ) {
124
+
125
+ // Passed all validations, Contruct API url
126
+ var url = self.config.DEFAULT_HOSTS.AUTH + self.config.AUTH_API_URLS.workflows;
127
+ url = helpers.api.constructAPIUrl(url,{ accountid: self.accountId });
128
+ var queryParams = { workflow_type: options.workflow_type, status: options.status };
129
+ if(options.start) { queryParams.start = options.start; }
130
+ if(options.end) { queryParams.end = options.end; }
131
+ if(options.cursor) { queryParams.cursor = options.cursor; }
132
+
133
+
134
+ // Setup request with URL and Params
135
+ var requestAPI = request.get(url).query(queryParams);
136
+ if(self.traceid) { requestAPI.set('X-Amzn-Trace-Id', self.traceid); }
137
+
138
+ requestAPI.end(function (error, response) {
139
+ if(error) {
140
+ err = new DLSError(helpers.errors.ERROR_TYPES.API_ERROR, error);
141
+ dfd.reject(err);
142
+ }
143
+ else { dfd.resolve(response.body); }
144
+ });
145
+ }
146
+ else {
147
+ err = {};
148
+ err.message = err.description = 'Mandatory params - workflow_type, status not found in ' +
149
+ 'request options.';
150
+ err = new DLSError(helpers.errors.ERROR_TYPES.SDK_ERROR, err);
151
+ dfd.reject(err);
152
+ }
153
+ return dfd.promise;
154
+ }
155
+
156
+ /* options = {
157
+ "workflow_type": "string", // required
158
+ "status" : "string", // required
159
+ "ext_user_id": "string" //required
160
+ "start": "string" //epoch
161
+ "end": "string" //epoch
162
+ "cursor" : "string"
163
+ };
164
+ */
165
+ function getAllWorkflowOfAUser(options) {
166
+ var self = this;
167
+ // Initializing promise
168
+ var dfd = q.defer();
169
+ if(options && options.workflow_type && options.status && options.ext_user_id) {
170
+
171
+ // Passed all validations, Contruct API url
172
+ var url = self.config.DEFAULT_HOSTS.AUTH + self.config.AUTH_API_URLS.getAllWorkflowOfAUser;
173
+ url = helpers.api.constructAPIUrl(url,{ accountid: self.accountId });
174
+ var queryParams = { workflow_type: options.workflow_type, status: options.status, ext_user_id: options.ext_user_id };
175
+ if(options.start) { queryParams.start = options.start; }
176
+ if(options.end) { queryParams.end = options.end; }
177
+ if(options.cursor) { queryParams.cursor = options.cursor; }
178
+
179
+
180
+ // Setup request with URL and Params
181
+ var requestAPI = request.get(url).query(queryParams);
182
+ if(self.traceid) { requestAPI.set('X-Amzn-Trace-Id', self.traceid); }
183
+
184
+ requestAPI.end(function (error, response) {
185
+ if(error) {
186
+ err = new DLSError(helpers.errors.ERROR_TYPES.API_ERROR, error);
187
+ dfd.reject(err);
188
+ }
189
+ else { dfd.resolve(response.body); }
190
+ });
191
+ }
192
+ else {
193
+ err = {};
194
+ err.message = err.description = 'Mandatory params - workflow_type, status, ext_user_id not found in ' +
195
+ 'request options.';
196
+ err = new DLSError(helpers.errors.ERROR_TYPES.SDK_ERROR, err);
197
+ dfd.reject(err);
198
+ }
199
+ return dfd.promise;
200
+ }
201
+
202
+ /* options = {
203
+ "workflowid": "string", // required
204
+ "context_id" : "string", // required
205
+ };
206
+ */
207
+ function getAWorkflow(options) {
208
+ var self = this;
209
+ // Initializing promise
210
+ var dfd = q.defer();
211
+ if(options && options.workflowid && options.context_id ) {
212
+
213
+ // Passed all validations, Contruct API url
214
+ var url = self.config.DEFAULT_HOSTS.AUTH + self.config.AUTH_API_URLS.getAWorkflow;
215
+ url = helpers.api.constructAPIUrl(url,{ accountid: self.accountId, workflowid: options.workflowid });
216
+
217
+ var queryParams = { context_id: options.context_id };
218
+
219
+
220
+ // Setup request with URL
221
+ var requestAPI = request.get(url).query(queryParams);
222
+ if(self.traceid) { requestAPI.set('X-Amzn-Trace-Id', self.traceid); }
223
+
224
+ requestAPI.end(function (error, response) {
225
+ if(error) {
226
+ err = new DLSError(helpers.errors.ERROR_TYPES.API_ERROR, error);
227
+ dfd.reject(err);
228
+ }
229
+ else { dfd.resolve(response.body); }
230
+ });
231
+ }
232
+ else {
233
+ err = {};
234
+ err.message = err.description = 'Mandatory params - workflow_type, status not found in ' +
235
+ 'request options.';
236
+ err = new DLSError(helpers.errors.ERROR_TYPES.SDK_ERROR, err);
237
+ dfd.reject(err);
238
+ }
239
+ return dfd.promise;
240
+ }
241
+
242
+ /* options = {
243
+ "workflowid": "string", // required
244
+ "body" : { // required
245
+ "context_id": "string" // required
246
+ }
247
+ };
248
+ */
249
+ function acceptAWorkflow(options) {
250
+ var self = this;
251
+ // Initializing promise
252
+ var dfd = q.defer();
253
+ if(options && options.workflowid && options.body && options.body.context_id ) {
254
+
255
+ // Passed all validations, Contruct API url
256
+ var url = self.config.DEFAULT_HOSTS.AUTH + self.config.AUTH_API_URLS.acceptAWorkflow;
257
+ url = helpers.api.constructAPIUrl(url,{ accountid: self.accountId, workflowid: options.workflowid });
258
+
259
+ var params = options.body;
260
+ // Setup request with URL
261
+ var requestAPI = request.put(url).send(params);
262
+ if(self.traceid) { requestAPI.set('X-Amzn-Trace-Id', self.traceid); }
263
+ requestAPI.end(function (error, response) {
264
+ if(error) {
265
+ err = new DLSError(helpers.errors.ERROR_TYPES.API_ERROR, error);
266
+ dfd.reject(err);
267
+ }
268
+ else { dfd.resolve(response); }
269
+ });
270
+ }
271
+ else {
272
+ err = {};
273
+ err.message = err.description = 'Mandatory params - workflowid, body or body.context_id not found in ' +
274
+ 'request options.';
275
+ err = new DLSError(helpers.errors.ERROR_TYPES.SDK_ERROR, err);
276
+ dfd.reject(err);
277
+ }
278
+ return dfd.promise;
279
+ }
280
+
281
+ /* options = {
282
+ "workflowid": "string", // required
283
+ "body" : { // required
284
+ "context_id": "string", // required
285
+ "org_id": "string", // required
286
+ }
287
+ };
288
+ */
289
+ function processAWorkflow(options) {
290
+ var self = this;
291
+ // Initializing promise
292
+ var dfd = q.defer();
293
+ if(options && options.workflowid && options.body && options.body.context_id &&
294
+ options.body.org_id) {
295
+
296
+ // Passed all validations, Contruct API url
297
+ var url = self.config.DEFAULT_HOSTS.AUTH + self.config.AUTH_API_URLS.processAWorkflow;
298
+ url = helpers.api.constructAPIUrl(url,{ accountid: self.accountId, workflowid: options.workflowid });
299
+
300
+ var params = options.body;
301
+ // Setup request with URL
302
+ var requestAPI = request.put(url).send(params);
303
+ if(self.traceid) { requestAPI.set('X-Amzn-Trace-Id', self.traceid); }
304
+
305
+ requestAPI.end(function (error, response) {
306
+ if(error) {
307
+ err = new DLSError(helpers.errors.ERROR_TYPES.API_ERROR, error);
308
+ dfd.reject(err);
309
+ }
310
+ else { dfd.resolve(response); }
311
+ });
312
+ }
313
+ else {
314
+ err = {};
315
+ err.message = err.description = 'Mandatory params - workflowid, body, body.context_id, body.org_id' +
316
+ ' in request options.';
317
+ err = new DLSError(helpers.errors.ERROR_TYPES.SDK_ERROR, err);
318
+ dfd.reject(err);
319
+ }
320
+ return dfd.promise;
321
+ }
322
+
323
+ /* options = {
324
+ "workflowid": "string", // required
325
+ "body" : { // required
326
+ "context_id": "string" // required
327
+ }
328
+ };
329
+ */
330
+ function revokeAWorkflow(options) {
331
+ var self = this;
332
+ // Initializing promise
333
+ var dfd = q.defer();
334
+ if(options && options.workflowid && options.body && options.body.context_id ) {
335
+
336
+ // Passed all validations, Contruct API url
337
+ var url = self.config.DEFAULT_HOSTS.AUTH + self.config.AUTH_API_URLS.revokeAWorkflow;
338
+ url = helpers.api.constructAPIUrl(url,{ accountid: self.accountId, workflowid: options.workflowid });
339
+
340
+ var params = options.body;
341
+
342
+
343
+ // Setup request with URL
344
+ var requestAPI = request.put(url).send(params);
345
+ if(self.traceid) { requestAPI.set('X-Amzn-Trace-Id', self.traceid); }
346
+
347
+ requestAPI.end(function (error, response) {
348
+ if(error) {
349
+ err = new DLSError(helpers.errors.ERROR_TYPES.API_ERROR, error);
350
+ dfd.reject(err);
351
+ }
352
+ else { dfd.resolve(response); }
353
+ });
354
+ }
355
+ else {
356
+ err = {};
357
+ err.message = err.description = 'Mandatory params - workflowid, body or body.context_id not found in ' +
358
+ 'request options.';
359
+ err = new DLSError(helpers.errors.ERROR_TYPES.SDK_ERROR, err);
360
+ dfd.reject(err);
361
+ }
362
+ return dfd.promise;
363
+ }
364
+
365
+ /* options = {
366
+ "workflowid": "string", // required
367
+ "body" : { // required
368
+ "context_id": "string" // required
369
+ }
370
+ };
371
+ */
372
+ function completeAWorkflow(options) {
373
+ var self = this;
374
+ // Initializing promise
375
+ var dfd = q.defer();
376
+ if(options && options.workflowid && options.body && options.body.context_id ) {
377
+
378
+ // Passed all validations, Contruct API url
379
+ var url = self.config.DEFAULT_HOSTS.AUTH + self.config.AUTH_API_URLS.completeAWorkflow;
380
+ url = helpers.api.constructAPIUrl(url,{ accountid: self.accountId, workflowid: options.workflowid });
381
+
382
+ var params = options.body;
383
+
384
+
385
+ // Setup request with URL
386
+ var requestAPI = request.put(url).send(params);
387
+ if(self.traceid) { requestAPI.set('X-Amzn-Trace-Id', self.traceid); }
388
+
389
+ requestAPI.end(function (error, response) {
390
+ if(error) {
391
+ err = new DLSError(helpers.errors.ERROR_TYPES.API_ERROR, error);
392
+ dfd.reject(err);
393
+ }
394
+ else { dfd.resolve(response); }
395
+ });
396
+ }
397
+ else {
398
+ err = {};
399
+ err.message = err.description = 'Mandatory params - workflowid, body or body.context_id not found in ' +
400
+ 'request options.';
401
+ err = new DLSError(helpers.errors.ERROR_TYPES.SDK_ERROR, err);
402
+ dfd.reject(err);
403
+ }
404
+ return dfd.promise;
405
+ }
406
+
407
+ /**
408
+ * options={
409
+ * "context_id": "string", //mandatory
410
+ * "body": {
411
+ "ext_user_id": "string", //mandatory
412
+ "workflow_type": "institution_request", //mandatory
413
+ "institution_request": {
414
+ "address": {
415
+ "city": "string",
416
+ "country": "string",
417
+ "street1": "string",
418
+ "street2": "string",
419
+ "street3": "string",
420
+ "house_no": "string",
421
+ "post_code": "string"
422
+ },
423
+ "display_name": "string",
424
+ "school_key": "string"
425
+ }
426
+ }
427
+ }
428
+ */
429
+ function updateWorkflowRequest(options) {
430
+ var self = this;
431
+ // Initializing promise
432
+ var dfd = q.defer();
433
+ // Validations
434
+
435
+ if(options && options.context_id && options.body.ext_user_id && options.body.workflow_type && options.workflowid) {
436
+ // Passed all validations, Contruct API url
437
+ var url = self.config.DEFAULT_HOSTS.AUTH +
438
+ self.config.AUTH_API_URLS.getAWorkflow;
439
+ url = helpers.api.constructAPIUrl(url, {
440
+ accountid: self.accountId, workflowid: options.workflowid
441
+ });
442
+ var queryParams = { context_id: options.context_id };
443
+
444
+ // Setup request with URL and Params
445
+ var requestAPI = request.put(url)
446
+ .set('Content-Type', 'application/json')
447
+ .set('Accept', 'application/json').query(queryParams)
448
+ .send(options.body)
449
+
450
+ if(self.traceid) { requestAPI.set('X-Amzn-Trace-Id', self.traceid); }
451
+ requestAPI.end(function(error, response) {
452
+ if(error) {
453
+ err = new DLSError(helpers.errors.ERROR_TYPES.API_ERROR, error);
454
+ dfd.reject(error);
455
+ }
456
+ else { dfd.resolve(response); }
457
+ });
458
+ } else {
459
+ var err = {};
460
+ err.message = err.description = 'context_id or ext_user_id or workflow_type or workflowid not found in request options.';
461
+ err = new DLSError(helpers.errors.ERROR_TYPES.SDK_ERROR, err);
462
+ dfd.reject(err);
463
+ }
464
+ return dfd.promise;
465
465
  }