import { IsString, IsNotEmpty, IsOptional, IsEmail, IsIn, IsBoolean, IsArray } from 'class-validator'

export class RegisterEmailAccountDto {
  @IsEmail()
  emailAddress: string

  @IsString() @IsNotEmpty()
  displayName: string

  @IsOptional() @IsString()
  notes?: string
}

export class ConfirmAssociationDto {
  @IsString() @IsNotEmpty()
  clientFolderId: string

  @IsOptional() @IsString()
  matterId?: string

  @IsString() @IsNotEmpty()
  confirmedBy: string
}

export class SendEmailDto {
  @IsString() @IsNotEmpty()
  clientFolderId: string

  @IsOptional() @IsString()
  matterId?: string

  @IsArray()
  to: { address: string; name?: string }[]

  @IsArray()
  @IsOptional()
  cc?: { address: string; name?: string }[]

  @IsString() @IsNotEmpty()
  subject: string

  @IsOptional() @IsString()
  bodyText?: string

  @IsOptional() @IsString()
  bodyHtml?: string

  @IsString() @IsNotEmpty()
  from: string     // registered email address to send from

  @IsOptional() @IsString()
  inReplyTo?: string
}

export class QueryEmailsDto {
  @IsOptional() @IsString()
  clientFolderId?: string

  @IsOptional() @IsString()
  matterId?: string

  @IsOptional() @IsIn(['inbound','outbound'])
  direction?: string

  @IsOptional() @IsIn(['auto_matched','confirmed','pending_review','unassociated'])
  associationStatus?: string

  @IsOptional() @IsBoolean()
  unreadOnly?: boolean

  @IsOptional() @IsString()
  limit?: string

  @IsOptional() @IsString()
  offset?: string
}
