@engage_so/core 1.4.1 → 1.5.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.
Files changed (2) hide show
  1. package/index.js +20 -20
  2. package/package.json +2 -2
package/index.js CHANGED
@@ -77,7 +77,7 @@ const identify = async (o) => {
77
77
  if (o.email && !/^\S+@\S+$/.test(o.email)) {
78
78
  throw new EngageError('Email invalid.')
79
79
  }
80
- const allowed = ['id', 'is_group', 'email', 'number', 'created_at', 'device_token', 'device_platform', 'first_name', 'last_name']
80
+ const allowed = ['id', 'is_account', 'email', 'number', 'created_at', 'device_token', 'device_platform', 'first_name', 'last_name']
81
81
  const params = {
82
82
  meta: {}
83
83
  }
@@ -102,7 +102,7 @@ const addAttribute = async (uid, data) => {
102
102
  if (!Object.keys(data).length) {
103
103
  throw new EngageError('Attributes missing.')
104
104
  }
105
- const notMeta = ['created_at', 'is_group', 'number', 'device_token', 'device_platform', 'email', 'first_name', 'last_name']
105
+ const notMeta = ['created_at', 'is_account', 'number', 'device_token', 'device_platform', 'email', 'first_name', 'last_name']
106
106
  const params = { meta: {} }
107
107
  for (const k in data) {
108
108
  if (notMeta.includes(k)) {
@@ -136,12 +136,12 @@ const track = async (uid, data) => {
136
136
  return _request(`${root}/users/${uid}/events`, data, 'POST')
137
137
  }
138
138
 
139
- const addToGroup = async (uid, gid, role) => {
139
+ const addToAccount = async (uid, gid, role) => {
140
140
  if (!uid) {
141
141
  throw new EngageError('User id missing.')
142
142
  }
143
143
  if (!gid) {
144
- throw new EngageError('Group id missing.')
144
+ throw new EngageError('Account id missing.')
145
145
  }
146
146
  if (role && typeof role !== 'string') {
147
147
  throw new EngageError('Role should be a text.')
@@ -152,42 +152,42 @@ const addToGroup = async (uid, gid, role) => {
152
152
  if (role) {
153
153
  g.role = role
154
154
  }
155
- return _request(`${root}/users/${uid}/groups`, { groups: [g] }, 'POST')
155
+ return _request(`${root}/users/${uid}/accounts`, { accounts: [g] }, 'POST')
156
156
  }
157
- const removeFromGroup = async (uid, gid) => {
157
+ const removeFromAccount = async (uid, gid) => {
158
158
  if (!uid) {
159
159
  throw new EngageError('User id missing.')
160
160
  }
161
161
  if (!gid) {
162
- throw new EngageError('Group id missing.')
162
+ throw new EngageError('Account id missing.')
163
163
  }
164
- return _request(`${root}/users/${uid}/groups/${gid}`, null, 'DELETE')
164
+ return _request(`${root}/users/${uid}/accounts/${gid}`, null, 'DELETE')
165
165
  }
166
166
 
167
- const changeGroupRole = async (uid, gid, role) => {
167
+ const changeAccountRole = async (uid, gid, role) => {
168
168
  if (!uid) {
169
169
  throw new EngageError('User id missing.')
170
170
  }
171
171
  if (!gid) {
172
- throw new EngageError('Group id missing.')
172
+ throw new EngageError('Account id missing.')
173
173
  }
174
174
  if (!role) {
175
175
  throw new EngageError('New role missing.')
176
176
  }
177
- return _request(`${root}/users/${uid}/groups/${gid}`, { role }, 'PUT')
177
+ return _request(`${root}/users/${uid}/accounts/${gid}`, { role }, 'PUT')
178
178
  }
179
179
 
180
- const convertToUser = async (uid) => {
180
+ const convertToCustomer = async (uid) => {
181
181
  if (!uid) {
182
182
  throw new EngageError('User id missing.')
183
183
  }
184
- return _request(`${root}/users/${uid}/convert`, { type: 'user' }, 'POST')
184
+ return _request(`${root}/users/${uid}/convert`, { type: 'customer' }, 'POST')
185
185
  }
186
- const convertToGroup = async (uid) => {
186
+ const convertToAccount = async (uid) => {
187
187
  if (!uid) {
188
188
  throw new EngageError('User id missing.')
189
189
  }
190
- return _request(`${root}/users/${uid}/convert`, { type: 'group' }, 'POST')
190
+ return _request(`${root}/users/${uid}/convert`, { type: 'account' }, 'POST')
191
191
  }
192
192
 
193
193
  module.exports = {
@@ -196,9 +196,9 @@ module.exports = {
196
196
  addAttribute,
197
197
  track,
198
198
  request,
199
- addToGroup,
200
- removeFromGroup,
201
- changeGroupRole,
202
- convertToUser,
203
- convertToGroup
199
+ addToAccount,
200
+ removeFromAccount,
201
+ changeAccountRole,
202
+ convertToCustomer,
203
+ convertToAccount
204
204
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@engage_so/core",
3
- "version": "1.4.1",
3
+ "version": "1.5.0",
4
4
  "description": "Event driven customer segmentation and targeted engagement.",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -18,5 +18,5 @@
18
18
  "devDependencies": {
19
19
  "jest": "^26.4.2"
20
20
  },
21
- "gitHead": "7fc22abf94ef02987964ecfb6c3871314e42f922"
21
+ "gitHead": "16373af376360be8a4e71aeff74c86648d37072a"
22
22
  }