comprodls-sdk 2.86.2-valky → 2.90.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.
- package/dist/comprodls-sdk.js +303 -558
- package/dist/comprodls-sdk.min.js +1 -1
- package/lib/config/index.js +3 -17
- package/lib/helpers/lib/errors.js +2 -4
- package/lib/services/auth/index.js +2 -178
- package/lib/services/authextn/index.js +111 -49
- package/lib/services/product/index.js +4 -12
- package/lib/services/pub/index.js +5 -12
- package/lib/services/pushX/index.js +127 -181
- package/lib/services/pushX/pubnubClientWrapper.js +3 -49
- package/lib/services/spaces/index.js +0 -5
- package/lib/services/spacesextn/index.js +1 -45
- package/lib/services/workflows/index.js +2 -4
- package/lib/services/xapi/index.js +43 -1
- package/package.json +2 -2
- package/test.js +38 -0
|
@@ -26,7 +26,6 @@
|
|
|
26
26
|
|
|
27
27
|
var q = require('q');
|
|
28
28
|
var request = require('superagent');
|
|
29
|
-
var Agent = require('agentkeepalive');
|
|
30
29
|
|
|
31
30
|
var helpers = require('../../helpers');
|
|
32
31
|
var pubnubClientWrapper = require('./pubnubClientWrapper');
|
|
@@ -37,25 +36,18 @@ var DLSError = helpers.errors.DLSError;
|
|
|
37
36
|
**********************************/
|
|
38
37
|
module.exports = pushX;
|
|
39
38
|
|
|
40
|
-
var keepaliveAgent = new Agent({
|
|
41
|
-
timeout: 60000,
|
|
42
|
-
freeSocketTimeout: 30000
|
|
43
|
-
});
|
|
44
|
-
|
|
45
39
|
/*********************************
|
|
46
40
|
* Public Function definitions
|
|
47
41
|
**********************************/
|
|
48
42
|
function pushX() {
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
"getPushedEvents": getPushedEvents.bind(this)
|
|
58
|
-
};
|
|
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
|
+
};
|
|
59
51
|
}
|
|
60
52
|
|
|
61
53
|
/*********************************
|
|
@@ -63,190 +55,144 @@ function pushX() {
|
|
|
63
55
|
**********************************/
|
|
64
56
|
|
|
65
57
|
function _connect(pubnubCW, options) {
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
// Adding SSL flag
|
|
75
|
-
return pubnubCW.setup({
|
|
76
|
-
'userid': options.userid,
|
|
77
|
-
'accountid': options.accountid,
|
|
78
|
-
'token': options.token,
|
|
79
|
-
'pubnub': {
|
|
80
|
-
'publishKey': options.publishKey,
|
|
81
|
-
'subscribeKey': options.subscribeKey,
|
|
82
|
-
'ssl': true,
|
|
83
|
-
'suppressLeaveEvents': true
|
|
58
|
+
var bpubnubV7 = true; // If pubnub v7 or higher in package.json, set it true
|
|
59
|
+
if (bpubnubV7 && !options.userid) {
|
|
60
|
+
var err = {};
|
|
61
|
+
err.message = err.description = 'Mandatory parameter userid not found in request options.';
|
|
62
|
+
err = new DLSError(helpers.errors.ERROR_TYPES.PUSHX_ERROR, err);
|
|
63
|
+
throw err;
|
|
84
64
|
}
|
|
85
|
-
|
|
65
|
+
|
|
66
|
+
// Adding SSL flag
|
|
67
|
+
return pubnubCW.setup({
|
|
68
|
+
'userid': options.userid,
|
|
69
|
+
'pubnub': {
|
|
70
|
+
'publishKey': options.publishKey,
|
|
71
|
+
'subscribeKey': options.subscribeKey,
|
|
72
|
+
'authKey': options.authKey,
|
|
73
|
+
'ssl': true
|
|
74
|
+
}
|
|
75
|
+
});
|
|
86
76
|
}
|
|
87
77
|
|
|
88
78
|
function _cleanup(pubnubCW) { pubnubCW.cleanup(); }
|
|
89
79
|
|
|
90
|
-
/*options = {
|
|
80
|
+
/*options = {
|
|
81
|
+
authKey: <authKey>
|
|
82
|
+
}*/
|
|
91
83
|
function grantByUserOrgId(options) {
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
84
|
+
var self = this;
|
|
85
|
+
var dfd = q.defer(); // Initializing promise
|
|
86
|
+
// Validations
|
|
87
|
+
var err = helpers.validations.isAuthenticated(self.orgId, self.token);
|
|
88
|
+
if(err) { dfd.reject(err); }
|
|
89
|
+
else {
|
|
90
|
+
// Passed all validations, Construct API url
|
|
91
|
+
var url = self.config.DEFAULT_HOSTS.PUSHX + self.config.PUSHX_API_URLS.grantByUserOrgId;
|
|
92
|
+
url = helpers.api.constructAPIUrl(url, { orgId: self.orgId });
|
|
93
|
+
// Setup request with URL and Params
|
|
94
|
+
var requestAPI = request.post(url)
|
|
95
|
+
.set('Content-Type', 'application/json')
|
|
96
|
+
.set('Accept', 'application/json');
|
|
97
|
+
|
|
98
|
+
var body = {};
|
|
99
|
+
if(options.authKey) { body.authKey = options.authKey; }
|
|
100
|
+
|
|
101
|
+
requestAPI.send(body);
|
|
102
|
+
|
|
103
|
+
//Setup token in Authorization header
|
|
104
|
+
requestAPI = helpers.api.setupAPIToken(requestAPI, self.token);
|
|
105
|
+
if(self.traceid) { requestAPI.set('X-Amzn-Trace-Id', self.traceid); }
|
|
106
|
+
|
|
107
|
+
// Call Change Password Api
|
|
108
|
+
requestAPI.end(function(err, response) {
|
|
109
|
+
if(err) {
|
|
110
|
+
err = new DLSError(helpers.errors.ERROR_TYPES.API_ERROR, err);
|
|
111
|
+
dfd.reject(err);
|
|
112
|
+
}
|
|
113
|
+
else { dfd.resolve(response.body); }
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
return dfd.promise;
|
|
110
117
|
}
|
|
111
118
|
|
|
112
119
|
/*options = {
|
|
113
120
|
accountId: <accountid>,
|
|
114
|
-
refId: <extRefId
|
|
121
|
+
refId: <extRefId>,
|
|
122
|
+
authKey: <authKey>
|
|
115
123
|
}*/
|
|
116
124
|
function grantByAccountId(options) {
|
|
117
|
-
var err ={};
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
125
|
+
var self = this, err ={};
|
|
126
|
+
var dfd = q.defer(); // Initializing promise
|
|
127
|
+
|
|
128
|
+
if(options.accountId && options.refId) {
|
|
129
|
+
// Passed all validations, Construct API url
|
|
130
|
+
var url = self.config.DEFAULT_HOSTS.PUSHX + self.config.PUSHX_API_URLS.grantByAccountId;
|
|
131
|
+
url = helpers.api.constructAPIUrl(url, { accountId: options.accountId });
|
|
132
|
+
// Setup request with URL and Params
|
|
133
|
+
var requestAPI = request.post(url)
|
|
134
|
+
.set('Content-Type', 'application/json')
|
|
135
|
+
.set('Accept', 'application/json');
|
|
136
|
+
if(self.traceid) { requestAPI.set('X-Amzn-Trace-Id', self.traceid); }
|
|
137
|
+
|
|
138
|
+
var body = { refId: options.refId };
|
|
139
|
+
if(options.authKey) { body.authKey = options.authKey; }
|
|
140
|
+
|
|
141
|
+
requestAPI.send(body);
|
|
142
|
+
requestAPI.end(function(err, response) {
|
|
143
|
+
if(err) {
|
|
144
|
+
err = new DLSError(helpers.errors.ERROR_TYPES.API_ERROR, err);
|
|
145
|
+
dfd.reject(err);
|
|
146
|
+
}
|
|
147
|
+
else { dfd.resolve(response.body); }
|
|
148
|
+
});
|
|
149
|
+
}
|
|
150
|
+
else {
|
|
151
|
+
err.message = err.description = "Required parameter ['accountId', 'refId'] " +
|
|
152
|
+
"not found in request options";
|
|
153
|
+
err = new DLSError(helpers.errors.ERROR_TYPES.SDK_ERROR, err);
|
|
154
|
+
dfd.reject(err);
|
|
155
|
+
}
|
|
156
|
+
return dfd.promise;
|
|
140
157
|
}
|
|
141
158
|
|
|
142
159
|
/*options = {
|
|
143
160
|
accountId: <accountid>,
|
|
144
161
|
extUserId: <extUserId>, //mandatory
|
|
162
|
+
authKey: <authKey>
|
|
145
163
|
}*/
|
|
146
164
|
function grantByAccountIdOnExtUserId(options) {
|
|
147
|
-
var err ={};
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
/**
|
|
173
|
-
* This function provides grant token on given channels
|
|
174
|
-
* @param { channels: { exactMatch: [], patterns: [] } } options
|
|
175
|
-
* @returns { token, publishKey, subscribeKey }
|
|
176
|
-
*/
|
|
177
|
-
function grantV2(options) {
|
|
178
|
-
var self = this, err = {};
|
|
179
|
-
var dfd = q.defer();
|
|
180
|
-
var body = { channels: {} };
|
|
181
|
-
if(!options.channels) {
|
|
182
|
-
err.message = err.description = "channels not given in input body.";
|
|
183
|
-
err = new DLSError(helpers.errors.ERROR_TYPES.SDK_ERROR, err);
|
|
184
|
-
dfd.reject(err);
|
|
185
|
-
return dfd.promise;
|
|
186
|
-
}
|
|
187
|
-
body.channels = options.channels;
|
|
188
|
-
// Passed all validations, Construct API url
|
|
189
|
-
var url = self.config.DEFAULT_HOSTS.PUSHX + self.config.PUSHX_API_URLS.grantV2;
|
|
190
|
-
// Setup request with URL and Params
|
|
191
|
-
var requestAPI = request.post(url)
|
|
192
|
-
.set('Content-Type', 'application/json')
|
|
193
|
-
.set('Accept', 'application/json');
|
|
194
|
-
if(self.traceid) { requestAPI.set('X-Amzn-Trace-Id', self.traceid); }
|
|
195
|
-
|
|
196
|
-
requestAPI.send(body);
|
|
197
|
-
requestAPI.end(function(err, response) {
|
|
198
|
-
if(err) {
|
|
199
|
-
err = new DLSError(helpers.errors.ERROR_TYPES.API_ERROR, err);
|
|
200
|
-
dfd.reject(err);
|
|
165
|
+
var self = this, err ={};
|
|
166
|
+
var dfd = q.defer(); // Initializing promise
|
|
167
|
+
|
|
168
|
+
if(options.accountId && options.extUserId) {
|
|
169
|
+
// Passed all validations, Construct API url
|
|
170
|
+
var url = self.config.DEFAULT_HOSTS.PUSHX + self.config.PUSHX_API_URLS.grantByAccountId;
|
|
171
|
+
url = helpers.api.constructAPIUrl(url, { accountId: options.accountId });
|
|
172
|
+
// Setup request with URL and Params
|
|
173
|
+
var requestAPI = request.post(url)
|
|
174
|
+
.set('Content-Type', 'application/json')
|
|
175
|
+
.set('Accept', 'application/json');
|
|
176
|
+
if(self.traceid) { requestAPI.set('X-Amzn-Trace-Id', self.traceid); }
|
|
177
|
+
|
|
178
|
+
var body = { extUserId: options.extUserId };
|
|
179
|
+
if(options.authKey) { body.authKey = options.authKey; }
|
|
180
|
+
|
|
181
|
+
requestAPI.send(body);
|
|
182
|
+
requestAPI.end(function(err, response) {
|
|
183
|
+
if(err) {
|
|
184
|
+
err = new DLSError(helpers.errors.ERROR_TYPES.API_ERROR, err);
|
|
185
|
+
dfd.reject(err);
|
|
186
|
+
}
|
|
187
|
+
else { dfd.resolve(response.body); }
|
|
188
|
+
});
|
|
201
189
|
}
|
|
202
|
-
else {
|
|
203
|
-
|
|
204
|
-
|
|
190
|
+
else {
|
|
191
|
+
err.message = err.description = "Required parameter ['accountId', 'extUserId'] " +
|
|
192
|
+
"not found in request options";
|
|
193
|
+
err = new DLSError(helpers.errors.ERROR_TYPES.SDK_ERROR, err);
|
|
194
|
+
dfd.reject(err);
|
|
195
|
+
}
|
|
196
|
+
return dfd.promise;
|
|
205
197
|
}
|
|
206
198
|
|
|
207
|
-
/**
|
|
208
|
-
* @param {
|
|
209
|
-
* *accountid: "string",
|
|
210
|
-
* *channelName: "string",
|
|
211
|
-
* *starttime: number,
|
|
212
|
-
* *endtime: number
|
|
213
|
-
* } options
|
|
214
|
-
*/
|
|
215
|
-
function getPushedEvents(options) {
|
|
216
|
-
var self = this;
|
|
217
|
-
var dfd = q.defer(); // Initializing promise
|
|
218
|
-
var accountid = options.accountid,
|
|
219
|
-
channelname = options.channelname,
|
|
220
|
-
starttime = options.starttime,
|
|
221
|
-
endtime = options.endtime;
|
|
222
|
-
|
|
223
|
-
if (accountid && channelname && starttime && endtime) {
|
|
224
|
-
// Passed all validations, Construct API url
|
|
225
|
-
var url = self.config.DEFAULT_HOSTS.PUSHX + self.config.PUSHX_API_URLS.getPushedEvents;
|
|
226
|
-
url = helpers.api.constructAPIUrl(url, { accountId: accountid });
|
|
227
|
-
|
|
228
|
-
// Setup request with URL and Params
|
|
229
|
-
var params = {channelname: channelname, starttime: starttime, endtime: endtime};
|
|
230
|
-
var requestAPI = request.get(url).query(params);
|
|
231
|
-
if(self.traceid) { requestAPI.set('X-Amzn-Trace-Id', self.traceid); }
|
|
232
|
-
|
|
233
|
-
requestAPI
|
|
234
|
-
.agent(keepaliveAgent)
|
|
235
|
-
.end(function(error, response) {
|
|
236
|
-
if (error) {
|
|
237
|
-
error = new DLSError(helpers.errors.ERROR_TYPES.API_ERROR, error);
|
|
238
|
-
dfd.reject(error);
|
|
239
|
-
} else {
|
|
240
|
-
dfd.resolve(response.body);
|
|
241
|
-
}
|
|
242
|
-
});
|
|
243
|
-
}
|
|
244
|
-
else {
|
|
245
|
-
var err = {};
|
|
246
|
-
err.message = err.description = 'Mandatory parameters [accountId, channelname,' +
|
|
247
|
-
' starttime, endtime] not found in request options';
|
|
248
|
-
err = new DLSError(helpers.errors.ERROR_TYPES.SDK_ERROR, err);
|
|
249
|
-
dfd.reject(err);
|
|
250
|
-
}
|
|
251
|
-
return dfd.promise;
|
|
252
|
-
}
|
|
@@ -75,7 +75,7 @@ module.exports = function () {
|
|
|
75
75
|
_eventEmitter.emit(subscribedChannel, message);
|
|
76
76
|
};
|
|
77
77
|
|
|
78
|
-
var _translatePubnubStatus = function(status
|
|
78
|
+
var _translatePubnubStatus = function(status) {
|
|
79
79
|
var channels = [], error, successObj;
|
|
80
80
|
switch (status.category) {
|
|
81
81
|
case "PNConnectedCategory":
|
|
@@ -104,10 +104,8 @@ module.exports = function () {
|
|
|
104
104
|
break;
|
|
105
105
|
case "PNAccessDeniedCategory":
|
|
106
106
|
if(status.operation === "PNSubscribeOperation") {
|
|
107
|
-
var errorText = status.errorData.response && status.errorData.response.text;
|
|
108
|
-
var errorJSON = errorText ? JSON.parse(errorText) : undefined;
|
|
109
107
|
var errorData = {
|
|
110
|
-
payload:
|
|
108
|
+
payload: JSON.parse(status.errorData.response.text).payload,
|
|
111
109
|
message: 'Forbidden: Subscription failed.',
|
|
112
110
|
errorDetails: {
|
|
113
111
|
operation: status.operation,
|
|
@@ -136,46 +134,6 @@ module.exports = function () {
|
|
|
136
134
|
error = new PUSHXError(helpers.errors.ERROR_CATEGORY.PUSHX, error);
|
|
137
135
|
_eventEmitter.emit('pushx_status', error);
|
|
138
136
|
break;
|
|
139
|
-
case "PNNetworkIssuesCategory":
|
|
140
|
-
if(status.operation === 'PNSubscribeOperation') {
|
|
141
|
-
if(!options.accountId) {
|
|
142
|
-
error = {
|
|
143
|
-
message: "Missing mandatory parameters to initiate polling operation - accountId",
|
|
144
|
-
status: status.statusCode,
|
|
145
|
-
type: helpers.errors.ERROR_TYPES.POLLING_INITIATION,
|
|
146
|
-
};
|
|
147
|
-
error = new PUSHXError(helpers.errors.ERROR_CATEGORY.PUSHX, error);
|
|
148
|
-
_eventEmitter.emit('pushx_status', error);
|
|
149
|
-
break;
|
|
150
|
-
}
|
|
151
|
-
else {
|
|
152
|
-
/**
|
|
153
|
-
* Handle network issue category status for 'subscription' opreration
|
|
154
|
-
* Start the events polling here.
|
|
155
|
-
*
|
|
156
|
-
* The wrapper supports multiple channels, but the APP currently uses a single channel only.
|
|
157
|
-
* Polling will also limited to a single channel.
|
|
158
|
-
*/
|
|
159
|
-
}
|
|
160
|
-
}
|
|
161
|
-
else {
|
|
162
|
-
// Handle network issue category status for other operations like 'unsubscription'
|
|
163
|
-
}
|
|
164
|
-
break;
|
|
165
|
-
case "PNReconnectedCategory":
|
|
166
|
-
// Handle reconnected category status.
|
|
167
|
-
break;
|
|
168
|
-
default:
|
|
169
|
-
// Emit error for other status-category received from pubnub
|
|
170
|
-
error = {
|
|
171
|
-
message: "PushX Error",
|
|
172
|
-
status: status.statusCode,
|
|
173
|
-
type: helpers.errors.ERROR_TYPES.UNEXPECTED_ERROR,
|
|
174
|
-
pushXError: status
|
|
175
|
-
};
|
|
176
|
-
error = new PUSHXError(helpers.errors.ERROR_CATEGORY.PUSHX, error);
|
|
177
|
-
_eventEmitter.emit('pushx_status', error);
|
|
178
|
-
break;
|
|
179
137
|
}
|
|
180
138
|
};
|
|
181
139
|
|
|
@@ -209,12 +167,9 @@ module.exports = function () {
|
|
|
209
167
|
var __setup = function (userOptions) {
|
|
210
168
|
var pubnubConfig = userOptions.pubnub;
|
|
211
169
|
pubnubConfig.uuid = userOptions.userid;
|
|
212
|
-
var accountId = userOptions.accountid;
|
|
213
|
-
var token = userOptions.token;
|
|
214
170
|
|
|
215
171
|
if (!_pubnubClient && pubnubConfig) {
|
|
216
172
|
_pubnubClient = new pubNub(pubnubConfig); //Connect with PubNub SDK
|
|
217
|
-
_pubnubClient.setToken(token);
|
|
218
173
|
processSetup();
|
|
219
174
|
} else {
|
|
220
175
|
return new Error('Already Initialized');
|
|
@@ -230,8 +185,7 @@ module.exports = function () {
|
|
|
230
185
|
_translatePubnubMessage(data);
|
|
231
186
|
},
|
|
232
187
|
"status": function (status) {
|
|
233
|
-
|
|
234
|
-
_translatePubnubStatus(status, statusOptions);
|
|
188
|
+
_translatePubnubStatus(status);
|
|
235
189
|
}
|
|
236
190
|
});
|
|
237
191
|
}
|
|
@@ -524,7 +524,6 @@ function provisionBulkSpaces(options) {
|
|
|
524
524
|
* *startdate: <epoch>,
|
|
525
525
|
* *enddate: <epoch>,
|
|
526
526
|
* description: 'string',
|
|
527
|
-
* ext_class_title : 'string',
|
|
528
527
|
* ext_data: {},
|
|
529
528
|
* limits: {
|
|
530
529
|
* *los: 0,
|
|
@@ -538,7 +537,6 @@ function provisionBulkSpaces(options) {
|
|
|
538
537
|
* clone_settings: {
|
|
539
538
|
* *src_ext_classid: 'string',
|
|
540
539
|
* products: boolean,
|
|
541
|
-
* bundles: boolean,
|
|
542
540
|
* assigned_paths: boolean,
|
|
543
541
|
* ext_assigned_path_id_rule: 'string' //enum: ['SRC_ID']
|
|
544
542
|
* advanced: {
|
|
@@ -552,9 +550,6 @@ function provisionBulkSpaces(options) {
|
|
|
552
550
|
* ],
|
|
553
551
|
* products: [
|
|
554
552
|
* { *productcode: 'string' },
|
|
555
|
-
* ],
|
|
556
|
-
* bundles: [
|
|
557
|
-
* { *bundlecode: 'string' },
|
|
558
553
|
* ]
|
|
559
554
|
* }
|
|
560
555
|
* }
|
|
@@ -44,8 +44,7 @@ var keepaliveAgent = new Agent({
|
|
|
44
44
|
function spacesextn(accountId) {
|
|
45
45
|
this.accountId = accountId;
|
|
46
46
|
return {
|
|
47
|
-
entitleBulkUsersToProducts: entitleBulkUsersToProducts.bind(this)
|
|
48
|
-
setupUser: setupUser.bind(this)
|
|
47
|
+
entitleBulkUsersToProducts: entitleBulkUsersToProducts.bind(this)
|
|
49
48
|
};
|
|
50
49
|
}
|
|
51
50
|
|
|
@@ -106,46 +105,3 @@ function entitleBulkUsersToProducts(options) {
|
|
|
106
105
|
return dfd.promise;
|
|
107
106
|
}
|
|
108
107
|
|
|
109
|
-
/**
|
|
110
|
-
* @param {
|
|
111
|
-
* *ext_user_id: "string",
|
|
112
|
-
* *workflow_type: "string",
|
|
113
|
-
* *<workflow_type>: {}
|
|
114
|
-
* } options
|
|
115
|
-
*/
|
|
116
|
-
function setupUser(options) {
|
|
117
|
-
var self = this;
|
|
118
|
-
//Initializing promise
|
|
119
|
-
var deferred = q.defer();
|
|
120
|
-
|
|
121
|
-
if (options && options.ext_user_id && options.workflow_type) {
|
|
122
|
-
//Passed all validations, Contruct API url
|
|
123
|
-
var url = self.config.DEFAULT_HOSTS.AUTHEXTN + self.config.AUTHEXTN_API_URLS.setupUser;
|
|
124
|
-
url = helpers.api.constructAPIUrl(url, { accountId: self.accountId });
|
|
125
|
-
|
|
126
|
-
var requestAPI = request.post(url)
|
|
127
|
-
.set('Content-Type', 'application/json')
|
|
128
|
-
.set('Accept', 'application/json')
|
|
129
|
-
.send(options);
|
|
130
|
-
|
|
131
|
-
if (self.traceid) { requestAPI.set('X-Amzn-Trace-Id', self.traceid); }
|
|
132
|
-
|
|
133
|
-
requestAPI
|
|
134
|
-
.agent(keepaliveAgent)
|
|
135
|
-
.end(function(err, res) {
|
|
136
|
-
if (err) {
|
|
137
|
-
err = new DLSError(helpers.errors.ERROR_TYPES.API_ERROR, err);
|
|
138
|
-
deferred.reject(err);
|
|
139
|
-
} else {
|
|
140
|
-
deferred.resolve(res.body);
|
|
141
|
-
}
|
|
142
|
-
});
|
|
143
|
-
} else {
|
|
144
|
-
var err = {};
|
|
145
|
-
err.message = err.description = 'Mandatory field \'ext_user_id\' or \'workflow_type\' not found '+
|
|
146
|
-
'in the request options.';
|
|
147
|
-
err = new DLSError(helpers.errors.ERROR_TYPES.SDK_ERROR, err);
|
|
148
|
-
deferred.reject(err);
|
|
149
|
-
}
|
|
150
|
-
return deferred.promise;
|
|
151
|
-
}
|
|
@@ -59,7 +59,6 @@ function workflows(accountId) {
|
|
|
59
59
|
"address": {
|
|
60
60
|
"city": "string",
|
|
61
61
|
"country": "string",
|
|
62
|
-
"line1": "string",
|
|
63
62
|
"street1": "string",
|
|
64
63
|
"street2": "string",
|
|
65
64
|
"street3": "string",
|
|
@@ -415,7 +414,6 @@ function completeAWorkflow(options) {
|
|
|
415
414
|
"address": {
|
|
416
415
|
"city": "string",
|
|
417
416
|
"country": "string",
|
|
418
|
-
"line1": "string",
|
|
419
417
|
"street1": "string",
|
|
420
418
|
"street2": "string",
|
|
421
419
|
"street3": "string",
|
|
@@ -425,7 +423,7 @@ function completeAWorkflow(options) {
|
|
|
425
423
|
"display_name": "string",
|
|
426
424
|
"school_key": "string"
|
|
427
425
|
}
|
|
428
|
-
}
|
|
426
|
+
}
|
|
429
427
|
}
|
|
430
428
|
*/
|
|
431
429
|
function updateWorkflowRequest(options) {
|
|
@@ -464,4 +462,4 @@ function updateWorkflowRequest(options) {
|
|
|
464
462
|
dfd.reject(err);
|
|
465
463
|
}
|
|
466
464
|
return dfd.promise;
|
|
467
|
-
}
|
|
465
|
+
}
|
|
@@ -42,7 +42,8 @@ function xapi(accountId) {
|
|
|
42
42
|
this.accountId = accountId;
|
|
43
43
|
return {
|
|
44
44
|
postStatement: postStatements.bind(this),
|
|
45
|
-
postExternalStatements: postExternalStatements.bind(this)
|
|
45
|
+
postExternalStatements: postExternalStatements.bind(this),
|
|
46
|
+
resetUserProductProgress: resetUserProductProgress.bind(this)
|
|
46
47
|
};
|
|
47
48
|
}
|
|
48
49
|
|
|
@@ -231,3 +232,44 @@ function postExternalStatements(options) {
|
|
|
231
232
|
});
|
|
232
233
|
return dfd.promise;
|
|
233
234
|
}
|
|
235
|
+
|
|
236
|
+
/*options = {
|
|
237
|
+
userid: 'string',
|
|
238
|
+
productcode: 'string',
|
|
239
|
+
actorid: 'string'
|
|
240
|
+
}*/
|
|
241
|
+
function resetUserProductProgress(options) {
|
|
242
|
+
var self = this;
|
|
243
|
+
// Initializing promise
|
|
244
|
+
var dfd = q.defer();
|
|
245
|
+
var err = {};
|
|
246
|
+
if(options && options.userid && options.productcode && options.actorid) {
|
|
247
|
+
|
|
248
|
+
// Passed all validations, Contruct API url
|
|
249
|
+
var url = self.config.DEFAULT_HOSTS.XAPI + self.config.XAPI_API_URLS.resetUserProductProgress;
|
|
250
|
+
url = helpers.api.constructAPIUrl(url, { accountId : self.accountId });
|
|
251
|
+
|
|
252
|
+
// Setup request with URL and Params
|
|
253
|
+
var requestAPI = request.delete(url)
|
|
254
|
+
.set('Content-Type', 'application/json')
|
|
255
|
+
.set('Accept', 'application/json')
|
|
256
|
+
.send(options);
|
|
257
|
+
|
|
258
|
+
if(self.traceid) { requestAPI.set('X-Amzn-Trace-Id', self.traceid); }
|
|
259
|
+
|
|
260
|
+
requestAPI.end(function(error, response) {
|
|
261
|
+
if(error) {
|
|
262
|
+
err = new DLSError(helpers.errors.ERROR_TYPES.API_ERROR, error);
|
|
263
|
+
dfd.reject(err);
|
|
264
|
+
}
|
|
265
|
+
else { dfd.resolve(response.body); }
|
|
266
|
+
});
|
|
267
|
+
}
|
|
268
|
+
else {
|
|
269
|
+
err.message = err.description = 'userid, productcode or actorid not found in request options.';
|
|
270
|
+
err = new DLSError(helpers.errors.ERROR_TYPES.SDK_ERROR, err);
|
|
271
|
+
dfd.reject(err);
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
return dfd.promise;
|
|
275
|
+
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "comprodls-sdk",
|
|
3
3
|
"description": "comproDLS SDK for JavaScript",
|
|
4
|
-
"version": "2.
|
|
4
|
+
"version": "2.90.2",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "Compro Technologies Private Limited",
|
|
7
7
|
"url": "http://www.comprotechnologies.com/"
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
"grunt": "^0.4.5",
|
|
25
25
|
"grunt-browserify": "^4.0.1",
|
|
26
26
|
"grunt-contrib-clean": "^1.0.0",
|
|
27
|
-
"grunt-contrib-uglify": "
|
|
27
|
+
"grunt-contrib-uglify": "^0.11.1",
|
|
28
28
|
"semver": "^5.1.0",
|
|
29
29
|
"shelljs": "^0.6.0"
|
|
30
30
|
}
|
package/test.js
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
|
|
2
|
+
var orgId = 'dev1';
|
|
3
|
+
|
|
4
|
+
var ComproDLS = require('../comprodls-sdk-js/lib/comprodls.js').init('DEVELOPMENT','GLOBAL');
|
|
5
|
+
|
|
6
|
+
var accountId = 'compro';
|
|
7
|
+
var tokenObj = {
|
|
8
|
+
// "access_token": "71a2d361-16b4-40b4-9a73-2499f808d7fe",
|
|
9
|
+
//"access_token" : "YWMtb2nasMuyEemJvL3ph9UnmAAAAW0KQNb1ziRGuAkJ_n6LweFX9KOhYaSQeKg~~5d5cf9be-cb5d-11e6-a329-0e34ffe5d91e", //student //YWMtw4m3tmsMEem5x6kSLL2ajAAAAWqQ3dJz4CkidQEwcm1LDszgrThOUuDLCkA~~5d5cf9be-cb5d-11e6-a329-0e34ffe5d91e
|
|
10
|
+
// "access_token" : "YWMtQAfQGHfCEemdBmGZgYqIcgAAAWrkJ96wsnysSc8M5ilW1ZI1jOeLo226vn8~~5d5cf9be-cb5d-11e6-a329-0e34ffe5d91e", //admin
|
|
11
|
+
// "expires_in": 604800,
|
|
12
|
+
// "refresh_token": "c002d2710236789e3f36d0b8670a07b684f44b4a43e9c4a322260c11390d37826a889053c876df0dc3ae49f4701cc27bdc42d77b62ec3735eaaf9ea35cc433f208aeb1d7003eddf38ec9ab418e40caa2fefb9fda6454a3b98daf9d911db4a4e8ca285a2dfbb395b7"
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
var self = this;
|
|
17
|
+
var Adapter = ComproDLS.AuthExtn(accountId);
|
|
18
|
+
|
|
19
|
+
var Options = {
|
|
20
|
+
"ext_user_id": "11jan_07",
|
|
21
|
+
"workflow_type": "org_entitlement",
|
|
22
|
+
"org_entitlement": {
|
|
23
|
+
"productcode": "evolve_l1",
|
|
24
|
+
"orgid": "dev1",
|
|
25
|
+
"dls_user_id": "71a2d361-16b4-40b4-9a73-2499f808d7fe",
|
|
26
|
+
"ext_role": "student"
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
Adapter.setupUser(Options)
|
|
31
|
+
.then(function (res) {
|
|
32
|
+
console.log("^^^^^^^^^^^^^", res);
|
|
33
|
+
})
|
|
34
|
+
.catch(function (err) {
|
|
35
|
+
console.log("ERR CATCG", err);
|
|
36
|
+
})
|
|
37
|
+
|
|
38
|
+
|