<?php

namespace Datalumo\PhpSdk\DataObjects;

class SummaryResponse
{
    public function __construct(
        public readonly string $summary,
        public readonly array $references,
        public readonly array $data,
        public readonly ?bool $hasRelevantResults = null,
    ) {}

    public static function fromArray(array $response): self
    {
        return new self(
            summary: $response['summary'],
            references: $response['references'] ?? [],
            data: array_map(Entry::fromArray(...), $response['data'] ?? []),
            hasRelevantResults: $response['has_relevant_results'] ?? null,
        );
    }
}
