import { ApiProperty } from "@nestjs/swagger";
import { IsInt, IsOptional, IsPositive, IsString, Length } from "class-validator";

export class CreateRefundDto {
  @ApiProperty({
    example: "pi_01HXYZABCDEFGHJKMNPQRSTV",
    description: "ID del payment intent a reembolsar. Se reembolsa contra el último attempt aprobado.",
  })
  @IsString()
  intentId!: string;

  @ApiProperty({
    required: false,
    example: 50000,
    description:
      "Monto a reembolsar en la unidad menor de la moneda (igual convención que `payment_intents.amount`). " +
      "Si se omite, se reembolsa el total restante del attempt.",
  })
  @IsOptional()
  @IsInt()
  @IsPositive()
  amount?: number;

  @ApiProperty({ required: false, example: "Cliente canceló la orden" })
  @IsOptional()
  @IsString()
  @Length(1, 500)
  reason?: string;
}
