<?php

declare(strict_types=1);

namespace App\Support\Baselines;

final class ResolutionOutcomeRecord
{
    /**
     * @param  non-empty-string  $reasonCode
     * @param  'policy'|'inventory'|'derived'|null  $sourceModelExpected
     * @param  'policy'|'inventory'|'derived'|null  $sourceModelFound
     */
    public function __construct(
        public readonly ResolutionOutcome $resolutionOutcome,
        public readonly string $reasonCode,
        public readonly OperatorActionCategory $operatorActionCategory,
        public readonly bool $structural,
        public readonly bool $retryable,
        public readonly ?string $sourceModelExpected = null,
        public readonly ?string $sourceModelFound = null,
    ) {}

    public function toArray(): array
    {
        return [
            'resolution_outcome' => $this->resolutionOutcome->value,
            'reason_code' => $this->reasonCode,
            'operator_action_category' => $this->operatorActionCategory->value,
            'structural' => $this->structural,
            'retryable' => $this->retryable,
            'source_model_expected' => $this->sourceModelExpected,
            'source_model_found' => $this->sourceModelFound,
        ];
    }
}
