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