35 lines
1.4 KiB
PHP
35 lines
1.4 KiB
PHP
<?php
|
|
|
|
namespace App\Controller\OgBoot\OgLive;
|
|
|
|
use App\Controller\OgBoot\AbstractOgBootController;
|
|
use Symfony\Component\HttpFoundation\JsonResponse;
|
|
use Symfony\Component\HttpFoundation\Response;
|
|
use Symfony\Component\HttpKernel\Attribute\AsController;
|
|
use Symfony\Component\HttpKernel\Exception\BadRequestHttpException;
|
|
use Symfony\Component\Validator\Exception\ValidatorException;
|
|
use Symfony\Contracts\HttpClient\Exception\ClientExceptionInterface;
|
|
use Symfony\Contracts\HttpClient\Exception\RedirectionExceptionInterface;
|
|
use Symfony\Contracts\HttpClient\Exception\ServerExceptionInterface;
|
|
use Symfony\Contracts\HttpClient\Exception\TransportExceptionInterface;
|
|
|
|
#[AsController]
|
|
class GetCollectionAction extends AbstractOgBootController
|
|
{
|
|
/**
|
|
* @throws TransportExceptionInterface
|
|
* @throws ServerExceptionInterface
|
|
* @throws RedirectionExceptionInterface
|
|
* @throws ClientExceptionInterface
|
|
*/
|
|
public function __invoke(): JsonResponse
|
|
{
|
|
$content = $this->createRequest('GET', '/ogboot/v1/oglives');
|
|
|
|
if (isset($content['error']) && $content['code'] === Response::HTTP_INTERNAL_SERVER_ERROR ) {
|
|
throw new BadRequestHttpException('An error occurred while fetching the collection: ' . $content['error']. ' (' . $content['details'] . ')');
|
|
}
|
|
|
|
return new JsonResponse(data: $content, status: Response::HTTP_OK);
|
|
}
|
|
} |