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 ProductVariantRequestModelNormalizer 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\\ProductVariantRequestModel'; |
20
|
|
|
} |
21
|
|
|
public function supportsNormalization($data, $format = null) |
22
|
|
|
{ |
23
|
|
|
return is_object($data) && get_class($data) === 'Starweb\\Api\\Generated\\Model\\ProductVariantRequestModel'; |
24
|
|
|
} |
25
|
|
|
public function denormalize($data, $class, $format = null, array $context = array()) |
26
|
|
|
{ |
27
|
|
|
if (!is_object($data)) { |
28
|
|
|
return null; |
29
|
|
|
} |
30
|
|
|
$object = new \Starweb\Api\Generated\Model\ProductVariantRequestModel(); |
31
|
|
|
if (property_exists($data, 'sku') && $data->{'sku'} !== null) { |
32
|
|
|
$object->setSku($data->{'sku'}); |
33
|
|
|
} |
34
|
|
|
if (property_exists($data, 'externalId') && $data->{'externalId'} !== null) { |
35
|
|
|
$object->setExternalId($data->{'externalId'}); |
36
|
|
|
} |
37
|
|
|
if (property_exists($data, 'externalIdType') && $data->{'externalIdType'} !== null) { |
38
|
|
|
$object->setExternalIdType($data->{'externalIdType'}); |
39
|
|
|
} |
40
|
|
|
if (property_exists($data, 'isActive') && $data->{'isActive'} !== null) { |
41
|
|
|
$object->setIsActive($data->{'isActive'}); |
42
|
|
|
} |
43
|
|
|
if (property_exists($data, 'sortIndex') && $data->{'sortIndex'} !== null) { |
44
|
|
|
$object->setSortIndex($data->{'sortIndex'}); |
45
|
|
|
} |
46
|
|
|
if (property_exists($data, 'stockStatusId') && $data->{'stockStatusId'} !== null) { |
47
|
|
|
$object->setStockStatusId($data->{'stockStatusId'}); |
48
|
|
|
} |
49
|
|
|
if (property_exists($data, 'stockQuantity') && $data->{'stockQuantity'} !== null) { |
50
|
|
|
$object->setStockQuantity($data->{'stockQuantity'}); |
51
|
|
|
} |
52
|
|
|
if (property_exists($data, 'weightInKg') && $data->{'weightInKg'} !== null) { |
53
|
|
|
$object->setWeightInKg($data->{'weightInKg'}); |
54
|
|
|
} |
55
|
|
|
if (property_exists($data, 'costPrice') && $data->{'costPrice'} !== null) { |
56
|
|
|
$object->setCostPrice($data->{'costPrice'}); |
57
|
|
|
} |
58
|
|
|
if (property_exists($data, 'ean') && $data->{'ean'} !== null) { |
59
|
|
|
$object->setEan($data->{'ean'}); |
60
|
|
|
} |
61
|
|
|
if (property_exists($data, 'mpn') && $data->{'mpn'} !== null) { |
62
|
|
|
$object->setMpn($data->{'mpn'}); |
63
|
|
|
} |
64
|
|
|
if (property_exists($data, 'imageFileId') && $data->{'imageFileId'} !== null) { |
65
|
|
|
$object->setImageFileId($data->{'imageFileId'}); |
66
|
|
|
} |
67
|
|
|
if (property_exists($data, 'attributeValueLinks') && $data->{'attributeValueLinks'} !== null) { |
68
|
|
|
$values = array(); |
69
|
|
|
foreach ($data->{'attributeValueLinks'} as $value) { |
70
|
|
|
$values[] = $value; |
71
|
|
|
} |
72
|
|
|
$object->setAttributeValueLinks($values); |
73
|
|
|
} |
74
|
|
|
if (property_exists($data, 'volumePricingInheritancePricelistIds') && $data->{'volumePricingInheritancePricelistIds'} !== null) { |
75
|
|
|
$values_1 = array(); |
76
|
|
|
foreach ($data->{'volumePricingInheritancePricelistIds'} as $value_1) { |
77
|
|
|
$values_1[] = $value_1; |
78
|
|
|
} |
79
|
|
|
$object->setVolumePricingInheritancePricelistIds($values_1); |
80
|
|
|
} |
81
|
|
|
return $object; |
82
|
|
|
} |
83
|
|
|
public function normalize($object, $format = null, array $context = array()) |
84
|
|
|
{ |
85
|
|
|
$data = new \stdClass(); |
86
|
|
|
if (null !== $object->getSku()) { |
87
|
|
|
$data->{'sku'} = $object->getSku(); |
88
|
|
|
} |
89
|
|
|
$data->{'externalId'} = $object->getExternalId(); |
90
|
|
|
$data->{'externalIdType'} = $object->getExternalIdType(); |
91
|
|
|
$data->{'isActive'} = $object->getIsActive(); |
92
|
|
|
$data->{'sortIndex'} = $object->getSortIndex(); |
93
|
|
|
$data->{'stockStatusId'} = $object->getStockStatusId(); |
94
|
|
|
$data->{'stockQuantity'} = $object->getStockQuantity(); |
95
|
|
|
$data->{'weightInKg'} = $object->getWeightInKg(); |
96
|
|
|
$data->{'costPrice'} = $object->getCostPrice(); |
97
|
|
|
$data->{'ean'} = $object->getEan(); |
98
|
|
|
$data->{'mpn'} = $object->getMpn(); |
99
|
|
|
$data->{'imageFileId'} = $object->getImageFileId(); |
100
|
|
|
if (null !== $object->getAttributeValueLinks()) { |
101
|
|
|
$values = array(); |
102
|
|
|
foreach ($object->getAttributeValueLinks() as $value) { |
103
|
|
|
$values[] = $value; |
104
|
|
|
} |
105
|
|
|
$data->{'attributeValueLinks'} = $values; |
106
|
|
|
} |
107
|
|
|
if (null !== $object->getVolumePricingInheritancePricelistIds()) { |
108
|
|
|
$values_1 = array(); |
109
|
|
|
foreach ($object->getVolumePricingInheritancePricelistIds() as $value_1) { |
110
|
|
|
$values_1[] = $value_1; |
111
|
|
|
} |
112
|
|
|
$data->{'volumePricingInheritancePricelistIds'} = $values_1; |
113
|
|
|
} |
114
|
|
|
else { |
115
|
|
|
$data->{'volumePricingInheritancePricelistIds'} = null; |
116
|
|
|
} |
117
|
|
|
return $data; |
118
|
|
|
} |
119
|
|
|
} |