import { IsString, IsNotEmpty, IsUrl, IsArray, ArrayNotEmpty, IsOptional, MaxLength } from 'class-validator';
import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger';

export class CreateWebhookDto {
  @ApiProperty({ description: 'Human-readable label for this webhook', maxLength: 100 })
  @IsString()
  @IsNotEmpty()
  @MaxLength(100)
  name: string;

  @ApiProperty({ description: 'HTTPS URL to POST events to' })
  @IsUrl({ protocols: ['https', 'http'], require_tld: false })
  url: string;

  @ApiProperty({
    description: 'Event keys to subscribe to',
    example: ['player_banned', 'server_down'],
    type: [String],
  })
  @IsArray()
  @ArrayNotEmpty()
  @IsString({ each: true })
  events: string[];

  @ApiPropertyOptional({
    description: 'HMAC-SHA256 signing secret. Auto-generated if omitted.',
    maxLength: 128,
  })
  @IsOptional()
  @IsString()
  @MaxLength(128)
  secret?: string;
}
