diff --git a/CHANGELOG.md b/CHANGELOG.md index 7875b29..81d46ca 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,9 @@ +6.3.3 +===== + +* (improvement) Use wired `HttpClient` to ease debugging. + + 6.3.2 ===== diff --git a/src/Api/PrismicApi.php b/src/Api/PrismicApi.php index a97d327..c381a32 100644 --- a/src/Api/PrismicApi.php +++ b/src/Api/PrismicApi.php @@ -3,7 +3,6 @@ namespace Torr\PrismicApi\Api; use Psr\Log\LoggerInterface; -use Symfony\Component\HttpClient\HttpClient; use Symfony\Component\HttpClient\HttpOptions; use Symfony\Contracts\HttpClient\Exception\DecodingExceptionInterface; use Symfony\Contracts\HttpClient\Exception\HttpExceptionInterface; @@ -30,9 +29,18 @@ public function __construct ( private readonly string $repository, private readonly string $contentToken, private readonly string $typesToken, + HttpClientInterface $client, ) { - $this->contentClient = HttpClient::createForBaseUri("https://{$repository}.prismic.io/api/v2/"); - $this->typesClient = HttpClient::createForBaseUri("https://customtypes.prismic.io/"); + $this->contentClient = $client->withOptions( + (new HttpOptions()) + ->setBaseUri("https://{$repository}.prismic.io/api/v2/") + ->toArray(), + ); + $this->typesClient = $client->withOptions( + (new HttpOptions()) + ->setBaseUri("https://customtypes.prismic.io/") + ->toArray(), + ); } diff --git a/src/Api/PrismicIntegrationFieldApi.php b/src/Api/PrismicIntegrationFieldApi.php index a8fdbdf..e8ff8fd 100644 --- a/src/Api/PrismicIntegrationFieldApi.php +++ b/src/Api/PrismicIntegrationFieldApi.php @@ -3,7 +3,6 @@ namespace Torr\PrismicApi\Api; use Psr\Log\LoggerInterface; -use Symfony\Component\HttpClient\HttpClient; use Symfony\Component\HttpClient\HttpOptions; use Symfony\Contracts\HttpClient\Exception\TransportExceptionInterface; use Symfony\Contracts\HttpClient\HttpClientInterface; @@ -28,9 +27,14 @@ public function __construct ( /** @var array */ private readonly array $tokens, private readonly LoggerInterface $logger, + HttpClientInterface $client, ) { - $this->client = HttpClient::createForBaseUri("https://if-api.prismic.io"); + $this->client = $client->withOptions( + (new HttpOptions()) + ->setBaseUri("https://if-api.prismic.io") + ->toArray(), + ); } /**