<?php

declare(strict_types=1);

/*
 * Chill is a software for social workers
 *
 * For the full copyright and license information, please view
 * the LICENSE file that was distributed with this source code.
 */

namespace Chill\TicketBundle\Controller;

use Chill\TicketBundle\Entity\Ticket;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Component\Serializer\SerializerInterface;

class TicketControllerApi
{
    public function __construct(private readonly SerializerInterface $serializer) {}

    #[Route('/api/1.0/ticket/ticket/{id}', requirements: ['id' => '\d+'], methods: ['GET'])]
    public function get(Ticket $ticket): JsonResponse
    {
        return new JsonResponse(
            $this->serializer->serialize($ticket, 'json', ['groups' => ['read']]),
            json: true
        );
    }
}
