import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger';
import { IsEmail, IsOptional, IsString, IsBoolean, IsUUID, IsArray, IsNotEmpty } from 'class-validator';
import { PartialType } from '@nestjs/mapped-types';

export class CreatePesRecipientDto {
  @ApiProperty({
    description: 'Email of the recipient',
    example: 'john.doe@example.com',
  })
  @IsEmail()
  @IsString()
  @IsNotEmpty()
  email: string;

  @ApiPropertyOptional({
    description: 'First name of the recipient',
    example: 'John',
    required: false,
  })
  @IsOptional()
  @IsString()
  firstName?: string;

  @ApiPropertyOptional({
    description: 'Last name of the recipient',
    example: 'Doe',
    required: false,
  })
  @IsOptional()
  @IsString()
  lastName?: string;

  @ApiPropertyOptional({
    description: 'Department of the recipient',
    example: 'Marketing',
    required: false,
  })
  @IsOptional()
  @IsString()
  department?: string;

  @ApiPropertyOptional({
    description: 'Verification status of the recipient',
    example: true,
    required: false,
  })
  @IsOptional()
  @IsBoolean()
  isVerified?: boolean;

  @ApiPropertyOptional({
    description: 'Notes about the recipient',
    example: 'Important client',
    required: false,
  })
  @IsOptional()
  @IsString()
  notes?: string;

  @ApiPropertyOptional({
    description: 'IDs of the recipient groups this recipient belongs to',
    type: [String],
    required: false,
  })
  @IsOptional()
  @IsArray()
  @IsUUID('all', { each: true })
  groupIds?: string[];
}

export class UpdatePesRecipientDto extends PartialType(CreatePesRecipientDto) {}

import { PesRecipientGroup } from '../entities/pes-recepient-group.entity';

export class PesRecipientResponseDto {
  @ApiProperty({
    description: 'Unique identifier of the recipient',
    example: '123e4567-e89b-12d3-a456-42661417400',
  })
  id: string;

  @ApiProperty({
    description: 'Email of the recipient',
    example: 'john.doe@example.com',
  })
  email: string;

  @ApiPropertyOptional({
    description: 'First name of the recipient',
    example: 'John',
    required: false,
  })
  firstName?: string;

  @ApiPropertyOptional({
    description: 'Last name of the recipient',
    example: 'Doe',
    required: false,
  })
  lastName?: string;

  @ApiPropertyOptional({
    description: 'Department of the recipient',
    example: 'Marketing',
    required: false,
  })
  department?: string;

  @ApiPropertyOptional({
    description: 'Verification status of the recipient',
    example: true,
    required: false,
  })
  isVerified?: boolean;

  @ApiPropertyOptional({
    description: 'Notes about the recipient',
    example: 'Important client',
    required: false,
  })
  notes?: string;

  @ApiProperty({
    description: 'Groups the recipient belongs to',
    type: [PesRecipientGroup],
    required: false,
  })
  groups: PesRecipientGroup[];

  @ApiProperty({
    description: 'Creation timestamp of the recipient',
    type: String,
    example: '2023-10-01T12:00:00Z',
  })
  createdAt: Date;

  @ApiProperty({
    description: 'Last update timestamp of the recipient',
    type: String,
    example: '2023-10-01T12:00:00Z',
  })
  updatedAt: Date;

  constructor(partial: Partial<PesRecipientResponseDto>) {
    Object.assign(this, partial);
  }
}
