Ejemplo n.º 1
0
 public function __invoke(Request $request, Response $response, callable $next)
 {
     $xml = file_get_contents('php://input');
     $xml = preg_replace('/[\\n\\r]/', '', $xml);
     $xml = preg_replace('/>\\s+/', '>', $xml);
     $rootBodyClass = 'DTS\\eBaySDK\\Trading\\Types\\AbstractResponseType';
     $parserBody = new XmlParser($rootBodyClass);
     $body = mb_strstr($xml, "<soapenv:Body>", false);
     $body = trim($body, "<soapenv:Body>");
     $body = mb_strstr($body, "</soapenv:Body>", true);
     $body = '<' . $body;
     /** @var AbstractResponseType $notification */
     $notification = $parserBody->parse($body);
     $notification->NotificationSignature = mb_strstr($xml, '<ebl:NotificationSignature xmlns:ebl="urn:ebay:apis:eBLBaseComponents">', false);
     $notification->NotificationSignature = trim($notification->NotificationSignature, '<ebl:NotificationSignature xmlns:ebl="urn:ebay:apis:eBLBaseComponents">');
     $notification->NotificationSignature = mb_strstr($notification->NotificationSignature, "</ebl:NotificationSignature>", true);
     $timestamp = mb_strstr($body, "<Timestamp>", false);
     $timestamp = trim($timestamp, "<Timestamp>");
     $timestamp = mb_strstr($timestamp, "</Timestamp>", true);
     if ($this->calculationSignature($timestamp) !== $notification->NotificationSignature) {
         throw new \Exception("Not Equalse signature", 403);
     }
     $item = ['add_date' => $notification->Timestamp->format("Y-m-d h:i:s"), 'soapaction' => $notification->NotificationEventName, 'data' => $body];
     $this->store->create($item);
     return $response->withStatus(200);
 }
Ejemplo n.º 2
0
 public function getAll()
 {
     if ($this->notificationType === null) {
         throw new \Exception("Not set notification Type");
     }
     $query = new Query();
     $query->setQuery(new EqNode(AllNotificationDataStoreFactory::KEY_EBAY_NOTIFICATION_TYPE, $this->notificationType));
     return $this->dataByType($this->dataStore->query($query));
 }
Ejemplo n.º 3
0
 public function getConfiguration()
 {
     if ($this->dataStore instanceof ConfigurableInterface) {
         return $this->dataStore->getConfiguration();
     }
     $query = new Query();
     $query->setLimit(new LimitNode(1));
     $data = $this->dataStore->query($query);
     $config = [];
     if (count($data) > 0 and isset($data[0])) {
         foreach ($data[0] as $key => $value) {
             $config[] = ['label' => $key, 'field' => $key];
         }
     }
     return $config;
 }
Ejemplo n.º 4
0
 protected function methodPatchWithId(Request $request, Response $response)
 {
     $cdsId = $request->getAttribute('Primary-Key-Value');
     $cdsConf = $this->getCdsConf($cdsId);
     if (empty($cdsConf)) {
         throw new \Exception("this cds id not found");
     }
     if ($cdsConf['query'] !== '') {
         $query = RqlParser::rqlDecode($cdsConf['query']);
     } else {
         $query = new Query();
     }
     $data = $this->getData($cdsConf['script_name'], $query);
     $query = new Query();
     $query->setQuery(new EqNode('cds_id', $cdsId));
     $items = $this->cds->query($query);
     foreach ($items as $item) {
         $this->cds->delete($item['id']);
     }
     foreach ($data as &$item) {
         $item['cds_id'] = $cdsId;
         $item['data_id'] = $item['id'];
         unset($item['id']);
     }
     $this->cds->create($data);
     $this->cdsManagerStore->update(['id' => $cdsConf['id'], 'freshness_date' => (new \DateTime())->format("Y-m-d H:i:s")]);
     $request = $request->withAttribute('CDS-ID', $cdsId);
     $request = $request->withAttribute('Response-Body', ['cdsId' => $cdsId]);
     $response = $response->withStatus(200);
     return array($request, $response);
 }
Ejemplo n.º 5
0
 public function __construct(DataStoresInterface $cachingDbTable, $cdsId)
 {
     $this->cachingDbTable = $cachingDbTable;
     $query = new Query();
     $query->setQuery(new EqNode($this->cdsIdentifierString, $cdsId));
     $this->items = $this->cachingDbTable->query($query);
     foreach ($this->items as &$item) {
         $item[$this->cachingDbTable->getIdentifier()] = $item[$this->dataIdentifierString];
         unset($item[$this->dataIdentifierString]);
         unset($item[$this->cdsIdentifierString]);
         $item = array_filter($item);
         foreach ($item as $key => $value) {
             switch ($key) {
                 case in_array($key, $this->fieldType['int']):
                     if (is_numeric($value)) {
                         $item[$key] = (int) $value;
                     } else {
                         throw new \Exception('Can\'t parse to int value:' . $value . 'from field: ' . $key);
                     }
                     break;
                 case in_array($key, $this->fieldType['float']):
                     if (is_numeric($value)) {
                         $item[$key] = (double) $value;
                     } else {
                         throw new \Exception('Can\'t parse to float value:' . $value . 'from field: ' . $key);
                     }
                     break;
                 case in_array($key, $this->fieldType['string']):
                     $item[$key] = (string) $value;
                     break;
                 default:
                     throw new \Exception('Type not set for field: ' . $key);
             }
         }
     }
     parent::__construct();
 }
Ejemplo n.º 6
0
 /**
  * Count elements of an object
  * @link http://php.net/manual/en/countable.count.php
  * @return int The custom count as an integer.
  * </p>
  * <p>
  * The return value is cast to an integer.
  * @since 5.1.0
  */
 public function count()
 {
     return $this->cashStore->count();
 }
Ejemplo n.º 7
0
 /**
  * {@inheritdoc}
  *
  * {@inheritdoc}
  */
 public function count()
 {
     $this->preCount();
     $result = $this->dataStore->count();
     return $this->postCount($result);
 }