import { IsString, IsOptional, IsNumber, Min, Max } from 'class-validator';
import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger';

export class CreditScoreRequestDto {
  @ApiProperty({ description: 'User ID', example: 'user-123' })
  @IsString()
  userId: string;

  @ApiPropertyOptional({ description: 'Issuer ID for issuer-specific scoring' })
  @IsOptional()
  @IsString()
  issuerId?: string;

  @ApiProperty({ description: 'Coupon redemption rate (0-1)', example: 0.75 })
  @IsNumber()
  @Min(0)
  @Max(1)
  redemptionRate: number;

  @ApiProperty({ description: 'Coupon breakage rate (0-1)', example: 0.15 })
  @IsNumber()
  @Min(0)
  @Max(1)
  breakageRate: number;

  @ApiProperty({ description: 'Account tenure in days', example: 365 })
  @IsNumber()
  @Min(0)
  tenureDays: number;

  @ApiProperty({ description: 'Customer satisfaction score (0-100)', example: 85 })
  @IsNumber()
  @Min(0)
  @Max(100)
  satisfactionScore: number;
}

export class CreditScoreResponseDto {
  @ApiProperty({ description: 'Composite credit score (0-100)' })
  score: number;

  @ApiProperty({ description: 'Credit level (A/B/C/D/F)', enum: ['A', 'B', 'C', 'D', 'F'] })
  level: string;

  @ApiProperty({ description: 'Score factor breakdown' })
  factors: Record<string, number>;

  @ApiPropertyOptional({ description: 'Improvement recommendations', type: [String] })
  recommendations?: string[];
}
