Skip to content

Commit 29c34df

Browse files
committed
Demo
1 parent 1a8a867 commit 29c34df

File tree

2 files changed

+30
-1
lines changed

2 files changed

+30
-1
lines changed

examples/demo.ts

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
#!/usr/bin/env -S npm run tsn -T
2+
3+
// INTERCOM_TEST_1_BEARER_TOKEN=*** pnpm tsn -T examples/demo.ts
4+
5+
import Intercom from 'intercom';
6+
7+
const intercom = new Intercom();
8+
const demoId = Math.floor(Math.random() * 10000);
9+
10+
async function main() {
11+
// Check account info
12+
const me = await intercom.me.retrieve({ "Intercom-Version": "2.10" });
13+
console.log(`Requesting as ${me?.name} (${me?.email})\n`);
14+
15+
// Check contacts
16+
let contacts = await intercom.contacts.list({ "Intercom-Version": "2.10" });
17+
console.log(`Contact count: ${contacts.data?.length}`);
18+
console.log(`${contacts.data?.map(contact => `\t${contact.email}`).join('\n')}\n`);
19+
20+
// Add contact
21+
const newEmail = `alex${demoId}@stainlessapi.com`;
22+
console.log(`Adding new contact ${newEmail}`);
23+
const createdContact = await intercom.contacts.create({ name: 'Alex', email: newEmail, "Intercom-Version": "2.10" });
24+
console.log(`Created contact with ID ${createdContact.id}`);
25+
}
26+
27+
main().catch((err) => {
28+
console.error(err);
29+
});

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646
"ts-node": "^10.5.0",
4747
"tsc-multi": "^1.1.0",
4848
"tsconfig-paths": "^4.0.0",
49-
"typescript": "^4.8.2"
49+
"typescript": "4.6.2"
5050
},
5151
"sideEffects": [
5252
"./_shims/index.js",

0 commit comments

Comments
 (0)