diff --git a/package.json b/package.json index 687e4cd6..da6f8fdb 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@sipgate/integration-bridge", - "version": "0.13.31", + "version": "0.13.32", "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 c31ff9e6..c560468b 100644 --- a/src/models/adapter.model.ts +++ b/src/models/adapter.model.ts @@ -13,17 +13,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 8f9b6417..5d62521c 100644 --- a/src/models/controller.model.ts +++ b/src/models/controller.model.ts @@ -67,7 +67,9 @@ export class Controller { infoLogger(`Fetching contacts…`, providerConfig); const fetchedContacts: Contact[] = await this.adapter.getContacts( - providerConfig + providerConfig, + req, + res ); if (!validate(this.ajv, contactsSchema, fetchedContacts)) { @@ -143,7 +145,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]); @@ -199,7 +203,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]); @@ -252,7 +258,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);