@@ -5,7 +5,7 @@ import { Operators, Role } from '../lib/common/common.types';
55import { SearchContactOrderBy } from '../lib/contact' ;
66
77describe ( 'contacts' , ( ) => {
8- it ( 'should create a contact with user role' , async ( ) => {
8+ it ( 'should create a contact with user role with external id ' , async ( ) => {
99 const id = '536e564f316c83104c000020' ;
1010
1111 const contact = {
@@ -44,6 +44,43 @@ describe('contacts', () => {
4444 assert . deepStrictEqual ( expectedReply , response ) ;
4545 } ) ;
4646
47+ it ( 'should create a contact with user role with email' , async ( ) => {
48+ const contact = {
49+ role : 'user' ,
50+ email : 'niko_bellic@mail.com' ,
51+ phone : '+48370044567' ,
52+ name : 'Niko Bellic' ,
53+ avatar : 'https://nico-from-gta-iv.com/lets_go_bowling.jpg' ,
54+ signed_up_at : 1638203719 ,
55+ last_seen_at : 1638203719 ,
56+ owner_id : 1 ,
57+ unsubscribed_from_emails : true ,
58+ } ;
59+
60+ const expectedReply = { } ;
61+
62+ nock ( 'https://api.intercom.io' )
63+ . post ( '/contacts' , contact )
64+ . reply ( 200 , expectedReply ) ;
65+
66+ const client = new Client ( {
67+ usernameAuth : { username : 'foo' , password : 'bar' } ,
68+ } ) ;
69+
70+ const response = await client . contacts . createUser ( {
71+ email : contact . email ,
72+ phone : contact . phone ,
73+ name : contact . name ,
74+ avatar : contact . avatar ,
75+ signedUpAt : contact . signed_up_at ,
76+ lastSeenAt : contact . last_seen_at ,
77+ ownerId : contact . owner_id ,
78+ isUnsubscribedFromEmails : contact . unsubscribed_from_emails ,
79+ } ) ;
80+
81+ assert . deepStrictEqual ( expectedReply , response ) ;
82+ } ) ;
83+
4784 it ( 'should create a contact with lead role' , async ( ) => {
4885 const contact = {
4986 role : 'lead' ,
0 commit comments