Skip to content

Commit b362fa8

Browse files
committed
Renamed users.delete to users.archive (deprecating old .delete function)
1 parent 43e6fbc commit b362fa8

File tree

3 files changed

+34
-6
lines changed

3 files changed

+34
-6
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -143,8 +143,8 @@ client.users.find({ email: '[email protected]' }, callback);
143143
```
144144

145145
```node
146-
// Delete user by id
147-
client.users.delete({ id: '1234' }, callback);
146+
// Archive user by id (https://developers.intercom.com/v2.0/reference#archive-a-user)
147+
client.users.archive({ id: '1234' }, callback);
148148
```
149149

150150
## Leads

lib/user.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,14 @@
11
import Bulk from './bulk';
22
import Scroll from './scroll';
3+
import { deprecate } from 'util';
34

45
export default class User {
56
constructor(client) {
67
this.client = client;
78
this.scroll = new Scroll(this.client, 'user');
9+
10+
// Keep this API around but mark it deprecated
11+
this.delete = deprecate(this.archive.bind(this), 'intercom-client - user.delete: Use user.archive instead');
812
}
913
create(data, f) {
1014
return this.client.post('/users', data, f);
@@ -27,7 +31,7 @@ export default class User {
2731
return this.client.get(`/users`, { email: params.email }, f);
2832
}
2933
}
30-
delete(params, f) {
34+
archive(params, f) {
3135
if (params.id) {
3236
return this.client.delete(`/users/${params.id}`, {}, f);
3337
} else if (params.user_id) {

test/user.js

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,23 +59,47 @@ describe('users', () => {
5959
done();
6060
});
6161
});
62-
it('should delete users by id', done => {
62+
it('should archive users by id', done => {
63+
nock('https://api.intercom.io').delete('/users/baz').reply(200, {});
64+
const client = new Client('foo', 'bar').usePromises();
65+
client.users.archive({ id: 'baz' }).then(r => {
66+
assert.equal(200, r.statusCode);
67+
done();
68+
});
69+
});
70+
it('should archive users by user_id', done => {
71+
nock('https://api.intercom.io').delete('/users').query({ user_id: 'foo' }).reply(200, {});
72+
const client = new Client('foo', 'bar').usePromises();
73+
client.users.archive({ user_id: 'foo' }).then(r => {
74+
assert.equal(200, r.statusCode);
75+
done();
76+
});
77+
});
78+
it('should archive users by email', done => {
79+
nock('https://api.intercom.io').delete('/users').query({ email: 'foo' }).reply(200, {});
80+
const client = new Client('foo', 'bar').usePromises();
81+
client.users.archive({ email: 'foo' }).then(r => {
82+
assert.equal(200, r.statusCode);
83+
done();
84+
});
85+
});
86+
it('should archive (using old delete function) users by id', done => {
6387
nock('https://api.intercom.io').delete('/users/baz').reply(200, {});
6488
const client = new Client('foo', 'bar').usePromises();
6589
client.users.delete({ id: 'baz' }).then(r => {
6690
assert.equal(200, r.statusCode);
6791
done();
6892
});
6993
});
70-
it('should delete users by user_id', done => {
94+
it('should archive (using old delete function) users by user_id', done => {
7195
nock('https://api.intercom.io').delete('/users').query({ user_id: 'foo' }).reply(200, {});
7296
const client = new Client('foo', 'bar').usePromises();
7397
client.users.delete({ user_id: 'foo' }).then(r => {
7498
assert.equal(200, r.statusCode);
7599
done();
76100
});
77101
});
78-
it('should delete users by email', done => {
102+
it('should archive (using old delete function) users by email', done => {
79103
nock('https://api.intercom.io').delete('/users').query({ email: 'foo' }).reply(200, {});
80104
const client = new Client('foo', 'bar').usePromises();
81105
client.users.delete({ email: 'foo' }).then(r => {

0 commit comments

Comments
 (0)