import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger';
import { IsString, IsNotEmpty, IsOptional, IsUUID, IsBoolean, IsObject } from 'class-validator';

export class CreateWebhookEndpointDto {
  @ApiProperty({ description: 'Name of the webhook endpoint' })
  @IsString()
  @IsNotEmpty()
  name: string;

  @ApiPropertyOptional({ description: 'Target pipeline ID' })
  @IsUUID()
  @IsOptional()
  pipelineId?: string;

  @ApiPropertyOptional({ description: 'Target stage ID' })
  @IsUUID()
  @IsOptional()
  stageId?: string;

  @ApiPropertyOptional({ description: 'Default assignee user ID' })
  @IsUUID()
  @IsOptional()
  defaultAssigneeId?: string;

  @ApiPropertyOptional({
    description: 'Field mappings: { "external_field": "contactPhone" }',
  })
  @IsObject()
  @IsOptional()
  fieldMappings?: Record<string, string>;

  @ApiPropertyOptional({
    description: 'List value mappings: { "targetField": { "1": "Option A" } }',
  })
  @IsObject()
  @IsOptional()
  listMappings?: Record<string, Record<string, string>>;

  @ApiPropertyOptional({ default: true })
  @IsBoolean()
  @IsOptional()
  antifraudEnabled?: boolean;
}
