diff --git a/php/src/Snagshout/Promote/Client.php b/php/src/Snagshout/Promote/Client.php index 2bb5cef..126469b 100644 --- a/php/src/Snagshout/Promote/Client.php +++ b/php/src/Snagshout/Promote/Client.php @@ -62,7 +62,6 @@ protected function buildResource(string $resourceClass): AbstractResource new Serializer( NormalizerFactory::create(), [ - new RawEncoder(), new JsonEncoder(new JsonEncode(), new JsonDecode()), ] ) diff --git a/php/src/Snagshout/Promote/Encoder/RawEncoder.php b/php/src/Snagshout/Promote/Encoder/RawEncoder.php deleted file mode 100644 index b34aa5a..0000000 --- a/php/src/Snagshout/Promote/Encoder/RawEncoder.php +++ /dev/null @@ -1,60 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - * - * This file is part of the Merchant package - */ - -namespace Snagshout\Promote\Encoder; - -use Symfony\Component\Serializer\Encoder\DecoderInterface; -use Symfony\Component\Serializer\Encoder\EncoderInterface; - -/** - * Class RawEncoder. - * - * Encoder with no encoding (keeps the same output as the input) - * - * @author Andrii Prykhodko - * @package Snagshout\Promote\Encoder - */ -class RawEncoder implements DecoderInterface, EncoderInterface -{ - const FORMAT = 'raw'; - - /** - * {@inheritdoc} - */ - public function decode($data, $format, array $context = array()) - { - return $data; - } - - /** - * {@inheritdoc} - */ - public function supportsDecoding($format): bool - { - return self::FORMAT === $format; - } - - /** - * {@inheritdoc} - */ - public function encode($data, $format, array $context = array()): string - { - return $data; - } - - /** - * {@inheritdoc} - */ - public function supportsEncoding($format): bool - { - return self::FORMAT === $format; - } -} diff --git a/php/src/Snagshout/Promote/Normalizer/DealImpressionsRequestBodyNormalizer.php b/php/src/Snagshout/Promote/Normalizer/DealImpressionsRequestBodyNormalizer.php index 8319249..0e98645 100644 --- a/php/src/Snagshout/Promote/Normalizer/DealImpressionsRequestBodyNormalizer.php +++ b/php/src/Snagshout/Promote/Normalizer/DealImpressionsRequestBodyNormalizer.php @@ -41,7 +41,8 @@ public function normalize($object, $format = null, array $context = []) if (null !== $object->getImpressions()) { $values = []; foreach ($object->getImpressions() as $value) { - $values[] = $this->serializer->serialize($value, 'raw', $context); + $json = $this->serializer->serialize($value, 'json', $context); + $values[] = json_decode($json, true); } $data['impressions'] = $values; } diff --git a/php/src/Snagshout/Promote/Normalizer/DealNormalizer.php b/php/src/Snagshout/Promote/Normalizer/DealNormalizer.php index 47fd6f0..f7b8866 100644 --- a/php/src/Snagshout/Promote/Normalizer/DealNormalizer.php +++ b/php/src/Snagshout/Promote/Normalizer/DealNormalizer.php @@ -220,14 +220,16 @@ public function normalize($object, $format = null, array $context = []) if (null !== $object->getCategories()) { $values = []; foreach ($object->getCategories() as $value) { - $values[] = $this->serializer->serialize($value, 'raw', $context); + $json = $this->serializer->serialize($value, 'json', $context); + $values[] = json_decode($json, true); } $data['categories'] = $values; } if (null !== $object->getMedia()) { $values_1 = []; foreach ($object->getMedia() as $value_1) { - $values_1[] = $this->serializer->serialize($value_1, 'raw', $context); + $json = $this->serializer->serialize($value_1, 'json', $context); + $values_1[] = json_decode($json, true); } $data['media'] = $values_1; } diff --git a/php/tests/Snagshout/Promote/Normalizer/DealNormalizerTest.php b/php/tests/Snagshout/Promote/Normalizer/DealNormalizerTest.php index ff6a580..e0bea9b 100644 --- a/php/tests/Snagshout/Promote/Normalizer/DealNormalizerTest.php +++ b/php/tests/Snagshout/Promote/Normalizer/DealNormalizerTest.php @@ -12,7 +12,6 @@ namespace Tests\Snagshout\Promote\Normalizer; use PHPUnit\Framework\TestCase as BaseTestCase; -use Snagshout\Promote\Encoder\RawEncoder; use Snagshout\Promote\Model\Category; use Snagshout\Promote\Model\Deal; use Snagshout\Promote\Model\Medium; @@ -38,7 +37,6 @@ protected function getSerializer() return new Serializer( NormalizerFactory::create(), [ - new RawEncoder(), new JsonEncoder( new JsonEncode(), new JsonDecode()