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,73 +1,73 @@
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 APIS Module Validations
22
- * This module contains validations for APIS module.
23
- ************************************************************/
24
- var validate = require('../validator').validate;
25
-
26
- /****************************************************
27
- * Setting up Exports/Public variables
28
- *****************************************************/
29
- exports.genericAPICaller = validateGenericAPICaller;
30
-
31
- /*********************************
32
- * Public Function definitions
33
- **********************************/
34
- function validateGenericAPICaller(apiName, method, url, params) {
35
- var validate_options = {
36
- 'apiName': apiName,
37
- 'method': method,
38
- 'url': url,
39
- 'params':params
40
- };
41
-
42
- var validate_constraints = {
43
- "apiName" : {
44
- "isString" : true,
45
- "presence" : true,
46
- "inclusion": {
47
- "within" : ["AUTH" , "PRODUCT" , "COLLAB" , "ANALYTICS" , "ACTIVITY" , "XAPI"],
48
- "message": "^Enter a valid API Name"
49
- }
50
- },
51
- "method" : {
52
- "isString" : true,
53
- "presence" : true,
54
- "inclusion": {
55
- "within" : ["GET" , "POST" , "PUT" , "DELETE"],
56
- "message": "^Enter a valid HTTP method"
57
- }
58
- },
59
- "url" : {
60
- "isString" : true,
61
- "presence" : true,
62
- "format": {
63
- "pattern": "^/.*$",
64
- "message": "^Url should start with a /"
65
- }
66
- },
67
- "params" : {
68
- "isObject" : true
69
- }
70
- };
71
-
72
- return validate(validate_options, validate_constraints);
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 APIS Module Validations
22
+ * This module contains validations for APIS module.
23
+ ************************************************************/
24
+ var validate = require('../validator').validate;
25
+
26
+ /****************************************************
27
+ * Setting up Exports/Public variables
28
+ *****************************************************/
29
+ exports.genericAPICaller = validateGenericAPICaller;
30
+
31
+ /*********************************
32
+ * Public Function definitions
33
+ **********************************/
34
+ function validateGenericAPICaller(apiName, method, url, params) {
35
+ var validate_options = {
36
+ 'apiName': apiName,
37
+ 'method': method,
38
+ 'url': url,
39
+ 'params':params
40
+ };
41
+
42
+ var validate_constraints = {
43
+ "apiName" : {
44
+ "isString" : true,
45
+ "presence" : true,
46
+ "inclusion": {
47
+ "within" : ["AUTH" , "PRODUCT" , "COLLAB" , "ANALYTICS" , "ACTIVITY" , "XAPI"],
48
+ "message": "^Enter a valid API Name"
49
+ }
50
+ },
51
+ "method" : {
52
+ "isString" : true,
53
+ "presence" : true,
54
+ "inclusion": {
55
+ "within" : ["GET" , "POST" , "PUT" , "DELETE"],
56
+ "message": "^Enter a valid HTTP method"
57
+ }
58
+ },
59
+ "url" : {
60
+ "isString" : true,
61
+ "presence" : true,
62
+ "format": {
63
+ "pattern": "^/.*$",
64
+ "message": "^Url should start with a /"
65
+ }
66
+ },
67
+ "params" : {
68
+ "isObject" : true
69
+ }
70
+ };
71
+
72
+ return validate(validate_options, validate_constraints);
73
73
  };
@@ -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
- * comproDLS SDK Error Helper Module
22
- * This module contains helper functions for Error management
23
- ************************************************************/
24
-
25
- //All possible Error types in SDK
26
- var ERROR_TYPES = {
27
- "API_ERROR": "API_ERROR",
28
- "SDK_ERROR": "SDK_ERROR",
29
- "CHANNEL_SUBSCRIPTION": "CHANNEL_SUBSCRIPTION"
30
- };
31
-
32
- var ERROR_CATEGORY = {
33
- PUSHX: 'PUSHX'
34
- };
35
-
36
-
37
- var ERROR_STATUS = {
38
- ERROR: 'ERROR'
39
- };
40
-
41
- /****************************************************
42
- * Setting up Exports/Public functions and variables
43
- *****************************************************/
44
- exports.DLSError = DLSError;
45
- exports.PUSHXError = PUSHXError;
46
- exports.ERROR_TYPES = ERROR_TYPES;
47
- exports.ERROR_CATEGORY = ERROR_CATEGORY;
48
-
49
- /*****************************************
50
- * Constructor for the DLS error object
51
- * Parameters:
52
- * type: Error Type. Possible values are SDK_ERROR and API_ERROR
53
- * err: JSON Error object. This can be:
54
- * 1. HTTP Error Object returned by comproDLS APIs (In case of API_ERROR)
55
- * 2. Custom Error Object(SDK_ERROR or Custom API_ERROR) with following structure
56
- * {
57
- * "message":"[String]",
58
- * "description":"[String]"
59
- * }
60
- ******************************************/
61
- function DLSError(type, err) {
62
- /*
63
- * We assume only two types of errors: SDK_ERROR (default)
64
- * or API_ERROR
65
- */
66
- this.type = type;
67
- if (type === ERROR_TYPES.API_ERROR) {
68
-
69
- //Depending on type of error (HTTP response or Custom) deal with different formats of the err object
70
- var msg, desc;
71
- if(err.response != undefined) {
72
- msg = err.response.body.message || err.response.body.dbErrorBody || err.response.body.code;
73
- desc = err.response.body.dbErrorDescription;
74
-
75
- // Add swagger errors
76
- if(err.response.body.results && err.response.body.results.errors) {
77
- msg = '';
78
- for(var idx in err.response.body.results.errors) {
79
- msg += err.response.body.results.errors[idx].message + ' ';
80
- }
81
- }
82
-
83
- // Add request_id
84
- if(err.response.body.server) {
85
- this.server = err.response.body.server;
86
- }
87
-
88
- } else {
89
- msg = err.message ? err.message : "";
90
- desc = err.description ? err.description : "";
91
- }
92
-
93
- //Set the message and description
94
- this.message = msg;
95
- this.description = desc;
96
- }
97
- else if(type === ERROR_TYPES.PUSHX_ERROR) {
98
-
99
- //Set the message and description
100
- this.message = err.message;
101
- this.data = err;
102
- }
103
- else {
104
- this.message = err.message ? err.message : "";
105
- this.description = err.description ? err.description : "";
106
- delete err.message;
107
- delete err.description;
108
- this.data = err;
109
- }
110
-
111
- if (type === ERROR_TYPES.API_ERROR || type === ERROR_TYPES.PUSHX_ERROR) {
112
- this.httpcode = err.status;
113
- }
114
- };
115
-
116
- function PUSHXError(category, error) {
117
-
118
- if (category === ERROR_CATEGORY.PUSHX) {
119
- this.category = ERROR_CATEGORY.PUSHX;
120
- this.type = ERROR_TYPES.CHANNEL_SUBSCRIPTION;
121
- this.status = ERROR_STATUS.ERROR;
122
- this.message = error.message;
123
- this.data = error;
124
- this.httpcode = (error.errorDetails && error.errorDetails.statusCode) ? error.errorDetails.statusCode : 500;
125
- }
126
- else {
127
- this.message = 'PUSHXError called for incorrect category.';
128
- }
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
+ * comproDLS SDK Error Helper Module
22
+ * This module contains helper functions for Error management
23
+ ************************************************************/
24
+
25
+ //All possible Error types in SDK
26
+ var ERROR_TYPES = {
27
+ "API_ERROR": "API_ERROR",
28
+ "SDK_ERROR": "SDK_ERROR",
29
+ "CHANNEL_SUBSCRIPTION": "CHANNEL_SUBSCRIPTION"
30
+ };
31
+
32
+ var ERROR_CATEGORY = {
33
+ PUSHX: 'PUSHX'
34
+ };
35
+
36
+
37
+ var ERROR_STATUS = {
38
+ ERROR: 'ERROR'
39
+ };
40
+
41
+ /****************************************************
42
+ * Setting up Exports/Public functions and variables
43
+ *****************************************************/
44
+ exports.DLSError = DLSError;
45
+ exports.PUSHXError = PUSHXError;
46
+ exports.ERROR_TYPES = ERROR_TYPES;
47
+ exports.ERROR_CATEGORY = ERROR_CATEGORY;
48
+
49
+ /*****************************************
50
+ * Constructor for the DLS error object
51
+ * Parameters:
52
+ * type: Error Type. Possible values are SDK_ERROR and API_ERROR
53
+ * err: JSON Error object. This can be:
54
+ * 1. HTTP Error Object returned by comproDLS APIs (In case of API_ERROR)
55
+ * 2. Custom Error Object(SDK_ERROR or Custom API_ERROR) with following structure
56
+ * {
57
+ * "message":"[String]",
58
+ * "description":"[String]"
59
+ * }
60
+ ******************************************/
61
+ function DLSError(type, err) {
62
+ /*
63
+ * We assume only two types of errors: SDK_ERROR (default)
64
+ * or API_ERROR
65
+ */
66
+ this.type = type;
67
+ if (type === ERROR_TYPES.API_ERROR) {
68
+
69
+ //Depending on type of error (HTTP response or Custom) deal with different formats of the err object
70
+ var msg, desc;
71
+ if(err.response != undefined) {
72
+ msg = err.response.body.message || err.response.body.dbErrorBody || err.response.body.code;
73
+ desc = err.response.body.dbErrorDescription;
74
+
75
+ // Add swagger errors
76
+ if(err.response.body.results && err.response.body.results.errors) {
77
+ msg = '';
78
+ for(var idx in err.response.body.results.errors) {
79
+ msg += err.response.body.results.errors[idx].message + ' ';
80
+ }
81
+ }
82
+
83
+ // Add request_id
84
+ if(err.response.body.server) {
85
+ this.server = err.response.body.server;
86
+ }
87
+
88
+ } else {
89
+ msg = err.message ? err.message : "";
90
+ desc = err.description ? err.description : "";
91
+ }
92
+
93
+ //Set the message and description
94
+ this.message = msg;
95
+ this.description = desc;
96
+ }
97
+ else if(type === ERROR_TYPES.PUSHX_ERROR) {
98
+
99
+ //Set the message and description
100
+ this.message = err.message;
101
+ this.data = err;
102
+ }
103
+ else {
104
+ this.message = err.message ? err.message : "";
105
+ this.description = err.description ? err.description : "";
106
+ delete err.message;
107
+ delete err.description;
108
+ this.data = err;
109
+ }
110
+
111
+ if (type === ERROR_TYPES.API_ERROR || type === ERROR_TYPES.PUSHX_ERROR) {
112
+ this.httpcode = err.status;
113
+ }
114
+ };
115
+
116
+ function PUSHXError(category, error) {
117
+
118
+ if (category === ERROR_CATEGORY.PUSHX) {
119
+ this.category = ERROR_CATEGORY.PUSHX;
120
+ this.type = ERROR_TYPES.CHANNEL_SUBSCRIPTION;
121
+ this.status = ERROR_STATUS.ERROR;
122
+ this.message = error.message;
123
+ this.data = error;
124
+ this.httpcode = (error.errorDetails && error.errorDetails.statusCode) ? error.errorDetails.statusCode : 500;
125
+ }
126
+ else {
127
+ this.message = 'PUSHXError called for incorrect category.';
128
+ }
129
+ };
@@ -1,24 +1,24 @@
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 Util Module
22
- * This module provides Utility functions for SDK
23
- ************************************************************/
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 Util Module
22
+ * This module provides Utility functions for SDK
23
+ ************************************************************/
24
24
  exports.isBrowser = typeof window !== "undefined";
@@ -1,101 +1,101 @@
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 Validator Helper Module
22
- * This module contains validation helper functions for comproDLS SDK
23
- ************************************************************/
24
- var validator = require("validate.js");
25
- var errors = require('./errors');
26
- var DLSError = errors.DLSError;
27
-
28
-
29
- /****************************************************
30
- * Setting up Exports/Public functions
31
- *****************************************************/
32
- exports.validate = validate;
33
- exports.isAuthenticated = validateIsAuthenticated;
34
-
35
- /*********************************
36
- * Public Function definitions
37
- **********************************/
38
- function validate(options, constraints) {
39
- var err = {};
40
- var validation_errors = validator(options, constraints);
41
- if (validation_errors) {
42
- for (var validation_error in validation_errors) {
43
- err.message = err.description = validation_errors[validation_error][0];
44
- err = new DLSError(errors.ERROR_TYPES.SDK_ERROR, err);
45
- return err;
46
- }
47
- } else {
48
- return undefined;
49
- }
50
- };
51
-
52
- function validateIsAuthenticated(orgId, token) {
53
- var validate_options = {
54
- 'organization': orgId,
55
- 'token': token
56
- };
57
-
58
- var validate_constraints = {
59
- "organization": {
60
- "presence": {
61
- "message" : "^SDK Instance does not have valid orgid or token. Please authenticate using authWithCredentials or authWithToken method."
62
- }
63
- },
64
- "token": {
65
- "presence": {
66
- "message" : "^SDK Instance does not have valid orgid or token. Please authenticate using authWithCredentials or authWithToken method."
67
- }
68
- }
69
- };
70
-
71
- return validate(validate_options, validate_constraints);
72
- };
73
-
74
- /*********************************
75
- * Private Function definitions
76
- **********************************/
77
- validator.validators.isString = function(value, options) {
78
- if (!validator.isString(value)) {
79
- return options.message || "is not a valid string";
80
- }
81
- };
82
-
83
- validator.validators.isObject = function(value, options) {
84
- if (!validator.isObject(value)) {
85
- return options.message || "is not a valid object";
86
- }
87
- };
88
-
89
- validator.validators.contains = function(value, options) {
90
- if (validator.isArray(options)) {
91
- for (var key in options) {
92
- if (!value || !value.hasOwnProperty(options[key])) {
93
- return options.message || "does not contain " + options[key];
94
- }
95
- }
96
- } else if (validator.isString(options)) {
97
- if (!value || !value.hasOwnProperty(options)) {
98
- return options.message || "does not contain " + options;
99
- }
100
- }
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 Validator Helper Module
22
+ * This module contains validation helper functions for comproDLS SDK
23
+ ************************************************************/
24
+ var validator = require("validate.js");
25
+ var errors = require('./errors');
26
+ var DLSError = errors.DLSError;
27
+
28
+
29
+ /****************************************************
30
+ * Setting up Exports/Public functions
31
+ *****************************************************/
32
+ exports.validate = validate;
33
+ exports.isAuthenticated = validateIsAuthenticated;
34
+
35
+ /*********************************
36
+ * Public Function definitions
37
+ **********************************/
38
+ function validate(options, constraints) {
39
+ var err = {};
40
+ var validation_errors = validator(options, constraints);
41
+ if (validation_errors) {
42
+ for (var validation_error in validation_errors) {
43
+ err.message = err.description = validation_errors[validation_error][0];
44
+ err = new DLSError(errors.ERROR_TYPES.SDK_ERROR, err);
45
+ return err;
46
+ }
47
+ } else {
48
+ return undefined;
49
+ }
50
+ };
51
+
52
+ function validateIsAuthenticated(orgId, token) {
53
+ var validate_options = {
54
+ 'organization': orgId,
55
+ 'token': token
56
+ };
57
+
58
+ var validate_constraints = {
59
+ "organization": {
60
+ "presence": {
61
+ "message" : "^SDK Instance does not have valid orgid or token. Please authenticate using authWithCredentials or authWithToken method."
62
+ }
63
+ },
64
+ "token": {
65
+ "presence": {
66
+ "message" : "^SDK Instance does not have valid orgid or token. Please authenticate using authWithCredentials or authWithToken method."
67
+ }
68
+ }
69
+ };
70
+
71
+ return validate(validate_options, validate_constraints);
72
+ };
73
+
74
+ /*********************************
75
+ * Private Function definitions
76
+ **********************************/
77
+ validator.validators.isString = function(value, options) {
78
+ if (!validator.isString(value)) {
79
+ return options.message || "is not a valid string";
80
+ }
81
+ };
82
+
83
+ validator.validators.isObject = function(value, options) {
84
+ if (!validator.isObject(value)) {
85
+ return options.message || "is not a valid object";
86
+ }
87
+ };
88
+
89
+ validator.validators.contains = function(value, options) {
90
+ if (validator.isArray(options)) {
91
+ for (var key in options) {
92
+ if (!value || !value.hasOwnProperty(options[key])) {
93
+ return options.message || "does not contain " + options[key];
94
+ }
95
+ }
96
+ } else if (validator.isString(options)) {
97
+ if (!value || !value.hasOwnProperty(options)) {
98
+ return options.message || "does not contain " + options;
99
+ }
100
+ }
101
101
  };