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.
Files changed (36) hide show
  1. package/.eslintrc +28 -28
  2. package/.github/workflows/npm-publish.yml +76 -0
  3. package/README.md +235 -235
  4. package/dist/comprodls-sdk.js +13543 -13543
  5. package/docs/npm-oidc-publishing-runbook.md +229 -0
  6. package/lib/comprodls.js +132 -132
  7. package/lib/config/index.js +356 -356
  8. package/lib/helpers/index.js +31 -31
  9. package/lib/helpers/lib/api/converter.js +129 -129
  10. package/lib/helpers/lib/api/index.js +46 -46
  11. package/lib/helpers/lib/errors.js +122 -122
  12. package/lib/helpers/lib/requestLayer.js +154 -154
  13. package/lib/helpers/lib/validator.js +192 -192
  14. package/lib/open_access/index.js +116 -116
  15. package/lib/services/analytics/index.js +1365 -1365
  16. package/lib/services/attempts/index.js +389 -389
  17. package/lib/services/auth/index.js +3708 -3708
  18. package/lib/services/authextn/index.js +1032 -1032
  19. package/lib/services/datasyncmanager/index.js +275 -275
  20. package/lib/services/drive/index.js +270 -270
  21. package/lib/services/integrations/index.js +525 -525
  22. package/lib/services/invitations/index.js +282 -282
  23. package/lib/services/product/index.js +343 -343
  24. package/lib/services/pub/index.js +530 -530
  25. package/lib/services/pushX/index.js +251 -251
  26. package/lib/services/pushX/pubnubClientWrapper.js +438 -438
  27. package/lib/services/rules/index.js +416 -416
  28. package/lib/services/spaces/index.js +999 -999
  29. package/lib/services/spacesextn/index.js +131 -131
  30. package/lib/services/superuser/index.js +160 -160
  31. package/lib/services/taxonomy/index.js +405 -405
  32. package/lib/services/workflows/index.js +406 -406
  33. package/lib/services/xapi/index.js +114 -114
  34. package/lib/token/index.js +120 -120
  35. package/lib/token/validations.js +85 -85
  36. package/package.json +5 -1
