Skip to content

Commit f56ba77

Browse files
authored
feat: add webhook client requests and types to aircall integration (#294)
1 parent cd854d7 commit f56ba77

File tree

3 files changed

+72
-2
lines changed

3 files changed

+72
-2
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": "@vesselapi/integrations",
3-
"version": "1.0.63",
3+
"version": "1.0.64",
44
"description": "Vessel integrations",
55
"main": "dist/index.js",
66
"module": "dist/index.mjs",

src/platforms/aircall/client.ts

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ import {
1515
aircallPagination,
1616
AircallStartUserCall,
1717
aircallUser,
18+
aircallWebhook,
19+
AircallWebhookEvent,
1820
} from './schemas';
1921

2022
const request = makeRequestFactory(async (auth, options) => {
@@ -144,5 +146,26 @@ export const client = {
144146
}),
145147
),
146148
},
149+
webhooks: {
150+
create: request(
151+
(args: { url: string; name: string; events: AircallWebhookEvent[] }) => ({
152+
url: `/webhooks`,
153+
method: 'POST',
154+
json: {
155+
custom_name: args.name,
156+
url: args.url,
157+
events: args.events,
158+
},
159+
schema: z.object({
160+
webhook: aircallWebhook,
161+
}),
162+
}),
163+
),
164+
delete: request((args: { id: string }) => ({
165+
url: `/webhooks/${args.id}`,
166+
method: 'DELETE',
167+
schema: z.any(),
168+
})),
169+
},
147170
passthrough: request.passthrough(),
148171
};

src/platforms/aircall/schemas.ts

Lines changed: 48 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ export type AircallContactUpdate = {
9090
$native?: Record<string, unknown>;
9191
};
9292

93-
const aircallNumber = z.object({
93+
export const aircallNumber = z.object({
9494
id: z.number(),
9595
name: z.string().nullable(),
9696
digits: z.string().nullable(),
@@ -124,3 +124,50 @@ export const aircallCall = z.object({
124124
});
125125

126126
export type AircallCall = z.infer<typeof aircallCall>;
127+
128+
export const aircallWebhook = z.object({
129+
webhook_id: z.string(),
130+
direct_link: z.string(),
131+
created_at: z.string(),
132+
url: z.string(),
133+
active: z.boolean(),
134+
events: z.array(z.string()),
135+
token: z.string(),
136+
});
137+
138+
export type AircallWebhook = z.infer<typeof aircallWebhook>;
139+
140+
export type AircallResource = 'user' | 'number' | 'call' | 'contact';
141+
142+
export type AircallWebhookEvent =
143+
| 'user.created'
144+
| 'user.deleted'
145+
| 'user.connected'
146+
| 'user.disconnected'
147+
| 'user.opened'
148+
| 'user.closed'
149+
| 'user.wut_start'
150+
| 'user.wut_end'
151+
| 'number.created'
152+
| 'number.deleted'
153+
| 'number.opened'
154+
| 'number.closed'
155+
| 'call.created'
156+
| 'call.ringing_on_agent'
157+
| 'call.agent_declined'
158+
| 'call.answered'
159+
| 'call.transferred'
160+
| 'call.unsuccessful_transfer'
161+
| 'call.hungup'
162+
| 'call.ended'
163+
| 'call.voicemail_left'
164+
| 'call.assigned'
165+
| 'call.archived'
166+
| 'call.tagged'
167+
| 'call.untagged'
168+
| 'call.commented'
169+
| 'call.hold'
170+
| 'call.unhold'
171+
| 'contact.created'
172+
| 'contact.updated'
173+
| 'contact.deleted';

0 commit comments

Comments
 (0)