import { ApiProperty } from '@nestjs/swagger'
import {
  IsBoolean,
  IsDate,
  IsInt,
  IsNotEmpty,
  IsObject,
  IsString
} from 'class-validator'

export type UserLicenseDTOOptionsRecognizer = {
  count: number
}

export type UserLicenseDTOOptionsAuth = object

export type UserLicenseDTOOptions = UserLicenseDTOOptionsRecognizer
  | UserLicenseDTOOptionsAuth

export class UserLicenseDTO {
  @IsInt()
  @IsNotEmpty()
  @ApiProperty({})
    id: number

  @IsString()
  @IsNotEmpty()
  @ApiProperty({})
    productName: string

  @IsString()
  @ApiProperty({})
    planType?: string

  @IsBoolean()
  @IsNotEmpty()
  @ApiProperty({})
    isTrial: boolean

  @IsDate()
  @IsNotEmpty()
  @ApiProperty({})
    start: Date

  @IsDate()
  @IsNotEmpty()
  @ApiProperty({})
    till: Date

  @IsObject()
  @ApiProperty({})
    options: UserLicenseDTOOptions
}
