export interface EmailRecipientDto {
  name?: string;
  address: string;
}

export interface EmailHeaderDto {
  key: string;
  value: string;
}

export interface EmailAttachmentDto {
  filename?: string;
  contentType?: string;
  encoding?: string;
  contentTransferEncoding?: string;
  contentDisposition?: "inline" | "attachment";
  content: string;
  cid?: string;
}

export interface MessageListQueryDto {
  next?: string;
  previous?: string;
  limit?: number;
  search?: string;
  from?: string;
  subject?: string;
  datestart?: string;
  dateend?: string;
  attachments?: boolean;
  unseen?: boolean;
  flagged?: boolean;
  order?: "asc" | "desc";
}

export interface DraftMessage extends Record<string, unknown> {
  id: number;
  mailbox: string;
  thread: string;
  from: {
    address: string;
    name: string;
  };
  to: Array<{
    address: string;
    name: string;
  }>;
  cc: Array<{
    address: string;
    name: string;
  }>;
  bcc: Array<{
    address: string;
    name: string;
  }>;
  messageId: string;
  subject: string;
  date: string;
  idate: string;
  intro: string;
  attachments: boolean;
  attachmentsList: EmailAttachmentDto[];
  size: number;
  seen: boolean;
  deleted: boolean;
  flagged: boolean;
  draft: boolean;
  answered: boolean;
  forwarded: boolean;
  references: string[];
  contentType: {
    value: string;
    params: {
      boundary: string;
    };
  };
}

export type InboxMessage = DraftMessage;

export interface Pager {
  page: number;
  limit: number;
  totalItems: number;
  totalPages: number;
  previousCursor: string | boolean;
  nextCursor: string | boolean;
}

export interface InboxResponse {
  statusCode: number;
  success: boolean;
  data: {
    pager: Pager;
    draftMails: DraftMessage[];
  };
}

export interface DraftUpdateDto {
  from?: EmailRecipientDto;
  to?: EmailRecipientDto[];
  cc?: EmailRecipientDto[];
  bcc?: EmailRecipientDto[];
  subject?: string;
  text?: string;
  html?: string;
  attachments?: EmailAttachmentDto[];
  isDraft?: boolean;
  uploadOnly?: boolean;
}
