comprodls-sdk 2.116.0 → 2.120.0-security

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.
@@ -333,7 +333,8 @@ exports.INTEGRATIONS_API_URLS = {
333
333
  auditTrail: '/accounts/{accountId}/audit-trail',
334
334
  customEvents: '/accounts/{accountId}/custom-events',
335
335
  schedules: '/accounts/{accountId}/context/{context}/schedule',
336
- particularSchedule: '/accounts/{accountId}/context/{context}/schedule/{scheduleId}'
336
+ particularSchedule: '/accounts/{accountId}/context/{context}/schedule/{scheduleId}',
337
+ bridgeToRabbitMQ: '/events/bridge-to-rabbitmq'
337
338
  };
338
339
 
339
340
  exports.DRIVE_API_URLS = {
@@ -52,7 +52,8 @@ function integrations(accountId) {
52
52
  createSchedule: createSchedule.bind(this),
53
53
  getSchedule: getSchedule.bind(this),
54
54
  updateSchedule: updateSchedule.bind(this),
55
- deleteSchedule: deleteSchedule.bind(this)
55
+ deleteSchedule: deleteSchedule.bind(this),
56
+ publishEventsToRabbitMQ: publishEventsToRabbitMQ.bind(this)
56
57
  };
57
58
  }
58
59
 
@@ -478,3 +479,47 @@ function deleteSchedule(options) {
478
479
 
479
480
  return deferred.promise;
480
481
  }
482
+
483
+ /**
484
+ * Wiki Link for SDK params
485
+ * https://github.com/comprodls/comprodls-sdk-js/wiki/22_Integrations-Adapter#publisheventstorabbitmqparams
486
+ */
487
+ function publishEventsToRabbitMQ(options) {
488
+ var self = this;
489
+ console.log('Publishing events to RabbitMQ with options in the publishEventsToRabbitMQ function:', JSON.stringify(options, null, 2));
490
+
491
+ return new Promise(function (resolve, reject) {
492
+ if (options && options.route && options.route.exchange && options.route.routingKey &&
493
+ options.data && options.data.context) {
494
+ // Construct API url
495
+ var url = self.config.DEFAULT_HOSTS.INTEGRATION +
496
+ self.config.INTEGRATIONS_API_URLS.bridgeToRabbitMQ;
497
+
498
+ var body = {
499
+ route: options.route,
500
+ data: options.data
501
+ };
502
+
503
+ // Setup request with URL and Params
504
+ var requestAPI = request.post(url)
505
+ .set('Content-Type', 'application/json')
506
+ .set('Accept', 'application/json')
507
+ .send(body);
508
+
509
+ if (self.traceid) { requestAPI.set('X-Amzn-Trace-Id', self.traceid); }
510
+
511
+ requestAPI.end(function (error, response) {
512
+ if (error) {
513
+ reject(new DLSError(helpers.errors.ERROR_TYPES.API_ERROR, error));
514
+ } else {
515
+ resolve(response.body);
516
+ }
517
+ });
518
+ } else {
519
+ var err = {};
520
+ err.message = err.description = 'Mandatory params - route(exchange or routingKey) or ' +
521
+ 'data(context) not found in request options.';
522
+ reject(new DLSError(helpers.errors.ERROR_TYPES.SDK_ERROR, err));
523
+ }
524
+ });
525
+ }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "comprodls-sdk",
3
3
  "description": "comproDLS SDK for JavaScript",
4
- "version": "2.116.0",
4
+ "version": "2.120.0-security",
5
5
  "author": {
6
6
  "name": "Compro Technologies Private Limited",
7
7
  "url": "http://www.comprotechnologies.com/"