1: <?php
2:
3: namespace SellerLabs\Snagshout\Normalizer;
4:
5: use Joli\Jane\Runtime\Reference;
6: use Symfony\Component\Serializer\Normalizer\DenormalizerInterface;
7: use Symfony\Component\Serializer\Normalizer\NormalizerInterface;
8: use Symfony\Component\Serializer\Normalizer\SerializerAwareNormalizer;
9: class V1GetStatusResponseNormalizer extends SerializerAwareNormalizer implements DenormalizerInterface, NormalizerInterface
10: {
11: public function supportsDenormalization($data, $type, $format = null)
12: {
13: if ($type !== 'SellerLabs\\Snagshout\\Model\\V1GetStatusResponse') {
14: return false;
15: }
16: return true;
17: }
18: public function supportsNormalization($data, $format = null)
19: {
20: if ($data instanceof \SellerLabs\Snagshout\Model\V1GetStatusResponse) {
21: return true;
22: }
23: return false;
24: }
25: public function denormalize($data, $class, $format = null, array $context = array())
26: {
27: $object = new \SellerLabs\Snagshout\Model\V1GetStatusResponse();
28: if (property_exists($data, 'errors')) {
29: $values = array();
30: foreach ($data->{'errors'} as $value) {
31: $values[] = $value;
32: }
33: $object->setErrors($values);
34: }
35: if (property_exists($data, 'error')) {
36: $object->setError($data->{'error'});
37: }
38: if (property_exists($data, 'code')) {
39: $object->setCode($data->{'code'});
40: }
41: if (property_exists($data, 'status')) {
42: $object->setStatus($data->{'status'});
43: }
44: if (property_exists($data, 'message')) {
45: $object->setMessage($data->{'message'});
46: }
47: if (property_exists($data, 'success')) {
48: $object->setSuccess($data->{'success'});
49: }
50: if (property_exists($data, 'data')) {
51: $object->setData($this->serializer->deserialize($data->{'data'}, 'SellerLabs\\Snagshout\\Model\\V1GetStatus', 'raw', $context));
52: }
53: if (property_exists($data, 'links')) {
54: $object->setLinks($this->serializer->deserialize($data->{'links'}, 'SellerLabs\\Snagshout\\Model\\Links', 'raw', $context));
55: }
56: return $object;
57: }
58: public function normalize($object, $format = null, array $context = array())
59: {
60: $data = new \stdClass();
61: if (null !== $object->getErrors()) {
62: $values = array();
63: foreach ($object->getErrors() as $value) {
64: $values[] = $value;
65: }
66: $data->{'errors'} = $values;
67: }
68: if (null !== $object->getError()) {
69: $data->{'error'} = $object->getError();
70: }
71: if (null !== $object->getCode()) {
72: $data->{'code'} = $object->getCode();
73: }
74: if (null !== $object->getStatus()) {
75: $data->{'status'} = $object->getStatus();
76: }
77: if (null !== $object->getMessage()) {
78: $data->{'message'} = $object->getMessage();
79: }
80: if (null !== $object->getSuccess()) {
81: $data->{'success'} = $object->getSuccess();
82: }
83: if (null !== $object->getData()) {
84: $data->{'data'} = $this->serializer->serialize($object->getData(), 'raw', $context);
85: }
86: if (null !== $object->getLinks()) {
87: $data->{'links'} = $this->serializer->serialize($object->getLinks(), 'raw', $context);
88: }
89: return $data;
90: }
91: }