37 lines
982 B
PHP
37 lines
982 B
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Service\Remote;
|
|
|
|
use App\Entity\Remote\Brilo\Comments\Comment;
|
|
use App\Entity\Remote\Brilo\Posts\Post;
|
|
use Psr\Log\LoggerInterface;
|
|
use Symfony\Component\Serializer\SerializerInterface;
|
|
use Symfony\Contracts\HttpClient\HttpClientInterface;
|
|
|
|
class BriloApiComments
|
|
{
|
|
use BriloApiFetchTrait;
|
|
|
|
public function __construct(
|
|
protected readonly HttpClientInterface $httpClient,
|
|
protected readonly LoggerInterface $logger,
|
|
protected readonly SerializerInterface $serializer,
|
|
protected readonly string $url,
|
|
protected readonly int $retryCount = 3,
|
|
protected readonly int $sleepTimeS = 1,
|
|
) {
|
|
}
|
|
|
|
/**
|
|
* Fetch all comments from the Brilo API and return them as an array of Comment entities.
|
|
* @return Comment[]
|
|
* @throws \Exception
|
|
*/
|
|
public function getComments(): array
|
|
{
|
|
return $this->fetchApiResponse($this->url, Comment::class);
|
|
}
|
|
}
|