comprodls-sdk 2.89.0 → 2.90.0-qa
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/README.md +1 -137
- package/dist/comprodls-sdk.js +5937 -8432
- package/dist/comprodls-sdk.min.js +15 -1
- package/lib/comprodls.js +39 -57
- package/lib/config/index.js +171 -199
- package/lib/helpers/index.js +3 -2
- package/lib/helpers/lib/api/converter.js +1 -2
- package/lib/helpers/lib/api/index.js +19 -94
- package/lib/helpers/lib/errors.js +73 -80
- package/lib/helpers/lib/requestLayer.js +154 -0
- package/lib/helpers/lib/validator.js +65 -52
- package/lib/open_access/index.js +48 -53
- package/lib/services/analytics/index.js +286 -1014
- package/lib/services/attempts/index.js +38 -88
- package/lib/services/auth/index.js +238 -896
- package/lib/services/authextn/index.js +50 -150
- package/lib/services/datasyncmanager/index.js +10 -45
- package/lib/services/drive/index.js +20 -83
- package/lib/services/integrations/index.js +51 -126
- package/lib/services/invitations/index.js +20 -61
- package/lib/services/product/index.js +74 -85
- package/lib/services/pub/index.js +159 -234
- package/lib/services/pushX/index.js +29 -33
- package/lib/services/pushX/pubnubClientWrapper.js +398 -398
- package/lib/services/rules/index.js +14 -67
- package/lib/services/spaces/index.js +106 -294
- package/lib/services/spacesextn/index.js +4 -24
- package/lib/services/superuser/index.js +21 -36
- package/lib/services/taxonomy/index.js +27 -57
- package/lib/services/workflows/index.js +37 -98
- package/lib/services/xapi/index.js +6 -125
- package/lib/token/index.js +73 -67
- package/lib/token/validations.js +45 -48
- package/package.json +1 -2
- package/lib/helpers/lib/api/validations.js +0 -73
- package/lib/helpers/lib/utils.js +0 -24
- package/lib/services/activity/activity.js +0 -209
- package/lib/services/activity/attempt.js +0 -431
- package/lib/services/activity/index.js +0 -28
- package/lib/services/auth/classProduct.js +0 -37
- package/lib/services/collab/index.js +0 -468
|
@@ -1,468 +0,0 @@
|
|
|
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 Collab API Adaptor
|
|
22
|
-
* Functions for calling Collab API.
|
|
23
|
-
************************************************************/
|
|
24
|
-
var request = require('superagent');
|
|
25
|
-
var q = require('q');
|
|
26
|
-
|
|
27
|
-
var helpers = require('../../helpers');
|
|
28
|
-
var DLSError = helpers.errors.DLSError;
|
|
29
|
-
|
|
30
|
-
/*********************************
|
|
31
|
-
* Setting Up Module Entry Point
|
|
32
|
-
**********************************/
|
|
33
|
-
module.exports = collab;
|
|
34
|
-
|
|
35
|
-
function collab() {
|
|
36
|
-
return {
|
|
37
|
-
"getPostsInClass": getPostsInClass.bind(this),
|
|
38
|
-
"createPostInClass": createPostInClass.bind(this),
|
|
39
|
-
"getPostsInProduct": getPostsInProduct.bind(this),
|
|
40
|
-
"createPostInProduct": createPostInProduct.bind(this),
|
|
41
|
-
"getMyFollowers": getMyFollowers.bind(this),
|
|
42
|
-
"getUsersFollowedByMe": getUsersFollowedByMe.bind(this),
|
|
43
|
-
"followUser": followUser.bind(this),
|
|
44
|
-
"unfollowUser": unfollowUser.bind(this)
|
|
45
|
-
}
|
|
46
|
-
};
|
|
47
|
-
|
|
48
|
-
/*********************************
|
|
49
|
-
* Public Function definitions
|
|
50
|
-
**********************************/
|
|
51
|
-
|
|
52
|
-
//options = {
|
|
53
|
-
// classid: "class uuid",
|
|
54
|
-
// cursor: "string", //(optional) cursor to get next set of activities.
|
|
55
|
-
// limit: integer //(optional) number of activities to be returned (default 10).
|
|
56
|
-
//}
|
|
57
|
-
function getPostsInClass(options) {
|
|
58
|
-
var self = this;
|
|
59
|
-
//Initializing promise
|
|
60
|
-
var dfd = q.defer();
|
|
61
|
-
var err = {};
|
|
62
|
-
//Validations
|
|
63
|
-
if(options && options.classid) {
|
|
64
|
-
err = helpers.validations.isAuthenticated(self.orgId, self.token);
|
|
65
|
-
if(err) {
|
|
66
|
-
dfd.reject(err);
|
|
67
|
-
} else {
|
|
68
|
-
//Passed all validations, Construct API url
|
|
69
|
-
var url = self.config.DEFAULT_HOSTS['COLLAB'] + self.config.COLLAB_API_URLS.postsInClassAPI;
|
|
70
|
-
url = helpers.api.constructAPIUrl(url, {
|
|
71
|
-
"orgId": self.orgId,
|
|
72
|
-
"classId": options.classid
|
|
73
|
-
});
|
|
74
|
-
|
|
75
|
-
//Contruct parameters
|
|
76
|
-
var params = {};
|
|
77
|
-
if(options.cursor) {
|
|
78
|
-
params.cursor = options.cursor;
|
|
79
|
-
}
|
|
80
|
-
if(options.limit) {
|
|
81
|
-
params.limit = options.limit;
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
//Setup request with URL and Params
|
|
85
|
-
var requestAPI = request.get(url).query(params);
|
|
86
|
-
if(self.traceid) { requestAPI.set('X-Amzn-Trace-Id', self.traceid); }
|
|
87
|
-
|
|
88
|
-
//Setup token in Authorization header
|
|
89
|
-
requestAPI = helpers.api.setupAPIToken(requestAPI, self.token);
|
|
90
|
-
|
|
91
|
-
//Call GET CLASS ALL POSTS Api
|
|
92
|
-
requestAPI.end(function(error, response){
|
|
93
|
-
if(error) {
|
|
94
|
-
err = new DLSError(helpers.errors.ERROR_TYPES.API_ERROR, error);
|
|
95
|
-
dfd.reject(err);
|
|
96
|
-
} else {
|
|
97
|
-
dfd.resolve(response.body);
|
|
98
|
-
}
|
|
99
|
-
});
|
|
100
|
-
}
|
|
101
|
-
} else {
|
|
102
|
-
err.message = err.description = 'Mandatory parameter "classid" not found in request options';
|
|
103
|
-
err = new DLSError(helpers.errors.ERROR_TYPES.SDK_ERROR, err);
|
|
104
|
-
dfd.reject(err);
|
|
105
|
-
}
|
|
106
|
-
return dfd.promise;
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
//options = {
|
|
110
|
-
// classid: "class uuid",
|
|
111
|
-
// verb: "verb",
|
|
112
|
-
// post: "post", // (optional)
|
|
113
|
-
// name: "name", // (optional)
|
|
114
|
-
// email: "email", // (optional)
|
|
115
|
-
// userid: "userid" // (optional)
|
|
116
|
-
//}
|
|
117
|
-
function createPostInClass(options) {
|
|
118
|
-
var self = this;
|
|
119
|
-
//Initializing promise
|
|
120
|
-
var dfd = q.defer();
|
|
121
|
-
var err = {};
|
|
122
|
-
//Validations
|
|
123
|
-
if(options && options.verb && options.classid) {
|
|
124
|
-
err = helpers.validations.isAuthenticated(self.orgId, self.token);
|
|
125
|
-
if(err) {
|
|
126
|
-
dfd.reject(err);
|
|
127
|
-
} else {
|
|
128
|
-
//Passed all validations, Construct API url
|
|
129
|
-
var url = self.config.DEFAULT_HOSTS['COLLAB'] + self.config.COLLAB_API_URLS.postsInClassAPI;
|
|
130
|
-
url = helpers.api.constructAPIUrl(url, {
|
|
131
|
-
"orgId": self.orgId,
|
|
132
|
-
"classId": options.classid
|
|
133
|
-
});
|
|
134
|
-
//Construct parameters
|
|
135
|
-
var params = {
|
|
136
|
-
verb: options.verb
|
|
137
|
-
};
|
|
138
|
-
if(options.post) {
|
|
139
|
-
params.post = options.post;
|
|
140
|
-
}
|
|
141
|
-
if(options.name) {
|
|
142
|
-
params.name = options.name;
|
|
143
|
-
}
|
|
144
|
-
if(options.email) {
|
|
145
|
-
params.email = options.email;
|
|
146
|
-
}
|
|
147
|
-
if(options.userid) {
|
|
148
|
-
params.userid = options.userid;
|
|
149
|
-
}
|
|
150
|
-
//Setup request with url and params
|
|
151
|
-
var requestAPI = request.post(url).send(params);
|
|
152
|
-
if(self.traceid) { requestAPI.set('X-Amzn-Trace-Id', self.traceid); }
|
|
153
|
-
|
|
154
|
-
//Setup token in Authorization Header
|
|
155
|
-
requestAPI = helpers.api.setupAPIToken(requestAPI, self.token);
|
|
156
|
-
//Call POST 'POST in CLASS'
|
|
157
|
-
requestAPI.end(function(error, response) {
|
|
158
|
-
if(error) {
|
|
159
|
-
err = new DLSError(helpers.errors.ERROR_TYPES.API_ERROR, error);
|
|
160
|
-
dfd.reject(err);
|
|
161
|
-
} else {
|
|
162
|
-
dfd.resolve(response.body);
|
|
163
|
-
}
|
|
164
|
-
})
|
|
165
|
-
}
|
|
166
|
-
} else {
|
|
167
|
-
err.message = err.description = 'Mandatory parameter "verb" or "classid" not found in request options';
|
|
168
|
-
err = new DLSError(helpers.errors.ERROR_TYPES.SDK_ERROR, err);
|
|
169
|
-
dfd.reject(err);
|
|
170
|
-
}
|
|
171
|
-
return dfd.promise;
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
//options = {
|
|
175
|
-
// productid: "product uuid",
|
|
176
|
-
// cursor: "string", //(optional) cursor to get next set of activities
|
|
177
|
-
// limit: integer //(optional) number of activities to be returned(default 10)
|
|
178
|
-
//}
|
|
179
|
-
function getPostsInProduct(options) {
|
|
180
|
-
var self = this;
|
|
181
|
-
//Initializing promise
|
|
182
|
-
var dfd = q.defer();
|
|
183
|
-
var err = {};
|
|
184
|
-
//Validations
|
|
185
|
-
if(options && options.productid) {
|
|
186
|
-
err = helpers.validations.isAuthenticated(self.orgId, self.token);
|
|
187
|
-
if(err) {
|
|
188
|
-
dfd.reject(err);
|
|
189
|
-
} else {
|
|
190
|
-
//Passed all validations, Construct API url
|
|
191
|
-
var url = self.config.DEFAULT_HOSTS['COLLAB'] + self.config.COLLAB_API_URLS.postsInProductAPI;
|
|
192
|
-
url = helpers.api.constructAPIUrl(url, {
|
|
193
|
-
"orgId": self.orgId,
|
|
194
|
-
"productId": options.productid
|
|
195
|
-
});
|
|
196
|
-
//Contruct parameters
|
|
197
|
-
var params = {};
|
|
198
|
-
if(options.cursor) {
|
|
199
|
-
params.cursor = options.cursor;
|
|
200
|
-
}
|
|
201
|
-
if(options.limit) {
|
|
202
|
-
params.limit = options.limit;
|
|
203
|
-
}
|
|
204
|
-
//Setup request with URL and Params
|
|
205
|
-
var requestAPI = request.get(url).query(params);
|
|
206
|
-
if(self.traceid) { requestAPI.set('X-Amzn-Trace-Id', self.traceid); }
|
|
207
|
-
|
|
208
|
-
//Setup token in Authorization header
|
|
209
|
-
requestAPI = helpers.api.setupAPIToken(requestAPI, self.token);
|
|
210
|
-
//Call GET CLASS ALL POSTS Api
|
|
211
|
-
requestAPI.end(function(error, response) {
|
|
212
|
-
if(error) {
|
|
213
|
-
err = new DLSError(helpers.errors.ERROR_TYPES.API_ERROR, error);
|
|
214
|
-
dfd.reject(err);
|
|
215
|
-
} else {
|
|
216
|
-
dfd.resolve(response.body);
|
|
217
|
-
}
|
|
218
|
-
});
|
|
219
|
-
}
|
|
220
|
-
} else {
|
|
221
|
-
err.message = err.description = 'Mandatory parameter "productid" not found in request options';
|
|
222
|
-
err = new DLSError(helpers.errors.ERROR_TYPES.SDK_ERROR, err);
|
|
223
|
-
dfd.reject(err);
|
|
224
|
-
}
|
|
225
|
-
return dfd.promise;
|
|
226
|
-
}
|
|
227
|
-
|
|
228
|
-
//options = {
|
|
229
|
-
// productid: "product uuid",
|
|
230
|
-
// verb: "string", // Possible value is 'post'
|
|
231
|
-
// post: "post", // (optional)
|
|
232
|
-
// name: "name", // (optional)
|
|
233
|
-
// email: "email", // (optional)
|
|
234
|
-
// userid: "userid" // (optional)
|
|
235
|
-
//}
|
|
236
|
-
function createPostInProduct(options) {
|
|
237
|
-
var self = this;
|
|
238
|
-
//Initializing promise
|
|
239
|
-
var dfd = q.defer();
|
|
240
|
-
var err = {};
|
|
241
|
-
if(options && options.verb && options.productid) {
|
|
242
|
-
//Validations
|
|
243
|
-
err = helpers.validations.isAuthenticated(self.orgId, self.token);
|
|
244
|
-
if(err) {
|
|
245
|
-
dfd.reject(err);
|
|
246
|
-
} else {
|
|
247
|
-
//Passed all validations, Construct API url
|
|
248
|
-
var url = self.config.DEFAULT_HOSTS['COLLAB'] + self.config.COLLAB_API_URLS.postsInProductAPI;
|
|
249
|
-
url = helpers.api.constructAPIUrl(url, {
|
|
250
|
-
"orgId": self.orgId,
|
|
251
|
-
"productId": options.productid
|
|
252
|
-
});
|
|
253
|
-
//Contruct params
|
|
254
|
-
var params = {
|
|
255
|
-
verb: options.verb
|
|
256
|
-
};
|
|
257
|
-
if(options.post) {
|
|
258
|
-
params.post = options.post;
|
|
259
|
-
}
|
|
260
|
-
if(options.name) {
|
|
261
|
-
params.name = options.name;
|
|
262
|
-
}
|
|
263
|
-
if(options.email) {
|
|
264
|
-
params.email = options.email;
|
|
265
|
-
}
|
|
266
|
-
if(options.userid) {
|
|
267
|
-
params.userid = options.userid;
|
|
268
|
-
}
|
|
269
|
-
//Setup request with url and params
|
|
270
|
-
var requestAPI = request.post(url).send(params);
|
|
271
|
-
if(self.traceid) { requestAPI.set('X-Amzn-Trace-Id', self.traceid); }
|
|
272
|
-
|
|
273
|
-
//Setup token in Authorization Header
|
|
274
|
-
requestAPI = helpers.api.setupAPIToken(requestAPI, self.token);
|
|
275
|
-
//Call POST 'POST in PRODUCT'
|
|
276
|
-
requestAPI.end(function(error, response) {
|
|
277
|
-
if(error) {
|
|
278
|
-
err = new DLSError(helpers.errors.ERROR_TYPES.API_ERROR, error);
|
|
279
|
-
dfd.reject(err);
|
|
280
|
-
} else {
|
|
281
|
-
dfd.resolve(response.body);
|
|
282
|
-
}
|
|
283
|
-
})
|
|
284
|
-
}
|
|
285
|
-
} else {
|
|
286
|
-
err.message = err.description = 'Mandatory parameter "verb" or "productid" not found in request options';
|
|
287
|
-
err = new DLSError(helpers.errors.ERROR_TYPES.SDK_ERROR, err);
|
|
288
|
-
dfd.reject(err);
|
|
289
|
-
}
|
|
290
|
-
return dfd.promise;
|
|
291
|
-
}
|
|
292
|
-
|
|
293
|
-
/*options = {
|
|
294
|
-
* cursor: 'string' // (optional) cursor string to fetch next set of followers
|
|
295
|
-
* limit: number // (optional) limits the number of followers to fetch at at time
|
|
296
|
-
*}
|
|
297
|
-
*/
|
|
298
|
-
function getMyFollowers(options) {
|
|
299
|
-
var self = this;
|
|
300
|
-
|
|
301
|
-
//Initializing Promise
|
|
302
|
-
var dfd = q.defer();
|
|
303
|
-
var err = {};
|
|
304
|
-
|
|
305
|
-
//Validations
|
|
306
|
-
err = helpers.validations.isAuthenticated(self.orgId, self.token);
|
|
307
|
-
if(err) {
|
|
308
|
-
dfd.reject(err);
|
|
309
|
-
} else {
|
|
310
|
-
//Passed all Validations, constructing url
|
|
311
|
-
var url = self.config.DEFAULT_HOSTS['COLLAB'] + self.config.COLLAB_API_URLS.getMyFollowers;
|
|
312
|
-
|
|
313
|
-
url = helpers.api.constructAPIUrl(url, {
|
|
314
|
-
orgId: self.orgId
|
|
315
|
-
})
|
|
316
|
-
//Attaching Query Params
|
|
317
|
-
var queryParams = {};
|
|
318
|
-
|
|
319
|
-
if(options.cursor) { queryParams.cursor = options.cursor; }
|
|
320
|
-
if(options.limit) { queryParams.limit = options.limit; }
|
|
321
|
-
|
|
322
|
-
//Setup request with url and params
|
|
323
|
-
var requestAPI = request.get(url).query(queryParams);
|
|
324
|
-
if(self.traceid) { requestAPI.set('X-Amzn-Trace-Id', self.traceid); }
|
|
325
|
-
|
|
326
|
-
//Setup token in Authorization Header
|
|
327
|
-
requestAPI = helpers.api.setupAPIToken(requestAPI, self.token);
|
|
328
|
-
//Call GET 'getFollower'
|
|
329
|
-
requestAPI.end(function(error, response) {
|
|
330
|
-
if(error) {
|
|
331
|
-
err = new DLSError(helpers.errors.ERROR_TYPES.API_ERROR, error);
|
|
332
|
-
dfd.reject(err);
|
|
333
|
-
} else {
|
|
334
|
-
dfd.resolve(response.body);
|
|
335
|
-
}
|
|
336
|
-
});
|
|
337
|
-
}
|
|
338
|
-
|
|
339
|
-
return dfd.promise;
|
|
340
|
-
}
|
|
341
|
-
|
|
342
|
-
/*options = {
|
|
343
|
-
* cursor: 'string' // (optional) cursor string to fetch next set of following users
|
|
344
|
-
* limit: number // (optional) limits the number of following users, to fetch at at time
|
|
345
|
-
*}
|
|
346
|
-
*/
|
|
347
|
-
function getUsersFollowedByMe(options) {
|
|
348
|
-
var self = this;
|
|
349
|
-
|
|
350
|
-
//Initializing Promise
|
|
351
|
-
var dfd = q.defer();
|
|
352
|
-
var err = {};
|
|
353
|
-
|
|
354
|
-
//Validations
|
|
355
|
-
err = helpers.validations.isAuthenticated(self.orgId, self.token);
|
|
356
|
-
if(err) {
|
|
357
|
-
dfd.reject(err);
|
|
358
|
-
} else {
|
|
359
|
-
//Passed all Validations, constructing url
|
|
360
|
-
var url = self.config.DEFAULT_HOSTS['COLLAB'] + self.config.COLLAB_API_URLS.getUsersFollowedByMe;
|
|
361
|
-
|
|
362
|
-
url = helpers.api.constructAPIUrl(url, {
|
|
363
|
-
orgId: self.orgId
|
|
364
|
-
})
|
|
365
|
-
//Attaching Query Params
|
|
366
|
-
var queryParams = {};
|
|
367
|
-
|
|
368
|
-
if(options.cursor) { queryParams.cursor = options.cursor; }
|
|
369
|
-
if(options.limit) { queryParams.limit = options.limit; }
|
|
370
|
-
|
|
371
|
-
//Setup request with url and params
|
|
372
|
-
var requestAPI = request.get(url).query(queryParams);
|
|
373
|
-
if(self.traceid) { requestAPI.set('X-Amzn-Trace-Id', self.traceid); }
|
|
374
|
-
|
|
375
|
-
//Setup token in Authorization Header
|
|
376
|
-
requestAPI = helpers.api.setupAPIToken(requestAPI, self.token);
|
|
377
|
-
//Call GET 'getFollower'
|
|
378
|
-
requestAPI.end(function(error, response) {
|
|
379
|
-
if(error) {
|
|
380
|
-
err = new DLSError(helpers.errors.ERROR_TYPES.API_ERROR, error);
|
|
381
|
-
dfd.reject(err);
|
|
382
|
-
} else {
|
|
383
|
-
dfd.resolve(response.body);
|
|
384
|
-
}
|
|
385
|
-
});
|
|
386
|
-
}
|
|
387
|
-
|
|
388
|
-
return dfd.promise;
|
|
389
|
-
}
|
|
390
|
-
|
|
391
|
-
/*options = {
|
|
392
|
-
* userid: 'string' // user uuid
|
|
393
|
-
*}
|
|
394
|
-
*/
|
|
395
|
-
function followUser(options) {
|
|
396
|
-
//Initializing Promise
|
|
397
|
-
var dfd = q.defer();
|
|
398
|
-
|
|
399
|
-
//calling function to 'create' connection (follow user)
|
|
400
|
-
updateConnectionForUser(this.orgId, this.token, this.config, options, 'create')
|
|
401
|
-
.then(function(response) { dfd.resolve(response); })
|
|
402
|
-
.catch(function(error) { dfd.reject(error); })
|
|
403
|
-
.done();
|
|
404
|
-
|
|
405
|
-
return dfd.promise;
|
|
406
|
-
}
|
|
407
|
-
|
|
408
|
-
/*options = {
|
|
409
|
-
* userid: 'string' // user uuid
|
|
410
|
-
*}
|
|
411
|
-
*/
|
|
412
|
-
function unfollowUser(options) {
|
|
413
|
-
//Initializing Promise
|
|
414
|
-
var dfd = q.defer();
|
|
415
|
-
|
|
416
|
-
//calling function to 'delete' connection (unfollow user)
|
|
417
|
-
updateConnectionForUser(this.orgId, this.token, this.config, options, 'delete')
|
|
418
|
-
.then(function(response) { dfd.resolve(response); })
|
|
419
|
-
.catch(function(error) { dfd.reject(error); })
|
|
420
|
-
.done();
|
|
421
|
-
|
|
422
|
-
return dfd.promise;
|
|
423
|
-
}
|
|
424
|
-
|
|
425
|
-
function updateConnectionForUser(orgid, token, config, options, action) {
|
|
426
|
-
//Initializing Promise
|
|
427
|
-
var dfd = q.defer();
|
|
428
|
-
var err = {};
|
|
429
|
-
|
|
430
|
-
//Validations
|
|
431
|
-
if(options && options.userid) {
|
|
432
|
-
//Validating Auth Token
|
|
433
|
-
err = helpers.validations.isAuthenticated(orgid, token);
|
|
434
|
-
if(err) {
|
|
435
|
-
dfd.reject(err);
|
|
436
|
-
} else {
|
|
437
|
-
//Passed all Validations, constructing url
|
|
438
|
-
var url = config.DEFAULT_HOSTS['COLLAB'] + config.COLLAB_API_URLS.connectionURL;
|
|
439
|
-
url = helpers.api.constructAPIUrl(url, {
|
|
440
|
-
orgId: orgid,
|
|
441
|
-
userId: options.userid
|
|
442
|
-
});
|
|
443
|
-
var requestAPI;
|
|
444
|
-
//Setup request with url and params
|
|
445
|
-
if(action === 'create') {
|
|
446
|
-
requestAPI = request.post(url).set('Content-Type', 'application/json');
|
|
447
|
-
} else if(action === 'delete') {
|
|
448
|
-
requestAPI = request.delete(url).set('Content-Type', 'application/json');
|
|
449
|
-
}
|
|
450
|
-
//Setup token in Authorization Header
|
|
451
|
-
requestAPI = helpers.api.setupAPIToken(requestAPI, token);
|
|
452
|
-
//Call POST/DELETE 'updateConnectionForUser'
|
|
453
|
-
requestAPI.end(function(error, response) {
|
|
454
|
-
if(error) {
|
|
455
|
-
err = new DLSError(helpers.errors.ERROR_TYPES.API_ERROR, error);
|
|
456
|
-
dfd.reject(err);
|
|
457
|
-
} else {
|
|
458
|
-
dfd.resolve(response.body);
|
|
459
|
-
}
|
|
460
|
-
});
|
|
461
|
-
}
|
|
462
|
-
} else {
|
|
463
|
-
err.message = err.description = 'Mandatory parameter "userid" not found in request options';
|
|
464
|
-
err = new DLSError(helpers.errors.ERROR_TYPES.SDK_ERROR, err);
|
|
465
|
-
dfd.reject(err);
|
|
466
|
-
}
|
|
467
|
-
return dfd.promise;
|
|
468
|
-
}
|