File tree Expand file tree Collapse file tree 2 files changed +23
-3
lines changed Expand file tree Collapse file tree 2 files changed +23
-3
lines changed Original file line number Diff line number Diff line change @@ -20,7 +20,11 @@ export interface Adapter {
20
20
getToken ?: ( config : Config ) => Promise < { apiKey : string } > ;
21
21
isValidToken ?: ( config : Config ) => Promise < boolean > ;
22
22
getAccountId ?: ( config : Config ) => Promise < string > ;
23
- getContact ?: ( config : Config , id : string ) => Promise < Contact > ;
23
+ getContact ?: (
24
+ config : Config ,
25
+ id : string ,
26
+ type : IntegrationEntityType ,
27
+ ) => Promise < Contact > ;
24
28
getContacts ?: ( config : Config ) => Promise < Contact [ ] > ;
25
29
getContactsDelta ?: (
26
30
config : Config ,
Original file line number Diff line number Diff line change @@ -13,6 +13,7 @@ import {
13
13
ContactDelta ,
14
14
ContactTemplate ,
15
15
ContactUpdate ,
16
+ IntegrationEntityType ,
16
17
ServerError ,
17
18
} from '.' ;
18
19
import { calendarEventsSchema , contactsSchema } from '../schemas' ;
@@ -464,13 +465,28 @@ export class Controller {
464
465
throw new ServerError ( 501 , 'Getting single contact is not implemented' ) ;
465
466
}
466
467
467
- try {
468
- infoLogger ( 'getContact' , 'START' , providerConfig . apiKey ) ;
468
+ infoLogger ( 'getContact' , 'START' , providerConfig . apiKey ) ;
469
+
470
+ const contactType : IntegrationEntityType | undefined = Object . values (
471
+ IntegrationEntityType ,
472
+ ) . find ( ( value ) => value === req . query . type ?. toString ( ) ) ;
469
473
474
+ if ( ! contactType ) {
475
+ throw new ServerError ( 400 , 'Missing contact type query parameter' ) ;
476
+ }
477
+
478
+ try {
470
479
const contactId = req . params . id ;
480
+ infoLogger (
481
+ 'getContact' ,
482
+ `Fetching contact ${ contactId } of type ${ contactType } ` ,
483
+ providerConfig . apiKey ,
484
+ ) ;
485
+
471
486
const responeContact = await this . adapter . getContact (
472
487
providerConfig ,
473
488
contactId ,
489
+ contactType ,
474
490
) ;
475
491
476
492
infoLogger ( 'getContact' , 'END' , providerConfig . apiKey ) ;
You can’t perform that action at this time.
0 commit comments