-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
41 lines (33 loc) · 1.32 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
const SubscriptionService = require('./src/subscription-service');
const PublishingService = require('./src/publishing-service');
class UnicornAdapter {
constructor(unicornUrl, callbackUrl, options) {
let maxTries;
if (options) {
maxTries = options.maxTries || 7;
} else {
maxTries = 7;
}
this.subscriptionService = new SubscriptionService(UnicornAdapter.notificationUrl(unicornUrl), callbackUrl, maxTries);
this.publishingService = new PublishingService(UnicornAdapter.eventUrl(unicornUrl));
}
static notificationUrl(unicornUrl) {
return `${unicornUrl}/webapi/REST/EventQuery/REST`
}
static eventUrl(unicornUrl) {
return `${unicornUrl}/webapi/REST/Event`
}
subscribeToEvent(eventName, attributes = ['*'], filters = {}, callbackUrl) {
return this.subscriptionService.subscribeToEvent(eventName, attributes, filters, callbackUrl);
}
unsubscribeFromEvent(uuid) {
return this.subscriptionService.unsubscribeFromEvent(uuid);
}
generateEvent(event, eventType, dataObjectState = '') {
return this.publishingService.generateChimeraEvent(event, eventType, dataObjectState);
}
generateChimeraEvent(event, eventType, dataObjectState = '') {
return this.publishingService.generateChimeraEvent(event, eventType, dataObjectState);
}
}
module.exports = UnicornAdapter;