Overview

Namespaces

  • SellerLabs
    • Snagshout
      • Model
      • Normalizer
      • Resource
      • Utils

Classes

  • SellerLabs\Snagshout\Client
  • SellerLabs\Snagshout\Model\AmazonData
  • SellerLabs\Snagshout\Model\Attribute
  • SellerLabs\Snagshout\Model\BookmarkMetadata
  • SellerLabs\Snagshout\Model\Campaign
  • SellerLabs\Snagshout\Model\Category
  • SellerLabs\Snagshout\Model\Image
  • SellerLabs\Snagshout\Model\ImageMetadata
  • SellerLabs\Snagshout\Model\Links
  • SellerLabs\Snagshout\Model\Product
  • SellerLabs\Snagshout\Model\PromoCode
  • SellerLabs\Snagshout\Model\Promotion
  • SellerLabs\Snagshout\Model\Shipping
  • SellerLabs\Snagshout\Model\V1GetCampaignsResponse
  • SellerLabs\Snagshout\Model\V1GetCategoriesResponse
  • SellerLabs\Snagshout\Model\V1GetStatus
  • SellerLabs\Snagshout\Model\V1GetStatusResponse
  • SellerLabs\Snagshout\Normalizer\AmazonDataNormalizer
  • SellerLabs\Snagshout\Normalizer\AttributeNormalizer
  • SellerLabs\Snagshout\Normalizer\BookmarkMetadataNormalizer
  • SellerLabs\Snagshout\Normalizer\CampaignNormalizer
  • SellerLabs\Snagshout\Normalizer\CategoryNormalizer
  • SellerLabs\Snagshout\Normalizer\ImageMetadataNormalizer
  • SellerLabs\Snagshout\Normalizer\ImageNormalizer
  • SellerLabs\Snagshout\Normalizer\LinksNormalizer
  • SellerLabs\Snagshout\Normalizer\NormalizerFactory
  • SellerLabs\Snagshout\Normalizer\ProductNormalizer
  • SellerLabs\Snagshout\Normalizer\PromoCodeNormalizer
  • SellerLabs\Snagshout\Normalizer\PromotionNormalizer
  • SellerLabs\Snagshout\Normalizer\ShippingNormalizer
  • SellerLabs\Snagshout\Normalizer\V1GetCampaignsResponseNormalizer
  • SellerLabs\Snagshout\Normalizer\V1GetCategoriesResponseNormalizer
  • SellerLabs\Snagshout\Normalizer\V1GetStatusNormalizer
  • SellerLabs\Snagshout\Normalizer\V1GetStatusResponseNormalizer
  • SellerLabs\Snagshout\Resource\CampaignResource
  • SellerLabs\Snagshout\Resource\CategoryResource
  • SellerLabs\Snagshout\Resource\FrontResource
  • SellerLabs\Snagshout\SyndicationClient
  • SellerLabs\Snagshout\Utils\NormalizerFactory
  • SellerLabs\Snagshout\Utils\NullNormalizer
  • Overview
  • Namespace
  • Class
 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 AmazonDataNormalizer extends SerializerAwareNormalizer implements DenormalizerInterface, NormalizerInterface
10: {
11:     public function supportsDenormalization($data, $type, $format = null)
12:     {
13:         if ($type !== 'SellerLabs\\Snagshout\\Model\\AmazonData') {
14:             return false;
15:         }
16:         return true;
17:     }
18:     public function supportsNormalization($data, $format = null)
19:     {
20:         if ($data instanceof \SellerLabs\Snagshout\Model\AmazonData) {
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\AmazonData();
28:         if (property_exists($data, 'asin')) {
29:             $object->setAsin($data->{'asin'});
30:         }
31:         if (property_exists($data, 'merchantId')) {
32:             $object->setMerchantId($data->{'merchantId'});
33:         }
34:         if (property_exists($data, 'fulfillment')) {
35:             $object->setFulfillment($data->{'fulfillment'});
36:         }
37:         if (property_exists($data, 'starRating')) {
38:             $object->setStarRating($data->{'starRating'});
39:         }
40:         if (property_exists($data, 'numReviews')) {
41:             $object->setNumReviews($data->{'numReviews'});
42:         }
43:         if (property_exists($data, 'productId')) {
44:             $object->setProductId($data->{'productId'});
45:         }
46:         if (property_exists($data, 'childAsins')) {
47:             $values = array();
48:             foreach ($data->{'childAsins'} as $value) {
49:                 $values[] = $value;
50:             }
51:             $object->setChildAsins($values);
52:         }
53:         return $object;
54:     }
55:     public function normalize($object, $format = null, array $context = array())
56:     {
57:         $data = new \stdClass();
58:         if (null !== $object->getAsin()) {
59:             $data->{'asin'} = $object->getAsin();
60:         }
61:         if (null !== $object->getMerchantId()) {
62:             $data->{'merchantId'} = $object->getMerchantId();
63:         }
64:         if (null !== $object->getFulfillment()) {
65:             $data->{'fulfillment'} = $object->getFulfillment();
66:         }
67:         if (null !== $object->getStarRating()) {
68:             $data->{'starRating'} = $object->getStarRating();
69:         }
70:         if (null !== $object->getNumReviews()) {
71:             $data->{'numReviews'} = $object->getNumReviews();
72:         }
73:         if (null !== $object->getProductId()) {
74:             $data->{'productId'} = $object->getProductId();
75:         }
76:         if (null !== $object->getChildAsins()) {
77:             $values = array();
78:             foreach ($object->getChildAsins() as $value) {
79:                 $values[] = $value;
80:             }
81:             $data->{'childAsins'} = $values;
82:         }
83:         return $data;
84:     }
85: }
API documentation generated by ApiGen