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,31 +1,31 @@
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 Helpers Module
23
- * This module provides definition of helper functions for SDK.
24
- ************************************************************/
25
-
26
- /****************************************************
27
- * Setting up Exports/Public functions and variables
28
- *****************************************************/
29
- exports.api = require('./lib/api');
30
- exports.errors = require('./lib/errors');
31
- exports.validations = require('./lib/validator');
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 Helpers Module
23
+ * This module provides definition of helper functions for SDK.
24
+ ************************************************************/
25
+
26
+ /****************************************************
27
+ * Setting up Exports/Public functions and variables
28
+ *****************************************************/
29
+ exports.api = require('./lib/api');
30
+ exports.errors = require('./lib/errors');
31
+ exports.validations = require('./lib/validator');
@@ -1,129 +1,129 @@
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
- var Errors = require('../errors');
22
- var DLSError = Errors.DLSError;
23
-
24
- /**
25
- * This function converts user entity to generate SDK response.
26
- * @param { *data: {userEntityDDB} } options
27
- */
28
- function __convertUserResponse(options) {
29
- var userEntity = options.data,
30
- userRoles = userEntity.roles;
31
-
32
- if(Array.isArray(userRoles)) {
33
-
34
- //convert to SDK response.
35
- var userRolesInResponse = {};
36
- for(var roleIndex in userRoles) {
37
- userRolesInResponse[userRoles[roleIndex]] = [];
38
- }
39
-
40
- userEntity.roles = userRolesInResponse;
41
- }
42
-
43
- return userEntity;
44
- }
45
-
46
- /**
47
- * This function converts class entity from DDB to generate SDK response.
48
- * @param { *data: {classEntityDDB} } options
49
- */
50
- function __convertClassResponse(options) {
51
- var classEntity = options.data;
52
-
53
- if (classEntity.hasOwnProperty('pk') === false) {
54
- // BAAS structure returned, no need to convert response.
55
- return classEntity;
56
- }
57
-
58
- var response = {
59
- uuid: classEntity.classid,
60
- type: 'group'
61
- };
62
-
63
- Object.assign(response, classEntity);
64
-
65
- var firstName = classEntity.class.instructor.first_name,
66
- lastName = classEntity.class.instructor.last_name;
67
-
68
- response.class.instructor.uuid = classEntity.class.instructor.dls_user_id;
69
-
70
- if (firstName || lastName) {
71
- response.class.instructor.name = firstName ? firstName : '';
72
-
73
- if (lastName) {
74
- response.class.instructor.name += firstName ? (' ' + lastName) : lastName;
75
- }
76
- }
77
-
78
- return response;
79
- }
80
-
81
- /**
82
- * This function converts enrollment entities to generate SDK response.
83
- * @param { *data: [enrollmentEntities] } options
84
- */
85
- function __convertEnrollmetsResponse(options) {
86
- var enrollmentEntities = options.data;
87
-
88
- //convert to SDK response.
89
- for(var enrollmentIdx in enrollmentEntities) {
90
- var enrollment = enrollmentEntities[enrollmentIdx];
91
- var firstName = enrollment.first_name,
92
- lastName = enrollment.last_name;
93
- if(firstName || lastName) {
94
- enrollment.name = firstName ? firstName : '';
95
-
96
- if(lastName) {
97
- enrollment.name += firstName ? (' ' + lastName) : lastName;
98
- }
99
- }
100
-
101
- enrollment.uuid = enrollment.dls_user_id;
102
-
103
- if(enrollment.username) {
104
- enrollment.ext_username = enrollment.username;
105
- }
106
- enrollment.username = enrollment.userid + '--ACCOUNT';
107
- }
108
-
109
- return enrollmentEntities;
110
- }
111
-
112
- function __convertElasticsearchErrResponse(options) {
113
- var err = options.err;
114
- var type = options.type;
115
- var error = new DLSError(type, err);
116
- if (err.response && err.response.body && err.response.body.meta &&
117
- err.response.body.meta.body) {
118
- error.message = 'Elasticsearch Error. Please refer data field for more information';
119
- error.data = err.response.body.meta.body;
120
- }
121
- return error;
122
- }
123
-
124
- module.exports = {
125
- convertUserResponse: __convertUserResponse,
126
- convertClassResponse: __convertClassResponse,
127
- convertEnrollmetsResponse: __convertEnrollmetsResponse,
128
- convertElasticsearchErrResponse : __convertElasticsearchErrResponse
129
- };
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
+ var Errors = require('../errors');
22
+ var DLSError = Errors.DLSError;
23
+
24
+ /**
25
+ * This function converts user entity to generate SDK response.
26
+ * @param { *data: {userEntityDDB} } options
27
+ */
28
+ function __convertUserResponse(options) {
29
+ var userEntity = options.data,
30
+ userRoles = userEntity.roles;
31
+
32
+ if(Array.isArray(userRoles)) {
33
+
34
+ //convert to SDK response.
35
+ var userRolesInResponse = {};
36
+ for(var roleIndex in userRoles) {
37
+ userRolesInResponse[userRoles[roleIndex]] = [];
38
+ }
39
+
40
+ userEntity.roles = userRolesInResponse;
41
+ }
42
+
43
+ return userEntity;
44
+ }
45
+
46
+ /**
47
+ * This function converts class entity from DDB to generate SDK response.
48
+ * @param { *data: {classEntityDDB} } options
49
+ */
50
+ function __convertClassResponse(options) {
51
+ var classEntity = options.data;
52
+
53
+ if (classEntity.hasOwnProperty('pk') === false) {
54
+ // BAAS structure returned, no need to convert response.
55
+ return classEntity;
56
+ }
57
+
58
+ var response = {
59
+ uuid: classEntity.classid,
60
+ type: 'group'
61
+ };
62
+
63
+ Object.assign(response, classEntity);
64
+
65
+ var firstName = classEntity.class.instructor.first_name,
66
+ lastName = classEntity.class.instructor.last_name;
67
+
68
+ response.class.instructor.uuid = classEntity.class.instructor.dls_user_id;
69
+
70
+ if (firstName || lastName) {
71
+ response.class.instructor.name = firstName ? firstName : '';
72
+
73
+ if (lastName) {
74
+ response.class.instructor.name += firstName ? (' ' + lastName) : lastName;
75
+ }
76
+ }
77
+
78
+ return response;
79
+ }
80
+
81
+ /**
82
+ * This function converts enrollment entities to generate SDK response.
83
+ * @param { *data: [enrollmentEntities] } options
84
+ */
85
+ function __convertEnrollmetsResponse(options) {
86
+ var enrollmentEntities = options.data;
87
+
88
+ //convert to SDK response.
89
+ for(var enrollmentIdx in enrollmentEntities) {
90
+ var enrollment = enrollmentEntities[enrollmentIdx];
91
+ var firstName = enrollment.first_name,
92
+ lastName = enrollment.last_name;
93
+ if(firstName || lastName) {
94
+ enrollment.name = firstName ? firstName : '';
95
+
96
+ if(lastName) {
97
+ enrollment.name += firstName ? (' ' + lastName) : lastName;
98
+ }
99
+ }
100
+
101
+ enrollment.uuid = enrollment.dls_user_id;
102
+
103
+ if(enrollment.username) {
104
+ enrollment.ext_username = enrollment.username;
105
+ }
106
+ enrollment.username = enrollment.userid + '--ACCOUNT';
107
+ }
108
+
109
+ return enrollmentEntities;
110
+ }
111
+
112
+ function __convertElasticsearchErrResponse(options) {
113
+ var err = options.err;
114
+ var type = options.type;
115
+ var error = new DLSError(type, err);
116
+ if (err.response && err.response.body && err.response.body.meta &&
117
+ err.response.body.meta.body) {
118
+ error.message = 'Elasticsearch Error. Please refer data field for more information';
119
+ error.data = err.response.body.meta.body;
120
+ }
121
+ return error;
122
+ }
123
+
124
+ module.exports = {
125
+ convertUserResponse: __convertUserResponse,
126
+ convertClassResponse: __convertClassResponse,
127
+ convertEnrollmetsResponse: __convertEnrollmetsResponse,
128
+ convertElasticsearchErrResponse : __convertElasticsearchErrResponse
129
+ };
@@ -1,46 +1,46 @@
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
- var format = require('string-template');
21
-
22
- exports.constructAPIUrl = constructAPIUrl;
23
- exports.setupAPIToken = setupAPIToken;
24
-
25
- /**
26
- * This function constructs the url of comproDLS API.
27
- * @param {String} url - comproDLS API URL with placeholders
28
- * @param {Object} options - JSON Object having actual values to replace in API URLs
29
- * @returns
30
- */
31
- function constructAPIUrl(url, options) {
32
- return format(url, options);
33
- };
34
-
35
- /**
36
- * [Deprecated] This function is no longer needed. Use requestLayer functions instead,
37
- * as the API token is now automatically handled by requestLayer.
38
- *
39
- * This function sets up the API token in the request header.
40
- * @param {Object} request - The request object to which the token will be added
41
- * @param {Object} token - The token object containing the access_token
42
- * @returns {*} The modified request object with the Authorization header set
43
- */
44
- function setupAPIToken(request, token) {
45
- return request.set('Authorization', token.access_token);
46
- };
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
+ var format = require('string-template');
21
+
22
+ exports.constructAPIUrl = constructAPIUrl;
23
+ exports.setupAPIToken = setupAPIToken;
24
+
25
+ /**
26
+ * This function constructs the url of comproDLS API.
27
+ * @param {String} url - comproDLS API URL with placeholders
28
+ * @param {Object} options - JSON Object having actual values to replace in API URLs
29
+ * @returns
30
+ */
31
+ function constructAPIUrl(url, options) {
32
+ return format(url, options);
33
+ };
34
+
35
+ /**
36
+ * [Deprecated] This function is no longer needed. Use requestLayer functions instead,
37
+ * as the API token is now automatically handled by requestLayer.
38
+ *
39
+ * This function sets up the API token in the request header.
40
+ * @param {Object} request - The request object to which the token will be added
41
+ * @param {Object} token - The token object containing the access_token
42
+ * @returns {*} The modified request object with the Authorization header set
43
+ */
44
+ function setupAPIToken(request, token) {
45
+ return request.set('Authorization', token.access_token);
46
+ };
@@ -1,122 +1,122 @@
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 Error Helper Module
23
- * This module contains helper functions for Error management
24
- ************************************************************/
25
-
26
- // All possible Error types in SDK
27
- var ERROR_TYPES = {
28
- API_ERROR: 'API_ERROR',
29
- SDK_ERROR: 'SDK_ERROR',
30
- CHANNEL_SUBSCRIPTION: 'CHANNEL_SUBSCRIPTION'
31
- };
32
-
33
- var ERROR_CATEGORY = {
34
- PUSHX: 'PUSHX'
35
- };
36
-
37
- var ERROR_STATUS = {
38
- ERROR: 'ERROR'
39
- };
40
-
41
- exports.DLSError = DLSError;
42
- exports.PUSHXError = PUSHXError;
43
- exports.ERROR_TYPES = ERROR_TYPES;
44
- exports.ERROR_CATEGORY = ERROR_CATEGORY;
45
-
46
- /**
47
- * Constructor for the DLS error object
48
- * Parameters:
49
- * type: Error Type. Possible values are SDK_ERROR and API_ERROR
50
- * err: JSON Error object. This can be:
51
- * 1. HTTP Error Object returned by comproDLS APIs (In case of API_ERROR)
52
- * 2. Custom Error Object(SDK_ERROR or Custom API_ERROR) with following structure
53
- * {
54
- * message: 'string',
55
- * description: 'string'
56
- * }
57
- */
58
- function DLSError(type, err) {
59
- // We assume only two types of errors: SDK_ERROR (default) or API_ERROR
60
- this.type = type;
61
- if (type === ERROR_TYPES.API_ERROR) {
62
-
63
- // Handling error on the basis of type of error (HTTP response or Custom)
64
- var msg, desc;
65
- if(err.response != undefined) {
66
- msg = err.response.body.message || err.response.body.dbErrorBody || err.response.body.code;
67
- desc = err.response.body.dbErrorDescription;
68
-
69
- // Add swagger errors
70
- if (err.response.body.results && err.response.body.results.errors) {
71
- msg = '';
72
- for (var idx in err.response.body.results.errors) {
73
- msg += err.response.body.results.errors[idx].message + ' ';
74
- }
75
- }
76
-
77
- // Add request_id
78
- if (err.response.body.server) {
79
- this.server = err.response.body.server;
80
- }
81
-
82
- } else {
83
- msg = err.message ? err.message : '';
84
- desc = err.description ? err.description : '';
85
- }
86
-
87
- //Set the message and description
88
- this.message = msg;
89
- this.description = desc;
90
- }
91
- else if (type === ERROR_TYPES.PUSHX_ERROR) {
92
- //Set the message and description
93
- this.message = err.message;
94
- this.data = err;
95
- }
96
- else {
97
- this.message = err.message ? err.message : '';
98
- this.description = err.description ? err.description : '';
99
- delete err.message;
100
- delete err.description;
101
- this.data = err;
102
- }
103
-
104
- if (type === ERROR_TYPES.API_ERROR || type === ERROR_TYPES.PUSHX_ERROR) {
105
- this.httpcode = err.status;
106
- }
107
- };
108
-
109
- function PUSHXError(category, error) {
110
- if (category === ERROR_CATEGORY.PUSHX) {
111
- this.category = ERROR_CATEGORY.PUSHX;
112
- this.type = error.type || ERROR_TYPES.CHANNEL_SUBSCRIPTION;
113
- this.status = ERROR_STATUS.ERROR;
114
- this.message = error.message;
115
- this.data = error;
116
- this.httpcode = (error.errorDetails && error.errorDetails.statusCode) ?
117
- error.errorDetails.statusCode : 500;
118
- }
119
- else {
120
- this.message = 'PUSHXError called for incorrect category.';
121
- }
122
- };
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 Error Helper Module
23
+ * This module contains helper functions for Error management
24
+ ************************************************************/
25
+
26
+ // All possible Error types in SDK
27
+ var ERROR_TYPES = {
28
+ API_ERROR: 'API_ERROR',
29
+ SDK_ERROR: 'SDK_ERROR',
30
+ CHANNEL_SUBSCRIPTION: 'CHANNEL_SUBSCRIPTION'
31
+ };
32
+
33
+ var ERROR_CATEGORY = {
34
+ PUSHX: 'PUSHX'
35
+ };
36
+
37
+ var ERROR_STATUS = {
38
+ ERROR: 'ERROR'
39
+ };
40
+
41
+ exports.DLSError = DLSError;
42
+ exports.PUSHXError = PUSHXError;
43
+ exports.ERROR_TYPES = ERROR_TYPES;
44
+ exports.ERROR_CATEGORY = ERROR_CATEGORY;
45
+
46
+ /**
47
+ * Constructor for the DLS error object
48
+ * Parameters:
49
+ * type: Error Type. Possible values are SDK_ERROR and API_ERROR
50
+ * err: JSON Error object. This can be:
51
+ * 1. HTTP Error Object returned by comproDLS APIs (In case of API_ERROR)
52
+ * 2. Custom Error Object(SDK_ERROR or Custom API_ERROR) with following structure
53
+ * {
54
+ * message: 'string',
55
+ * description: 'string'
56
+ * }
57
+ */
58
+ function DLSError(type, err) {
59
+ // We assume only two types of errors: SDK_ERROR (default) or API_ERROR
60
+ this.type = type;
61
+ if (type === ERROR_TYPES.API_ERROR) {
62
+
63
+ // Handling error on the basis of type of error (HTTP response or Custom)
64
+ var msg, desc;
65
+ if(err.response != undefined) {
66
+ msg = err.response.body.message || err.response.body.dbErrorBody || err.response.body.code;
67
+ desc = err.response.body.dbErrorDescription;
68
+
69
+ // Add swagger errors
70
+ if (err.response.body.results && err.response.body.results.errors) {
71
+ msg = '';
72
+ for (var idx in err.response.body.results.errors) {
73
+ msg += err.response.body.results.errors[idx].message + ' ';
74
+ }
75
+ }
76
+
77
+ // Add request_id
78
+ if (err.response.body.server) {
79
+ this.server = err.response.body.server;
80
+ }
81
+
82
+ } else {
83
+ msg = err.message ? err.message : '';
84
+ desc = err.description ? err.description : '';
85
+ }
86
+
87
+ //Set the message and description
88
+ this.message = msg;
89
+ this.description = desc;
90
+ }
91
+ else if (type === ERROR_TYPES.PUSHX_ERROR) {
92
+ //Set the message and description
93
+ this.message = err.message;
94
+ this.data = err;
95
+ }
96
+ else {
97
+ this.message = err.message ? err.message : '';
98
+ this.description = err.description ? err.description : '';
99
+ delete err.message;
100
+ delete err.description;
101
+ this.data = err;
102
+ }
103
+
104
+ if (type === ERROR_TYPES.API_ERROR || type === ERROR_TYPES.PUSHX_ERROR) {
105
+ this.httpcode = err.status;
106
+ }
107
+ };
108
+
109
+ function PUSHXError(category, error) {
110
+ if (category === ERROR_CATEGORY.PUSHX) {
111
+ this.category = ERROR_CATEGORY.PUSHX;
112
+ this.type = error.type || ERROR_TYPES.CHANNEL_SUBSCRIPTION;
113
+ this.status = ERROR_STATUS.ERROR;
114
+ this.message = error.message;
115
+ this.data = error;
116
+ this.httpcode = (error.errorDetails && error.errorDetails.statusCode) ?
117
+ error.errorDetails.statusCode : 500;
118
+ }
119
+ else {
120
+ this.message = 'PUSHXError called for incorrect category.';
121
+ }
122
+ };