Skip to content

Commit

Permalink
fix: Compatibility with older Symfony versions
Browse files Browse the repository at this point in the history
  • Loading branch information
davidgrayston-paddle committed Oct 11, 2024
1 parent 02ae267 commit 645c3a5
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions src/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,9 @@
use Psr\Http\Message\UriInterface;
use Psr\Log\LoggerInterface;
use Psr\Log\NullLogger;
use Symfony\Component\Serializer\Context\Normalizer\ObjectNormalizerContextBuilder;
use Symfony\Component\Serializer\Encoder\JsonEncoder;
use Symfony\Component\Serializer\NameConverter\CamelCaseToSnakeCaseNameConverter;
use Symfony\Component\Serializer\Normalizer\AbstractObjectNormalizer;
use Symfony\Component\Serializer\Normalizer\BackedEnumNormalizer;
use Symfony\Component\Serializer\Normalizer\JsonSerializableNormalizer;
use Symfony\Component\Serializer\Normalizer\ObjectNormalizer;
Expand Down Expand Up @@ -178,16 +178,18 @@ private function requestRaw(string $method, string|UriInterface $uri, array|\Jso
new JsonSerializableNormalizer(),
new ObjectNormalizer(
nameConverter: new CamelCaseToSnakeCaseNameConverter(),
defaultContext: (new ObjectNormalizerContextBuilder())
->withPreserveEmptyObjects(true)
->toArray(),
defaultContext: [
AbstractObjectNormalizer::PRESERVE_EMPTY_OBJECTS => true,
],
),
],
[new JsonEncoder()],
);

if ($payload !== null) {
$body = $serializer->serialize($payload, 'json');
$body = $serializer->serialize($payload, 'json', [
AbstractObjectNormalizer::PRESERVE_EMPTY_OBJECTS => true,
]);

$request = $request->withBody(
// Satisfies empty body requests.
Expand Down

0 comments on commit 645c3a5

Please sign in to comment.