import { ApiProperty } from '@nestjs/swagger';
import { IsArray, ArrayNotEmpty, IsInt, IsOptional } from 'class-validator';
import { Type } from 'class-transformer';

/**
 * DTO for fetching tuition fee details for one or more visa cases.
 *
 * This DTO is typically used in endpoints where the user needs to retrieve
 * tuition fee and commission-related information for multiple visa cases
 * at once.
 */
export class SearchCaseTuitionFeeDto {
  /**
   * Array of Visa Case IDs for which tuition fees need to be fetched.
   *
   * Validation rules:
   * - Must be an array
   * - Cannot be empty
   * - Each element must be an integer
   * - Automatically converted to numbers by class-transformer
   *
   * Example payload:
   * ```json
   * {
   *   "visa_case_ids": [11, 14, 19]
   * }
   * ```
   */
  @ApiProperty({
    type: [Number],
    required: true,
    example: [11, 14, 19],
    description: 'Array of visa_case_ids to fetch tuition fee details for',
  })
  @IsArray({ message: 'visa_case_ids must be an array of numbers' })
  @ArrayNotEmpty({ message: 'visa_case_ids cannot be empty' })
  @IsInt({ each: true, message: 'Each visa_case_id must be an integer' })
  @Type(() => Number)
  visa_case_ids: number[];

  /**
   * Optional commission instance number.
   *
   * Validation rules:
   * - Optional field
   * - Must be an integer if provided
   * - Automatically converted to a number by class-transformer
   *
   * Example payload:
   * ```json
   * {
   *   "commission_instance": 1
   * }
   * ```
   */
  @ApiProperty({
    required: false,
    example: 1,
    description: 'Optional commission instance number',
  })
  @IsOptional()
  @IsInt({ message: 'commission_instance must be an integer' })
  @Type(() => Number)
  commission_instance?: number;
}
