@engage_so/core 2.0.8 → 2.0.10

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 (3) hide show
  1. package/dist/index.js +10 -10
  2. package/package.json +2 -2
  3. package/src/index.ts +10 -10
package/dist/index.js CHANGED
@@ -29,7 +29,7 @@ if (typeof btoa === 'undefined') {
29
29
  // const rootURL = 'https://api.engage.so/v1'
30
30
  let auth = '';
31
31
  const notMeta = ['created_at', 'is_account', 'number', 'device_token', 'device_platform', 'email', 'first_name', 'last_name', 'tz', 'app_version', 'app_build', 'app_last_active'];
32
- const apiRoot = 'https://api.engage.so/v1/';
32
+ const apiRoot = 'https://api.engage.so/v1';
33
33
  function _request(url, params, method) {
34
34
  return __awaiter(this, void 0, void 0, function* () {
35
35
  try {
@@ -117,7 +117,7 @@ function identify(user) {
117
117
  params.meta[k] = user[k];
118
118
  }
119
119
  }
120
- return _request(`users/${user.id}`, params, 'PUT');
120
+ return _request(`/users/${user.id}`, params, 'PUT');
121
121
  });
122
122
  }
123
123
  exports.identify = identify;
@@ -146,7 +146,7 @@ function addAttribute(uid, attributes) {
146
146
  if (Object.keys(params.meta).length) {
147
147
  delete params.meta;
148
148
  }
149
- return _request(`users/${uid}`, params, 'PUT');
149
+ return _request(`/users/${uid}`, params, 'PUT');
150
150
  });
151
151
  }
152
152
  exports.addAttribute = addAttribute;
@@ -169,7 +169,7 @@ function track(uid, data) {
169
169
  throw new error_1.EngageError('Attributes missing.');
170
170
  }
171
171
  }
172
- return _request(`users/${uid}/events`, data, 'POST');
172
+ return _request(`/users/${uid}/events`, data, 'POST');
173
173
  });
174
174
  }
175
175
  exports.track = track;
@@ -181,7 +181,7 @@ function merge(sourceUid, destinationUid) {
181
181
  if (!destinationUid) {
182
182
  throw new error_1.EngageError('Destination ID missing.');
183
183
  }
184
- return _request(`users/merge`, {
184
+ return _request(`/users/merge`, {
185
185
  source: sourceUid,
186
186
  destination: destinationUid
187
187
  }, 'POST');
@@ -206,7 +206,7 @@ function addToAccount(uid, accountId, role) {
206
206
  if (role) {
207
207
  g.role = role;
208
208
  }
209
- return _request(`users/${uid}/accounts`, { accounts: [g] }, 'POST');
209
+ return _request(`/users/${uid}/accounts`, { accounts: [g] }, 'POST');
210
210
  });
211
211
  }
212
212
  exports.addToAccount = addToAccount;
@@ -218,7 +218,7 @@ function removeFromAccount(uid, accountId) {
218
218
  if (!accountId) {
219
219
  throw new error_1.EngageError('Account ID missing.');
220
220
  }
221
- return _request(`users/${uid}/accounts/${accountId}`, null, 'DELETE');
221
+ return _request(`/users/${uid}/accounts/${accountId}`, null, 'DELETE');
222
222
  });
223
223
  }
224
224
  exports.removeFromAccount = removeFromAccount;
@@ -233,7 +233,7 @@ function changeAccountRole(uid, accountId, role) {
233
233
  if (!role) {
234
234
  throw new error_1.EngageError('New role missing.');
235
235
  }
236
- return _request(`users/${uid}/accounts/${accountId}`, { role }, 'PUT');
236
+ return _request(`/users/${uid}/accounts/${accountId}`, { role }, 'PUT');
237
237
  });
238
238
  }
239
239
  exports.changeAccountRole = changeAccountRole;
@@ -242,7 +242,7 @@ function convertToCustomer(uid) {
242
242
  if (!uid) {
243
243
  throw new error_1.EngageError('User ID missing.');
244
244
  }
245
- return _request(`users/${uid}/convert`, { type: 'customer' }, 'POST');
245
+ return _request(`/users/${uid}/convert`, { type: 'customer' }, 'POST');
246
246
  });
247
247
  }
248
248
  exports.convertToCustomer = convertToCustomer;
@@ -251,7 +251,7 @@ function convertToAccount(uid) {
251
251
  if (!uid) {
252
252
  throw new error_1.EngageError('User ID missing.');
253
253
  }
254
- return _request(`users/${uid}/convert`, { type: 'account' }, 'POST');
254
+ return _request(`/users/${uid}/convert`, { type: 'account' }, 'POST');
255
255
  });
256
256
  }
257
257
  exports.convertToAccount = convertToAccount;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@engage_so/core",
3
- "version": "2.0.8",
3
+ "version": "2.0.10",
4
4
  "description": "Engage JS core.",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",
