namibia
HEAD
namibia / module / Valuation / src / Valuation / Controller / XmlRpcController.php
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 |
<?php namespace Valuation\Controller; class XmlRpcController extends \Zend\Mvc\Controller\AbstractActionController { /** * @var \Zend\Session\Container */ protected $session; /** * @var array */ protected $request; /** * @var array */ protected $response; /** * @var \Zend\ServiceManager\ServiceManager */ protected $sm; protected $em; /** * @var boolean */ protected $authenticated = false; /** * @var \User\Service\Authentication */ protected $authDetails; public function xmlRpcServerAction() { ini_set('memory_limit','512M'); \Utility\Registry::setServiceManager($this->serviceLocator); \Utility\Registry::addDynamicConfig( \Utility\Cache::fetchEntity( 'Config\Entity\Config', 1, \Utility\Registry::getEntityManager(), 600 ) ); $server = new \Zend\XmlRpc\Server(); $server->setClass('Valuation\Service\XmlRpc'); echo $server->handle(); $response = $this->getResponse(); $response->setStatusCode(200); return $response; } public function callbackAction() { if (IS_LIVE_ENV) { return; } ini_set('memory_limit','512M'); \Utility\Registry::setServiceManager($this->serviceLocator); \Utility\Registry::addDynamicConfig( \Utility\Cache::fetchEntity( 'Config\Entity\Config', 1, \Utility\Registry::getEntityManager(), 600 ) ); try { $server = new \Zend\XmlRpc\Server(); $server->setClass('Valuation\Service\XmlRpcCallback'); echo $server->handle(); $response = $this->getResponse(); $response->setStatusCode(200); } catch (\Exception $e) { error_log("$e"); } return $response; } public function xmlRpcClientAction() { if (IS_LIVE_ENV) { return; } ini_set('memory_limit','512M'); try { $url = IS_DEV_ENV ? 'http://namibia.local/xmlrpc/1.0' : 'http://bid4cars.com.na/xmlrpc/1.0'; $client = new \Zend\XmlRpc\Client($url); //$client = new \Zend\XmlRpc\Client($url . '/callback'); $arg1 = '4afb4a290f971186654f18dd6a13a7d7'; $arg2 = 'Kia123'; $authToken = $client->call('Authenticate', array($arg1, $arg2)); /* $arg1 = 'b@imperial.com'; $arg2 = array('freakin' => 'moo'); var_dump($client->call('SentToSales', array($arg1, $arg2))); */ //$authToken = '80f6de496cac332ab704a52bd427bab4'; $email = 'a@b.com'; $valuation = array( 'ItemId' => '123qweasdzxc!QAZ', 'CustomerName' => 'Qwerty i10', 'CustomerSurname' => 'Poiuytre', 'CustomerMobile' => '27112223333', 'Km' => 456, 'VehicleYearId' => 41, 'VehicleTypeId' => 6085, 'VehicleFuelTypeId' => 2, 'VehicleTransmissionTypeId' => 2, 'RegistrationNumber' => 'SomeRegNr', 'VehiclePhoto1URL' => 'http://bid4cars.nirph.com/img/bin/235785.jpg', 'VehiclePhoto2URL' => 'http://bid4cars.nirph.com/img/bin/235786.jpg', 'Damages' => array( array('VehicleComponentId' => 1, 'Amount' => 2000), array('VehicleComponentId' => 3, 'Amount' => 2500) ), 'Accessories' => array( array('VehicleAccessoryId' => 2), array('VehicleAccessoryId' => 3), array('VehicleAccessoryId' => 4) ) ); echo '<pre>'; var_dump($client->call('CreateValuation', array($authToken, $email, $valuation))); echo '</pre>'; } catch (\Zend\XmlRpc\Client\Exception\HttpException $e) { echo $e->getCode() . ":" . $e->getMessage(); } // Disabling view $response = $this->getResponse(); $response->setStatusCode(200); return $response; } public function triggerSentToSalesAction() { \Utility\Registry::setServiceManager($this->serviceLocator); \Utility\Registry::addDynamicConfig( \Utility\Cache::fetchEntity( 'Config\Entity\Config', 1, \Utility\Registry::getEntityManager(), 600 ) ); $service = new \Valuation\Service\XmlRpcCallback(); $valuationId = $this->getRequest()->getParam('valuationId'); $service->triggerSentToSales($valuationId); return "\n"; } public function retryCallbacksAction() { \Utility\Registry::setServiceManager($this->serviceLocator); \Utility\Registry::addDynamicConfig( \Utility\Cache::fetchEntity( 'Config\Entity\Config', 1, \Utility\Registry::getEntityManager(), 600 ) ); $service = new \Valuation\Service\XmlRpcCallback(); $service->retryCallbacks(); return "\n"; } } |
Commits for namibiamodule/Valuation/src/Valuation/Controller/XmlRpcController.php
Revision | Author | Commited | Message |
---|---|---|---|
f5b7b4 ... Diff | Mark | Mon 12 Dec, 2016 11:55:35 +0000 | updates |
df0489 ... | Mark | Fri 14 Oct, 2016 10:01:00 +0000 | initial commit |