1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Starweb\Api\Generated\Normalizer; |
4
|
|
|
|
5
|
|
|
use Jane\JsonSchemaRuntime\Reference; |
6
|
|
|
use Symfony\Component\Serializer\Exception\InvalidArgumentException; |
7
|
|
|
use Symfony\Component\Serializer\Normalizer\DenormalizerAwareInterface; |
8
|
|
|
use Symfony\Component\Serializer\Normalizer\DenormalizerAwareTrait; |
9
|
|
|
use Symfony\Component\Serializer\Normalizer\DenormalizerInterface; |
10
|
|
|
use Symfony\Component\Serializer\Normalizer\NormalizerAwareInterface; |
11
|
|
|
use Symfony\Component\Serializer\Normalizer\NormalizerAwareTrait; |
12
|
|
|
use Symfony\Component\Serializer\Normalizer\NormalizerInterface; |
13
|
|
|
class PricelistModelNormalizer implements DenormalizerInterface, NormalizerInterface, DenormalizerAwareInterface, NormalizerAwareInterface |
14
|
|
|
{ |
15
|
|
|
use DenormalizerAwareTrait; |
16
|
|
|
use NormalizerAwareTrait; |
17
|
|
|
public function supportsDenormalization($data, $type, $format = null) |
18
|
|
|
{ |
19
|
|
|
return $type === 'Starweb\\Api\\Generated\\Model\\PricelistModel'; |
20
|
|
|
} |
21
|
|
|
public function supportsNormalization($data, $format = null) |
22
|
|
|
{ |
23
|
|
|
return get_class($data) === 'Starweb\\Api\\Generated\\Model\\PricelistModel'; |
24
|
|
|
} |
25
|
|
|
public function denormalize($data, $class, $format = null, array $context = array()) |
26
|
|
|
{ |
27
|
|
|
if (!is_object($data)) { |
28
|
|
|
throw new InvalidArgumentException(); |
29
|
|
|
} |
30
|
|
|
$object = new \Starweb\Api\Generated\Model\PricelistModel(); |
31
|
|
|
if (property_exists($data, 'pricelistId')) { |
32
|
|
|
$object->setPricelistId($data->{'pricelistId'}); |
33
|
|
|
} |
34
|
|
|
if (property_exists($data, 'name')) { |
35
|
|
|
$object->setName($data->{'name'}); |
36
|
|
|
} |
37
|
|
|
if (property_exists($data, 'isMaster')) { |
38
|
|
|
$object->setIsMaster($data->{'isMaster'}); |
39
|
|
|
} |
40
|
|
|
if (property_exists($data, 'isActive')) { |
41
|
|
|
$object->setIsActive($data->{'isActive'}); |
42
|
|
|
} |
43
|
|
|
if (property_exists($data, 'region')) { |
44
|
|
|
$object->setRegion($data->{'region'}); |
45
|
|
|
} |
46
|
|
|
if (property_exists($data, 'countryCodes')) { |
47
|
|
|
$values = array(); |
48
|
|
|
foreach ($data->{'countryCodes'} as $value) { |
49
|
|
|
$values[] = $value; |
50
|
|
|
} |
51
|
|
|
$object->setCountryCodes($values); |
52
|
|
|
} |
53
|
|
|
if (property_exists($data, 'currencyCode')) { |
54
|
|
|
$object->setCurrencyCode($data->{'currencyCode'}); |
55
|
|
|
} |
56
|
|
|
if (property_exists($data, 'parentPricelistId')) { |
57
|
|
|
$object->setParentPricelistId($data->{'parentPricelistId'}); |
58
|
|
|
} |
59
|
|
|
if (property_exists($data, 'isCustomerPricelist')) { |
60
|
|
|
$object->setIsCustomerPricelist($data->{'isCustomerPricelist'}); |
61
|
|
|
} |
62
|
|
|
if (property_exists($data, 'isCountryPricelist')) { |
63
|
|
|
$object->setIsCountryPricelist($data->{'isCountryPricelist'}); |
64
|
|
|
} |
65
|
|
|
return $object; |
66
|
|
|
} |
67
|
|
|
public function normalize($object, $format = null, array $context = array()) |
68
|
|
|
{ |
69
|
|
|
$data = new \stdClass(); |
70
|
|
|
if (null !== $object->getPricelistId()) { |
71
|
|
|
$data->{'pricelistId'} = $object->getPricelistId(); |
72
|
|
|
} |
73
|
|
|
if (null !== $object->getName()) { |
74
|
|
|
$data->{'name'} = $object->getName(); |
75
|
|
|
} |
76
|
|
|
if (null !== $object->getIsMaster()) { |
77
|
|
|
$data->{'isMaster'} = $object->getIsMaster(); |
78
|
|
|
} |
79
|
|
|
if (null !== $object->getIsActive()) { |
80
|
|
|
$data->{'isActive'} = $object->getIsActive(); |
81
|
|
|
} |
82
|
|
|
if (null !== $object->getRegion()) { |
83
|
|
|
$data->{'region'} = $object->getRegion(); |
84
|
|
|
} |
85
|
|
|
if (null !== $object->getCountryCodes()) { |
86
|
|
|
$values = array(); |
87
|
|
|
foreach ($object->getCountryCodes() as $value) { |
88
|
|
|
$values[] = $value; |
89
|
|
|
} |
90
|
|
|
$data->{'countryCodes'} = $values; |
91
|
|
|
} |
92
|
|
|
if (null !== $object->getCurrencyCode()) { |
93
|
|
|
$data->{'currencyCode'} = $object->getCurrencyCode(); |
94
|
|
|
} |
95
|
|
|
if (null !== $object->getParentPricelistId()) { |
96
|
|
|
$data->{'parentPricelistId'} = $object->getParentPricelistId(); |
97
|
|
|
} |
98
|
|
|
if (null !== $object->getIsCustomerPricelist()) { |
99
|
|
|
$data->{'isCustomerPricelist'} = $object->getIsCustomerPricelist(); |
100
|
|
|
} |
101
|
|
|
if (null !== $object->getIsCountryPricelist()) { |
102
|
|
|
$data->{'isCountryPricelist'} = $object->getIsCountryPricelist(); |
103
|
|
|
} |
104
|
|
|
return $data; |
105
|
|
|
} |
106
|
|
|
} |