Skip to content
This repository has been archived by the owner on Apr 30, 2024. It is now read-only.

Commit

Permalink
Merge pull request #47 from 21TORR/di-http-client
Browse files Browse the repository at this point in the history
  • Loading branch information
keichinger authored Oct 13, 2022
2 parents 1390f90 + 20ba570 commit 9d96253
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 5 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
6.3.3
=====

* (improvement) Use wired `HttpClient` to ease debugging.


6.3.2
=====

Expand Down
14 changes: 11 additions & 3 deletions src/Api/PrismicApi.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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(),
);
}


Expand Down
8 changes: 6 additions & 2 deletions src/Api/PrismicIntegrationFieldApi.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -28,9 +27,14 @@ public function __construct (
/** @var array<string, string> */
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(),
);
}

/**
Expand Down

0 comments on commit 9d96253

Please sign in to comment.