comprodls-sdk 2.123.2-security → 2.123.4-oidc-poc.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.eslintrc +28 -28
- package/.github/workflows/npm-publish.yml +76 -0
- package/README.md +235 -235
- package/dist/comprodls-sdk.js +13543 -13543
- package/docs/npm-oidc-publishing-runbook.md +229 -0
- package/lib/comprodls.js +132 -132
- package/lib/config/index.js +356 -356
- package/lib/helpers/index.js +31 -31
- package/lib/helpers/lib/api/converter.js +129 -129
- package/lib/helpers/lib/api/index.js +46 -46
- package/lib/helpers/lib/errors.js +122 -122
- package/lib/helpers/lib/requestLayer.js +154 -154
- package/lib/helpers/lib/validator.js +192 -192
- package/lib/open_access/index.js +116 -116
- package/lib/services/analytics/index.js +1365 -1365
- package/lib/services/attempts/index.js +389 -389
- package/lib/services/auth/index.js +3708 -3708
- package/lib/services/authextn/index.js +1032 -1032
- package/lib/services/datasyncmanager/index.js +275 -275
- package/lib/services/drive/index.js +270 -270
- package/lib/services/integrations/index.js +525 -525
- package/lib/services/invitations/index.js +282 -282
- package/lib/services/product/index.js +343 -343
- package/lib/services/pub/index.js +530 -530
- package/lib/services/pushX/index.js +251 -251
- package/lib/services/pushX/pubnubClientWrapper.js +438 -438
- package/lib/services/rules/index.js +416 -416
- package/lib/services/spaces/index.js +999 -999
- package/lib/services/spacesextn/index.js +131 -131
- package/lib/services/superuser/index.js +160 -160
- package/lib/services/taxonomy/index.js +405 -405
- package/lib/services/workflows/index.js +406 -406
- package/lib/services/xapi/index.js +114 -114
- package/lib/token/index.js +120 -120
- package/lib/token/validations.js +85 -85
- package/package.json +5 -1
|
@@ -1,270 +1,270 @@
|
|
|
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 drive Adaptor
|
|
23
|
-
* Functions for calling Drive-service API.
|
|
24
|
-
************************************************************/
|
|
25
|
-
|
|
26
|
-
var q = require('q');
|
|
27
|
-
var request = require('superagent');
|
|
28
|
-
var Agent = require('agentkeepalive');
|
|
29
|
-
|
|
30
|
-
var helpers = require('../../helpers');
|
|
31
|
-
var DLSError = helpers.errors.DLSError;
|
|
32
|
-
|
|
33
|
-
module.exports = documents;
|
|
34
|
-
|
|
35
|
-
var keepaliveAgent = new Agent({
|
|
36
|
-
timeout: 60000,
|
|
37
|
-
freeSocketTimeout: 30000
|
|
38
|
-
});
|
|
39
|
-
|
|
40
|
-
/*********************************
|
|
41
|
-
* Public Function definitions
|
|
42
|
-
**********************************/
|
|
43
|
-
function documents() {
|
|
44
|
-
return {
|
|
45
|
-
getAParticularDocument: getAParticularDocument.bind(this),
|
|
46
|
-
getAllDocumentsInAFolder: getAllDocumentsInAFolder.bind(this),
|
|
47
|
-
createMultipleDocuments: createMultipleDocuments.bind(this),
|
|
48
|
-
updateMultipleDocuments: updateMultipleDocuments.bind(this),
|
|
49
|
-
deleteMultipleDocuments: deleteMultipleDocuments.bind(this),
|
|
50
|
-
};
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
/**
|
|
54
|
-
* Wiki Link for SDK params
|
|
55
|
-
* https://github.com/comprodls/comprodls-sdk-js/wiki/24_DRIVE-Adapter#getaparticulardocumentparams
|
|
56
|
-
*/
|
|
57
|
-
function getAParticularDocument(options) {
|
|
58
|
-
var self = this;
|
|
59
|
-
var dfd = q.defer();
|
|
60
|
-
|
|
61
|
-
if (options && options.accountid && options.extuserid && options.documentid && options.folderid) {
|
|
62
|
-
//Passed all validations, Construct API url
|
|
63
|
-
var url = self.config.DEFAULT_HOSTS.DRIVE + self.config.DRIVE_API_URLS.getAParticularDocument;
|
|
64
|
-
var urlOptions = {
|
|
65
|
-
accountid: options.accountid, extuserid: options.extuserid,
|
|
66
|
-
documentid: options.documentid
|
|
67
|
-
};
|
|
68
|
-
url = helpers.api.constructAPIUrl(url, urlOptions);
|
|
69
|
-
|
|
70
|
-
var params = { folderid: options.folderid };
|
|
71
|
-
//Setup request with URL and Params
|
|
72
|
-
var requestAPI = request.get(url).query(params);
|
|
73
|
-
|
|
74
|
-
if (self.traceid) { requestAPI.set('X-Amzn-Trace-Id', self.traceid); }
|
|
75
|
-
|
|
76
|
-
requestAPI.end(function (err, response) {
|
|
77
|
-
if (err) {
|
|
78
|
-
err = new DLSError(helpers.errors.ERROR_TYPES.API_ERROR, err);
|
|
79
|
-
dfd.reject(err);
|
|
80
|
-
}
|
|
81
|
-
else { dfd.resolve(response.body); }
|
|
82
|
-
});
|
|
83
|
-
}
|
|
84
|
-
else {
|
|
85
|
-
var error = {};
|
|
86
|
-
error.message = error.description = 'Mandatory params - accountid or extuserid or ' +
|
|
87
|
-
'documentid or folderid not found in request options.';
|
|
88
|
-
error = new DLSError(helpers.errors.ERROR_TYPES.SDK_ERROR, error);
|
|
89
|
-
dfd.reject(error);
|
|
90
|
-
}
|
|
91
|
-
return dfd.promise;
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
/**
|
|
95
|
-
* Wiki Link for SDK params
|
|
96
|
-
* https://github.com/comprodls/comprodls-sdk-js/wiki/24_DRIVE-Adapter#getalldocumentsinafolderparams
|
|
97
|
-
*/
|
|
98
|
-
function getAllDocumentsInAFolder(options) {
|
|
99
|
-
var self = this;
|
|
100
|
-
var dfd = q.defer();
|
|
101
|
-
|
|
102
|
-
if (options && options.accountid && options.extuserid && options.folderid) {
|
|
103
|
-
//Passed all validations, Construct API url
|
|
104
|
-
var url = self.config.DEFAULT_HOSTS.DRIVE + self.config.DRIVE_API_URLS.getAllDocumentsInAFolder;
|
|
105
|
-
url = helpers.api.constructAPIUrl(url,
|
|
106
|
-
{ accountid: options.accountid, extuserid: options.extuserid });
|
|
107
|
-
|
|
108
|
-
// Contruct parameters
|
|
109
|
-
var params = { folderid: options.folderid };
|
|
110
|
-
if (options.classid) { params.classid = options.classid; }
|
|
111
|
-
if (options.productcode) { params.productcode = options.productcode; }
|
|
112
|
-
if (options.assigned_path_id) { params.assigned_path_id = options.assigned_path_id; }
|
|
113
|
-
if (options['item-code']) { params['item-code'] = options['item-code']; }
|
|
114
|
-
if (options.cursor) { params.cursor = options.cursor; }
|
|
115
|
-
|
|
116
|
-
//Setup request with URL and Params
|
|
117
|
-
var requestAPI = request.get(url).query(params);
|
|
118
|
-
|
|
119
|
-
if (self.traceid) { requestAPI.set('X-Amzn-Trace-Id', self.traceid); }
|
|
120
|
-
|
|
121
|
-
requestAPI.end(function (err, response) {
|
|
122
|
-
if (err) {
|
|
123
|
-
err = new DLSError(helpers.errors.ERROR_TYPES.API_ERROR, err);
|
|
124
|
-
dfd.reject(err);
|
|
125
|
-
}
|
|
126
|
-
else { dfd.resolve(response.body); }
|
|
127
|
-
});
|
|
128
|
-
}
|
|
129
|
-
else {
|
|
130
|
-
var error = {};
|
|
131
|
-
error.message = error.description = 'Mandatory params - accountid or extuserid or folderid ' +
|
|
132
|
-
'not found in request options.';
|
|
133
|
-
error = new DLSError(helpers.errors.ERROR_TYPES.SDK_ERROR, error);
|
|
134
|
-
dfd.reject(error);
|
|
135
|
-
}
|
|
136
|
-
return dfd.promise;
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
/**
|
|
140
|
-
* Wiki Link for SDK params
|
|
141
|
-
* https://github.com/comprodls/comprodls-sdk-js/wiki/24_DRIVE-Adapter#createmultipledocumentsparams
|
|
142
|
-
*/
|
|
143
|
-
function createMultipleDocuments(options) {
|
|
144
|
-
var self = this;
|
|
145
|
-
var dfd = q.defer();
|
|
146
|
-
|
|
147
|
-
if (options && options.accountid && options.extuserid && options.body) {
|
|
148
|
-
// Passed all validations, Contruct API url
|
|
149
|
-
|
|
150
|
-
var url = self.config.DEFAULT_HOSTS.DRIVE + self.config.DRIVE_API_URLS.documents;
|
|
151
|
-
url = helpers.api.constructAPIUrl(url, {
|
|
152
|
-
accountid: options.accountid, userid: options.extuserid
|
|
153
|
-
});
|
|
154
|
-
|
|
155
|
-
// Setup request with URL and Params
|
|
156
|
-
var requestAPI = request.post(url)
|
|
157
|
-
.set('Content-Type', 'application/json')
|
|
158
|
-
.set('Accept', 'application/json')
|
|
159
|
-
.send(options.body);
|
|
160
|
-
|
|
161
|
-
if (self.traceid) { requestAPI.set('X-Amzn-Trace-Id', self.traceid); }
|
|
162
|
-
|
|
163
|
-
requestAPI
|
|
164
|
-
.agent(keepaliveAgent)
|
|
165
|
-
.end(function(error, response) {
|
|
166
|
-
if (error) {
|
|
167
|
-
var err = new DLSError(helpers.errors.ERROR_TYPES.API_ERROR, error);
|
|
168
|
-
dfd.reject(err);
|
|
169
|
-
}
|
|
170
|
-
else { dfd.resolve(response.body); }
|
|
171
|
-
});
|
|
172
|
-
} else {
|
|
173
|
-
var err = {};
|
|
174
|
-
err.message = err.description = 'Mandatory param - accountid, extuserid or body' +
|
|
175
|
-
' not found in request options.';
|
|
176
|
-
err = new DLSError(helpers.errors.ERROR_TYPES.SDK_ERROR, err);
|
|
177
|
-
dfd.reject(err);
|
|
178
|
-
}
|
|
179
|
-
return dfd.promise;
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
/**
|
|
183
|
-
* Wiki Link for SDK params
|
|
184
|
-
* https://github.com/comprodls/comprodls-sdk-js/wiki/24_DRIVE-Adapter#updatemultipledocumentsparams
|
|
185
|
-
*/
|
|
186
|
-
function updateMultipleDocuments(options) {
|
|
187
|
-
// Initializing promise
|
|
188
|
-
var deferred = q.defer();
|
|
189
|
-
var self = this;
|
|
190
|
-
var error = {};
|
|
191
|
-
|
|
192
|
-
if (options && options.accountid && options.extuserid && options.body) {
|
|
193
|
-
// Passed all validations, Contruct API url
|
|
194
|
-
var url = self.config.DEFAULT_HOSTS.DRIVE + self.config.DRIVE_API_URLS.documents;
|
|
195
|
-
|
|
196
|
-
url = helpers.api.constructAPIUrl(url, {
|
|
197
|
-
accountid: options.accountid, userid: options.extuserid
|
|
198
|
-
});
|
|
199
|
-
|
|
200
|
-
// Setup request with URL and Params
|
|
201
|
-
var requestAPI = request.put(url)
|
|
202
|
-
.set('Content-Type', 'application/json')
|
|
203
|
-
.set('Accept', 'application/json')
|
|
204
|
-
.send(options.body);
|
|
205
|
-
|
|
206
|
-
if (self.traceid) { requestAPI.set('X-Amzn-Trace-Id', self.traceid); }
|
|
207
|
-
|
|
208
|
-
requestAPI
|
|
209
|
-
.agent(keepaliveAgent)
|
|
210
|
-
.end(function(error, response) {
|
|
211
|
-
if (error) {
|
|
212
|
-
error = new DLSError(helpers.errors.ERROR_TYPES.API_ERROR, error);
|
|
213
|
-
deferred.reject(error);
|
|
214
|
-
} else {
|
|
215
|
-
deferred.resolve(response.body);
|
|
216
|
-
}
|
|
217
|
-
});
|
|
218
|
-
} else {
|
|
219
|
-
error.message = error.description = 'Mandatory param - accountid, extuserid or body' +
|
|
220
|
-
' not found in the request options.';
|
|
221
|
-
error = new DLSError(helpers.errors.ERROR_TYPES.SDK_ERROR, error);
|
|
222
|
-
deferred.reject(error);
|
|
223
|
-
}
|
|
224
|
-
|
|
225
|
-
return deferred.promise;
|
|
226
|
-
}
|
|
227
|
-
|
|
228
|
-
/**
|
|
229
|
-
* Wiki Link for SDK params
|
|
230
|
-
* https://github.com/comprodls/comprodls-sdk-js/wiki/24_DRIVE-Adapter#deletemultipledocumentsparams
|
|
231
|
-
*/
|
|
232
|
-
function deleteMultipleDocuments(options) {
|
|
233
|
-
var self = this;
|
|
234
|
-
var dfd = q.defer();
|
|
235
|
-
|
|
236
|
-
if (options && options.accountid && options.extuserid && options.body) {
|
|
237
|
-
// Passed all validations, Contruct API url
|
|
238
|
-
var url = self.config.DEFAULT_HOSTS.DRIVE + self.config.DRIVE_API_URLS.documents;
|
|
239
|
-
url = helpers.api.constructAPIUrl(url, {
|
|
240
|
-
accountid: options.accountid, userid: options.extuserid
|
|
241
|
-
});
|
|
242
|
-
|
|
243
|
-
// Setup request with URL and Params
|
|
244
|
-
var requestAPI = request.delete(url)
|
|
245
|
-
.set('Content-Type', 'application/json')
|
|
246
|
-
.set('Accept', 'application/json')
|
|
247
|
-
.send(options.body);
|
|
248
|
-
|
|
249
|
-
if (self.traceid) { requestAPI.set('X-Amzn-Trace-Id', self.traceid); }
|
|
250
|
-
|
|
251
|
-
requestAPI
|
|
252
|
-
.agent(keepaliveAgent)
|
|
253
|
-
.end(function (error, response) {
|
|
254
|
-
if (error) {
|
|
255
|
-
var err = new DLSError(helpers.errors.ERROR_TYPES.API_ERROR, error);
|
|
256
|
-
dfd.reject(err);
|
|
257
|
-
}
|
|
258
|
-
else { dfd.resolve(response.body); }
|
|
259
|
-
});
|
|
260
|
-
}
|
|
261
|
-
else {
|
|
262
|
-
var err = {};
|
|
263
|
-
err.message = err.description = 'Mandatory param - accountid, extuserid or body' +
|
|
264
|
-
' not found in request options.';
|
|
265
|
-
err = new DLSError(helpers.errors.ERROR_TYPES.SDK_ERROR, err);
|
|
266
|
-
dfd.reject(err);
|
|
267
|
-
}
|
|
268
|
-
|
|
269
|
-
return dfd.promise;
|
|
270
|
-
}
|
|
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 drive Adaptor
|
|
23
|
+
* Functions for calling Drive-service API.
|
|
24
|
+
************************************************************/
|
|
25
|
+
|
|
26
|
+
var q = require('q');
|
|
27
|
+
var request = require('superagent');
|
|
28
|
+
var Agent = require('agentkeepalive');
|
|
29
|
+
|
|
30
|
+
var helpers = require('../../helpers');
|
|
31
|
+
var DLSError = helpers.errors.DLSError;
|
|
32
|
+
|
|
33
|
+
module.exports = documents;
|
|
34
|
+
|
|
35
|
+
var keepaliveAgent = new Agent({
|
|
36
|
+
timeout: 60000,
|
|
37
|
+
freeSocketTimeout: 30000
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
/*********************************
|
|
41
|
+
* Public Function definitions
|
|
42
|
+
**********************************/
|
|
43
|
+
function documents() {
|
|
44
|
+
return {
|
|
45
|
+
getAParticularDocument: getAParticularDocument.bind(this),
|
|
46
|
+
getAllDocumentsInAFolder: getAllDocumentsInAFolder.bind(this),
|
|
47
|
+
createMultipleDocuments: createMultipleDocuments.bind(this),
|
|
48
|
+
updateMultipleDocuments: updateMultipleDocuments.bind(this),
|
|
49
|
+
deleteMultipleDocuments: deleteMultipleDocuments.bind(this),
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Wiki Link for SDK params
|
|
55
|
+
* https://github.com/comprodls/comprodls-sdk-js/wiki/24_DRIVE-Adapter#getaparticulardocumentparams
|
|
56
|
+
*/
|
|
57
|
+
function getAParticularDocument(options) {
|
|
58
|
+
var self = this;
|
|
59
|
+
var dfd = q.defer();
|
|
60
|
+
|
|
61
|
+
if (options && options.accountid && options.extuserid && options.documentid && options.folderid) {
|
|
62
|
+
//Passed all validations, Construct API url
|
|
63
|
+
var url = self.config.DEFAULT_HOSTS.DRIVE + self.config.DRIVE_API_URLS.getAParticularDocument;
|
|
64
|
+
var urlOptions = {
|
|
65
|
+
accountid: options.accountid, extuserid: options.extuserid,
|
|
66
|
+
documentid: options.documentid
|
|
67
|
+
};
|
|
68
|
+
url = helpers.api.constructAPIUrl(url, urlOptions);
|
|
69
|
+
|
|
70
|
+
var params = { folderid: options.folderid };
|
|
71
|
+
//Setup request with URL and Params
|
|
72
|
+
var requestAPI = request.get(url).query(params);
|
|
73
|
+
|
|
74
|
+
if (self.traceid) { requestAPI.set('X-Amzn-Trace-Id', self.traceid); }
|
|
75
|
+
|
|
76
|
+
requestAPI.end(function (err, response) {
|
|
77
|
+
if (err) {
|
|
78
|
+
err = new DLSError(helpers.errors.ERROR_TYPES.API_ERROR, err);
|
|
79
|
+
dfd.reject(err);
|
|
80
|
+
}
|
|
81
|
+
else { dfd.resolve(response.body); }
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
else {
|
|
85
|
+
var error = {};
|
|
86
|
+
error.message = error.description = 'Mandatory params - accountid or extuserid or ' +
|
|
87
|
+
'documentid or folderid not found in request options.';
|
|
88
|
+
error = new DLSError(helpers.errors.ERROR_TYPES.SDK_ERROR, error);
|
|
89
|
+
dfd.reject(error);
|
|
90
|
+
}
|
|
91
|
+
return dfd.promise;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* Wiki Link for SDK params
|
|
96
|
+
* https://github.com/comprodls/comprodls-sdk-js/wiki/24_DRIVE-Adapter#getalldocumentsinafolderparams
|
|
97
|
+
*/
|
|
98
|
+
function getAllDocumentsInAFolder(options) {
|
|
99
|
+
var self = this;
|
|
100
|
+
var dfd = q.defer();
|
|
101
|
+
|
|
102
|
+
if (options && options.accountid && options.extuserid && options.folderid) {
|
|
103
|
+
//Passed all validations, Construct API url
|
|
104
|
+
var url = self.config.DEFAULT_HOSTS.DRIVE + self.config.DRIVE_API_URLS.getAllDocumentsInAFolder;
|
|
105
|
+
url = helpers.api.constructAPIUrl(url,
|
|
106
|
+
{ accountid: options.accountid, extuserid: options.extuserid });
|
|
107
|
+
|
|
108
|
+
// Contruct parameters
|
|
109
|
+
var params = { folderid: options.folderid };
|
|
110
|
+
if (options.classid) { params.classid = options.classid; }
|
|
111
|
+
if (options.productcode) { params.productcode = options.productcode; }
|
|
112
|
+
if (options.assigned_path_id) { params.assigned_path_id = options.assigned_path_id; }
|
|
113
|
+
if (options['item-code']) { params['item-code'] = options['item-code']; }
|
|
114
|
+
if (options.cursor) { params.cursor = options.cursor; }
|
|
115
|
+
|
|
116
|
+
//Setup request with URL and Params
|
|
117
|
+
var requestAPI = request.get(url).query(params);
|
|
118
|
+
|
|
119
|
+
if (self.traceid) { requestAPI.set('X-Amzn-Trace-Id', self.traceid); }
|
|
120
|
+
|
|
121
|
+
requestAPI.end(function (err, response) {
|
|
122
|
+
if (err) {
|
|
123
|
+
err = new DLSError(helpers.errors.ERROR_TYPES.API_ERROR, err);
|
|
124
|
+
dfd.reject(err);
|
|
125
|
+
}
|
|
126
|
+
else { dfd.resolve(response.body); }
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
else {
|
|
130
|
+
var error = {};
|
|
131
|
+
error.message = error.description = 'Mandatory params - accountid or extuserid or folderid ' +
|
|
132
|
+
'not found in request options.';
|
|
133
|
+
error = new DLSError(helpers.errors.ERROR_TYPES.SDK_ERROR, error);
|
|
134
|
+
dfd.reject(error);
|
|
135
|
+
}
|
|
136
|
+
return dfd.promise;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
/**
|
|
140
|
+
* Wiki Link for SDK params
|
|
141
|
+
* https://github.com/comprodls/comprodls-sdk-js/wiki/24_DRIVE-Adapter#createmultipledocumentsparams
|
|
142
|
+
*/
|
|
143
|
+
function createMultipleDocuments(options) {
|
|
144
|
+
var self = this;
|
|
145
|
+
var dfd = q.defer();
|
|
146
|
+
|
|
147
|
+
if (options && options.accountid && options.extuserid && options.body) {
|
|
148
|
+
// Passed all validations, Contruct API url
|
|
149
|
+
|
|
150
|
+
var url = self.config.DEFAULT_HOSTS.DRIVE + self.config.DRIVE_API_URLS.documents;
|
|
151
|
+
url = helpers.api.constructAPIUrl(url, {
|
|
152
|
+
accountid: options.accountid, userid: options.extuserid
|
|
153
|
+
});
|
|
154
|
+
|
|
155
|
+
// Setup request with URL and Params
|
|
156
|
+
var requestAPI = request.post(url)
|
|
157
|
+
.set('Content-Type', 'application/json')
|
|
158
|
+
.set('Accept', 'application/json')
|
|
159
|
+
.send(options.body);
|
|
160
|
+
|
|
161
|
+
if (self.traceid) { requestAPI.set('X-Amzn-Trace-Id', self.traceid); }
|
|
162
|
+
|
|
163
|
+
requestAPI
|
|
164
|
+
.agent(keepaliveAgent)
|
|
165
|
+
.end(function(error, response) {
|
|
166
|
+
if (error) {
|
|
167
|
+
var err = new DLSError(helpers.errors.ERROR_TYPES.API_ERROR, error);
|
|
168
|
+
dfd.reject(err);
|
|
169
|
+
}
|
|
170
|
+
else { dfd.resolve(response.body); }
|
|
171
|
+
});
|
|
172
|
+
} else {
|
|
173
|
+
var err = {};
|
|
174
|
+
err.message = err.description = 'Mandatory param - accountid, extuserid or body' +
|
|
175
|
+
' not found in request options.';
|
|
176
|
+
err = new DLSError(helpers.errors.ERROR_TYPES.SDK_ERROR, err);
|
|
177
|
+
dfd.reject(err);
|
|
178
|
+
}
|
|
179
|
+
return dfd.promise;
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
/**
|
|
183
|
+
* Wiki Link for SDK params
|
|
184
|
+
* https://github.com/comprodls/comprodls-sdk-js/wiki/24_DRIVE-Adapter#updatemultipledocumentsparams
|
|
185
|
+
*/
|
|
186
|
+
function updateMultipleDocuments(options) {
|
|
187
|
+
// Initializing promise
|
|
188
|
+
var deferred = q.defer();
|
|
189
|
+
var self = this;
|
|
190
|
+
var error = {};
|
|
191
|
+
|
|
192
|
+
if (options && options.accountid && options.extuserid && options.body) {
|
|
193
|
+
// Passed all validations, Contruct API url
|
|
194
|
+
var url = self.config.DEFAULT_HOSTS.DRIVE + self.config.DRIVE_API_URLS.documents;
|
|
195
|
+
|
|
196
|
+
url = helpers.api.constructAPIUrl(url, {
|
|
197
|
+
accountid: options.accountid, userid: options.extuserid
|
|
198
|
+
});
|
|
199
|
+
|
|
200
|
+
// Setup request with URL and Params
|
|
201
|
+
var requestAPI = request.put(url)
|
|
202
|
+
.set('Content-Type', 'application/json')
|
|
203
|
+
.set('Accept', 'application/json')
|
|
204
|
+
.send(options.body);
|
|
205
|
+
|
|
206
|
+
if (self.traceid) { requestAPI.set('X-Amzn-Trace-Id', self.traceid); }
|
|
207
|
+
|
|
208
|
+
requestAPI
|
|
209
|
+
.agent(keepaliveAgent)
|
|
210
|
+
.end(function(error, response) {
|
|
211
|
+
if (error) {
|
|
212
|
+
error = new DLSError(helpers.errors.ERROR_TYPES.API_ERROR, error);
|
|
213
|
+
deferred.reject(error);
|
|
214
|
+
} else {
|
|
215
|
+
deferred.resolve(response.body);
|
|
216
|
+
}
|
|
217
|
+
});
|
|
218
|
+
} else {
|
|
219
|
+
error.message = error.description = 'Mandatory param - accountid, extuserid or body' +
|
|
220
|
+
' not found in the request options.';
|
|
221
|
+
error = new DLSError(helpers.errors.ERROR_TYPES.SDK_ERROR, error);
|
|
222
|
+
deferred.reject(error);
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
return deferred.promise;
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
/**
|
|
229
|
+
* Wiki Link for SDK params
|
|
230
|
+
* https://github.com/comprodls/comprodls-sdk-js/wiki/24_DRIVE-Adapter#deletemultipledocumentsparams
|
|
231
|
+
*/
|
|
232
|
+
function deleteMultipleDocuments(options) {
|
|
233
|
+
var self = this;
|
|
234
|
+
var dfd = q.defer();
|
|
235
|
+
|
|
236
|
+
if (options && options.accountid && options.extuserid && options.body) {
|
|
237
|
+
// Passed all validations, Contruct API url
|
|
238
|
+
var url = self.config.DEFAULT_HOSTS.DRIVE + self.config.DRIVE_API_URLS.documents;
|
|
239
|
+
url = helpers.api.constructAPIUrl(url, {
|
|
240
|
+
accountid: options.accountid, userid: options.extuserid
|
|
241
|
+
});
|
|
242
|
+
|
|
243
|
+
// Setup request with URL and Params
|
|
244
|
+
var requestAPI = request.delete(url)
|
|
245
|
+
.set('Content-Type', 'application/json')
|
|
246
|
+
.set('Accept', 'application/json')
|
|
247
|
+
.send(options.body);
|
|
248
|
+
|
|
249
|
+
if (self.traceid) { requestAPI.set('X-Amzn-Trace-Id', self.traceid); }
|
|
250
|
+
|
|
251
|
+
requestAPI
|
|
252
|
+
.agent(keepaliveAgent)
|
|
253
|
+
.end(function (error, response) {
|
|
254
|
+
if (error) {
|
|
255
|
+
var err = new DLSError(helpers.errors.ERROR_TYPES.API_ERROR, error);
|
|
256
|
+
dfd.reject(err);
|
|
257
|
+
}
|
|
258
|
+
else { dfd.resolve(response.body); }
|
|
259
|
+
});
|
|
260
|
+
}
|
|
261
|
+
else {
|
|
262
|
+
var err = {};
|
|
263
|
+
err.message = err.description = 'Mandatory param - accountid, extuserid or body' +
|
|
264
|
+
' not found in request options.';
|
|
265
|
+
err = new DLSError(helpers.errors.ERROR_TYPES.SDK_ERROR, err);
|
|
266
|
+
dfd.reject(err);
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
return dfd.promise;
|
|
270
|
+
}
|