UNPKG

1.75 kBJavaScriptView Raw
1const guid = require('./utils/guid')
2
3class Timeline {
4 constructor(client) {
5 this.client = client
6 }
7
8 createEventType(applicationId, userId, data) {
9 data.applicationId = data.applicationId || applicationId
10 const parameters = {
11 method: 'POST',
12 path: `/integrations/v1/${applicationId}/timeline/event-types?userId=${userId}`,
13 body: data,
14 }
15 return this.client._request(parameters)
16 }
17
18 updateEventType(applicationId, eventTypeId, data) {
19 data.applicationId = data.applicationId || applicationId
20 const parameters = {
21 method: 'PUT',
22 path: `/integrations/v1/${applicationId}/timeline/event-types/${eventTypeId}`,
23 body: data,
24 }
25
26 return this.client._request(parameters)
27 }
28
29 createEventTypeProperty(applicationId, eventTypeId, userId, data) {
30 const parameters = {
31 method: 'POST',
32 path: `/integrations/v1/${applicationId}/timeline/event-types/${eventTypeId}/properties?userId=${userId}`,
33 body: data,
34 }
35
36 return this.client._request(parameters)
37 }
38
39 updateEventTypeProperty(applicationId, eventTypeId, propertyId, data) {
40 data.id = data.id || propertyId
41 const parameters = {
42 method: 'PUT',
43 path: `/integrations/v1/${applicationId}/timeline/event-types/${eventTypeId}/properties`,
44 body: data,
45 }
46
47 return this.client._request(parameters)
48 }
49
50 createTimelineEvent(applicationId, eventTypeId, data) {
51 if (!data.id) {
52 data.id = guid()
53 }
54
55 data.eventTypeId = data.eventTypeId || eventTypeId
56
57 const parameters = {
58 method: 'PUT',
59 path: `/integrations/v1/${applicationId}/timeline/event`,
60 body: data,
61 }
62
63 return this.client._request(parameters)
64 }
65}
66
67module.exports = Timeline