<?php

namespace App\Http\Resources\Api\V1;

use App\Domain\Tool\Models\Tool;
use Illuminate\Http\Request;
use Illuminate\Http\Resources\Json\JsonResource;

/** @mixin Tool */
class ToolResource extends JsonResource
{
    public function toArray(Request $request): array
    {
        return [
            'id' => $this->id,
            'name' => $this->name,
            'slug' => $this->slug,
            'description' => $this->description,
            'type' => $this->type->value,
            'status' => $this->status->value,
            'risk_level' => $this->risk_level?->value,
            'transport_config' => $this->transport_config,
            'tool_definitions' => $this->tool_definitions,
            'settings' => $this->settings,
            'health_status' => $this->health_status,
            'last_health_check' => $this->last_health_check?->toISOString(),
            'credential_id' => $this->credential_id,
            'function_count' => $this->functionCount(),
            'agents_count' => $this->whenCounted('agents'),
            'created_at' => $this->created_at->toISOString(),
            'updated_at' => $this->updated_at->toISOString(),
        ];
    }
}
