import { typeParser } from '@lib/utils/type-parser';
import { ApiProperty } from '@nestjs/swagger';
import { Expose, Transform } from 'class-transformer';
import { IsInt, IsString } from 'class-validator';
import dayjs from 'dayjs';

export class ClientContract {
  @Expose()
  @ApiProperty({ description: '고객사 계약 id' })
  @Transform(({ value }) => typeParser.int(value))
  @IsInt()
  ccnId!: number;

  @Expose()
  @ApiProperty({ description: '계약코드' })
  @IsString()
  ccnCode!: string;

  @Expose()
  @ApiProperty({ description: 'API 사용단가' })
  @Transform(({ value }) => typeParser.int(value))
  @IsInt()
  ccnApiPrice!: number;

  @Expose()
  @ApiProperty({ description: '계약시작일' })
  @Transform(({ value }) =>
    dayjs(value).startOf('day').format('YYYY-MM-DD HH:mm:ss'),
  )
  @IsString()
  ccnContractStartedAt!: string;

  @Expose()
  @ApiProperty({ description: '계약종료일' })
  @IsString()
  @Transform(({ value }) =>
    dayjs(value).endOf('day').format('YYYY-MM-DD HH:mm:ss'),
  )
  ccnContractEndedAt!: string;

  @Expose()
  @ApiProperty({ description: 'CI 횟수제한 여부 (0: OFF, 1: ON)' })
  @Transform(({ value }) => typeParser.int(value))
  @IsInt()
  ccnCiLimitEnabled!: number;

  @Expose()
  @ApiProperty({ description: 'CI 횟수제한값' })
  @Transform(({ value }) => typeParser.int(value))
  @IsInt()
  ccnCiLimitCount!: number;

  @Expose()
  @ApiProperty({ description: '고객사 계약 생성일시' })
  @IsString()
  ccnCreatedAt!: string;

  @Expose()
  @ApiProperty({ description: '고객사 계약 수정일시' })
  @IsString()
  ccnUpdatedAt?: string;
}
