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,530 +1,530 @@
|
|
|
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 Pub Adaptor
|
|
23
|
-
* Functions for calling Pub.
|
|
24
|
-
************************************************************/
|
|
25
|
-
|
|
26
|
-
var request = require('superagent');
|
|
27
|
-
var q = require('q');
|
|
28
|
-
var Agent = require('agentkeepalive');
|
|
29
|
-
|
|
30
|
-
var helpers = require('../../helpers');
|
|
31
|
-
var DLSError = helpers.errors.DLSError;
|
|
32
|
-
|
|
33
|
-
var keepaliveAgent = new Agent({
|
|
34
|
-
timeout: 60000,
|
|
35
|
-
freeSocketTimeout: 30000
|
|
36
|
-
});
|
|
37
|
-
|
|
38
|
-
module.exports = pub;
|
|
39
|
-
|
|
40
|
-
function pub() {
|
|
41
|
-
return {
|
|
42
|
-
promoteProduct: promoteProduct.bind(this),
|
|
43
|
-
registerProduct: registerProduct.bind(this),
|
|
44
|
-
ingestProduct: ingestProduct.bind(this),
|
|
45
|
-
createBundle: createBundle.bind(this),
|
|
46
|
-
updateBundle: updateBundle.bind(this),
|
|
47
|
-
getAllBundles: getAllBundles.bind(this),
|
|
48
|
-
getSingleBundle: getSingleBundle.bind(this),
|
|
49
|
-
createProductFamily: createProductFamily.bind(this),
|
|
50
|
-
updateProductFamily: updateProductFamily.bind(this),
|
|
51
|
-
getSingleProductFamily: getSingleProductFamily.bind(this),
|
|
52
|
-
getAllProductFamilies: getAllProductFamilies.bind(this)
|
|
53
|
-
};
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
/*********************************
|
|
57
|
-
* Public Function definitions
|
|
58
|
-
**********************************/
|
|
59
|
-
|
|
60
|
-
/**
|
|
61
|
-
* Wiki Link for SDK params
|
|
62
|
-
* https://github.com/comprodls/comprodls-sdk-js/wiki/07_PUB-Adapter#promoteproductparams
|
|
63
|
-
*/
|
|
64
|
-
function promoteProduct(options) {
|
|
65
|
-
var self = this;
|
|
66
|
-
//Initializing promise
|
|
67
|
-
var dfd = q.defer();
|
|
68
|
-
|
|
69
|
-
//Contruct parameters
|
|
70
|
-
if (options && options.productcode) {
|
|
71
|
-
//Construct API url
|
|
72
|
-
var url = self.config.DEFAULT_HOSTS['PUB'] + self.config.PUB_API_URLS.promoteAPI;
|
|
73
|
-
url = helpers.api.constructAPIUrl(url, {
|
|
74
|
-
'orgId': self.orgId, 'productcode': options.productcode
|
|
75
|
-
});
|
|
76
|
-
|
|
77
|
-
var params = { source: {}, target: {} };
|
|
78
|
-
if (options.ext_user_id) { params.ext_user_id = options.ext_user_id; }
|
|
79
|
-
if (options.source && options.source.stage) { params.source.stage = options.source.stage; }
|
|
80
|
-
if (options.target) {
|
|
81
|
-
if(options.target.org) { params.target.org = options.target.org; }
|
|
82
|
-
if(options.target.stage) { params.target.stage = options.target.stage; }
|
|
83
|
-
}
|
|
84
|
-
if(options.externalrefid) { params.externalrefid = options.externalrefid; }
|
|
85
|
-
|
|
86
|
-
//Setup request with URL and Post data
|
|
87
|
-
var requestAPI = request.post(url).send(params);
|
|
88
|
-
|
|
89
|
-
if(self.traceid) { requestAPI.set('X-Amzn-Trace-Id', self.traceid); }
|
|
90
|
-
requestAPI
|
|
91
|
-
.agent(keepaliveAgent)
|
|
92
|
-
.end(function (err, response) {
|
|
93
|
-
if (err) {
|
|
94
|
-
err = new DLSError(helpers.errors.ERROR_TYPES.API_ERROR, err);
|
|
95
|
-
dfd.reject(err);
|
|
96
|
-
} else {
|
|
97
|
-
dfd.resolve(response);
|
|
98
|
-
}
|
|
99
|
-
});
|
|
100
|
-
} else {
|
|
101
|
-
var err = {};
|
|
102
|
-
err.message = err.description = 'Mandatory field \'options\' are not provided '+
|
|
103
|
-
'in the request options.';
|
|
104
|
-
err = new DLSError(helpers.errors.ERROR_TYPES.SDK_ERROR, err);
|
|
105
|
-
dfd.reject(err);
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
return dfd.promise;
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
/**
|
|
112
|
-
* Wiki Link for SDK params
|
|
113
|
-
* https://github.com/comprodls/comprodls-sdk-js/wiki/07_PUB-Adapter#registerproductparams
|
|
114
|
-
*/
|
|
115
|
-
function registerProduct(options) {
|
|
116
|
-
var self = this;
|
|
117
|
-
var dfd = q.defer();
|
|
118
|
-
|
|
119
|
-
if (options) {
|
|
120
|
-
//Construct API url
|
|
121
|
-
var url = self.config.DEFAULT_HOSTS['PUB'] + self.config.PUB_API_URLS.registerProductAPI;
|
|
122
|
-
url = helpers.api.constructAPIUrl(url, { 'orgId' : self.orgId });
|
|
123
|
-
|
|
124
|
-
var params = {};
|
|
125
|
-
if (options.targetorg) { params.targetorgid = options.targetorg; }
|
|
126
|
-
if (options.repositorytype) { params.repositorytype = options.repositorytype; }
|
|
127
|
-
if (options.producttitle) { params.producttitle = options.producttitle; }
|
|
128
|
-
if (options.producttype) { params.producttype = options.producttype; }
|
|
129
|
-
if (options.productcode) { params.productcode = options.productcode; }
|
|
130
|
-
if (options.s3) { params.s3 = options.s3; }
|
|
131
|
-
if (options.externalrefid) { params.externalrefid = options.externalrefid; }
|
|
132
|
-
if (options['bundle-codes']) { params['bundle-codes'] = options['bundle-codes']; }
|
|
133
|
-
|
|
134
|
-
// Setup request with URL and Post data
|
|
135
|
-
var requestAPI = request.post(url).send(params);
|
|
136
|
-
|
|
137
|
-
if (self.traceid) { requestAPI.set('X-Amzn-Trace-Id', self.traceid); }
|
|
138
|
-
requestAPI
|
|
139
|
-
.agent(keepaliveAgent)
|
|
140
|
-
.end(function(err, response) {
|
|
141
|
-
if (err) {
|
|
142
|
-
err = new DLSError(helpers.errors.ERROR_TYPES.API_ERROR, err);
|
|
143
|
-
dfd.reject(err);
|
|
144
|
-
} else {
|
|
145
|
-
dfd.resolve(response);
|
|
146
|
-
}
|
|
147
|
-
});
|
|
148
|
-
} else {
|
|
149
|
-
var err = {};
|
|
150
|
-
err.message = err.description = 'Mandatory field \'options\' are not provided '+
|
|
151
|
-
'in the request options.';
|
|
152
|
-
err = new DLSError(helpers.errors.ERROR_TYPES.SDK_ERROR, err);
|
|
153
|
-
dfd.reject(err);
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
return dfd.promise;
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
/**
|
|
160
|
-
* Wiki Link for SDK params
|
|
161
|
-
* https://github.com/comprodls/comprodls-sdk-js/wiki/07_PUB-Adapter#ingestproductparams
|
|
162
|
-
*/
|
|
163
|
-
function ingestProduct(options) {
|
|
164
|
-
var self = this;
|
|
165
|
-
//Initializing promise
|
|
166
|
-
var dfd = q.defer();
|
|
167
|
-
|
|
168
|
-
if (options && options.productcode) {
|
|
169
|
-
//Construct API url
|
|
170
|
-
var url = self.config.DEFAULT_HOSTS['PUB'] + self.config.PUB_API_URLS.ingestByCodeAPI;
|
|
171
|
-
url = helpers.api.constructAPIUrl(url, {
|
|
172
|
-
'orgId' : self.orgId, 'productcode' : options.productcode
|
|
173
|
-
});
|
|
174
|
-
|
|
175
|
-
//Contruct parameters
|
|
176
|
-
var params = {};
|
|
177
|
-
if (options.ext_user_id) { params.ext_user_id = options.ext_user_id; }
|
|
178
|
-
if (options.branchref) { params.branchref = options.branchref; }
|
|
179
|
-
if (options.externalrefid) { params.externalrefid = options.externalrefid; }
|
|
180
|
-
if (options['bundle-codes']) { params['bundle-codes'] = options['bundle-codes']; }
|
|
181
|
-
|
|
182
|
-
//Setup request with URL and Post data
|
|
183
|
-
var requestAPI = request.post(url).send(params);
|
|
184
|
-
|
|
185
|
-
if (self.traceid) { requestAPI.set('X-Amzn-Trace-Id', self.traceid); }
|
|
186
|
-
requestAPI
|
|
187
|
-
.agent(keepaliveAgent)
|
|
188
|
-
.end(function(err, response) {
|
|
189
|
-
if (err) {
|
|
190
|
-
err = new DLSError(helpers.errors.ERROR_TYPES.API_ERROR, err);
|
|
191
|
-
dfd.reject(err);
|
|
192
|
-
} else {
|
|
193
|
-
dfd.resolve(response);
|
|
194
|
-
}
|
|
195
|
-
});
|
|
196
|
-
} else {
|
|
197
|
-
var err = {};
|
|
198
|
-
err.message = err.description = 'Mandatory field \'productcode\' is not provided '+
|
|
199
|
-
'in the request options.';
|
|
200
|
-
err = new DLSError(helpers.errors.ERROR_TYPES.SDK_ERROR, err);
|
|
201
|
-
dfd.reject(err);
|
|
202
|
-
}
|
|
203
|
-
|
|
204
|
-
return dfd.promise;
|
|
205
|
-
}
|
|
206
|
-
|
|
207
|
-
/**
|
|
208
|
-
* Wiki Link for SDK params
|
|
209
|
-
* https://github.com/comprodls/comprodls-sdk-js/wiki/07_PUB-Adapter#createbundleparams
|
|
210
|
-
*/
|
|
211
|
-
function createBundle(options) {
|
|
212
|
-
var self = this;
|
|
213
|
-
//Initializing promise
|
|
214
|
-
var dfd = q.defer();
|
|
215
|
-
var err;
|
|
216
|
-
//Validations
|
|
217
|
-
if(options && options.stage && options['bundle-code'] && options.body && options.body.title &&
|
|
218
|
-
options.body.products)
|
|
219
|
-
{
|
|
220
|
-
//Passed all validations, Construct API url
|
|
221
|
-
var url = self.config.DEFAULT_HOSTS['PUB'] + self.config.PUB_API_URLS.createBundle;
|
|
222
|
-
url = helpers.api.constructAPIUrl(url, { orgid: self.orgId, stage: options.stage });
|
|
223
|
-
|
|
224
|
-
//Contruct parameters
|
|
225
|
-
options.body['bundle-code'] = options['bundle-code'];
|
|
226
|
-
//Setup request with URL and Post data
|
|
227
|
-
var requestAPI = request.post(url).send(options.body);
|
|
228
|
-
|
|
229
|
-
if(self.traceid) { requestAPI.set('X-Amzn-Trace-Id', self.traceid); }
|
|
230
|
-
|
|
231
|
-
requestAPI.end(function (err, response) {
|
|
232
|
-
if(err) {
|
|
233
|
-
err = new DLSError(helpers.errors.ERROR_TYPES.API_ERROR, err);
|
|
234
|
-
dfd.reject(err);
|
|
235
|
-
} else {
|
|
236
|
-
dfd.resolve(response.body);
|
|
237
|
-
}
|
|
238
|
-
});
|
|
239
|
-
}
|
|
240
|
-
else {
|
|
241
|
-
err = {};
|
|
242
|
-
err.message = err.description = 'Required parameter stage or bundle-code or title or ' +
|
|
243
|
-
'products not found in request options';
|
|
244
|
-
err = new DLSError(helpers.errors.ERROR_TYPES.SDK_ERROR, err);
|
|
245
|
-
dfd.reject(err);
|
|
246
|
-
}
|
|
247
|
-
return dfd.promise;
|
|
248
|
-
}
|
|
249
|
-
|
|
250
|
-
/**
|
|
251
|
-
* Wiki Link for SDK params
|
|
252
|
-
* https://github.com/comprodls/comprodls-sdk-js/wiki/07_PUB-Adapter#updatebundleparams
|
|
253
|
-
*/
|
|
254
|
-
function updateBundle(options) {
|
|
255
|
-
var self = this;
|
|
256
|
-
|
|
257
|
-
//Initializing promise
|
|
258
|
-
var dfd = q.defer();
|
|
259
|
-
var err;
|
|
260
|
-
|
|
261
|
-
//Validations
|
|
262
|
-
if(options && options.stage && options['bundle-code'] && options.body && options.body.products) {
|
|
263
|
-
//Passed all validations, Construct API url
|
|
264
|
-
var url = self.config.DEFAULT_HOSTS['PUB'] + self.config.PUB_API_URLS.updateBundle;
|
|
265
|
-
url = helpers.api.constructAPIUrl(url, {
|
|
266
|
-
orgid: self.orgId, stage: options.stage, bundleCode: options['bundle-code']
|
|
267
|
-
});
|
|
268
|
-
|
|
269
|
-
//Setup request with URL and Post data
|
|
270
|
-
var requestAPI = request.put(url).send(options.body);
|
|
271
|
-
|
|
272
|
-
if(self.traceid) { requestAPI.set('X-Amzn-Trace-Id', self.traceid); }
|
|
273
|
-
requestAPI.end(function (err, response) {
|
|
274
|
-
if(err) {
|
|
275
|
-
err = new DLSError(helpers.errors.ERROR_TYPES.API_ERROR, err);
|
|
276
|
-
dfd.reject(err);
|
|
277
|
-
} else {
|
|
278
|
-
dfd.resolve(response.body);
|
|
279
|
-
}
|
|
280
|
-
});
|
|
281
|
-
}
|
|
282
|
-
else {
|
|
283
|
-
err = {};
|
|
284
|
-
err.message = err.description = 'Required parameter stage or bundle-code or ' +
|
|
285
|
-
'products not found in request options';
|
|
286
|
-
err = new DLSError(helpers.errors.ERROR_TYPES.SDK_ERROR, err);
|
|
287
|
-
dfd.reject(err);
|
|
288
|
-
}
|
|
289
|
-
return dfd.promise;
|
|
290
|
-
}
|
|
291
|
-
|
|
292
|
-
/**
|
|
293
|
-
* Wiki Link for SDK params
|
|
294
|
-
* https://github.com/comprodls/comprodls-sdk-js/wiki/07_PUB-Adapter#getallbundlesparams
|
|
295
|
-
*/
|
|
296
|
-
function getAllBundles(options) {
|
|
297
|
-
var self = this;
|
|
298
|
-
//Initializing promise
|
|
299
|
-
var dfd = q.defer();
|
|
300
|
-
|
|
301
|
-
//Construct API url
|
|
302
|
-
var url = self.config.DEFAULT_HOSTS['PUB'] + self.config.PUB_API_URLS.getAllBundles;
|
|
303
|
-
|
|
304
|
-
url = helpers.api.constructAPIUrl(url, { orgid: self.orgId, });
|
|
305
|
-
//Contruct parameters
|
|
306
|
-
var params = {};
|
|
307
|
-
if(options) {
|
|
308
|
-
if(options.stage){
|
|
309
|
-
params.stage = options.stage;
|
|
310
|
-
}
|
|
311
|
-
if(options.target_role){
|
|
312
|
-
params.target_role = options.target_role;
|
|
313
|
-
}
|
|
314
|
-
}
|
|
315
|
-
|
|
316
|
-
//Setup request with URL and Post data
|
|
317
|
-
var requestAPI = request.get(url).query(params);
|
|
318
|
-
|
|
319
|
-
if(self.traceid) { requestAPI.set('X-Amzn-Trace-Id', self.traceid); }
|
|
320
|
-
requestAPI.end(function (err, response) {
|
|
321
|
-
if(err) {
|
|
322
|
-
err = new DLSError(helpers.errors.ERROR_TYPES.API_ERROR, err);
|
|
323
|
-
dfd.reject(err);
|
|
324
|
-
} else {
|
|
325
|
-
dfd.resolve(response.body);
|
|
326
|
-
}
|
|
327
|
-
});
|
|
328
|
-
return dfd.promise;
|
|
329
|
-
}
|
|
330
|
-
|
|
331
|
-
/**
|
|
332
|
-
* Wiki Link for SDK params
|
|
333
|
-
* https://github.com/comprodls/comprodls-sdk-js/wiki/07_PUB-Adapter#getsinglebundleparams
|
|
334
|
-
*/
|
|
335
|
-
function getSingleBundle(options) {
|
|
336
|
-
var self = this;
|
|
337
|
-
var dfd = q.defer();
|
|
338
|
-
|
|
339
|
-
//Validations
|
|
340
|
-
var err;
|
|
341
|
-
if(options && options['bundle-code']) {
|
|
342
|
-
|
|
343
|
-
//Passed all validations, Construct API url
|
|
344
|
-
var url = self.config.DEFAULT_HOSTS['PUB'] + self.config.PUB_API_URLS.getSingleBundle;
|
|
345
|
-
|
|
346
|
-
url = helpers.api.constructAPIUrl(url, { orgid: self.orgId, bundleCode: options['bundle-code'] });
|
|
347
|
-
//Contruct parameters
|
|
348
|
-
var params = {};
|
|
349
|
-
if(options && options.stage) { params.stage = options.stage; }
|
|
350
|
-
//Setup request with URL and Post data
|
|
351
|
-
|
|
352
|
-
var requestAPI = request.get(url).query(params);
|
|
353
|
-
|
|
354
|
-
if(self.traceid) { requestAPI.set('X-Amzn-Trace-Id', self.traceid); }
|
|
355
|
-
requestAPI.end(function (err, response) {
|
|
356
|
-
if(err) {
|
|
357
|
-
err = new DLSError(helpers.errors.ERROR_TYPES.API_ERROR, err);
|
|
358
|
-
dfd.reject(err);
|
|
359
|
-
} else {
|
|
360
|
-
dfd.resolve(response.body);
|
|
361
|
-
}
|
|
362
|
-
});
|
|
363
|
-
}
|
|
364
|
-
else {
|
|
365
|
-
err = {};
|
|
366
|
-
err.message = err.description = 'Required parameter bundle-code not found in request options';
|
|
367
|
-
err = new DLSError(helpers.errors.ERROR_TYPES.SDK_ERROR, err);
|
|
368
|
-
dfd.reject(err);
|
|
369
|
-
}
|
|
370
|
-
|
|
371
|
-
return dfd.promise;
|
|
372
|
-
}
|
|
373
|
-
|
|
374
|
-
/**
|
|
375
|
-
* Wiki Link for SDK params
|
|
376
|
-
* https://github.com/comprodls/comprodls-sdk-js/wiki/07_PUB-Adapter#createproductfamilyparams
|
|
377
|
-
*/
|
|
378
|
-
function createProductFamily(options) {
|
|
379
|
-
var self = this;
|
|
380
|
-
//Initializing promise
|
|
381
|
-
var dfd = q.defer();
|
|
382
|
-
var err;
|
|
383
|
-
//Validations
|
|
384
|
-
if (options && options.stage && options.body && options.body['family-code'])
|
|
385
|
-
{
|
|
386
|
-
//Passed all validations, Construct API url
|
|
387
|
-
var url = self.config.DEFAULT_HOSTS['PUB'] + self.config.PUB_API_URLS.createProductFamily;
|
|
388
|
-
url = helpers.api.constructAPIUrl(url, { orgid: self.orgId, stage: options.stage });
|
|
389
|
-
|
|
390
|
-
//Setup request with URL and Post data
|
|
391
|
-
var requestAPI = request.post(url).send(options.body);
|
|
392
|
-
|
|
393
|
-
if(self.traceid) { requestAPI.set('X-Amzn-Trace-Id', self.traceid); }
|
|
394
|
-
|
|
395
|
-
requestAPI.end(function (err, response) {
|
|
396
|
-
if(err) {
|
|
397
|
-
err = new DLSError(helpers.errors.ERROR_TYPES.API_ERROR, err);
|
|
398
|
-
dfd.reject(err);
|
|
399
|
-
} else {
|
|
400
|
-
dfd.resolve(response.body);
|
|
401
|
-
}
|
|
402
|
-
});
|
|
403
|
-
}
|
|
404
|
-
else {
|
|
405
|
-
err = {};
|
|
406
|
-
err.message = err.description = 'Required parameter stage or family-code ' +
|
|
407
|
-
'not found in request options';
|
|
408
|
-
err = new DLSError(helpers.errors.ERROR_TYPES.SDK_ERROR, err);
|
|
409
|
-
dfd.reject(err);
|
|
410
|
-
}
|
|
411
|
-
return dfd.promise;
|
|
412
|
-
}
|
|
413
|
-
|
|
414
|
-
/**
|
|
415
|
-
* Wiki Link for SDK params
|
|
416
|
-
* https://github.com/comprodls/comprodls-sdk-js/wiki/07_PUB-Adapter#updateproductfamilyparams
|
|
417
|
-
*/
|
|
418
|
-
function updateProductFamily(options) {
|
|
419
|
-
var self = this;
|
|
420
|
-
|
|
421
|
-
//Initializing promise
|
|
422
|
-
var dfd = q.defer();
|
|
423
|
-
var err;
|
|
424
|
-
|
|
425
|
-
//Validations
|
|
426
|
-
if (options && options.stage && options['family-code']) {
|
|
427
|
-
//Passed all validations, Construct API url
|
|
428
|
-
var url = self.config.DEFAULT_HOSTS['PUB'] + self.config.PUB_API_URLS.updateProductFamily;
|
|
429
|
-
url = helpers.api.constructAPIUrl(url, {
|
|
430
|
-
orgid: self.orgId, stage: options.stage, familyCode: options['family-code']
|
|
431
|
-
});
|
|
432
|
-
|
|
433
|
-
//Setup request with URL and Post data
|
|
434
|
-
var requestAPI = request.put(url).send(options.body);
|
|
435
|
-
|
|
436
|
-
if(self.traceid) { requestAPI.set('X-Amzn-Trace-Id', self.traceid); }
|
|
437
|
-
requestAPI.end(function (err, response) {
|
|
438
|
-
if(err) {
|
|
439
|
-
err = new DLSError(helpers.errors.ERROR_TYPES.API_ERROR, err);
|
|
440
|
-
dfd.reject(err);
|
|
441
|
-
} else {
|
|
442
|
-
dfd.resolve(response.body);
|
|
443
|
-
}
|
|
444
|
-
});
|
|
445
|
-
}
|
|
446
|
-
else {
|
|
447
|
-
err = {};
|
|
448
|
-
err.message = err.description = 'Required parameter stage or family-code ' +
|
|
449
|
-
'not found in request options';
|
|
450
|
-
err = new DLSError(helpers.errors.ERROR_TYPES.SDK_ERROR, err);
|
|
451
|
-
dfd.reject(err);
|
|
452
|
-
}
|
|
453
|
-
return dfd.promise;
|
|
454
|
-
}
|
|
455
|
-
|
|
456
|
-
/**
|
|
457
|
-
* Wiki Link for SDK params
|
|
458
|
-
* https://github.com/comprodls/comprodls-sdk-js/wiki/07_PUB-Adapter#getsingleproductfamilyparams
|
|
459
|
-
*/
|
|
460
|
-
function getSingleProductFamily(options) {
|
|
461
|
-
var self = this;
|
|
462
|
-
var dfd = q.defer();
|
|
463
|
-
|
|
464
|
-
//Validations
|
|
465
|
-
var err;
|
|
466
|
-
if(options && options['family-code']) {
|
|
467
|
-
//Passed all validations, Construct API url
|
|
468
|
-
var url = self.config.DEFAULT_HOSTS['PUB'] + self.config.PUB_API_URLS.getSingleProductFamily;
|
|
469
|
-
url = helpers.api.constructAPIUrl(url, {
|
|
470
|
-
orgid: self.orgId, familyCode: options['family-code']
|
|
471
|
-
});
|
|
472
|
-
|
|
473
|
-
//Contruct parameters
|
|
474
|
-
var params = {};
|
|
475
|
-
if(options.stage) { params.stage = options.stage; }
|
|
476
|
-
|
|
477
|
-
//Setup request with URL and Post data
|
|
478
|
-
var requestAPI = request.get(url).query(params);
|
|
479
|
-
if(self.traceid) { requestAPI.set('X-Amzn-Trace-Id', self.traceid); }
|
|
480
|
-
|
|
481
|
-
requestAPI.end(function (err, response) {
|
|
482
|
-
if(err) {
|
|
483
|
-
err = new DLSError(helpers.errors.ERROR_TYPES.API_ERROR, err);
|
|
484
|
-
dfd.reject(err);
|
|
485
|
-
} else {
|
|
486
|
-
dfd.resolve(response.body);
|
|
487
|
-
}
|
|
488
|
-
});
|
|
489
|
-
}
|
|
490
|
-
else {
|
|
491
|
-
err = {};
|
|
492
|
-
err.message = err.description = 'Required parameter family-code not found in request options';
|
|
493
|
-
err = new DLSError(helpers.errors.ERROR_TYPES.SDK_ERROR, err);
|
|
494
|
-
dfd.reject(err);
|
|
495
|
-
}
|
|
496
|
-
|
|
497
|
-
return dfd.promise;
|
|
498
|
-
}
|
|
499
|
-
|
|
500
|
-
/**
|
|
501
|
-
* Wiki Link for SDK params
|
|
502
|
-
* https://github.com/comprodls/comprodls-sdk-js/wiki/07_PUB-Adapter#getallproductfamiliesparams
|
|
503
|
-
*/
|
|
504
|
-
function getAllProductFamilies(options) {
|
|
505
|
-
var self = this;
|
|
506
|
-
//Initializing promise
|
|
507
|
-
var dfd = q.defer();
|
|
508
|
-
|
|
509
|
-
//Construct API url
|
|
510
|
-
var url = self.config.DEFAULT_HOSTS['PUB'] + self.config.PUB_API_URLS.getAllProductFamilies;
|
|
511
|
-
|
|
512
|
-
url = helpers.api.constructAPIUrl(url, { orgid: self.orgId, });
|
|
513
|
-
//Contruct parameters
|
|
514
|
-
var params = {};
|
|
515
|
-
if(options && options.stage) { params.stage = options.stage; }
|
|
516
|
-
|
|
517
|
-
//Setup request with URL and Post data
|
|
518
|
-
var requestAPI = request.get(url).query(params);
|
|
519
|
-
|
|
520
|
-
if(self.traceid) { requestAPI.set('X-Amzn-Trace-Id', self.traceid); }
|
|
521
|
-
requestAPI.end(function (err, response) {
|
|
522
|
-
if(err) {
|
|
523
|
-
err = new DLSError(helpers.errors.ERROR_TYPES.API_ERROR, err);
|
|
524
|
-
dfd.reject(err);
|
|
525
|
-
} else {
|
|
526
|
-
dfd.resolve(response.body);
|
|
527
|
-
}
|
|
528
|
-
});
|
|
529
|
-
return dfd.promise;
|
|
530
|
-
}
|
|
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 Pub Adaptor
|
|
23
|
+
* Functions for calling Pub.
|
|
24
|
+
************************************************************/
|
|
25
|
+
|
|
26
|
+
var request = require('superagent');
|
|
27
|
+
var q = require('q');
|
|
28
|
+
var Agent = require('agentkeepalive');
|
|
29
|
+
|
|
30
|
+
var helpers = require('../../helpers');
|
|
31
|
+
var DLSError = helpers.errors.DLSError;
|
|
32
|
+
|
|
33
|
+
var keepaliveAgent = new Agent({
|
|
34
|
+
timeout: 60000,
|
|
35
|
+
freeSocketTimeout: 30000
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
module.exports = pub;
|
|
39
|
+
|
|
40
|
+
function pub() {
|
|
41
|
+
return {
|
|
42
|
+
promoteProduct: promoteProduct.bind(this),
|
|
43
|
+
registerProduct: registerProduct.bind(this),
|
|
44
|
+
ingestProduct: ingestProduct.bind(this),
|
|
45
|
+
createBundle: createBundle.bind(this),
|
|
46
|
+
updateBundle: updateBundle.bind(this),
|
|
47
|
+
getAllBundles: getAllBundles.bind(this),
|
|
48
|
+
getSingleBundle: getSingleBundle.bind(this),
|
|
49
|
+
createProductFamily: createProductFamily.bind(this),
|
|
50
|
+
updateProductFamily: updateProductFamily.bind(this),
|
|
51
|
+
getSingleProductFamily: getSingleProductFamily.bind(this),
|
|
52
|
+
getAllProductFamilies: getAllProductFamilies.bind(this)
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/*********************************
|
|
57
|
+
* Public Function definitions
|
|
58
|
+
**********************************/
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* Wiki Link for SDK params
|
|
62
|
+
* https://github.com/comprodls/comprodls-sdk-js/wiki/07_PUB-Adapter#promoteproductparams
|
|
63
|
+
*/
|
|
64
|
+
function promoteProduct(options) {
|
|
65
|
+
var self = this;
|
|
66
|
+
//Initializing promise
|
|
67
|
+
var dfd = q.defer();
|
|
68
|
+
|
|
69
|
+
//Contruct parameters
|
|
70
|
+
if (options && options.productcode) {
|
|
71
|
+
//Construct API url
|
|
72
|
+
var url = self.config.DEFAULT_HOSTS['PUB'] + self.config.PUB_API_URLS.promoteAPI;
|
|
73
|
+
url = helpers.api.constructAPIUrl(url, {
|
|
74
|
+
'orgId': self.orgId, 'productcode': options.productcode
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
var params = { source: {}, target: {} };
|
|
78
|
+
if (options.ext_user_id) { params.ext_user_id = options.ext_user_id; }
|
|
79
|
+
if (options.source && options.source.stage) { params.source.stage = options.source.stage; }
|
|
80
|
+
if (options.target) {
|
|
81
|
+
if(options.target.org) { params.target.org = options.target.org; }
|
|
82
|
+
if(options.target.stage) { params.target.stage = options.target.stage; }
|
|
83
|
+
}
|
|
84
|
+
if(options.externalrefid) { params.externalrefid = options.externalrefid; }
|
|
85
|
+
|
|
86
|
+
//Setup request with URL and Post data
|
|
87
|
+
var requestAPI = request.post(url).send(params);
|
|
88
|
+
|
|
89
|
+
if(self.traceid) { requestAPI.set('X-Amzn-Trace-Id', self.traceid); }
|
|
90
|
+
requestAPI
|
|
91
|
+
.agent(keepaliveAgent)
|
|
92
|
+
.end(function (err, response) {
|
|
93
|
+
if (err) {
|
|
94
|
+
err = new DLSError(helpers.errors.ERROR_TYPES.API_ERROR, err);
|
|
95
|
+
dfd.reject(err);
|
|
96
|
+
} else {
|
|
97
|
+
dfd.resolve(response);
|
|
98
|
+
}
|
|
99
|
+
});
|
|
100
|
+
} else {
|
|
101
|
+
var err = {};
|
|
102
|
+
err.message = err.description = 'Mandatory field \'options\' are not provided '+
|
|
103
|
+
'in the request options.';
|
|
104
|
+
err = new DLSError(helpers.errors.ERROR_TYPES.SDK_ERROR, err);
|
|
105
|
+
dfd.reject(err);
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
return dfd.promise;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
/**
|
|
112
|
+
* Wiki Link for SDK params
|
|
113
|
+
* https://github.com/comprodls/comprodls-sdk-js/wiki/07_PUB-Adapter#registerproductparams
|
|
114
|
+
*/
|
|
115
|
+
function registerProduct(options) {
|
|
116
|
+
var self = this;
|
|
117
|
+
var dfd = q.defer();
|
|
118
|
+
|
|
119
|
+
if (options) {
|
|
120
|
+
//Construct API url
|
|
121
|
+
var url = self.config.DEFAULT_HOSTS['PUB'] + self.config.PUB_API_URLS.registerProductAPI;
|
|
122
|
+
url = helpers.api.constructAPIUrl(url, { 'orgId' : self.orgId });
|
|
123
|
+
|
|
124
|
+
var params = {};
|
|
125
|
+
if (options.targetorg) { params.targetorgid = options.targetorg; }
|
|
126
|
+
if (options.repositorytype) { params.repositorytype = options.repositorytype; }
|
|
127
|
+
if (options.producttitle) { params.producttitle = options.producttitle; }
|
|
128
|
+
if (options.producttype) { params.producttype = options.producttype; }
|
|
129
|
+
if (options.productcode) { params.productcode = options.productcode; }
|
|
130
|
+
if (options.s3) { params.s3 = options.s3; }
|
|
131
|
+
if (options.externalrefid) { params.externalrefid = options.externalrefid; }
|
|
132
|
+
if (options['bundle-codes']) { params['bundle-codes'] = options['bundle-codes']; }
|
|
133
|
+
|
|
134
|
+
// Setup request with URL and Post data
|
|
135
|
+
var requestAPI = request.post(url).send(params);
|
|
136
|
+
|
|
137
|
+
if (self.traceid) { requestAPI.set('X-Amzn-Trace-Id', self.traceid); }
|
|
138
|
+
requestAPI
|
|
139
|
+
.agent(keepaliveAgent)
|
|
140
|
+
.end(function(err, response) {
|
|
141
|
+
if (err) {
|
|
142
|
+
err = new DLSError(helpers.errors.ERROR_TYPES.API_ERROR, err);
|
|
143
|
+
dfd.reject(err);
|
|
144
|
+
} else {
|
|
145
|
+
dfd.resolve(response);
|
|
146
|
+
}
|
|
147
|
+
});
|
|
148
|
+
} else {
|
|
149
|
+
var err = {};
|
|
150
|
+
err.message = err.description = 'Mandatory field \'options\' are not provided '+
|
|
151
|
+
'in the request options.';
|
|
152
|
+
err = new DLSError(helpers.errors.ERROR_TYPES.SDK_ERROR, err);
|
|
153
|
+
dfd.reject(err);
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
return dfd.promise;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
/**
|
|
160
|
+
* Wiki Link for SDK params
|
|
161
|
+
* https://github.com/comprodls/comprodls-sdk-js/wiki/07_PUB-Adapter#ingestproductparams
|
|
162
|
+
*/
|
|
163
|
+
function ingestProduct(options) {
|
|
164
|
+
var self = this;
|
|
165
|
+
//Initializing promise
|
|
166
|
+
var dfd = q.defer();
|
|
167
|
+
|
|
168
|
+
if (options && options.productcode) {
|
|
169
|
+
//Construct API url
|
|
170
|
+
var url = self.config.DEFAULT_HOSTS['PUB'] + self.config.PUB_API_URLS.ingestByCodeAPI;
|
|
171
|
+
url = helpers.api.constructAPIUrl(url, {
|
|
172
|
+
'orgId' : self.orgId, 'productcode' : options.productcode
|
|
173
|
+
});
|
|
174
|
+
|
|
175
|
+
//Contruct parameters
|
|
176
|
+
var params = {};
|
|
177
|
+
if (options.ext_user_id) { params.ext_user_id = options.ext_user_id; }
|
|
178
|
+
if (options.branchref) { params.branchref = options.branchref; }
|
|
179
|
+
if (options.externalrefid) { params.externalrefid = options.externalrefid; }
|
|
180
|
+
if (options['bundle-codes']) { params['bundle-codes'] = options['bundle-codes']; }
|
|
181
|
+
|
|
182
|
+
//Setup request with URL and Post data
|
|
183
|
+
var requestAPI = request.post(url).send(params);
|
|
184
|
+
|
|
185
|
+
if (self.traceid) { requestAPI.set('X-Amzn-Trace-Id', self.traceid); }
|
|
186
|
+
requestAPI
|
|
187
|
+
.agent(keepaliveAgent)
|
|
188
|
+
.end(function(err, response) {
|
|
189
|
+
if (err) {
|
|
190
|
+
err = new DLSError(helpers.errors.ERROR_TYPES.API_ERROR, err);
|
|
191
|
+
dfd.reject(err);
|
|
192
|
+
} else {
|
|
193
|
+
dfd.resolve(response);
|
|
194
|
+
}
|
|
195
|
+
});
|
|
196
|
+
} else {
|
|
197
|
+
var err = {};
|
|
198
|
+
err.message = err.description = 'Mandatory field \'productcode\' is not provided '+
|
|
199
|
+
'in the request options.';
|
|
200
|
+
err = new DLSError(helpers.errors.ERROR_TYPES.SDK_ERROR, err);
|
|
201
|
+
dfd.reject(err);
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
return dfd.promise;
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
/**
|
|
208
|
+
* Wiki Link for SDK params
|
|
209
|
+
* https://github.com/comprodls/comprodls-sdk-js/wiki/07_PUB-Adapter#createbundleparams
|
|
210
|
+
*/
|
|
211
|
+
function createBundle(options) {
|
|
212
|
+
var self = this;
|
|
213
|
+
//Initializing promise
|
|
214
|
+
var dfd = q.defer();
|
|
215
|
+
var err;
|
|
216
|
+
//Validations
|
|
217
|
+
if(options && options.stage && options['bundle-code'] && options.body && options.body.title &&
|
|
218
|
+
options.body.products)
|
|
219
|
+
{
|
|
220
|
+
//Passed all validations, Construct API url
|
|
221
|
+
var url = self.config.DEFAULT_HOSTS['PUB'] + self.config.PUB_API_URLS.createBundle;
|
|
222
|
+
url = helpers.api.constructAPIUrl(url, { orgid: self.orgId, stage: options.stage });
|
|
223
|
+
|
|
224
|
+
//Contruct parameters
|
|
225
|
+
options.body['bundle-code'] = options['bundle-code'];
|
|
226
|
+
//Setup request with URL and Post data
|
|
227
|
+
var requestAPI = request.post(url).send(options.body);
|
|
228
|
+
|
|
229
|
+
if(self.traceid) { requestAPI.set('X-Amzn-Trace-Id', self.traceid); }
|
|
230
|
+
|
|
231
|
+
requestAPI.end(function (err, response) {
|
|
232
|
+
if(err) {
|
|
233
|
+
err = new DLSError(helpers.errors.ERROR_TYPES.API_ERROR, err);
|
|
234
|
+
dfd.reject(err);
|
|
235
|
+
} else {
|
|
236
|
+
dfd.resolve(response.body);
|
|
237
|
+
}
|
|
238
|
+
});
|
|
239
|
+
}
|
|
240
|
+
else {
|
|
241
|
+
err = {};
|
|
242
|
+
err.message = err.description = 'Required parameter stage or bundle-code or title or ' +
|
|
243
|
+
'products not found in request options';
|
|
244
|
+
err = new DLSError(helpers.errors.ERROR_TYPES.SDK_ERROR, err);
|
|
245
|
+
dfd.reject(err);
|
|
246
|
+
}
|
|
247
|
+
return dfd.promise;
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
/**
|
|
251
|
+
* Wiki Link for SDK params
|
|
252
|
+
* https://github.com/comprodls/comprodls-sdk-js/wiki/07_PUB-Adapter#updatebundleparams
|
|
253
|
+
*/
|
|
254
|
+
function updateBundle(options) {
|
|
255
|
+
var self = this;
|
|
256
|
+
|
|
257
|
+
//Initializing promise
|
|
258
|
+
var dfd = q.defer();
|
|
259
|
+
var err;
|
|
260
|
+
|
|
261
|
+
//Validations
|
|
262
|
+
if(options && options.stage && options['bundle-code'] && options.body && options.body.products) {
|
|
263
|
+
//Passed all validations, Construct API url
|
|
264
|
+
var url = self.config.DEFAULT_HOSTS['PUB'] + self.config.PUB_API_URLS.updateBundle;
|
|
265
|
+
url = helpers.api.constructAPIUrl(url, {
|
|
266
|
+
orgid: self.orgId, stage: options.stage, bundleCode: options['bundle-code']
|
|
267
|
+
});
|
|
268
|
+
|
|
269
|
+
//Setup request with URL and Post data
|
|
270
|
+
var requestAPI = request.put(url).send(options.body);
|
|
271
|
+
|
|
272
|
+
if(self.traceid) { requestAPI.set('X-Amzn-Trace-Id', self.traceid); }
|
|
273
|
+
requestAPI.end(function (err, response) {
|
|
274
|
+
if(err) {
|
|
275
|
+
err = new DLSError(helpers.errors.ERROR_TYPES.API_ERROR, err);
|
|
276
|
+
dfd.reject(err);
|
|
277
|
+
} else {
|
|
278
|
+
dfd.resolve(response.body);
|
|
279
|
+
}
|
|
280
|
+
});
|
|
281
|
+
}
|
|
282
|
+
else {
|
|
283
|
+
err = {};
|
|
284
|
+
err.message = err.description = 'Required parameter stage or bundle-code or ' +
|
|
285
|
+
'products not found in request options';
|
|
286
|
+
err = new DLSError(helpers.errors.ERROR_TYPES.SDK_ERROR, err);
|
|
287
|
+
dfd.reject(err);
|
|
288
|
+
}
|
|
289
|
+
return dfd.promise;
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
/**
|
|
293
|
+
* Wiki Link for SDK params
|
|
294
|
+
* https://github.com/comprodls/comprodls-sdk-js/wiki/07_PUB-Adapter#getallbundlesparams
|
|
295
|
+
*/
|
|
296
|
+
function getAllBundles(options) {
|
|
297
|
+
var self = this;
|
|
298
|
+
//Initializing promise
|
|
299
|
+
var dfd = q.defer();
|
|
300
|
+
|
|
301
|
+
//Construct API url
|
|
302
|
+
var url = self.config.DEFAULT_HOSTS['PUB'] + self.config.PUB_API_URLS.getAllBundles;
|
|
303
|
+
|
|
304
|
+
url = helpers.api.constructAPIUrl(url, { orgid: self.orgId, });
|
|
305
|
+
//Contruct parameters
|
|
306
|
+
var params = {};
|
|
307
|
+
if(options) {
|
|
308
|
+
if(options.stage){
|
|
309
|
+
params.stage = options.stage;
|
|
310
|
+
}
|
|
311
|
+
if(options.target_role){
|
|
312
|
+
params.target_role = options.target_role;
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
//Setup request with URL and Post data
|
|
317
|
+
var requestAPI = request.get(url).query(params);
|
|
318
|
+
|
|
319
|
+
if(self.traceid) { requestAPI.set('X-Amzn-Trace-Id', self.traceid); }
|
|
320
|
+
requestAPI.end(function (err, response) {
|
|
321
|
+
if(err) {
|
|
322
|
+
err = new DLSError(helpers.errors.ERROR_TYPES.API_ERROR, err);
|
|
323
|
+
dfd.reject(err);
|
|
324
|
+
} else {
|
|
325
|
+
dfd.resolve(response.body);
|
|
326
|
+
}
|
|
327
|
+
});
|
|
328
|
+
return dfd.promise;
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
/**
|
|
332
|
+
* Wiki Link for SDK params
|
|
333
|
+
* https://github.com/comprodls/comprodls-sdk-js/wiki/07_PUB-Adapter#getsinglebundleparams
|
|
334
|
+
*/
|
|
335
|
+
function getSingleBundle(options) {
|
|
336
|
+
var self = this;
|
|
337
|
+
var dfd = q.defer();
|
|
338
|
+
|
|
339
|
+
//Validations
|
|
340
|
+
var err;
|
|
341
|
+
if(options && options['bundle-code']) {
|
|
342
|
+
|
|
343
|
+
//Passed all validations, Construct API url
|
|
344
|
+
var url = self.config.DEFAULT_HOSTS['PUB'] + self.config.PUB_API_URLS.getSingleBundle;
|
|
345
|
+
|
|
346
|
+
url = helpers.api.constructAPIUrl(url, { orgid: self.orgId, bundleCode: options['bundle-code'] });
|
|
347
|
+
//Contruct parameters
|
|
348
|
+
var params = {};
|
|
349
|
+
if(options && options.stage) { params.stage = options.stage; }
|
|
350
|
+
//Setup request with URL and Post data
|
|
351
|
+
|
|
352
|
+
var requestAPI = request.get(url).query(params);
|
|
353
|
+
|
|
354
|
+
if(self.traceid) { requestAPI.set('X-Amzn-Trace-Id', self.traceid); }
|
|
355
|
+
requestAPI.end(function (err, response) {
|
|
356
|
+
if(err) {
|
|
357
|
+
err = new DLSError(helpers.errors.ERROR_TYPES.API_ERROR, err);
|
|
358
|
+
dfd.reject(err);
|
|
359
|
+
} else {
|
|
360
|
+
dfd.resolve(response.body);
|
|
361
|
+
}
|
|
362
|
+
});
|
|
363
|
+
}
|
|
364
|
+
else {
|
|
365
|
+
err = {};
|
|
366
|
+
err.message = err.description = 'Required parameter bundle-code not found in request options';
|
|
367
|
+
err = new DLSError(helpers.errors.ERROR_TYPES.SDK_ERROR, err);
|
|
368
|
+
dfd.reject(err);
|
|
369
|
+
}
|
|
370
|
+
|
|
371
|
+
return dfd.promise;
|
|
372
|
+
}
|
|
373
|
+
|
|
374
|
+
/**
|
|
375
|
+
* Wiki Link for SDK params
|
|
376
|
+
* https://github.com/comprodls/comprodls-sdk-js/wiki/07_PUB-Adapter#createproductfamilyparams
|
|
377
|
+
*/
|
|
378
|
+
function createProductFamily(options) {
|
|
379
|
+
var self = this;
|
|
380
|
+
//Initializing promise
|
|
381
|
+
var dfd = q.defer();
|
|
382
|
+
var err;
|
|
383
|
+
//Validations
|
|
384
|
+
if (options && options.stage && options.body && options.body['family-code'])
|
|
385
|
+
{
|
|
386
|
+
//Passed all validations, Construct API url
|
|
387
|
+
var url = self.config.DEFAULT_HOSTS['PUB'] + self.config.PUB_API_URLS.createProductFamily;
|
|
388
|
+
url = helpers.api.constructAPIUrl(url, { orgid: self.orgId, stage: options.stage });
|
|
389
|
+
|
|
390
|
+
//Setup request with URL and Post data
|
|
391
|
+
var requestAPI = request.post(url).send(options.body);
|
|
392
|
+
|
|
393
|
+
if(self.traceid) { requestAPI.set('X-Amzn-Trace-Id', self.traceid); }
|
|
394
|
+
|
|
395
|
+
requestAPI.end(function (err, response) {
|
|
396
|
+
if(err) {
|
|
397
|
+
err = new DLSError(helpers.errors.ERROR_TYPES.API_ERROR, err);
|
|
398
|
+
dfd.reject(err);
|
|
399
|
+
} else {
|
|
400
|
+
dfd.resolve(response.body);
|
|
401
|
+
}
|
|
402
|
+
});
|
|
403
|
+
}
|
|
404
|
+
else {
|
|
405
|
+
err = {};
|
|
406
|
+
err.message = err.description = 'Required parameter stage or family-code ' +
|
|
407
|
+
'not found in request options';
|
|
408
|
+
err = new DLSError(helpers.errors.ERROR_TYPES.SDK_ERROR, err);
|
|
409
|
+
dfd.reject(err);
|
|
410
|
+
}
|
|
411
|
+
return dfd.promise;
|
|
412
|
+
}
|
|
413
|
+
|
|
414
|
+
/**
|
|
415
|
+
* Wiki Link for SDK params
|
|
416
|
+
* https://github.com/comprodls/comprodls-sdk-js/wiki/07_PUB-Adapter#updateproductfamilyparams
|
|
417
|
+
*/
|
|
418
|
+
function updateProductFamily(options) {
|
|
419
|
+
var self = this;
|
|
420
|
+
|
|
421
|
+
//Initializing promise
|
|
422
|
+
var dfd = q.defer();
|
|
423
|
+
var err;
|
|
424
|
+
|
|
425
|
+
//Validations
|
|
426
|
+
if (options && options.stage && options['family-code']) {
|
|
427
|
+
//Passed all validations, Construct API url
|
|
428
|
+
var url = self.config.DEFAULT_HOSTS['PUB'] + self.config.PUB_API_URLS.updateProductFamily;
|
|
429
|
+
url = helpers.api.constructAPIUrl(url, {
|
|
430
|
+
orgid: self.orgId, stage: options.stage, familyCode: options['family-code']
|
|
431
|
+
});
|
|
432
|
+
|
|
433
|
+
//Setup request with URL and Post data
|
|
434
|
+
var requestAPI = request.put(url).send(options.body);
|
|
435
|
+
|
|
436
|
+
if(self.traceid) { requestAPI.set('X-Amzn-Trace-Id', self.traceid); }
|
|
437
|
+
requestAPI.end(function (err, response) {
|
|
438
|
+
if(err) {
|
|
439
|
+
err = new DLSError(helpers.errors.ERROR_TYPES.API_ERROR, err);
|
|
440
|
+
dfd.reject(err);
|
|
441
|
+
} else {
|
|
442
|
+
dfd.resolve(response.body);
|
|
443
|
+
}
|
|
444
|
+
});
|
|
445
|
+
}
|
|
446
|
+
else {
|
|
447
|
+
err = {};
|
|
448
|
+
err.message = err.description = 'Required parameter stage or family-code ' +
|
|
449
|
+
'not found in request options';
|
|
450
|
+
err = new DLSError(helpers.errors.ERROR_TYPES.SDK_ERROR, err);
|
|
451
|
+
dfd.reject(err);
|
|
452
|
+
}
|
|
453
|
+
return dfd.promise;
|
|
454
|
+
}
|
|
455
|
+
|
|
456
|
+
/**
|
|
457
|
+
* Wiki Link for SDK params
|
|
458
|
+
* https://github.com/comprodls/comprodls-sdk-js/wiki/07_PUB-Adapter#getsingleproductfamilyparams
|
|
459
|
+
*/
|
|
460
|
+
function getSingleProductFamily(options) {
|
|
461
|
+
var self = this;
|
|
462
|
+
var dfd = q.defer();
|
|
463
|
+
|
|
464
|
+
//Validations
|
|
465
|
+
var err;
|
|
466
|
+
if(options && options['family-code']) {
|
|
467
|
+
//Passed all validations, Construct API url
|
|
468
|
+
var url = self.config.DEFAULT_HOSTS['PUB'] + self.config.PUB_API_URLS.getSingleProductFamily;
|
|
469
|
+
url = helpers.api.constructAPIUrl(url, {
|
|
470
|
+
orgid: self.orgId, familyCode: options['family-code']
|
|
471
|
+
});
|
|
472
|
+
|
|
473
|
+
//Contruct parameters
|
|
474
|
+
var params = {};
|
|
475
|
+
if(options.stage) { params.stage = options.stage; }
|
|
476
|
+
|
|
477
|
+
//Setup request with URL and Post data
|
|
478
|
+
var requestAPI = request.get(url).query(params);
|
|
479
|
+
if(self.traceid) { requestAPI.set('X-Amzn-Trace-Id', self.traceid); }
|
|
480
|
+
|
|
481
|
+
requestAPI.end(function (err, response) {
|
|
482
|
+
if(err) {
|
|
483
|
+
err = new DLSError(helpers.errors.ERROR_TYPES.API_ERROR, err);
|
|
484
|
+
dfd.reject(err);
|
|
485
|
+
} else {
|
|
486
|
+
dfd.resolve(response.body);
|
|
487
|
+
}
|
|
488
|
+
});
|
|
489
|
+
}
|
|
490
|
+
else {
|
|
491
|
+
err = {};
|
|
492
|
+
err.message = err.description = 'Required parameter family-code not found in request options';
|
|
493
|
+
err = new DLSError(helpers.errors.ERROR_TYPES.SDK_ERROR, err);
|
|
494
|
+
dfd.reject(err);
|
|
495
|
+
}
|
|
496
|
+
|
|
497
|
+
return dfd.promise;
|
|
498
|
+
}
|
|
499
|
+
|
|
500
|
+
/**
|
|
501
|
+
* Wiki Link for SDK params
|
|
502
|
+
* https://github.com/comprodls/comprodls-sdk-js/wiki/07_PUB-Adapter#getallproductfamiliesparams
|
|
503
|
+
*/
|
|
504
|
+
function getAllProductFamilies(options) {
|
|
505
|
+
var self = this;
|
|
506
|
+
//Initializing promise
|
|
507
|
+
var dfd = q.defer();
|
|
508
|
+
|
|
509
|
+
//Construct API url
|
|
510
|
+
var url = self.config.DEFAULT_HOSTS['PUB'] + self.config.PUB_API_URLS.getAllProductFamilies;
|
|
511
|
+
|
|
512
|
+
url = helpers.api.constructAPIUrl(url, { orgid: self.orgId, });
|
|
513
|
+
//Contruct parameters
|
|
514
|
+
var params = {};
|
|
515
|
+
if(options && options.stage) { params.stage = options.stage; }
|
|
516
|
+
|
|
517
|
+
//Setup request with URL and Post data
|
|
518
|
+
var requestAPI = request.get(url).query(params);
|
|
519
|
+
|
|
520
|
+
if(self.traceid) { requestAPI.set('X-Amzn-Trace-Id', self.traceid); }
|
|
521
|
+
requestAPI.end(function (err, response) {
|
|
522
|
+
if(err) {
|
|
523
|
+
err = new DLSError(helpers.errors.ERROR_TYPES.API_ERROR, err);
|
|
524
|
+
dfd.reject(err);
|
|
525
|
+
} else {
|
|
526
|
+
dfd.resolve(response.body);
|
|
527
|
+
}
|
|
528
|
+
});
|
|
529
|
+
return dfd.promise;
|
|
530
|
+
}
|