@@ -1,343 +1,343 @@
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 Product API Adaptor
23
- * Functions for calling Product API.
24
- ************************************************************/
25
- var request = require('superagent');
26
- var q = require('q');
27
-
28
- var helpers = require('../../helpers');
29
- var DLSError = helpers.errors.DLSError;
30
-
31
- module.exports = product;
32
-
33
- function product(accountId) {
34
- this.accountId = accountId;
35
- return {
36
- getProduct: getProduct.bind(this),
37
- getGlobalEntitlementsForAUser: getGlobalEntitlementsForAUser.bind(this),
38
- getMicroEntitlementsForAUser: getMicroEntitlementsForAUser.bind(this),
39
-
40
- getAllBundles: getAllBundles.bind(this),
41
- getSingleBundle: getSingleBundle.bind(this),
42
-
43
- getSingleProductFamily: getSingleProductFamily.bind(this),
44
- getAllProductFamilies: getAllProductFamilies.bind(this)
45
- };
46
- }
47
-
48
- /**
49
- * Wiki Link for SDK params
50
- * https://github.com/comprodls/comprodls-sdk-js/wiki/05_PRODUCT-Adapter#getproductparams
51
- */
52
- function getProduct(options) {
53
- var dfd = q.defer();
54
- var self = this;
55
- var err = {};
56
-
57
- if(options && options.productcode) {
58
- //Passed all validations, Construct API url
59
- var url = self.config.DEFAULT_HOSTS['PRODUCT'] +
60
- self.config.PRODUCT_API_URLS.getProductAPI;
61
- url = helpers.api.constructAPIUrl(url, {
62
- accountId: self.accountId,
63
- productCode: options.productcode
64
- });
65
-
66
- //Construct parameters
67
- var params = {};
68
- if(options.details) {
69
- params.details = options.details;
70
- }
71
- if(options.stage) {
72
- params.stage = options.stage;
73
- }
74
- //Setup request with URL and Params
75
- var requestAPI = request.get(url).query(params);
76
- if(self.traceid) { requestAPI.set('X-Amzn-Trace-Id', self.traceid); }
77
-
78
- //Call GET All Products Source Api
79
- requestAPI.end(function(err, response) {
80
- if (err) {
81
- err = new DLSError(helpers.errors.ERROR_TYPES.API_ERROR, err);
82
- dfd.reject(err);
83
- } else {
84
- dfd.resolve(response.body);
85
- }
86
- });
87
- }
88
- else {
89
- err.message = err.description = 'productcode not found in request options';
90
- err = new DLSError(helpers.errors.ERROR_TYPES.SDK_ERROR, err);
91
- dfd.reject(err);
92
- }
93
-
94
- return dfd.promise;
95
- }
96
-
97
- /**
98
- * Wiki Link for SDK params
99
- * https://github.com/comprodls/comprodls-sdk-js/wiki/05_PRODUCT-Adapter#getglobalentitlementsforauserparams
100
- */
101
- function getGlobalEntitlementsForAUser(options) {
102
- var self = this;
103
-
104
- //Initializing promise
105
- var dfd = q.defer();
106
-
107
- if(options && options.extUserId) {
108
- //Passed all validations, Construct API url
109
- var url = self.config.DEFAULT_HOSTS.PRODUCT +
110
- self.config.PRODUCT_API_URLS.getEntitlementsOfAUser;
111
- url = helpers.api.constructAPIUrl(url,
112
- { accountId : self.accountId, extUserId : options.extUserId });
113
-
114
- //Contruct parameters
115
- var query = {};
116
- if(options.productDetails) { query.productDetails = options.productDetails; }
117
- if(options.bundleDetails) { query.bundleDetails = options.bundleDetails; }
118
-
119
- //Setup request with URL and Params
120
- var requestAPI = request.get(url).query(query);
121
- if(self.traceid) { requestAPI.set('X-Amzn-Trace-Id', self.traceid); }
122
-
123
- //Call GET ALL USER Api
124
- requestAPI.end(function(err, response) {
125
- if (err) {
126
- err = new DLSError(helpers.errors.ERROR_TYPES.API_ERROR, err);
127
- dfd.reject(err);
128
- }
129
- else { dfd.resolve(response.body); }
130
- });
131
- }
132
- else {
133
- var err = {};
134
- err.message = err.description = 'Mandatory parameter extUserId not found in request options';
135
- err = new DLSError(helpers.errors.ERROR_TYPES.SDK_ERROR, err);
136
- dfd.reject(err);
137
- }
138
- return dfd.promise;
139
- }
140
-
141
- /**
142
- * Wiki Link for SDK params
143
- * https://github.com/comprodls/comprodls-sdk-js/wiki/05_PRODUCT-Adapter#getmicroentitlementsforauserparams
144
- */
145
- function getMicroEntitlementsForAUser(options) {
146
- var self = this;
147
-
148
- //Initializing promise
149
- var dfd = q.defer();
150
-
151
- if(options && options.extuserid && options.productcode ) {
152
- //Passed all validations, Construct API url
153
- var url = self.config.DEFAULT_HOSTS.PRODUCT +
154
- self.config.PRODUCT_API_URLS.getMicroEntitlementsOfAUser;
155
- url = helpers.api.constructAPIUrl(url,
156
- { accountId : self.accountId, extUserId : options.extuserid });
157
-
158
- //Contruct parameters
159
- var query = {};
160
- query.productcode = options.productcode;
161
- if (options.context) { query.context = options.context; }
162
- if (options.feature_key) { query.feature_key = options.feature_key; }
163
- if (options.cursor) { query.cursor = options.cursor; }
164
-
165
- //Setup request with URL and Params
166
- var requestAPI = request.get(url).query(query);
167
- if(self.traceid) { requestAPI.set('X-Amzn-Trace-Id', self.traceid); }
168
-
169
- //Call Get All User Micro Entitlements Api
170
- requestAPI.end(function(err, response) {
171
- if (err) {
172
- err = new DLSError(helpers.errors.ERROR_TYPES.API_ERROR, err);
173
- dfd.reject(err);
174
- }
175
- else { dfd.resolve(response.body); }
176
- });
177
- }
178
- else {
179
- var err = {};
180
- err.message = err.description = 'Mandatory parameter extuserid or productcode' +
181
- 'not found in request options';
182
- err = new DLSError(helpers.errors.ERROR_TYPES.SDK_ERROR, err);
183
- dfd.reject(err);
184
- }
185
- return dfd.promise;
186
- }
187
-
188
- /**
189
- * Wiki Link for SDK params
190
- * https://github.com/comprodls/comprodls-sdk-js/wiki/05_PRODUCT-Adapter#getallbundlesparams
191
- */
192
- function getAllBundles(options) {
193
- var self = this;
194
- var dfd = q.defer();
195
-
196
- //Passed all validations, Construct API url
197
- var url = self.config.DEFAULT_HOSTS.PRODUCT + self.config.PRODUCT_API_URLS.getAllBundles;
198
-
199
- url = helpers.api.constructAPIUrl(url, { accountId : self.accountId });
200
- //Contruct parameters
201
- var params = {};
202
- if(options) {
203
- if(options.stage){
204
- params.stage = options.stage;
205
- }
206
- if(options.target_role){
207
- params.target_role = options.target_role;
208
- }
209
- }
210
-
211
- //Setup request with URL and Post data
212
- var requestAPI = request.get(url).query(params);
213
- if(self.traceid) { requestAPI.set('X-Amzn-Trace-Id', self.traceid); }
214
-
215
- requestAPI.end(function (err, response) {
216
- if(err) {
217
- err = new DLSError(helpers.errors.ERROR_TYPES.API_ERROR, err);
218
- dfd.reject(err);
219
- } else {
220
- dfd.resolve(response.body);
221
- }
222
- });
223
-
224
- return dfd.promise;
225
- }
226
-
227
- /**
228
- * Wiki Link for SDK params
229
- * https://github.com/comprodls/comprodls-sdk-js/wiki/05_PRODUCT-Adapter#getsinglebundleparams
230
- */
231
- function getSingleBundle(options) {
232
- var self = this;
233
- var dfd = q.defer();
234
- var err;
235
-
236
- if(options && options['bundle-code']) {
237
-
238
- var url = self.config.DEFAULT_HOSTS.PRODUCT + self.config.PRODUCT_API_URLS.getSingleBundle;
239
-
240
- url = helpers.api.constructAPIUrl(url, { accountId : self.accountId, bundleCode: options['bundle-code'] });
241
- //Contruct parameters
242
- var params = {};
243
- if(options.stage) { params.stage = options.stage; }
244
- //Setup request with URL and Post data
245
-
246
- var requestAPI = request.get(url).query(params);
247
- if(self.traceid) { requestAPI.set('X-Amzn-Trace-Id', self.traceid); }
248
-
249
- requestAPI.end(function (err, response) {
250
- if(err) {
251
- err = new DLSError(helpers.errors.ERROR_TYPES.API_ERROR, err);
252
- dfd.reject(err);
253
- } else {
254
- dfd.resolve(response.body);
255
- }
256
- });
257
- }
258
- else {
259
- err = {};
260
- err.message = err.description = 'Required parameter bundle-code not found in request options';
261
- err = new DLSError(helpers.errors.ERROR_TYPES.SDK_ERROR, err);
262
- dfd.reject(err);
263
- }
264
-
265
- return dfd.promise;
266
- }
267
-
268
- /**
269
- * Wiki Link for SDK params
270
- * https://github.com/comprodls/comprodls-sdk-js/wiki/05_PRODUCT-Adapter#getallproductfamiliesparams
271
- */
272
- function getAllProductFamilies(options) {
273
- var self = this;
274
- var dfd = q.defer();
275
-
276
- //Passed all validations, Construct API url
277
- var url = self.config.DEFAULT_HOSTS.PRODUCT + self.config.PRODUCT_API_URLS.getAllProductFamilies;
278
-
279
- url = helpers.api.constructAPIUrl(url, { accountId: self.accountId });
280
- //Contruct parameters
281
- var params = {};
282
- if (options && options.stage) { params.stage = options.stage; }
283
-
284
- //Setup request with URL and Post data
285
- var requestAPI = request.get(url).query(params);
286
- if (self.traceid) { requestAPI.set('X-Amzn-Trace-Id', self.traceid); }
287
-
288
- requestAPI.end(function (err, response) {
289
- if (err) {
290
- err = new DLSError(helpers.errors.ERROR_TYPES.API_ERROR, err);
291
- dfd.reject(err);
292
- } else {
293
- dfd.resolve(response.body);
294
- }
295
- });
296
-
297
- return dfd.promise;
298
- }
299
-
300
- /**
301
- * Wiki Link for SDK params
302
- * https://github.com/comprodls/comprodls-sdk-js/wiki/05_PRODUCT-Adapter#getsingleproductfamilyparams
303
- */
304
- function getSingleProductFamily(options) {
305
- var self = this;
306
- var dfd = q.defer();
307
- var err;
308
-
309
- if (options && options['family-code']) {
310
-
311
- var url = self.config.DEFAULT_HOSTS.PRODUCT +
312
- self.config.PRODUCT_API_URLS.getSingleProductFamily;
313
-
314
- url = helpers.api.constructAPIUrl(url, {
315
- accountId: self.accountId, familyCode: options['family-code']
316
- });
317
-
318
- //Contruct parameters
319
- var params = {};
320
- if (options.stage) { params.stage = options.stage; }
321
-
322
- //Setup request with URL and Post data
323
- var requestAPI = request.get(url).query(params);
324
- if (self.traceid) { requestAPI.set('X-Amzn-Trace-Id', self.traceid); }
325
-
326
- requestAPI.end(function (err, response) {
327
- if (err) {
328
- err = new DLSError(helpers.errors.ERROR_TYPES.API_ERROR, err);
329
- dfd.reject(err);
330
- } else {
331
- dfd.resolve(response.body);
332
- }
333
- });
334
- }
335
- else {
336
- err = {};
337
- err.message = err.description = 'Required parameter family-code not found in request options';
338
- err = new DLSError(helpers.errors.ERROR_TYPES.SDK_ERROR, err);
339
- dfd.reject(err);
340
- }
341
-
342
- return dfd.promise;
343
- }
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 Product API Adaptor
23
+ * Functions for calling Product API.
24
+ ************************************************************/
25
+ var request = require('superagent');
26
+ var q = require('q');
27
+
28
+ var helpers = require('../../helpers');
29
+ var DLSError = helpers.errors.DLSError;
30
+
31
+ module.exports = product;
32
+
33
+ function product(accountId) {
34
+ this.accountId = accountId;
35
+ return {
36
+ getProduct: getProduct.bind(this),
37
+ getGlobalEntitlementsForAUser: getGlobalEntitlementsForAUser.bind(this),
38
+ getMicroEntitlementsForAUser: getMicroEntitlementsForAUser.bind(this),
39
+
40
+ getAllBundles: getAllBundles.bind(this),
41
+ getSingleBundle: getSingleBundle.bind(this),
42
+
43
+ getSingleProductFamily: getSingleProductFamily.bind(this),
44
+ getAllProductFamilies: getAllProductFamilies.bind(this)
45
+ };
46
+ }
47
+
48
+ /**
49
+ * Wiki Link for SDK params
50
+ * https://github.com/comprodls/comprodls-sdk-js/wiki/05_PRODUCT-Adapter#getproductparams
51
+ */
52
+ function getProduct(options) {
53
+ var dfd = q.defer();
54
+ var self = this;
55
+ var err = {};
56
+
57
+ if(options && options.productcode) {
58
+ //Passed all validations, Construct API url
59
+ var url = self.config.DEFAULT_HOSTS['PRODUCT'] +
60
+ self.config.PRODUCT_API_URLS.getProductAPI;
61
+ url = helpers.api.constructAPIUrl(url, {
62
+ accountId: self.accountId,
63
+ productCode: options.productcode
64
+ });
65
+
66
+ //Construct parameters
67
+ var params = {};
68
+ if(options.details) {
69
+ params.details = options.details;
70
+ }
71
+ if(options.stage) {
72
+ params.stage = options.stage;
73
+ }
74
+ //Setup request with URL and Params
75
+ var requestAPI = request.get(url).query(params);
76
+ if(self.traceid) { requestAPI.set('X-Amzn-Trace-Id', self.traceid); }
77
+
78
+ //Call GET All Products Source Api
79
+ requestAPI.end(function(err, response) {
80
+ if (err) {
81
+ err = new DLSError(helpers.errors.ERROR_TYPES.API_ERROR, err);
82
+ dfd.reject(err);
83
+ } else {
84
+ dfd.resolve(response.body);
85
+ }
86
+ });
87
+ }
88
+ else {
89
+ err.message = err.description = 'productcode not found in request options';
90
+ err = new DLSError(helpers.errors.ERROR_TYPES.SDK_ERROR, err);
91
+ dfd.reject(err);
92
+ }
93
+
94
+ return dfd.promise;
95
+ }
96
+
97
+ /**
98
+ * Wiki Link for SDK params
99
+ * https://github.com/comprodls/comprodls-sdk-js/wiki/05_PRODUCT-Adapter#getglobalentitlementsforauserparams
100
+ */
101
+ function getGlobalEntitlementsForAUser(options) {
102
+ var self = this;
103
+
104
+ //Initializing promise
105
+ var dfd = q.defer();
106
+
107
+ if(options && options.extUserId) {
108
+ //Passed all validations, Construct API url
109
+ var url = self.config.DEFAULT_HOSTS.PRODUCT +
110
+ self.config.PRODUCT_API_URLS.getEntitlementsOfAUser;
111
+ url = helpers.api.constructAPIUrl(url,
112
+ { accountId : self.accountId, extUserId : options.extUserId });
113
+
114
+ //Contruct parameters
115
+ var query = {};
116
+ if(options.productDetails) { query.productDetails = options.productDetails; }
117
+ if(options.bundleDetails) { query.bundleDetails = options.bundleDetails; }
118
+
119
+ //Setup request with URL and Params
120
+ var requestAPI = request.get(url).query(query);
121
+ if(self.traceid) { requestAPI.set('X-Amzn-Trace-Id', self.traceid); }
122
+
123
+ //Call GET ALL USER Api
124
+ requestAPI.end(function(err, response) {
125
+ if (err) {
126
+ err = new DLSError(helpers.errors.ERROR_TYPES.API_ERROR, err);
127
+ dfd.reject(err);
128
+ }
129
+ else { dfd.resolve(response.body); }
130
+ });
131
+ }
132
+ else {
133
+ var err = {};
134
+ err.message = err.description = 'Mandatory parameter extUserId not found in request options';
135
+ err = new DLSError(helpers.errors.ERROR_TYPES.SDK_ERROR, err);
136
+ dfd.reject(err);
137
+ }
138
+ return dfd.promise;
139
+ }
140
+
141
+ /**
142
+ * Wiki Link for SDK params
143
+ * https://github.com/comprodls/comprodls-sdk-js/wiki/05_PRODUCT-Adapter#getmicroentitlementsforauserparams
144
+ */
145
+ function getMicroEntitlementsForAUser(options) {
146
+ var self = this;
147
+
148
+ //Initializing promise
149
+ var dfd = q.defer();
150
+
151
+ if(options && options.extuserid && options.productcode ) {
152
+ //Passed all validations, Construct API url
153
+ var url = self.config.DEFAULT_HOSTS.PRODUCT +
154
+ self.config.PRODUCT_API_URLS.getMicroEntitlementsOfAUser;
155
+ url = helpers.api.constructAPIUrl(url,
156
+ { accountId : self.accountId, extUserId : options.extuserid });
157
+
158
+ //Contruct parameters
159
+ var query = {};
160
+ query.productcode = options.productcode;
161
+ if (options.context) { query.context = options.context; }
162
+ if (options.feature_key) { query.feature_key = options.feature_key; }
163
+ if (options.cursor) { query.cursor = options.cursor; }
164
+
165
+ //Setup request with URL and Params
166
+ var requestAPI = request.get(url).query(query);
167
+ if(self.traceid) { requestAPI.set('X-Amzn-Trace-Id', self.traceid); }
168
+
169
+ //Call Get All User Micro Entitlements Api
170
+ requestAPI.end(function(err, response) {
171
+ if (err) {
172
+ err = new DLSError(helpers.errors.ERROR_TYPES.API_ERROR, err);
173
+ dfd.reject(err);
174
+ }
175
+ else { dfd.resolve(response.body); }
176
+ });
177
+ }
178
+ else {
179
+ var err = {};
180
+ err.message = err.description = 'Mandatory parameter extuserid or productcode' +
181
+ 'not found in request options';
182
+ err = new DLSError(helpers.errors.ERROR_TYPES.SDK_ERROR, err);
183
+ dfd.reject(err);
184
+ }
185
+ return dfd.promise;
186
+ }
187
+
188
+ /**
189
+ * Wiki Link for SDK params
190
+ * https://github.com/comprodls/comprodls-sdk-js/wiki/05_PRODUCT-Adapter#getallbundlesparams
191
+ */
192
+ function getAllBundles(options) {
193
+ var self = this;
194
+ var dfd = q.defer();
195
+
196
+ //Passed all validations, Construct API url
197
+ var url = self.config.DEFAULT_HOSTS.PRODUCT + self.config.PRODUCT_API_URLS.getAllBundles;
198
+
199
+ url = helpers.api.constructAPIUrl(url, { accountId : self.accountId });
200
+ //Contruct parameters
201
+ var params = {};
202
+ if(options) {
203
+ if(options.stage){
204
+ params.stage = options.stage;
205
+ }
206
+ if(options.target_role){
207
+ params.target_role = options.target_role;
208
+ }
209
+ }
210
+
211
+ //Setup request with URL and Post data
212
+ var requestAPI = request.get(url).query(params);
213
+ if(self.traceid) { requestAPI.set('X-Amzn-Trace-Id', self.traceid); }
214
+
215
+ requestAPI.end(function (err, response) {
216
+ if(err) {
217
+ err = new DLSError(helpers.errors.ERROR_TYPES.API_ERROR, err);
218
+ dfd.reject(err);
219
+ } else {
220
+ dfd.resolve(response.body);
221
+ }
222
+ });
223
+
224
+ return dfd.promise;
225
+ }
226
+
227
+ /**
228
+ * Wiki Link for SDK params
229
+ * https://github.com/comprodls/comprodls-sdk-js/wiki/05_PRODUCT-Adapter#getsinglebundleparams
230
+ */
231
+ function getSingleBundle(options) {
232
+ var self = this;
233
+ var dfd = q.defer();
234
+ var err;
235
+
236
+ if(options && options['bundle-code']) {
237
+
238
+ var url = self.config.DEFAULT_HOSTS.PRODUCT + self.config.PRODUCT_API_URLS.getSingleBundle;
239
+
240
+ url = helpers.api.constructAPIUrl(url, { accountId : self.accountId, bundleCode: options['bundle-code'] });
241
+ //Contruct parameters
242
+ var params = {};
243
+ if(options.stage) { params.stage = options.stage; }
244
+ //Setup request with URL and Post data
245
+
246
+ var requestAPI = request.get(url).query(params);
247
+ if(self.traceid) { requestAPI.set('X-Amzn-Trace-Id', self.traceid); }
248
+
249
+ requestAPI.end(function (err, response) {
250
+ if(err) {
251
+ err = new DLSError(helpers.errors.ERROR_TYPES.API_ERROR, err);
252
+ dfd.reject(err);
253
+ } else {
254
+ dfd.resolve(response.body);
255
+ }
256
+ });
257
+ }
258
+ else {
259
+ err = {};
260
+ err.message = err.description = 'Required parameter bundle-code not found in request options';
261
+ err = new DLSError(helpers.errors.ERROR_TYPES.SDK_ERROR, err);
262
+ dfd.reject(err);
263
+ }
264
+
265
+ return dfd.promise;
266
+ }
267
+
268
+ /**
269
+ * Wiki Link for SDK params
270
+ * https://github.com/comprodls/comprodls-sdk-js/wiki/05_PRODUCT-Adapter#getallproductfamiliesparams
271
+ */
272
+ function getAllProductFamilies(options) {
273
+ var self = this;
274
+ var dfd = q.defer();
275
+
276
+ //Passed all validations, Construct API url
277
+ var url = self.config.DEFAULT_HOSTS.PRODUCT + self.config.PRODUCT_API_URLS.getAllProductFamilies;
278
+
279
+ url = helpers.api.constructAPIUrl(url, { accountId: self.accountId });
280
+ //Contruct parameters
281
+ var params = {};
282
+ if (options && options.stage) { params.stage = options.stage; }
283
+
284
+ //Setup request with URL and Post data
285
+ var requestAPI = request.get(url).query(params);
286
+ if (self.traceid) { requestAPI.set('X-Amzn-Trace-Id', self.traceid); }
287
+
288
+ requestAPI.end(function (err, response) {
289
+ if (err) {
290
+ err = new DLSError(helpers.errors.ERROR_TYPES.API_ERROR, err);
291
+ dfd.reject(err);
292
+ } else {
293
+ dfd.resolve(response.body);
294
+ }
295
+ });
296
+
297
+ return dfd.promise;
298
+ }
299
+
300
+ /**
301
+ * Wiki Link for SDK params
302
+ * https://github.com/comprodls/comprodls-sdk-js/wiki/05_PRODUCT-Adapter#getsingleproductfamilyparams
303
+ */
304
+ function getSingleProductFamily(options) {
305
+ var self = this;
306
+ var dfd = q.defer();
307
+ var err;
308
+
309
+ if (options && options['family-code']) {
310
+
311
+ var url = self.config.DEFAULT_HOSTS.PRODUCT +
312
+ self.config.PRODUCT_API_URLS.getSingleProductFamily;
313
+
314
+ url = helpers.api.constructAPIUrl(url, {
315
+ accountId: self.accountId, familyCode: options['family-code']
316
+ });
317
+
318
+ //Contruct parameters
319
+ var params = {};
320
+ if (options.stage) { params.stage = options.stage; }
321
+
322
+ //Setup request with URL and Post data
323
+ var requestAPI = request.get(url).query(params);
324
+ if (self.traceid) { requestAPI.set('X-Amzn-Trace-Id', self.traceid); }
325
+
326
+ requestAPI.end(function (err, response) {
327
+ if (err) {
328
+ err = new DLSError(helpers.errors.ERROR_TYPES.API_ERROR, err);
329
+ dfd.reject(err);
330
+ } else {
331
+ dfd.resolve(response.body);
332
+ }
333
+ });
334
+ }
335
+ else {
336
+ err = {};
337
+ err.message = err.description = 'Required parameter family-code not found in request options';
338
+ err = new DLSError(helpers.errors.ERROR_TYPES.SDK_ERROR, err);
339
+ dfd.reject(err);
340
+ }
341
+
342
+ return dfd.promise;
343
+ }