File tree Expand file tree Collapse file tree 2 files changed +30
-1
lines changed
Expand file tree Collapse file tree 2 files changed +30
-1
lines changed Original file line number Diff line number Diff line change 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+ } ) ;
Original file line number Diff line number Diff line change 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" ,
You can’t perform that action at this time.
0 commit comments