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.
- package/.eslintrc +28 -28
- package/.npmignore +5 -0
- package/README.md +371 -371
- package/dist/comprodls-sdk.js +11493 -11471
- package/dist/comprodls-sdk.min.js +14 -14
- package/grunt/publish.js +148 -148
- package/lib/comprodls.js +146 -146
- package/lib/config/index.js +337 -337
- package/lib/helpers/index.js +29 -29
- package/lib/helpers/lib/api/converter.js +119 -119
- package/lib/helpers/lib/api/index.js +120 -120
- package/lib/helpers/lib/api/validations.js +72 -72
- package/lib/helpers/lib/errors.js +129 -129
- package/lib/helpers/lib/utils.js +23 -23
- package/lib/helpers/lib/validator.js +100 -100
- package/lib/open_access/index.js +121 -121
- package/lib/services/activity/activity.js +209 -209
- package/lib/services/activity/attempt.js +431 -431
- package/lib/services/activity/index.js +28 -28
- package/lib/services/analytics/index.js +1555 -1555
- package/lib/services/attempts/index.js +342 -342
- package/lib/services/auth/classProduct.js +37 -37
- package/lib/services/auth/index.js +2541 -2541
- package/lib/services/collab/index.js +468 -468
- package/lib/services/drive/index.js +144 -144
- package/lib/services/integrations/index.js +279 -279
- package/lib/services/invitations/index.js +313 -313
- package/lib/services/lrs/index.js +459 -459
- package/lib/services/product/index.js +267 -267
- package/lib/services/pub/index.js +407 -407
- package/lib/services/push/index.js +187 -187
- package/lib/services/push/pubnubClientWrapper.js +557 -557
- package/lib/services/push/sessionStorage.js +64 -64
- package/lib/services/pushX/index.js +190 -190
- package/lib/services/pushX/pubnubClientWrapper.js +211 -211
- package/lib/services/sisevents/index.js +113 -113
- package/lib/services/spaces/index.js +976 -929
- package/lib/services/superuser/index.js +175 -175
- package/lib/services/workflows/index.js +464 -464
- package/lib/services/xapi/index.js +232 -232
- package/lib/token/index.js +114 -114
- package/lib/token/validations.js +88 -88
- package/package-lock.json +5095 -0
- package/package.json +1 -1
- package/test.js +50 -50
- package/.vscode/launch.json +0 -23
- package/npm-debug.log.189866131 +0 -0
- package/npm-debug.log.712840116 +0 -26
|
@@ -1,64 +1,64 @@
|
|
|
1
|
-
module.exports = (function () {
|
|
2
|
-
var _sessionStorageKey = "ComproDLS.PubnubClientWrapper.Session";
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* Function to check if the session storage supported by browser.
|
|
6
|
-
*/
|
|
7
|
-
var __isSessionStorageSupported = function() {
|
|
8
|
-
return (typeof(Storage) !== "undefined");
|
|
9
|
-
};
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* Function to store data in session storage
|
|
13
|
-
*/
|
|
14
|
-
var __setData = function(data) {
|
|
15
|
-
if (__isSessionStorageSupported()) { // Web storage supported by browser.
|
|
16
|
-
sessionStorage.setItem(_sessionStorageKey,
|
|
17
|
-
JSON.stringify(data));
|
|
18
|
-
return { "error": false };
|
|
19
|
-
} else {
|
|
20
|
-
return { "error": true };
|
|
21
|
-
}
|
|
22
|
-
};
|
|
23
|
-
|
|
24
|
-
/**
|
|
25
|
-
* Function to get data from session storage
|
|
26
|
-
*/
|
|
27
|
-
var __getData = function() {
|
|
28
|
-
if (__isSessionStorageSupported()) { // Web storage supported by browser.
|
|
29
|
-
var sessionStorageData = JSON.parse(sessionStorage.getItem(_sessionStorageKey));
|
|
30
|
-
if(sessionStorageData) {
|
|
31
|
-
return {
|
|
32
|
-
"error": false,
|
|
33
|
-
"data": sessionStorageData
|
|
34
|
-
};
|
|
35
|
-
} else {
|
|
36
|
-
return {
|
|
37
|
-
"error": true,
|
|
38
|
-
"message": "No data found in browser sessionStorage."
|
|
39
|
-
};
|
|
40
|
-
}
|
|
41
|
-
} else {
|
|
42
|
-
return { "error": true };
|
|
43
|
-
}
|
|
44
|
-
};
|
|
45
|
-
|
|
46
|
-
/**
|
|
47
|
-
* Function to remove data from session storage
|
|
48
|
-
*/
|
|
49
|
-
var __removeData = function() {
|
|
50
|
-
if (__isSessionStorageSupported()) { // Web storage supported by browser.
|
|
51
|
-
sessionStorage.removeItem(_sessionStorageKey);
|
|
52
|
-
return { "error": false };
|
|
53
|
-
} else {
|
|
54
|
-
return { "error": true };
|
|
55
|
-
}
|
|
56
|
-
};
|
|
57
|
-
|
|
58
|
-
return {
|
|
59
|
-
"setData": __setData,
|
|
60
|
-
"getData": __getData,
|
|
61
|
-
"removeData": __removeData,
|
|
62
|
-
"isSessionStorageSupported" : __isSessionStorageSupported
|
|
63
|
-
};
|
|
64
|
-
}) ();
|
|
1
|
+
module.exports = (function () {
|
|
2
|
+
var _sessionStorageKey = "ComproDLS.PubnubClientWrapper.Session";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Function to check if the session storage supported by browser.
|
|
6
|
+
*/
|
|
7
|
+
var __isSessionStorageSupported = function() {
|
|
8
|
+
return (typeof(Storage) !== "undefined");
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Function to store data in session storage
|
|
13
|
+
*/
|
|
14
|
+
var __setData = function(data) {
|
|
15
|
+
if (__isSessionStorageSupported()) { // Web storage supported by browser.
|
|
16
|
+
sessionStorage.setItem(_sessionStorageKey,
|
|
17
|
+
JSON.stringify(data));
|
|
18
|
+
return { "error": false };
|
|
19
|
+
} else {
|
|
20
|
+
return { "error": true };
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Function to get data from session storage
|
|
26
|
+
*/
|
|
27
|
+
var __getData = function() {
|
|
28
|
+
if (__isSessionStorageSupported()) { // Web storage supported by browser.
|
|
29
|
+
var sessionStorageData = JSON.parse(sessionStorage.getItem(_sessionStorageKey));
|
|
30
|
+
if(sessionStorageData) {
|
|
31
|
+
return {
|
|
32
|
+
"error": false,
|
|
33
|
+
"data": sessionStorageData
|
|
34
|
+
};
|
|
35
|
+
} else {
|
|
36
|
+
return {
|
|
37
|
+
"error": true,
|
|
38
|
+
"message": "No data found in browser sessionStorage."
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
} else {
|
|
42
|
+
return { "error": true };
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Function to remove data from session storage
|
|
48
|
+
*/
|
|
49
|
+
var __removeData = function() {
|
|
50
|
+
if (__isSessionStorageSupported()) { // Web storage supported by browser.
|
|
51
|
+
sessionStorage.removeItem(_sessionStorageKey);
|
|
52
|
+
return { "error": false };
|
|
53
|
+
} else {
|
|
54
|
+
return { "error": true };
|
|
55
|
+
}
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
return {
|
|
59
|
+
"setData": __setData,
|
|
60
|
+
"getData": __getData,
|
|
61
|
+
"removeData": __removeData,
|
|
62
|
+
"isSessionStorageSupported" : __isSessionStorageSupported
|
|
63
|
+
};
|
|
64
|
+
}) ();
|
|
@@ -1,190 +1,190 @@
|
|
|
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 PUSHX Adaptor
|
|
23
|
-
* Functions for calling PUSHX.
|
|
24
|
-
************************************************************/
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
var q = require('q');
|
|
28
|
-
var request = require('superagent');
|
|
29
|
-
|
|
30
|
-
var helpers = require('../../helpers');
|
|
31
|
-
var pubnubClientWrapper = require('./pubnubClientWrapper');
|
|
32
|
-
var DLSError = helpers.errors.DLSError;
|
|
33
|
-
|
|
34
|
-
/*********************************
|
|
35
|
-
* Setting Up Module Entry Point
|
|
36
|
-
**********************************/
|
|
37
|
-
module.exports = pushX;
|
|
38
|
-
|
|
39
|
-
/*********************************
|
|
40
|
-
* Public Function definitions
|
|
41
|
-
**********************************/
|
|
42
|
-
function pushX() {
|
|
43
|
-
var _pubnubClientWrapper = pubnubClientWrapper();
|
|
44
|
-
return {
|
|
45
|
-
"connect": _connect.bind(this, _pubnubClientWrapper),
|
|
46
|
-
"cleanup": _cleanup.bind(this, _pubnubClientWrapper),
|
|
47
|
-
"grantByUserOrgId": grantByUserOrgId.bind(this),
|
|
48
|
-
"grantByAccountId": grantByAccountId.bind(this),
|
|
49
|
-
"grantByAccountIdOnExtUserId": grantByAccountIdOnExtUserId.bind(this)
|
|
50
|
-
};
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
/*********************************
|
|
54
|
-
* Public Function definitions
|
|
55
|
-
**********************************/
|
|
56
|
-
|
|
57
|
-
function _connect(pubnubCW, options) {
|
|
58
|
-
// Adding SSL flag
|
|
59
|
-
return pubnubCW.setup({
|
|
60
|
-
'userid': options.userid,
|
|
61
|
-
'pubnub': {
|
|
62
|
-
'publishKey': options.publishKey,
|
|
63
|
-
'subscribeKey': options.subscribeKey,
|
|
64
|
-
'authKey': options.authKey,
|
|
65
|
-
'ssl': true
|
|
66
|
-
}
|
|
67
|
-
});
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
function _cleanup(pubnubCW) { pubnubCW.cleanup(); }
|
|
71
|
-
|
|
72
|
-
/*options = {
|
|
73
|
-
authKey: <authKey>
|
|
74
|
-
}*/
|
|
75
|
-
function grantByUserOrgId(options) {
|
|
76
|
-
var self = this;
|
|
77
|
-
var dfd = q.defer(); // Initializing promise
|
|
78
|
-
// Validations
|
|
79
|
-
var err = helpers.validations.isAuthenticated(self.orgId, self.token);
|
|
80
|
-
if(err) { dfd.reject(err); }
|
|
81
|
-
else {
|
|
82
|
-
// Passed all validations, Construct API url
|
|
83
|
-
var url = self.config.DEFAULT_HOSTS.PUSHX + self.config.PUSHX_API_URLS.grantByUserOrgId;
|
|
84
|
-
url = helpers.api.constructAPIUrl(url, { orgId: self.orgId });
|
|
85
|
-
// Setup request with URL and Params
|
|
86
|
-
var requestAPI = request.post(url)
|
|
87
|
-
.set('Content-Type', 'application/json')
|
|
88
|
-
.set('Accept', 'application/json');
|
|
89
|
-
|
|
90
|
-
var body = {};
|
|
91
|
-
if(options.authKey) { body.authKey = options.authKey; }
|
|
92
|
-
|
|
93
|
-
requestAPI.send(body);
|
|
94
|
-
|
|
95
|
-
//Setup token in Authorization header
|
|
96
|
-
requestAPI = helpers.api.setupAPIToken(requestAPI, self.token);
|
|
97
|
-
if(self.traceid) { requestAPI.set('X-Amzn-Trace-Id', self.traceid); }
|
|
98
|
-
|
|
99
|
-
// Call Change Password Api
|
|
100
|
-
requestAPI.end(function(err, response) {
|
|
101
|
-
if(err) {
|
|
102
|
-
err = new DLSError(helpers.errors.ERROR_TYPES.API_ERROR, err);
|
|
103
|
-
dfd.reject(err);
|
|
104
|
-
}
|
|
105
|
-
else { dfd.resolve(response.body); }
|
|
106
|
-
});
|
|
107
|
-
}
|
|
108
|
-
return dfd.promise;
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
/*options = {
|
|
112
|
-
accountId: <accountid>,
|
|
113
|
-
refId: <extRefId>,
|
|
114
|
-
authKey: <authKey>
|
|
115
|
-
}*/
|
|
116
|
-
function grantByAccountId(options) {
|
|
117
|
-
var self = this, err ={};
|
|
118
|
-
var dfd = q.defer(); // Initializing promise
|
|
119
|
-
|
|
120
|
-
if(options.accountId && options.refId) {
|
|
121
|
-
// Passed all validations, Construct API url
|
|
122
|
-
var url = self.config.DEFAULT_HOSTS.PUSHX + self.config.PUSHX_API_URLS.grantByAccountId;
|
|
123
|
-
url = helpers.api.constructAPIUrl(url, { accountId: options.accountId });
|
|
124
|
-
// Setup request with URL and Params
|
|
125
|
-
var requestAPI = request.post(url)
|
|
126
|
-
.set('Content-Type', 'application/json')
|
|
127
|
-
.set('Accept', 'application/json');
|
|
128
|
-
if(self.traceid) { requestAPI.set('X-Amzn-Trace-Id', self.traceid); }
|
|
129
|
-
|
|
130
|
-
var body = { refId: options.refId };
|
|
131
|
-
if(options.authKey) { body.authKey = options.authKey; }
|
|
132
|
-
|
|
133
|
-
requestAPI.send(body);
|
|
134
|
-
requestAPI.end(function(err, response) {
|
|
135
|
-
if(err) {
|
|
136
|
-
err = new DLSError(helpers.errors.ERROR_TYPES.API_ERROR, err);
|
|
137
|
-
dfd.reject(err);
|
|
138
|
-
}
|
|
139
|
-
else { dfd.resolve(response.body); }
|
|
140
|
-
});
|
|
141
|
-
}
|
|
142
|
-
else {
|
|
143
|
-
err.message = err.description = "Required parameter ['accountId', 'refId'] " +
|
|
144
|
-
"not found in request options";
|
|
145
|
-
err = new DLSError(helpers.errors.ERROR_TYPES.SDK_ERROR, err);
|
|
146
|
-
dfd.reject(err);
|
|
147
|
-
}
|
|
148
|
-
return dfd.promise;
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
/*options = {
|
|
152
|
-
accountId: <accountid>,
|
|
153
|
-
extUserId: <extUserId>, //mandatory
|
|
154
|
-
authKey: <authKey>
|
|
155
|
-
}*/
|
|
156
|
-
function grantByAccountIdOnExtUserId(options) {
|
|
157
|
-
var self = this, err ={};
|
|
158
|
-
var dfd = q.defer(); // Initializing promise
|
|
159
|
-
|
|
160
|
-
if(options.accountId && options.extUserId) {
|
|
161
|
-
// Passed all validations, Construct API url
|
|
162
|
-
var url = self.config.DEFAULT_HOSTS.PUSHX + self.config.PUSHX_API_URLS.grantByAccountId;
|
|
163
|
-
url = helpers.api.constructAPIUrl(url, { accountId: options.accountId });
|
|
164
|
-
// Setup request with URL and Params
|
|
165
|
-
var requestAPI = request.post(url)
|
|
166
|
-
.set('Content-Type', 'application/json')
|
|
167
|
-
.set('Accept', 'application/json');
|
|
168
|
-
if(self.traceid) { requestAPI.set('X-Amzn-Trace-Id', self.traceid); }
|
|
169
|
-
|
|
170
|
-
var body = { extUserId: options.extUserId };
|
|
171
|
-
if(options.authKey) { body.authKey = options.authKey; }
|
|
172
|
-
|
|
173
|
-
requestAPI.send(body);
|
|
174
|
-
requestAPI.end(function(err, response) {
|
|
175
|
-
if(err) {
|
|
176
|
-
err = new DLSError(helpers.errors.ERROR_TYPES.API_ERROR, err);
|
|
177
|
-
dfd.reject(err);
|
|
178
|
-
}
|
|
179
|
-
else { dfd.resolve(response.body); }
|
|
180
|
-
});
|
|
181
|
-
}
|
|
182
|
-
else {
|
|
183
|
-
err.message = err.description = "Required parameter ['accountId', 'extUserId'] " +
|
|
184
|
-
"not found in request options";
|
|
185
|
-
err = new DLSError(helpers.errors.ERROR_TYPES.SDK_ERROR, err);
|
|
186
|
-
dfd.reject(err);
|
|
187
|
-
}
|
|
188
|
-
return dfd.promise;
|
|
189
|
-
}
|
|
190
|
-
|
|
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 PUSHX Adaptor
|
|
23
|
+
* Functions for calling PUSHX.
|
|
24
|
+
************************************************************/
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
var q = require('q');
|
|
28
|
+
var request = require('superagent');
|
|
29
|
+
|
|
30
|
+
var helpers = require('../../helpers');
|
|
31
|
+
var pubnubClientWrapper = require('./pubnubClientWrapper');
|
|
32
|
+
var DLSError = helpers.errors.DLSError;
|
|
33
|
+
|
|
34
|
+
/*********************************
|
|
35
|
+
* Setting Up Module Entry Point
|
|
36
|
+
**********************************/
|
|
37
|
+
module.exports = pushX;
|
|
38
|
+
|
|
39
|
+
/*********************************
|
|
40
|
+
* Public Function definitions
|
|
41
|
+
**********************************/
|
|
42
|
+
function pushX() {
|
|
43
|
+
var _pubnubClientWrapper = pubnubClientWrapper();
|
|
44
|
+
return {
|
|
45
|
+
"connect": _connect.bind(this, _pubnubClientWrapper),
|
|
46
|
+
"cleanup": _cleanup.bind(this, _pubnubClientWrapper),
|
|
47
|
+
"grantByUserOrgId": grantByUserOrgId.bind(this),
|
|
48
|
+
"grantByAccountId": grantByAccountId.bind(this),
|
|
49
|
+
"grantByAccountIdOnExtUserId": grantByAccountIdOnExtUserId.bind(this)
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/*********************************
|
|
54
|
+
* Public Function definitions
|
|
55
|
+
**********************************/
|
|
56
|
+
|
|
57
|
+
function _connect(pubnubCW, options) {
|
|
58
|
+
// Adding SSL flag
|
|
59
|
+
return pubnubCW.setup({
|
|
60
|
+
'userid': options.userid,
|
|
61
|
+
'pubnub': {
|
|
62
|
+
'publishKey': options.publishKey,
|
|
63
|
+
'subscribeKey': options.subscribeKey,
|
|
64
|
+
'authKey': options.authKey,
|
|
65
|
+
'ssl': true
|
|
66
|
+
}
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
function _cleanup(pubnubCW) { pubnubCW.cleanup(); }
|
|
71
|
+
|
|
72
|
+
/*options = {
|
|
73
|
+
authKey: <authKey>
|
|
74
|
+
}*/
|
|
75
|
+
function grantByUserOrgId(options) {
|
|
76
|
+
var self = this;
|
|
77
|
+
var dfd = q.defer(); // Initializing promise
|
|
78
|
+
// Validations
|
|
79
|
+
var err = helpers.validations.isAuthenticated(self.orgId, self.token);
|
|
80
|
+
if(err) { dfd.reject(err); }
|
|
81
|
+
else {
|
|
82
|
+
// Passed all validations, Construct API url
|
|
83
|
+
var url = self.config.DEFAULT_HOSTS.PUSHX + self.config.PUSHX_API_URLS.grantByUserOrgId;
|
|
84
|
+
url = helpers.api.constructAPIUrl(url, { orgId: self.orgId });
|
|
85
|
+
// Setup request with URL and Params
|
|
86
|
+
var requestAPI = request.post(url)
|
|
87
|
+
.set('Content-Type', 'application/json')
|
|
88
|
+
.set('Accept', 'application/json');
|
|
89
|
+
|
|
90
|
+
var body = {};
|
|
91
|
+
if(options.authKey) { body.authKey = options.authKey; }
|
|
92
|
+
|
|
93
|
+
requestAPI.send(body);
|
|
94
|
+
|
|
95
|
+
//Setup token in Authorization header
|
|
96
|
+
requestAPI = helpers.api.setupAPIToken(requestAPI, self.token);
|
|
97
|
+
if(self.traceid) { requestAPI.set('X-Amzn-Trace-Id', self.traceid); }
|
|
98
|
+
|
|
99
|
+
// Call Change Password Api
|
|
100
|
+
requestAPI.end(function(err, response) {
|
|
101
|
+
if(err) {
|
|
102
|
+
err = new DLSError(helpers.errors.ERROR_TYPES.API_ERROR, err);
|
|
103
|
+
dfd.reject(err);
|
|
104
|
+
}
|
|
105
|
+
else { dfd.resolve(response.body); }
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
return dfd.promise;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
/*options = {
|
|
112
|
+
accountId: <accountid>,
|
|
113
|
+
refId: <extRefId>,
|
|
114
|
+
authKey: <authKey>
|
|
115
|
+
}*/
|
|
116
|
+
function grantByAccountId(options) {
|
|
117
|
+
var self = this, err ={};
|
|
118
|
+
var dfd = q.defer(); // Initializing promise
|
|
119
|
+
|
|
120
|
+
if(options.accountId && options.refId) {
|
|
121
|
+
// Passed all validations, Construct API url
|
|
122
|
+
var url = self.config.DEFAULT_HOSTS.PUSHX + self.config.PUSHX_API_URLS.grantByAccountId;
|
|
123
|
+
url = helpers.api.constructAPIUrl(url, { accountId: options.accountId });
|
|
124
|
+
// Setup request with URL and Params
|
|
125
|
+
var requestAPI = request.post(url)
|
|
126
|
+
.set('Content-Type', 'application/json')
|
|
127
|
+
.set('Accept', 'application/json');
|
|
128
|
+
if(self.traceid) { requestAPI.set('X-Amzn-Trace-Id', self.traceid); }
|
|
129
|
+
|
|
130
|
+
var body = { refId: options.refId };
|
|
131
|
+
if(options.authKey) { body.authKey = options.authKey; }
|
|
132
|
+
|
|
133
|
+
requestAPI.send(body);
|
|
134
|
+
requestAPI.end(function(err, response) {
|
|
135
|
+
if(err) {
|
|
136
|
+
err = new DLSError(helpers.errors.ERROR_TYPES.API_ERROR, err);
|
|
137
|
+
dfd.reject(err);
|
|
138
|
+
}
|
|
139
|
+
else { dfd.resolve(response.body); }
|
|
140
|
+
});
|
|
141
|
+
}
|
|
142
|
+
else {
|
|
143
|
+
err.message = err.description = "Required parameter ['accountId', 'refId'] " +
|
|
144
|
+
"not found in request options";
|
|
145
|
+
err = new DLSError(helpers.errors.ERROR_TYPES.SDK_ERROR, err);
|
|
146
|
+
dfd.reject(err);
|
|
147
|
+
}
|
|
148
|
+
return dfd.promise;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
/*options = {
|
|
152
|
+
accountId: <accountid>,
|
|
153
|
+
extUserId: <extUserId>, //mandatory
|
|
154
|
+
authKey: <authKey>
|
|
155
|
+
}*/
|
|
156
|
+
function grantByAccountIdOnExtUserId(options) {
|
|
157
|
+
var self = this, err ={};
|
|
158
|
+
var dfd = q.defer(); // Initializing promise
|
|
159
|
+
|
|
160
|
+
if(options.accountId && options.extUserId) {
|
|
161
|
+
// Passed all validations, Construct API url
|
|
162
|
+
var url = self.config.DEFAULT_HOSTS.PUSHX + self.config.PUSHX_API_URLS.grantByAccountId;
|
|
163
|
+
url = helpers.api.constructAPIUrl(url, { accountId: options.accountId });
|
|
164
|
+
// Setup request with URL and Params
|
|
165
|
+
var requestAPI = request.post(url)
|
|
166
|
+
.set('Content-Type', 'application/json')
|
|
167
|
+
.set('Accept', 'application/json');
|
|
168
|
+
if(self.traceid) { requestAPI.set('X-Amzn-Trace-Id', self.traceid); }
|
|
169
|
+
|
|
170
|
+
var body = { extUserId: options.extUserId };
|
|
171
|
+
if(options.authKey) { body.authKey = options.authKey; }
|
|
172
|
+
|
|
173
|
+
requestAPI.send(body);
|
|
174
|
+
requestAPI.end(function(err, response) {
|
|
175
|
+
if(err) {
|
|
176
|
+
err = new DLSError(helpers.errors.ERROR_TYPES.API_ERROR, err);
|
|
177
|
+
dfd.reject(err);
|
|
178
|
+
}
|
|
179
|
+
else { dfd.resolve(response.body); }
|
|
180
|
+
});
|
|
181
|
+
}
|
|
182
|
+
else {
|
|
183
|
+
err.message = err.description = "Required parameter ['accountId', 'extUserId'] " +
|
|
184
|
+
"not found in request options";
|
|
185
|
+
err = new DLSError(helpers.errors.ERROR_TYPES.SDK_ERROR, err);
|
|
186
|
+
dfd.reject(err);
|
|
187
|
+
}
|
|
188
|
+
return dfd.promise;
|
|
189
|
+
}
|
|
190
|
+
|