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 OrderItemModelCollectionDataItemNormalizer 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\\OrderItemModelCollectionDataItem'; |
20
|
|
|
} |
21
|
|
|
public function supportsNormalization($data, $format = null) |
22
|
|
|
{ |
23
|
|
|
return is_object($data) && get_class($data) === 'Starweb\\Api\\Generated\\Model\\OrderItemModelCollectionDataItem'; |
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\OrderItemModelCollectionDataItem(); |
31
|
|
|
if (property_exists($data, 'itemId') && $data->{'itemId'} !== null) { |
32
|
|
|
$object->setItemId($data->{'itemId'}); |
33
|
|
|
} |
34
|
|
|
if (property_exists($data, 'sku') && $data->{'sku'} !== null) { |
35
|
|
|
$object->setSku($data->{'sku'}); |
36
|
|
|
} |
37
|
|
|
if (property_exists($data, 'description') && $data->{'description'} !== null) { |
38
|
|
|
$object->setDescription($data->{'description'}); |
39
|
|
|
} |
40
|
|
|
if (property_exists($data, 'quantity') && $data->{'quantity'} !== null) { |
41
|
|
|
$object->setQuantity($data->{'quantity'}); |
42
|
|
|
} |
43
|
|
|
if (property_exists($data, 'unitSymbol') && $data->{'unitSymbol'} !== null) { |
44
|
|
|
$object->setUnitSymbol($data->{'unitSymbol'}); |
45
|
|
|
} |
46
|
|
|
if (property_exists($data, 'unitPrice') && $data->{'unitPrice'} !== null) { |
47
|
|
|
$object->setUnitPrice($data->{'unitPrice'}); |
48
|
|
|
} |
49
|
|
|
if (property_exists($data, 'vatRate') && $data->{'vatRate'} !== null) { |
50
|
|
|
$object->setVatRate($data->{'vatRate'}); |
51
|
|
|
} |
52
|
|
|
if (property_exists($data, 'discount') && $data->{'discount'} !== null) { |
53
|
|
|
$object->setDiscount($data->{'discount'}); |
54
|
|
|
} |
55
|
|
|
if (property_exists($data, 'discountType') && $data->{'discountType'} !== null) { |
56
|
|
|
$object->setDiscountType($data->{'discountType'}); |
57
|
|
|
} |
58
|
|
|
if (property_exists($data, 'sortIndex') && $data->{'sortIndex'} !== null) { |
59
|
|
|
$object->setSortIndex($data->{'sortIndex'}); |
60
|
|
|
} |
61
|
|
|
if (property_exists($data, 'bundledItems') && $data->{'bundledItems'} !== null) { |
62
|
|
|
$object->setBundledItems($this->denormalizer->denormalize($data->{'bundledItems'}, 'Starweb\\Api\\Generated\\Model\\OrderItemBundledModelItemBundledItems', 'json', $context)); |
|
|
|
|
63
|
|
|
} |
64
|
|
|
return $object; |
65
|
|
|
} |
66
|
|
|
public function normalize($object, $format = null, array $context = array()) |
67
|
|
|
{ |
68
|
|
|
$data = new \stdClass(); |
69
|
|
|
if (null !== $object->getSku()) { |
70
|
|
|
$data->{'sku'} = $object->getSku(); |
71
|
|
|
} |
72
|
|
|
if (null !== $object->getDescription()) { |
73
|
|
|
$data->{'description'} = $object->getDescription(); |
74
|
|
|
} |
75
|
|
|
if (null !== $object->getQuantity()) { |
76
|
|
|
$data->{'quantity'} = $object->getQuantity(); |
77
|
|
|
} |
78
|
|
|
if (null !== $object->getUnitSymbol()) { |
79
|
|
|
$data->{'unitSymbol'} = $object->getUnitSymbol(); |
80
|
|
|
} |
81
|
|
|
if (null !== $object->getUnitPrice()) { |
82
|
|
|
$data->{'unitPrice'} = $object->getUnitPrice(); |
83
|
|
|
} |
84
|
|
|
if (null !== $object->getVatRate()) { |
85
|
|
|
$data->{'vatRate'} = $object->getVatRate(); |
86
|
|
|
} |
87
|
|
|
if (null !== $object->getDiscount()) { |
88
|
|
|
$data->{'discount'} = $object->getDiscount(); |
89
|
|
|
} |
90
|
|
|
if (null !== $object->getDiscountType()) { |
91
|
|
|
$data->{'discountType'} = $object->getDiscountType(); |
92
|
|
|
} |
93
|
|
|
if (null !== $object->getSortIndex()) { |
94
|
|
|
$data->{'sortIndex'} = $object->getSortIndex(); |
95
|
|
|
} |
96
|
|
|
if (null !== $object->getBundledItems()) { |
97
|
|
|
$data->{'bundledItems'} = $this->normalizer->normalize($object->getBundledItems(), 'json', $context); |
98
|
|
|
} |
99
|
|
|
return $data; |
100
|
|
|
} |
101
|
|
|
} |