rejoiner 2.14.0 → 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.
- package/lib/endpoints/customer.js +51 -0
- package/package.json +1 -1
|
@@ -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 }
|
package/package.json
CHANGED