import { IsString, IsOptional, IsEnum, IsDateString } from 'class-validator';
import { ApiProperty } from '@nestjs/swagger';

/**
 * Fetch Insights DTO
 * كائن نقل بيانات جلب الرؤى
 * 
 * Defines the structure and validation for fetching Meta Ads insights.
 * يحدد الهيكل والتحقق من جلب رؤى إعلانات ميتا.
 */
export enum MetaLevel {
  AD = 'ad',
  ADSET = 'adset',
  CAMPAIGN = 'campaign',
  ACCOUNT = 'account',
}

export class FetchMetaInsightsDto {
  @ApiProperty({
    description: 'The Meta Ad Account ID (e.g., act_12345)',
    example: 'act_123456789',
    required: false,
  })
  @IsString()
  @IsOptional()
  adAccountId?: string;

  @ApiProperty({
    description: 'The User ID for token lookup',
    example: 'user-123',
    required: false,
  })
  @IsString()
  @IsOptional()
  userId?: string;

  @ApiProperty({
    description: 'Start date for insights (YYYY-MM-DD)',
    example: '2024-01-01',
    required: false,
  })
  @IsDateString()
  @IsOptional()
  dateStart?: string;

  @ApiProperty({
    description: 'End date for insights (YYYY-MM-DD)',
    example: '2024-01-31',
    required: false,
  })
  @IsDateString()
  @IsOptional()
  dateEnd?: string;

  @ApiProperty({
    enum: MetaLevel,
    default: MetaLevel.CAMPAIGN,
    description: 'Level of reporting',
  })
  @IsEnum(MetaLevel)
  @IsOptional()
  level: MetaLevel = MetaLevel.CAMPAIGN;
}
