Files
cal.diy/apps/api/v2/src/modules/webhooks/inputs/webhook.input.ts
T
Morgan c059d79a51 feat: api v2 webhooks for users and event-types (#15996)
* feat: webhooks for users

* fixup! feat: webhooks for users

* feat: webhooks for user event types

* feat: webhooks for user event types

* fixup! Merge branch 'main' into feat-webhooks-api-v2

* doc

* chore: split webhook service

* chore: webhook repo only depends on prisma

* chore: split webhook outputs

* fixup! chore: split webhook outputs

* chore: describe payload template

* chore: pipe webhook input and output

* chore: use partialType for update dtos

* chore: improve dto
2024-08-02 12:18:35 +00:00

50 lines
1.3 KiB
TypeScript

import { ApiProperty, PartialType } from "@nestjs/swagger";
import { WebhookTriggerEvents } from "@prisma/client";
import { IsArray, IsBoolean, IsEnum, IsOptional, IsString } from "class-validator";
export class CreateWebhookInputDto {
@IsString()
@IsOptional()
@ApiProperty({
description:
"The template of the payload that will be sent to the subscriberUrl, check cal.com/docs/core-features/webhooks for more information",
example: JSON.stringify({
content: "A new event has been scheduled",
type: "{{type}}",
name: "{{title}}",
organizer: "{{organizer.name}}",
booker: "{{attendees.0.name}}",
}),
})
payloadTemplate?: string;
@IsBoolean()
active!: boolean;
@IsString()
subscriberUrl!: string;
@IsArray()
@ApiProperty({
example: [
"BOOKING_CREATED",
"BOOKING_RESCHEDULED",
"BOOKING_CANCELLED",
"BOOKING_CONFIRMED",
"BOOKING_REJECTED",
"BOOKING_COMPLETED",
"BOOKING_NO_SHOW",
"BOOKING_REOPENED",
],
enum: WebhookTriggerEvents,
})
@IsEnum(WebhookTriggerEvents, { each: true })
triggers!: WebhookTriggerEvents[];
@IsString()
@IsOptional()
secret?: string;
}
export class UpdateWebhookInputDto extends PartialType(CreateWebhookInputDto) {}