feat: api endpoints
This commit is contained in:
1 parent
7379f5ac93
commit
231aaaac9b
26 files changed
+606
-43
No files matched your search
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
namespace App\Controller\Api;
|
||||
|
||||
use App\BusProNet\XmlLoader\PickupXmlLoader;
|
||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||
use Symfony\Component\HttpFoundation\JsonResponse;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\Routing\Attribute\Route;
|
||||
|
||||
#[Route('/api')]
|
||||
class PickupController extends AbstractController
|
||||
{
|
||||
public function __construct(private readonly PickupXmlLoader $xmlLoader)
|
||||
{
|
||||
}
|
||||
|
||||
#[Route('/pickups', name: 'api_pickup_all')]
|
||||
public function index(): JsonResponse
|
||||
{
|
||||
$pickups = $this->xmlLoader->loadAll();
|
||||
|
||||
return $this->json($pickups, Response::HTTP_OK, [], ['groups' => 'api:list']);
|
||||
}
|
||||
|
||||
#[Route('/pickups/{id}', name: 'api_pickup_single')]
|
||||
public function single(int $id): JsonResponse
|
||||
{
|
||||
$pickup = $this->xmlLoader->loadById($id);
|
||||
|
||||
return $this->json($pickup, Response::HTTP_OK, [], ['groups' => 'api:list']);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user