diff --git a/Module.php b/Module.php index b5afdd5..d76a52d 100644 --- a/Module.php +++ b/Module.php @@ -53,7 +53,7 @@ public function getHydratorConfig() { return [ 'invokables' => [ - 'Zoho\Subscriptions\Hydrator\CustomerHydrator' => 'Zoho\Subscriptions\Hydrator\CustomerHydrator', + 'Zoho\Subscriptions\Hydrator\Customer' => 'Zoho\Subscriptions\Hydrator\CustomerHydrator', ] ]; } diff --git a/src/Factory/ResourceAbstractFactory.php b/src/Factory/ResourceAbstractFactory.php index 411f871..bcdb8f6 100644 --- a/src/Factory/ResourceAbstractFactory.php +++ b/src/Factory/ResourceAbstractFactory.php @@ -96,22 +96,6 @@ public function createServiceWithName(ServiceLocatorInterface $serviceLocator, $ $zohoConfig = $config['zoho']; $resourceConfig = $config['zoho']['resources'][$requestedName]; - /*$opensslCapath = ini_get('openssl.capath'); - - if (!empty($opensslCapath)) { - $clientConfig = ['sslcapath' => $opensslCapath]; - } else { - $clientConfig = ['sslcapath' => $zohoConfig['ssl_config']['sslcapath']]; - } - - $httpClient = new Client(null, $clientConfig); - $httpClient->setHeaders(array( - 'Content-Type' => 'application/json;charset=UTF-8', - 'X-com-zoho-subscriptions-organizationid' => $zohoConfig['organization_id'], - 'Authorization' => 'Zoho-authtoken ' . $zohoConfig['auth_token'], - )); - - $resource = new Resource($httpClient);*/ $curl = curl_init(); curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); curl_setopt($curl, CURLOPT_HTTPHEADER, [ @@ -130,14 +114,14 @@ public function createServiceWithName(ServiceLocatorInterface $serviceLocator, $ $inputFilter = $inputFilterFactory->createInputFilter($resourceConfig['input-filter']); $resource->setInputFilter($inputFilter); - $hydrator = new ClassMethods(true); + $hydratorManager = $serviceLocator->get('HydratorManager'); + + $hydratorName = str_replace('Entity', 'Hydrator', $entityClass); - if (isset($resourceConfig['strategies']) && is_array($resourceConfig['strategies'])) { - foreach ($resourceConfig['strategies'] as $field => $strategy) { - if ($serviceLocator->has($strategy)) { - $hydrator->addStrategy($field, $serviceLocator->get($strategy)); - } - } + if ($hydratorManager->hast($hydratorName)) { + $hydrator = $hydratorManager->get($hydratorName); + } else { + $hydrator = new ClassMethods(); } $resource->setHydrator($hydrator); diff --git a/src/Hydrator/CustomerHydrator.php b/src/Hydrator/CustomerHydrator.php index 4bdc7d5..4b0c775 100644 --- a/src/Hydrator/CustomerHydrator.php +++ b/src/Hydrator/CustomerHydrator.php @@ -3,6 +3,7 @@ namespace Zoho\Subscriptions\Hydrator; use Zend\Stdlib\Hydrator\ClassMethods as ClassMethodsHydrator; +use Zend\Stdlib\Hydrator\Strategy\DateTimeFormatterStrategy; use Zoho\Subscriptions\Hydrator\Strategy\AddressStrategy; class CustomerHydrator extends ClassMethodsHydrator @@ -12,7 +13,10 @@ public function __construct() parent::__construct(); $addressStrategy = new AddressStrategy(); + $datetimeStrategy = new DateTimeFormatterStrategy(\DateTime::ISO8601); $this->addStrategy('billing_address', $addressStrategy); $this->addStrategy('shipping_address', $addressStrategy); + $this->addStrategy('created_time', $datetimeStrategy); + $this->addStrategy('updated_time', $datetimeStrategy); } } \ No newline at end of file