rejoiner 2.13.2 → 2.15.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.
@@ -39,6 +39,57 @@ const customerEndpoint = (client) => {
39
39
  throw new Error(`Invalid API version: ${client.apiVersion}`)
40
40
  }
41
41
  },
42
+ tags: {
43
+ get: async (email) => {
44
+ if (client.apiVersion !== 2) {
45
+ throw new Error('Tags endpoints require API v2')
46
+ }
47
+
48
+ const { id: customerId } = await client.customer.get(email)
49
+ const path = `customers/${customerId}/tags/`
50
+
51
+ return dispatchReturnData('get')(path)
52
+ },
53
+ set: async (email, tags, startJourney = true) => {
54
+ if (client.apiVersion !== 2) {
55
+ throw new Error('Tags endpoints require API v2')
56
+ }
57
+
58
+ const { id: customerId } = await client.customer.get(email)
59
+ const path = `customers/${customerId}/tags/`
60
+
61
+ const data = { tags }
62
+ if (!startJourney) data.start_journey = false
63
+
64
+ return dispatchReturnData('put')(path, data)
65
+ },
66
+ add: async (email, tags, startJourney = true) => {
67
+ if (client.apiVersion !== 2) {
68
+ throw new Error('Tags endpoints require API v2')
69
+ }
70
+
71
+ const { id: customerId } = await client.customer.get(email)
72
+ const path = `customers/${customerId}/tags/`
73
+
74
+ const data = { tags }
75
+ if (!startJourney) data.start_journey = false
76
+
77
+ return dispatchReturnData('patch')(path, data)
78
+ },
79
+ remove: async (email, tags, startJourney = true) => {
80
+ if (client.apiVersion !== 2) {
81
+ throw new Error('Tags endpoints require API v2')
82
+ }
83
+
84
+ const { id: customerId } = await client.customer.get(email)
85
+ const path = `customers/${customerId}/tags/remove/`
86
+
87
+ const data = { tags }
88
+ if (!startJourney) data.start_journey = false
89
+
90
+ return dispatchReturnData('patch')(path, data)
91
+ },
92
+ },
42
93
  preferenceTags: {
43
94
  get: (email) => {
44
95
  const params = { email }
@@ -0,0 +1,15 @@
1
+ const customer = require('./customer')
2
+ const journeys = require('./journeys')
3
+ const lists = require('./lists')
4
+ const ping = require('./ping')
5
+ const segments = require('./segments')
6
+ const sessions = require('./sessions')
7
+
8
+ module.exports = {
9
+ customer,
10
+ journeys,
11
+ lists,
12
+ ping,
13
+ segments,
14
+ sessions,
15
+ }
package/lib/rejoiner.js CHANGED
@@ -1,9 +1,9 @@
1
1
  const axios = require('axios')
2
2
  const crypto = require('crypto')
3
- const fs = require('graceful-fs')
4
- const path = require('path')
5
3
  const merge = require('lodash.merge')
6
4
 
5
+ const endpoints = require('./endpoints')
6
+
7
7
  const {
8
8
  DEFAULT_API_VERSION,
9
9
  REJOINER_API_KEY,
@@ -34,11 +34,9 @@ function Rejoiner2(options) {
34
34
  },
35
35
  })
36
36
 
37
- fs.readdirSync(path.join(__dirname, 'endpoints'))
38
- .filter((file) => file.indexOf('.') !== 0)
39
- .forEach((file) => {
40
- // eslint-disable-next-line global-require, import/no-dynamic-require
41
- const endpoint = require(path.join(__dirname, 'endpoints', file))(this)
37
+ Object.values(endpoints)
38
+ .forEach((model) => {
39
+ const endpoint = model(this)
42
40
  this[endpoint.path] = endpoint
43
41
  })
44
42
 
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "rejoiner",
3
3
  "description": "Rejoiner REST API client wrapper for Node.js",
4
- "version": "2.13.2",
4
+ "version": "2.15.0",
5
5
  "main": "lib/rejoiner.js",
6
6
  "author": "Sascha Bratton <sascha@brattonbratton.com>",
7
7
  "license": "MIT",