private function authenticateRequest(HttpRequest $request)
 {
     $body = JsonRpc\json_decode((string) $request->getBody()->getContents(), true);
     $body['auth'] = $this->auth_token;
     $json_body = JsonRpc\json_encode($body);
     $request = $request->withBody(Psr7\stream_for($json_body));
     return $request;
 }
Beispiel #2
0
 /**
  * @param  string $key
  *
  * @return mixed
  */
 protected function getFieldFromBody($key)
 {
     $rpc = JsonRpc\json_decode((string) $this->getBody(), true);
     return isset($rpc[$key]) ? $rpc[$key] : null;
 }
Beispiel #3
0
 /**
  * {@inheritdoc}
  */
 public function fromResponse(HttpResponseInterface $response)
 {
     return $this->createResponse($response->getStatusCode(), $response->getHeaders(), JsonRpc\json_decode((string) $response->getBody(), true) ?: []);
 }
Beispiel #4
0
 /**
  * @param  ResponseInterface $response
  *
  * @return ResponseInterface[]
  */
 protected function getBatchResponses(ResponseInterface $response)
 {
     $results = JsonRpc\json_decode((string) $response->getBody(), true);
     return array_map(function (array $result) use($response) {
         return $this->messageFactory->createResponse($response->getStatusCode(), $response->getHeaders(), $result);
     }, $results);
 }