/** * @param RpcRequestInterface $request * @param RpcResponseInterface $response */ private function logResponseWithRequest(RpcRequestInterface $request, RpcResponseInterface $response) { $hash = spl_object_hash($response); if (in_array($hash, $this->loggedResponses, true)) { return; } if ($response->isSuccessful()) { $this->logger->info(sprintf('Method "%s" call was successful', $request->getMethod()), ['request_hash' => spl_object_hash($request)]); $this->logger->debug(sprintf("Response:\n%s", json_encode($response->getBody(), JSON_PRETTY_PRINT)), ['request_hash' => spl_object_hash($request)]); } else { $this->logger->info(sprintf('Method "%s" call was failed', $request->getMethod()), ['request_hash' => spl_object_hash($request)]); $this->logger->error(sprintf('ERROR %s: %s', $response->getError()->getCode(), $response->getError()->getMessage()), ['request_hash' => spl_object_hash($request)]); } $this->loggedResponses[] = $hash; }
/** * @param RpcRequestInterface $request * @param string $id * @return static */ public static function fromRpcRequest(RpcRequestInterface $request, $id) { return new static($request->getMethod(), $request->getParameters(), $id); }
public static function emptyQueue(RpcRequestInterface $request) { $ex = new static(sprintf('Mock queue is empty while calling "%s"', $request->getMethod())); $ex->request = $request; return $ex; }
public function getKey(RpcRequestInterface $request) { $data = ['method' => (string) $request->getMethod(), 'params' => json_decode(json_encode($request->getParameters()), true)]; $stringData = json_encode($data); return $this->keyPrefix . sha1($stringData); }