Skip to content

Commit 7e85914

Browse files
committed
0.13.32 added optional parameters req, res for getContacts, createContact, updateContact and deleteContact
1 parent f263359 commit 7e85914

File tree

3 files changed

+28
-9
lines changed

3 files changed

+28
-9
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@sipgate/integration-bridge",
3-
"version": "0.13.31",
3+
"version": "0.13.32",
44
"description": "sipgate Integration Bridge Framework",
55
"main": "dist/index.js",
66
"types": "dist/index.d.ts",

src/models/adapter.model.ts

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,17 +13,30 @@ import {
1313

1414
export interface Adapter {
1515
getToken?: (config: Config) => Promise<{ apiKey: string }>;
16-
getContacts?: (config: Config) => Promise<Contact[]>;
16+
getContacts?: (
17+
config: Config,
18+
req?: Request,
19+
res?: Response
20+
) => Promise<Contact[]>;
1721
createContact?: (
1822
config: Config,
19-
contact: ContactTemplate
23+
contact: ContactTemplate,
24+
req?: Request,
25+
res?: Response
2026
) => Promise<Contact>;
2127
updateContact?: (
2228
config: Config,
2329
id: string,
24-
contact: ContactUpdate
30+
contact: ContactUpdate,
31+
req?: Request,
32+
res?: Response
2533
) => Promise<Contact>;
26-
deleteContact?: (config: Config, id: string) => Promise<void>;
34+
deleteContact?: (
35+
config: Config,
36+
id: string,
37+
req?: Request,
38+
res?: Response
39+
) => Promise<void>;
2740
getCalendarEvents?: (
2841
config: Config,
2942
options?: CalendarFilterOptions | null

src/models/controller.model.ts

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,9 @@ export class Controller {
6767
infoLogger(`Fetching contacts…`, providerConfig);
6868

6969
const fetchedContacts: Contact[] = await this.adapter.getContacts(
70-
providerConfig
70+
providerConfig,
71+
req,
72+
res
7173
);
7274

7375
if (!validate(this.ajv, contactsSchema, fetchedContacts)) {
@@ -143,7 +145,9 @@ export class Controller {
143145

144146
const contact: Contact = await this.adapter.createContact(
145147
req.providerConfig,
146-
req.body as ContactTemplate
148+
req.body as ContactTemplate,
149+
req,
150+
res
147151
);
148152

149153
const valid = validate(this.ajv, contactsSchema, [contact]);
@@ -199,7 +203,9 @@ export class Controller {
199203
const contact: Contact = await this.adapter.updateContact(
200204
req.providerConfig,
201205
req.params.id,
202-
req.body as ContactUpdate
206+
req.body as ContactUpdate,
207+
req,
208+
res
203209
);
204210

205211
const valid = validate(this.ajv, contactsSchema, [contact]);
@@ -252,7 +258,7 @@ export class Controller {
252258
console.log(`Deleting contact for key "${anonymizeKey(apiKey)}"`);
253259

254260
const contactId: string = req.params.id;
255-
await this.adapter.deleteContact(req.providerConfig, contactId);
261+
await this.adapter.deleteContact(req.providerConfig, contactId, req, res);
256262

257263
if (this.adapter.getToken && req.providerConfig) {
258264
const { apiKey } = await this.adapter.getToken(req.providerConfig);

0 commit comments

Comments
 (0)