comprodls-sdk 2.71.0-development → 2.72.0

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/lib/comprodls.js CHANGED
@@ -83,8 +83,6 @@ function comproDLS(environment, realm, options) {
83
83
  try {
84
84
  config.DEFAULT_HOSTS = config.REALM_HOSTS[realm.toUpperCase()][environment.toUpperCase()];
85
85
  if(!config.DEFAULT_HOSTS){ throw 'Invalid Environment'; }
86
-
87
- config.PUBNUB_ORIGINS = config.PUBNUB_ORIGINS[realm.toUpperCase()][environment.toUpperCase()];
88
86
  }
89
87
  catch (e){
90
88
  var realmObj = config.REALM_HOSTS[realm.toUpperCase()];
@@ -350,7 +350,8 @@ exports.PUB_API_URLS = {
350
350
 
351
351
  exports.PUSHX_API_URLS = {
352
352
  grantByUserOrgId: '/orgs/{orgId}/grants',
353
- grantByAccountId: '/accounts/{accountId}/grants'
353
+ grantByAccountId: '/accounts/{accountId}/grants',
354
+ getPushedEvents: '/accounts/{accountId}/pushed-events/channels'
354
355
  };
355
356
 
356
357
  exports.INTEGRATIONS_API_URLS = {
@@ -379,23 +380,3 @@ exports.RULES_API_URLS = {
379
380
  updateRuleDisplay: '/org/{orgId}/context/{context}/rule_type/{ruleType}/rules/{ruleId}/update-rule-display',
380
381
  getUserRule: '/org/{orgId}/context/{context}/rule_type/{ruleType}/users/{userId}/rules'
381
382
  };
382
-
383
- exports.PUBNUB_ORIGINS = {
384
- ASGARD: {
385
- THOR: {
386
- CUSTOM: 'pushdlsthor.pubnubapi.com'
387
- }
388
- },
389
- GLOBAL: {
390
- PRODUCTION: {
391
- },
392
- PROD1: {}
393
- },
394
- CUP: {
395
- QA: {},
396
- REL: {},
397
- HFX: {},
398
- ALPHA: {},
399
- PROD1: {}
400
- }
401
- };
@@ -26,6 +26,7 @@
26
26
 
27
27
  var q = require('q');
28
28
  var request = require('superagent');
29
+ var Agent = require('agentkeepalive');
29
30
 
30
31
  var helpers = require('../../helpers');
31
32
  var pubnubClientWrapper = require('./pubnubClientWrapper');
@@ -36,6 +37,11 @@ var DLSError = helpers.errors.DLSError;
36
37
  **********************************/
37
38
  module.exports = pushX;
38
39
 
40
+ var keepaliveAgent = new Agent({
41
+ timeout: 60000,
42
+ freeSocketTimeout: 30000
43
+ });
44
+
39
45
  /*********************************
40
46
  * Public Function definitions
41
47
  **********************************/
@@ -46,14 +52,15 @@ function pushX() {
46
52
  "cleanup": _cleanup.bind(this, _pubnubClientWrapper),
47
53
  "grantByUserOrgId": grantByUserOrgId.bind(this),
48
54
  "grantByAccountId": grantByAccountId.bind(this),
49
- "grantByAccountIdOnExtUserId": grantByAccountIdOnExtUserId.bind(this)
55
+ "grantByAccountIdOnExtUserId": grantByAccountIdOnExtUserId.bind(this),
56
+ "getPushedEvents": getPushedEvents.bind(this)
50
57
  };
51
58
  }
52
59
 
53
60
  /*********************************
54
61
  * Public Function definitions
55
62
  **********************************/
56
-
63
+ // This is a dummy comment to test release.
57
64
  function _connect(pubnubCW, options) {
58
65
  var bpubnubV7 = true; // If pubnub v7 or higher in package.json, set it true
59
66
  if (bpubnubV7 && !options.userid) {
@@ -70,8 +77,7 @@ function _connect(pubnubCW, options) {
70
77
  'publishKey': options.publishKey,
71
78
  'subscribeKey': options.subscribeKey,
72
79
  'authKey': options.authKey,
73
- 'ssl': true,
74
- 'origin': this.config.PUBNUB_ORIGINS.CUSTOM
80
+ 'ssl': true
75
81
  }
76
82
  });
77
83
  }
@@ -197,3 +203,49 @@ function grantByAccountIdOnExtUserId(options) {
197
203
  return dfd.promise;
198
204
  }
199
205
 
206
+ /**
207
+ * @param {
208
+ * *accountid: "string",
209
+ * *channelName: "string",
210
+ * *starttime: number,
211
+ * *endtime: number
212
+ * } options
213
+ */
214
+ function getPushedEvents(options) {
215
+ var self = this;
216
+ var dfd = q.defer(); // Initializing promise
217
+ var accountid = options.accountid,
218
+ channelname = options.channelname,
219
+ starttime = options.starttime,
220
+ endtime = options.endtime;
221
+
222
+ if (accountid && channelname && starttime && endtime) {
223
+ // Passed all validations, Construct API url
224
+ var url = self.config.DEFAULT_HOSTS.PUSHX + self.config.PUSHX_API_URLS.getPushedEvents;
225
+ url = helpers.api.constructAPIUrl(url, { accountId: accountid });
226
+
227
+ // Setup request with URL and Params
228
+ var params = {channelname: channelname, starttime: starttime, endtime: endtime};
229
+ var requestAPI = request.get(url).query(params);
230
+ if(self.traceid) { requestAPI.set('X-Amzn-Trace-Id', self.traceid); }
231
+
232
+ requestAPI
233
+ .agent(keepaliveAgent)
234
+ .end(function(error, response) {
235
+ if (error) {
236
+ error = new DLSError(helpers.errors.ERROR_TYPES.API_ERROR, error);
237
+ dfd.reject(error);
238
+ } else {
239
+ dfd.resolve(response.body);
240
+ }
241
+ });
242
+ }
243
+ else {
244
+ var err = {};
245
+ err.message = err.description = 'Mandatory parameters [accountId, channelname,' +
246
+ ' starttime, endtime] not found in request options';
247
+ err = new DLSError(helpers.errors.ERROR_TYPES.SDK_ERROR, err);
248
+ dfd.reject(err);
249
+ }
250
+ return dfd.promise;
251
+ }
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.71.0-development",
4
+ "version": "2.72.0",
5
5
  "author": {
6
6
  "name": "Compro Technologies Private Limited",
7
7
  "url": "http://www.comprotechnologies.com/"