<?php

namespace App\Services\Mail;

use Illuminate\Support\Carbon;

/**
 * One message as it came off the server, before anything is decided about it.
 *
 * A plain value object rather than an Eloquent model: what the mailbox hands
 * back is not yet a record, and deciding whose it is, whether it is a duplicate
 * and what to do with it belongs to the ingest, not to the reader.
 */
final readonly class FetchedMail
{
    /**
     * @param  array<int, array{name: string, bytes: int}>  $attachments  names and sizes only — never files
     */
    public function __construct(
        public string $uid,
        public string $messageId,
        public string $fromEmail,
        public ?string $fromName,
        public string $subject,
        public string $body,
        public Carbon $receivedAt,
        public array $attachments = [],
    ) {}
}
