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

export class UpdateWebhookDto {
  @ApiPropertyOptional({ description: 'Human-readable label for this webhook', maxLength: 100 })
  @IsOptional()
  @IsString()
  @MaxLength(100)
  name?: string;

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

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

  @ApiPropertyOptional({ description: 'Enable or disable this webhook' })
  @IsOptional()
  @IsBoolean()
  is_active?: boolean;
}
