import { ApiProperty, ApiPropertyOptional } from "@nestjs/swagger"
import { Transform } from "class-transformer"
import { IsNotEmpty, IsObject, IsOptional, IsString } from "class-validator"

export class SendPushByFcmTokenDto {
  @ApiProperty({
    description: "Firebase Cloud Messaging device registration token",
    example: "dXyz...:APA91b...",
  })
  @Transform(({ value }) => (typeof value === "string" ? value.trim() : value))
  @IsString()
  @IsNotEmpty()
  fcm_token: string

  @ApiProperty({
    description: "Notification title shown on the device",
    example: "Trip update",
  })
  @IsString()
  @IsNotEmpty()
  title: string

  @ApiProperty({
    description: "Notification body / message",
    example: "Your driver is on the way.",
  })
  @IsString()
  @IsNotEmpty()
  message: string

  @ApiPropertyOptional({
    description:
      "Arbitrary string-keyed payload delivered to the client (values are stringified for FCM)",
    example: { type: "trip", trip_id: "42" },
  })
  @IsOptional()
  @IsObject()
  data?: Record<string, unknown>
}
