UNPKG

887 BJavaScriptView Raw
1class Campaign {
2 constructor(client) {
3 this.client = client
4 }
5
6 get(options) {
7 return this.client._request({
8 method: 'GET',
9 path: '/email/public/v1/campaigns',
10 qs: options,
11 })
12 }
13
14 getById(options) {
15 return this.client._request({
16 method: 'GET',
17 path: '/email/public/v1/campaigns/by-id',
18 qs: options,
19 })
20 }
21
22 getOne(id) {
23 if (!id || typeof id === 'function') {
24 const error = new Error('id parameter must be provided.')
25 if (typeof id === 'function') {
26 id(error)
27 }
28 return Promise.reject(error)
29 }
30
31 return this.client._request({
32 method: 'GET',
33 path: `/email/public/v1/campaigns/${id}`,
34 })
35 }
36
37 events(options) {
38 return this.client._request({
39 method: 'GET',
40 path: '/email/public/v1/events',
41 qs: options,
42 })
43 }
44}
45
46module.exports = Campaign