import { ApiProperty } from "@nestjs/swagger";
import { PaymentIntentStatus, Provider } from "@prisma/client";

export class PaymentIntentDto {
  @ApiProperty({ example: "pi_01HXYZABCDEFGHJKMNPQRSTV" })
  id!: string;

  @ApiProperty({ example: "mer_01HXYZABCDEFGHJKMNPQRSTV" })
  merchantId!: string;

  @ApiProperty({ required: false, nullable: true, example: "cus_01HXYZABCDEFGHJKMNPQRSTV" })
  customerId!: string | null;

  @ApiProperty({ required: false, nullable: true, example: "ORDER-2026-0123" })
  externalReference!: string | null;

  @ApiProperty({
    example: "150000.0000",
    description: "Decimal(20,4) serializado como string para evitar pérdida de precisión.",
  })
  amount!: string;

  @ApiProperty({ example: "PYG" })
  currency!: string;

  @ApiProperty({ example: "PY" })
  country!: string;

  @ApiProperty({ required: false, nullable: true, example: "Pago de orden #0123" })
  description!: string | null;

  @ApiProperty({ required: false, nullable: true, enum: Provider, example: Provider.dlocal })
  requestedProvider!: Provider | null;

  @ApiProperty({
    required: false,
    nullable: true,
    example: "18",
    description: "Medio de pago pre-seleccionado (código del provider, ej. platformId de Dpago).",
  })
  platformId!: string | null;

  @ApiProperty({ enum: PaymentIntentStatus, example: PaymentIntentStatus.created })
  status!: PaymentIntentStatus;

  @ApiProperty({ required: false, nullable: true, example: { orderId: "ORDER-2026-0123" } })
  metadata!: Record<string, unknown> | null;

  @ApiProperty({ required: false, nullable: true, example: "2026-06-08T14:30:00.000Z" })
  expiresAt!: Date | null;

  @ApiProperty({ example: "2026-06-07T14:30:00.000Z" })
  createdAt!: Date;

  @ApiProperty({ example: "2026-06-07T14:30:00.000Z" })
  updatedAt!: Date;
}

export class PaymentIntentListDto {
  @ApiProperty({ type: [PaymentIntentDto] })
  data!: PaymentIntentDto[];

  @ApiProperty({ required: false, nullable: true, example: null })
  nextCursor!: string | null;
}
