/**
 * Resend API Types
 *
 * Type definitions for Resend email API operations.
 */

/**
 * Resend credentials format
 * Stored in credentials table, encrypted
 */
export interface ResendCredentials {
  apiKey: string // API key (re_xxxxxxxxx)
}

/**
 * Send email parameters
 */
export interface SendEmailParams {
  from: string // "Name <sender@domain.com>"
  to: string | string[] // Recipients (max 50)
  subject: string // Email subject
  html?: string // HTML content
  text?: string // Plain text (auto-generated from HTML if omitted)
  replyTo?: string | string[] // Reply-to address
  cc?: string | string[] // CC recipients
  bcc?: string | string[] // BCC recipients
  headers?: Record<string, string> // Custom headers (for unsubscribe)
  tags?: Array<{ name: string; value: string }> // Key-value metadata
  idempotencyKey?: string // Resend Idempotency-Key header — same key returns the original send instead of duplicating
}

/**
 * Send email result
 */
export interface SendEmailResult {
  id: string // Email ID
  success: boolean
}

/**
 * Get email parameters
 */
export interface GetEmailParams {
  emailId: string // Email ID to retrieve
}

/**
 * Get email result
 */
export interface GetEmailResult {
  id: string
  to: string[]
  from: string
  subject: string
  lastEvent: string // 'sent', 'delivered', 'bounced', 'complained', 'failed'
  createdAt: string
}

/**
 * Resend API response for send email
 */
export interface ResendSendEmailResponse {
  id: string
}

/**
 * Resend API response for get email
 */
export interface ResendGetEmailResponse {
  id: string
  to: string[]
  from: string
  subject: string
  last_event: string
  created_at: string
}
