import { IsString, IsUrl, IsArray, IsEnum, IsOptional } from 'class-validator';
import { ApiProperty } from '@nestjs/swagger';
import { WebhookEventType } from '../enums/webhook-event-type.enum';

export class CreateWebhookDto {
  @ApiProperty({
    description: 'Webhook URL to send events to',
    example: 'https://example.com/webhooks/events',
  })
  @IsUrl()
  url: string;

  @ApiProperty({
    description: 'Array of event types to subscribe to',
    enum: WebhookEventType,
    isArray: true,
    example: ['APPROVAL_REQUIRED', 'REQUEST_APPROVED'],
  })
  @IsArray()
  @IsEnum(WebhookEventType, { each: true })
  events: WebhookEventType[];

  @ApiProperty({
    description: 'Optional description for the webhook',
    example: 'Webhook for approval notifications',
    required: false,
  })
  @IsOptional()
  @IsString()
  description?: string;
}