@@ -26,5 +26,5 @@
26
26
  "buffer": "^6.0.3",
27
27
  "cross-fetch": "^4.0.0"
28
28
  },
29
- "gitHead": "f8a2fd94418dc873d1894994b0ebb3bb4bc1fd51"
29
+ "gitHead": "707f8f2a8d6b697d26395f5d25885f75bee3e355"
30
30
  }
package/src/index.ts CHANGED
@@ -41,7 +41,7 @@ type Methods = 'POST' | 'PUT' | 'DELETE'
41
41
  // const rootURL = 'https://api.engage.so/v1'
42
42
  let auth: string = ''
43
43
  const notMeta = ['created_at', 'is_account', 'number', 'device_token', 'device_platform', 'email', 'first_name', 'last_name', 'tz', 'app_version', 'app_build', 'app_last_active']
44
- const apiRoot = 'https://api.engage.so/v1/'
44
+ const apiRoot = 'https://api.engage.so/v1'
45
45
 
46
46
  async function _request (url: string, params: Record<string, any> | null, method: Methods) {
47
47
  try {
@@ -125,7 +125,7 @@ export async function identify (user: UserIdentifyParams) {
125
125
  }
126
126
  }
127
127
 
128
- return _request(`users/${user.id}`, params, 'PUT')
128
+ return _request(`/users/${user.id}`, params, 'PUT')
129
129
  }
130
130
  export async function addAttribute (uid: string, attributes: UserAttrParams) {
131
131
  if (!uid) {
@@ -151,7 +151,7 @@ export async function addAttribute (uid: string, attributes: UserAttrParams) {
151
151
  delete params.meta
152
152
  }
153
153
 
154
- return _request(`users/${uid}`, params, 'PUT')
154
+ return _request(`/users/${uid}`, params, 'PUT')
155
155
  }
156
156
  export async function track (uid: string, data: EventParameter) {
157
157
  if (!uid) {
@@ -171,7 +171,7 @@ export async function track (uid: string, data: EventParameter) {
171
171
  }
172
172
  }
173
173
 
174
- return _request(`users/${uid}/events`, data, 'POST')
174
+ return _request(`/users/${uid}/events`, data, 'POST')
175
175
  }
176
176
 
177
177
  export async function merge (sourceUid: string, destinationUid: string) {
@@ -182,7 +182,7 @@ export async function merge (sourceUid: string, destinationUid: string) {
182
182
  throw new EngageError('Destination ID missing.')
183
183
  }
184
184
 
185
- return _request(`users/merge`, {
185
+ return _request(`/users/merge`, {
186
186
  source: sourceUid,
187
187
  destination: destinationUid
188
188
  }, 'POST')
@@ -205,7 +205,7 @@ export async function addToAccount(uid: string, accountId: string, role: string)
205
205
  if (role) {
206
206
  g.role = role
207
207
  }
208
- return _request(`users/${uid}/accounts`, { accounts: [g] }, 'POST')
208
+ return _request(`/users/${uid}/accounts`, { accounts: [g] }, 'POST')
209
209
  }
210
210
  export async function removeFromAccount (uid: string, accountId: string){
211
211
  if (!uid) {
@@ -214,7 +214,7 @@ export async function removeFromAccount (uid: string, accountId: string){
214
214
  if (!accountId) {
215
215
  throw new EngageError('Account ID missing.')
216
216
  }
217
- return _request(`users/${uid}/accounts/${accountId}`, null, 'DELETE')
217
+ return _request(`/users/${uid}/accounts/${accountId}`, null, 'DELETE')
218
218
  }
219
219
  export async function changeAccountRole (uid: string, accountId: string, role: string) {
220
220
  if (!uid) {
@@ -226,17 +226,17 @@ export async function changeAccountRole (uid: string, accountId: string, role: s
226
226
  if (!role) {
227
227
  throw new EngageError('New role missing.')
228
228
  }
229
- return _request(`users/${uid}/accounts/${accountId}`, { role }, 'PUT')
229
+ return _request(`/users/${uid}/accounts/${accountId}`, { role }, 'PUT')
230
230
  }
231
231
  export async function convertToCustomer (uid: string) {
232
232
  if (!uid) {
233
233
  throw new EngageError('User ID missing.')
234
234
  }
235
- return _request(`users/${uid}/convert`, { type: 'customer' }, 'POST')
235
+ return _request(`/users/${uid}/convert`, { type: 'customer' }, 'POST')
236
236
  }
237
237
  export async function convertToAccount (uid: string) {
238
238
  if (!uid) {
239
239
  throw new EngageError('User ID missing.')
240
240
  }
241
- return _request(`users/${uid}/convert`, { type: 'account' }, 'POST')
241
+ return _request(`/users/${uid}/convert`, { type: 'account' }, 'POST')
242
242
  }