<?php

namespace App\Services\Ai;

class ReportInsightResult
{
    public function __construct(
        public readonly string $provider,
        public readonly string $executiveSummary,
        public readonly string $customerNote,
        public readonly string $technicalNote,
        public readonly array $risks,
        public readonly array $opportunities,
        public readonly array $actions,
        public readonly ?string $rawResponse = null,
    ) {
    }

    public function toReportUpdateArray(): array
    {
        return [
            'ai_status' => 'completed',
            'ai_provider' => $this->provider,
            'ai_executive_summary' => $this->executiveSummary,
            'ai_customer_note' => $this->customerNote,
            'ai_technical_note' => $this->technicalNote,
            'ai_risks' => array_values($this->risks),
            'ai_opportunities' => array_values($this->opportunities),
            'ai_actions' => array_values($this->actions),
            'ai_raw_response' => $this->rawResponse,
            'ai_error_message' => null,
            'ai_generated_at' => now(),
        ];
    }
}
