import { ApiProperty, ApiPropertyOptional } from "@nestjs/swagger"
import { IsNotEmpty, IsString, IsOptional, IsNumber } from "class-validator"
import { Type } from "class-transformer"
import { messageKey } from "src/constants/message-keys"
import { validationMessage } from "src/utils/helpers"

export class CreateSubscriptionPlanDto {
  @ApiProperty({
    description: "Plan name",
    example: "Premium Monthly",
  })
  @IsString()
  @IsNotEmpty({
    message: validationMessage(messageKey.field_required, {
      ":field": "name",
    }),
  })
  name: string

  @ApiPropertyOptional({
    description: "Description",
    example: "Full access to all features billed monthly",
  })
  @IsOptional()
  @IsString()
  description?: string

  @ApiProperty({
    description: "Price",
    example: 9.99,
  })
  @IsNotEmpty({
    message: validationMessage(messageKey.field_required, {
      ":field": "price",
    }),
  })
  @Type(() => Number)
  @IsNumber()
  price: number

  @ApiPropertyOptional({
    description: "Currency code",
    example: "usd",
  })
  @IsOptional()
  @IsString()
  currency?: string

  @ApiPropertyOptional({
    description: "Billing interval (month or year)",
    example: "month",
  })
  @IsOptional()
  @IsString()
  interval?: string

  @ApiPropertyOptional({
    description: "Number of intervals between billings",
    example: 1,
  })
  @IsOptional()
  @Type(() => Number)
  @IsNumber()
  interval_count?: number

  @ApiPropertyOptional({
    description: "List of features (JSON string or comma-separated)",
    example: "['Unlimited access', 'Priority support']",
  })
  @IsOptional()
  features?: string

  @ApiPropertyOptional({
    description: "Stripe Price ID",
    example: "price_1234567890",
  })
  @IsOptional()
  @IsString()
  stripe_price_id?: string

  @ApiPropertyOptional({
    description: "Stripe Product ID",
    example: "prod_1234567890",
  })
  @IsOptional()
  @IsString()
  stripe_product_id?: string

  @ApiPropertyOptional({
    description: "Sort order for display",
    example: 0,
  })
  @IsOptional()
  @Type(() => Number)
  @IsNumber()
  sort_order?: number
}
