import { IsString, IsEnum, IsDate, IsOptional, IsUrl } from 'class-validator';
import { Type } from 'class-transformer';
import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger';
import { SocialMediaPlatformEnum } from 'common/enum/social-media-platform.enum';

export class CreateScheduledPostDto {
  @ApiProperty({ description: 'Unique identifier for the alert', example: '12345' })
  @IsString()
  alertId: string;

  @ApiProperty({ enum: SocialMediaPlatformEnum, description: 'Social media platform where the post will be published', example: 'linkedin' })
  @IsEnum(SocialMediaPlatformEnum)
  platform: SocialMediaPlatformEnum;

  @ApiProperty({ description: 'Content of the scheduled post', example: 'This is a scheduled post' })
  @IsString()
  content: string;

  @ApiProperty({ description: 'URL of the image to be included in the post', example: 'https://res.cloudinary.com/dls7wndku/image/upload/v1746005301/dfuk/ticket/1746005299844-kitten.png' })
  @IsUrl()
  imageUrl: string;

  @ApiProperty({ type: String, format: 'date-time', description: 'Scheduled date and time to publish the post', example: '2023-10-01T12:00:00Z' })
  @IsDate()
  @Type(() => Date)
  scheduledTime: Date;

  @ApiProperty({ enum: ['pending', 'published', 'failed'], description: 'Current status of the scheduled post', example: 'pending' })
  @IsEnum(['pending', 'published', 'failed'])
  status: 'pending' | 'published' | 'failed';

  @ApiPropertyOptional({ description: 'Error message if the post failed to publish', example: 'Failed to connect to Facebook API' })
  @IsOptional()
  @IsString()
  error?: string;

  @ApiProperty({ type: String, format: 'date-time', description: 'Timestamp when the post was created', example: '2023-10-01T12:00:00Z' })
  @IsDate()
  @Type(() => Date)
  createdAt: Date;
}
