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); }
public function refresh() { $this->cashStore->deleteAll(); $all = $this->dataSource->getAll(); if ($all instanceof \Traversable or is_array($all)) { foreach ($all as $item) { $this->cashStore->create($item, true); } } else { throw new DataStoreException("Not return data by DataSource"); } }
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); }
/** * {@inheritdoc} * * {@inheritdoc} */ public function create($itemData, $rewriteIfExist = false) { $this->preCreate($itemData, $rewriteIfExist); $result = $this->dataStore->create($itemData, $rewriteIfExist); return $this->postCreate($result, $itemData, $rewriteIfExist); }