Skip to content

Commit 4782cef

Browse files
committed
0.13.27 added optional parameters req, res for getContacts, createContct, updateContact and deleteContact
1 parent 7e90d78 commit 4782cef

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.26",
3+
"version": "0.13.27",
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
@@ -12,17 +12,30 @@ import {
1212

1313
export interface Adapter {
1414
getToken?: (config: Config) => Promise<{ apiKey: string }>;
15-
getContacts?: (config: Config) => Promise<Contact[]>;
15+
getContacts?: (
16+
config: Config,
17+
req?: Request,
18+
res?: Response
19+
) => Promise<Contact[]>;
1620
createContact?: (
1721
config: Config,
18-
contact: ContactTemplate
22+
contact: ContactTemplate,
23+
req?: Request,
24+
res?: Response
1925
) => Promise<Contact>;
2026
updateContact?: (
2127
config: Config,
2228
id: string,
23-
contact: ContactUpdate
29+
contact: ContactUpdate,
30+
req?: Request,
31+
res?: Response
2432
) => Promise<Contact>;
25-
deleteContact?: (config: Config, id: string) => Promise<void>;
33+
deleteContact?: (
34+
config: Config,
35+
id: string,
36+
req?: Request,
37+
res?: Response
38+
) => Promise<void>;
2639
getCalendarEvents?: (
2740
config: Config,
2841
options?: CalendarFilterOptions | null

src/models/controller.model.ts

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,9 @@ export class Controller {
6565
console.log(`[${anonKey}] Fetching contacts`);
6666

6767
const fetchedContacts: Contact[] = await this.adapter.getContacts(
68-
req.providerConfig
68+
req.providerConfig,
69+
req,
70+
res
6971
);
7072

7173
if (!validate(this.ajv, contactsSchema, fetchedContacts)) {
@@ -137,7 +139,9 @@ export class Controller {
137139

138140
const contact: Contact = await this.adapter.createContact(
139141
req.providerConfig,
140-
req.body as ContactTemplate
142+
req.body as ContactTemplate,
143+
req,
144+
res
141145
);
142146

143147
const valid = validate(this.ajv, contactsSchema, [contact]);
@@ -193,7 +197,9 @@ export class Controller {
193197
const contact: Contact = await this.adapter.updateContact(
194198
req.providerConfig,
195199
req.params.id,
196-
req.body as ContactUpdate
200+
req.body as ContactUpdate,
201+
req,
202+
res
197203
);
198204

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

248254
const contactId: string = req.params.id;
249-
await this.adapter.deleteContact(req.providerConfig, contactId);
255+
await this.adapter.deleteContact(req.providerConfig, contactId, req, res);
250256

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

0 commit comments

Comments
 (0)