feat(service): add post api
This commit is contained in:
@@ -4,7 +4,32 @@ declare(strict_types=1);
|
||||
|
||||
namespace App\Service\Remote;
|
||||
|
||||
use App\Entity\Remote\Brilo\Posts\Post;
|
||||
use App\Entity\Remote\Brilo\Users\User;
|
||||
use Psr\Log\LoggerInterface;
|
||||
use Symfony\Component\Serializer\SerializerInterface;
|
||||
use Symfony\Contracts\HttpClient\HttpClientInterface;
|
||||
|
||||
class BriloApiPosts
|
||||
{
|
||||
use BriloApiFetchTrait;
|
||||
|
||||
public function __construct(
|
||||
protected readonly HttpClientInterface $httpClient,
|
||||
protected readonly LoggerInterface $logger,
|
||||
protected readonly SerializerInterface $serializer,
|
||||
protected readonly int $retryCount = 3,
|
||||
protected readonly int $sleepTimeS = 1,
|
||||
) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetch all posts from Brilo API and return them as an array of Post entities.
|
||||
* @return Post[]
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function getPosts(): array
|
||||
{
|
||||
return $this->fetchApiResponse('https://jsonplaceholder.typicode.com/posts', Post::class);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,6 +25,7 @@ final class BriloApiUsers
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetch all users from the Brilo API and return them as an array of User entities.
|
||||
* @return User[]
|
||||
* @throws \Exception
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user