|
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 PaymentMethodModelNormalizer 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\\PaymentMethodModel'; |
|
20
|
|
|
} |
|
21
|
|
|
public function supportsNormalization($data, $format = null) |
|
22
|
|
|
{ |
|
23
|
|
|
return get_class($data) === 'Starweb\\Api\\Generated\\Model\\PaymentMethodModel'; |
|
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\PaymentMethodModel(); |
|
31
|
|
|
if (property_exists($data, 'paymentMethodId')) { |
|
32
|
|
|
$object->setPaymentMethodId($data->{'paymentMethodId'}); |
|
33
|
|
|
} |
|
34
|
|
|
if (property_exists($data, 'idCode')) { |
|
35
|
|
|
$object->setIdCode($data->{'idCode'}); |
|
36
|
|
|
} |
|
37
|
|
|
if (property_exists($data, 'active')) { |
|
38
|
|
|
$object->setActive($data->{'active'}); |
|
39
|
|
|
} |
|
40
|
|
|
if (property_exists($data, 'fee')) { |
|
41
|
|
|
$object->setFee($data->{'fee'}); |
|
42
|
|
|
} |
|
43
|
|
|
if (property_exists($data, 'validForCountries')) { |
|
44
|
|
|
$object->setValidForCountries($data->{'validForCountries'}); |
|
45
|
|
|
} |
|
46
|
|
|
if (property_exists($data, 'validCountriesSelected')) { |
|
47
|
|
|
$values = array(); |
|
48
|
|
|
foreach ($data->{'validCountriesSelected'} as $value) { |
|
49
|
|
|
$values[] = $value; |
|
50
|
|
|
} |
|
51
|
|
|
$object->setValidCountriesSelected($values); |
|
52
|
|
|
} |
|
53
|
|
|
if (property_exists($data, 'validForMinItemsSubtotal')) { |
|
54
|
|
|
$object->setValidForMinItemsSubtotal($data->{'validForMinItemsSubtotal'}); |
|
55
|
|
|
} |
|
56
|
|
|
if (property_exists($data, 'validForMaxItemsSubtotal')) { |
|
57
|
|
|
$object->setValidForMaxItemsSubtotal($data->{'validForMaxItemsSubtotal'}); |
|
58
|
|
|
} |
|
59
|
|
|
if (property_exists($data, 'validForMinWeight')) { |
|
60
|
|
|
$object->setValidForMinWeight($data->{'validForMinWeight'}); |
|
61
|
|
|
} |
|
62
|
|
|
if (property_exists($data, 'validForMaxWeight')) { |
|
63
|
|
|
$object->setValidForMaxWeight($data->{'validForMaxWeight'}); |
|
64
|
|
|
} |
|
65
|
|
|
if (property_exists($data, 'validForShippingMethods')) { |
|
66
|
|
|
$object->setValidForShippingMethods($data->{'validForShippingMethods'}); |
|
67
|
|
|
} |
|
68
|
|
|
if (property_exists($data, 'validForCustomerType')) { |
|
69
|
|
|
$object->setValidForCustomerType($data->{'validForCustomerType'}); |
|
70
|
|
|
} |
|
71
|
|
|
if (property_exists($data, 'isClickAndCollect')) { |
|
72
|
|
|
$object->setIsClickAndCollect($data->{'isClickAndCollect'}); |
|
73
|
|
|
} |
|
74
|
|
|
if (property_exists($data, 'languages')) { |
|
75
|
|
|
$object->setLanguages($this->denormalizer->denormalize($data->{'languages'}, 'Starweb\\Api\\Generated\\Model\\PaymentMethodLanguageModelCollection', 'json', $context)); |
|
|
|
|
|
|
76
|
|
|
} |
|
77
|
|
|
return $object; |
|
78
|
|
|
} |
|
79
|
|
|
public function normalize($object, $format = null, array $context = array()) |
|
80
|
|
|
{ |
|
81
|
|
|
$data = new \stdClass(); |
|
82
|
|
|
if (null !== $object->getPaymentMethodId()) { |
|
83
|
|
|
$data->{'paymentMethodId'} = $object->getPaymentMethodId(); |
|
84
|
|
|
} |
|
85
|
|
|
if (null !== $object->getIdCode()) { |
|
86
|
|
|
$data->{'idCode'} = $object->getIdCode(); |
|
87
|
|
|
} |
|
88
|
|
|
if (null !== $object->getActive()) { |
|
89
|
|
|
$data->{'active'} = $object->getActive(); |
|
90
|
|
|
} |
|
91
|
|
|
if (null !== $object->getFee()) { |
|
92
|
|
|
$data->{'fee'} = $object->getFee(); |
|
93
|
|
|
} |
|
94
|
|
|
if (null !== $object->getValidForCountries()) { |
|
95
|
|
|
$data->{'validForCountries'} = $object->getValidForCountries(); |
|
96
|
|
|
} |
|
97
|
|
|
if (null !== $object->getValidCountriesSelected()) { |
|
98
|
|
|
$values = array(); |
|
99
|
|
|
foreach ($object->getValidCountriesSelected() as $value) { |
|
100
|
|
|
$values[] = $value; |
|
101
|
|
|
} |
|
102
|
|
|
$data->{'validCountriesSelected'} = $values; |
|
103
|
|
|
} |
|
104
|
|
|
$data->{'validForMinItemsSubtotal'} = $object->getValidForMinItemsSubtotal(); |
|
105
|
|
|
$data->{'validForMaxItemsSubtotal'} = $object->getValidForMaxItemsSubtotal(); |
|
106
|
|
|
$data->{'validForMinWeight'} = $object->getValidForMinWeight(); |
|
107
|
|
|
$data->{'validForMaxWeight'} = $object->getValidForMaxWeight(); |
|
108
|
|
|
if (null !== $object->getValidForShippingMethods()) { |
|
109
|
|
|
$data->{'validForShippingMethods'} = $object->getValidForShippingMethods(); |
|
110
|
|
|
} |
|
111
|
|
|
$data->{'validForCustomerType'} = $object->getValidForCustomerType(); |
|
112
|
|
|
if (null !== $object->getIsClickAndCollect()) { |
|
113
|
|
|
$data->{'isClickAndCollect'} = $object->getIsClickAndCollect(); |
|
114
|
|
|
} |
|
115
|
|
|
if (null !== $object->getLanguages()) { |
|
116
|
|
|
$data->{'languages'} = $this->normalizer->normalize($object->getLanguages(), 'json', $context); |
|
117
|
|
|
} |
|
118
|
|
|
return $data; |
|
119
|
|
|
} |
|
120
|
|
|
} |