<?php

declare(strict_types=1);

namespace ImovelZapAi\Visits\Application\Services;

use ImovelZapAi\Visits\Infrastructure\Persistence\Eloquent\VisitModel;

final class VisitSnapshotter
{
    /**
     * @return array<string, mixed>
     */
    public function snapshot(VisitModel $visit): array
    {
        return [
            'status' => $visit->status instanceof \BackedEnum ? $visit->status->value : (string) $visit->status,
            'responsible_user_id' => $visit->responsible_user_id,
            'property_id' => $visit->property_id,
            'scheduled_start' => $visit->scheduled_start?->toIso8601String(),
            'scheduled_end' => $visit->scheduled_end?->toIso8601String(),
            'outcome' => $visit->outcome instanceof \BackedEnum ? $visit->outcome->value : $visit->outcome,
            'check_in_at' => $visit->check_in_at?->toIso8601String(),
            'check_out_at' => $visit->check_out_at?->toIso8601String(),
        ];
    }
}
