<?php

namespace App\Category\Controller;

use App\Shared\Controller\BaseController;
use App\Shared\Constant\ErrorCodes;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\Routing\Attribute\Route;
use OpenApi\Attributes as OA;

/**
 * Legacy stub — all endpoints migrated to domain-specific controllers:
 *   Provinces/Cities → App\Location\Controller\LocationController
 *   Specialties      → App\Specialty\Controller\SpecialtyController
 *   DoctorServices   → App\DoctorService\Controller\DoctorServiceController
 *   Insurances       → App\Insurance\Controller\InsuranceController
 *   Tags             → App\Tag\Controller\TagController
 */
#[OA\Tag(name: 'Categories')]
class CategoryController extends BaseController
{
    #[Route('/api/v1/categorys/{bundle}', methods: ['GET'])]
    public function legacyList(string $bundle): JsonResponse
    {
        $map = [
            'state'                    => '/api/v1/provinces',
            'city'                     => '/api/v1/cities',
            'specially_doctor'         => '/api/v1/specialties',
            'doctor_services'          => '/api/v1/doctor-services',
            'insurance_type'           => '/api/v1/insurances?type=basic',
            'supplementary_insurance'  => '/api/v1/insurances?type=supplementary',
            'tag'                      => '/api/v1/tags',
        ];

        $newUrl = $map[$bundle] ?? null;
        if ($newUrl === null) {
            return $this->error(ErrorCodes::ERR_GONE, 'این endpoint حذف شده است', 410);
        }

        return $this->error(
            'ERR_MOVED',
            sprintf('این endpoint منتقل شده. لطفاً از %s استفاده کنید.', $newUrl),
            301
        );
    }
}
