diff --git a/package.json b/package.json index 998fb240..c68fbbd1 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@sipgate/integration-bridge", - "version": "0.13.26", + "version": "0.13.27", "description": "sipgate Integration Bridge Framework", "main": "dist/index.js", "types": "dist/index.d.ts", diff --git a/src/models/adapter.model.ts b/src/models/adapter.model.ts index 64aae5a7..ca1cb6ee 100644 --- a/src/models/adapter.model.ts +++ b/src/models/adapter.model.ts @@ -12,17 +12,30 @@ import { export interface Adapter { getToken?: (config: Config) => Promise<{ apiKey: string }>; - getContacts?: (config: Config) => Promise; + getContacts?: ( + config: Config, + req?: Request, + res?: Response + ) => Promise; createContact?: ( config: Config, - contact: ContactTemplate + contact: ContactTemplate, + req?: Request, + res?: Response ) => Promise; updateContact?: ( config: Config, id: string, - contact: ContactUpdate + contact: ContactUpdate, + req?: Request, + res?: Response ) => Promise; - deleteContact?: (config: Config, id: string) => Promise; + deleteContact?: ( + config: Config, + id: string, + req?: Request, + res?: Response + ) => Promise; getCalendarEvents?: ( config: Config, options?: CalendarFilterOptions | null diff --git a/src/models/controller.model.ts b/src/models/controller.model.ts index 8a8dcb77..51f16394 100644 --- a/src/models/controller.model.ts +++ b/src/models/controller.model.ts @@ -65,7 +65,9 @@ export class Controller { console.log(`[${anonKey}] Fetching contacts`); const fetchedContacts: Contact[] = await this.adapter.getContacts( - req.providerConfig + req.providerConfig, + req, + res ); if (!validate(this.ajv, contactsSchema, fetchedContacts)) { @@ -137,7 +139,9 @@ export class Controller { const contact: Contact = await this.adapter.createContact( req.providerConfig, - req.body as ContactTemplate + req.body as ContactTemplate, + req, + res ); const valid = validate(this.ajv, contactsSchema, [contact]); @@ -193,7 +197,9 @@ export class Controller { const contact: Contact = await this.adapter.updateContact( req.providerConfig, req.params.id, - req.body as ContactUpdate + req.body as ContactUpdate, + req, + res ); const valid = validate(this.ajv, contactsSchema, [contact]); @@ -246,7 +252,7 @@ export class Controller { console.log(`Deleting contact for key "${anonymizeKey(apiKey)}"`); const contactId: string = req.params.id; - await this.adapter.deleteContact(req.providerConfig, contactId); + await this.adapter.deleteContact(req.providerConfig, contactId, req, res); if (this.adapter.getToken && req.providerConfig) { const { apiKey } = await this.adapter.getToken(req.providerConfig);