Skip to content

Commit a228aa6

Browse files
committed
Merge pull request #2 from intercom/BL/events
events
2 parents dea1a06 + 9dd9b1b commit a228aa6

File tree

4 files changed

+44
-0
lines changed

4 files changed

+44
-0
lines changed

README.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
# intercom-node
22
> Official Node bindings to the Intercom API
33
4+
## Beta
5+
6+
This client library is in active development, and should not be used in production software yet.
7+
48
## Testing
59

610
```node
@@ -67,6 +71,18 @@ client.users.delete({ id: '1234' }, function (d) {
6771
console.log(d.body)
6872
});
6973
```
74+
## Events
75+
76+
```node
77+
// Create a event
78+
client.events.create({
79+
event_name: 'Foo',
80+
created_at: 1439826340,
81+
user_id: 'bar'
82+
}, function (d) {
83+
console.log(d);
84+
});
85+
```
7086

7187
## License
7288

lib/client.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
var unirest = require('unirest');
22
import {User} from './user';
3+
import {Event} from './event';
34

45
export class Client {
56
constructor(appId, appApiKey) {
67
this.appId = appId;
78
this.appApiKey = appApiKey;
89
this.users = new User(this);
10+
this.events = new Event(this);
911
}
1012
ping(f) {
1113
unirest.get('https://api.intercom.io/admins')

lib/event.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
export class Event {
2+
constructor(client) {
3+
this.client = client;
4+
}
5+
create(data, f) {
6+
this.client.post('/events', data, f);
7+
}
8+
}

test/event.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import assert from 'assert';
2+
import {Client} from '../lib';
3+
var nock = require('nock');
4+
5+
describe('events', function () {
6+
it('should be created', function (done) {
7+
nock('https://api.intercom.io').post('/events', { event_name: 'Foo', created_at: 1234, user_id: 'bar' }).reply(200, {});
8+
let client = new Client('foo', 'bar');
9+
client.events.create({
10+
event_name: 'Foo',
11+
created_at: 1234,
12+
user_id: 'bar'
13+
}, function (r) {
14+
assert.equal(200, r.status);
15+
done();
16+
});
17+
});
18+
});

0 commit comments

Comments
 (0)