|
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 OrderItemModelNormalizer 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\\OrderItemModel'; |
|
20
|
|
|
} |
|
21
|
|
|
public function supportsNormalization($data, $format = null) |
|
22
|
|
|
{ |
|
23
|
|
|
return get_class($data) === 'Starweb\\Api\\Generated\\Model\\OrderItemModel'; |
|
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\OrderItemModel(); |
|
31
|
|
|
if (property_exists($data, 'itemId')) { |
|
32
|
|
|
$object->setItemId($data->{'itemId'}); |
|
33
|
|
|
} |
|
34
|
|
|
if (property_exists($data, 'sku')) { |
|
35
|
|
|
$object->setSku($data->{'sku'}); |
|
36
|
|
|
} |
|
37
|
|
|
if (property_exists($data, 'description')) { |
|
38
|
|
|
$object->setDescription($data->{'description'}); |
|
39
|
|
|
} |
|
40
|
|
|
if (property_exists($data, 'quantity')) { |
|
41
|
|
|
$object->setQuantity($data->{'quantity'}); |
|
42
|
|
|
} |
|
43
|
|
|
if (property_exists($data, 'unitSymbol')) { |
|
44
|
|
|
$object->setUnitSymbol($data->{'unitSymbol'}); |
|
45
|
|
|
} |
|
46
|
|
|
if (property_exists($data, 'unitPrice')) { |
|
47
|
|
|
$object->setUnitPrice($data->{'unitPrice'}); |
|
48
|
|
|
} |
|
49
|
|
|
if (property_exists($data, 'vatRate')) { |
|
50
|
|
|
$object->setVatRate($data->{'vatRate'}); |
|
51
|
|
|
} |
|
52
|
|
|
if (property_exists($data, 'discount')) { |
|
53
|
|
|
$object->setDiscount($data->{'discount'}); |
|
54
|
|
|
} |
|
55
|
|
|
if (property_exists($data, 'discountType')) { |
|
56
|
|
|
$object->setDiscountType($data->{'discountType'}); |
|
57
|
|
|
} |
|
58
|
|
|
if (property_exists($data, 'sortIndex')) { |
|
59
|
|
|
$object->setSortIndex($data->{'sortIndex'}); |
|
60
|
|
|
} |
|
61
|
|
|
return $object; |
|
62
|
|
|
} |
|
63
|
|
|
public function normalize($object, $format = null, array $context = array()) |
|
64
|
|
|
{ |
|
65
|
|
|
$data = new \stdClass(); |
|
66
|
|
|
if (null !== $object->getItemId()) { |
|
67
|
|
|
$data->{'itemId'} = $object->getItemId(); |
|
68
|
|
|
} |
|
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
|
|
|
return $data; |
|
97
|
|
|
} |
|
98
|
|
|
} |