/**
  * {@inheritdoc}
  */
 public function request($method, $path, $body = null, array $options = [])
 {
     $response = $this->decoratedClient->request($method, $path, $body, $options);
     $filePath = $this->fileResolver->getFilePath($method, $path, $body, $options);
     file_put_contents($filePath, $response);
     return $response;
 }
Exemplo n.º 2
0
 /**
  * @param string $method
  * @param string $path
  * @param object $body
  * @param array  $options
  *
  * @return object
  *
  * @throws ServerError
  */
 private function request($method, $path, $body, array $options)
 {
     $body = $this->serializeBody($body, $options);
     try {
         $responseContents = $this->httpClient->request($method, $path, $body, $options);
         $response = $this->getResponse($responseContents, $options);
     } catch (ServerException $e) {
         throw new ServerError(new Status(Status::FAILURE, $e->getMessage()));
     } catch (RequestException $e) {
         if ($response = $e->getResponse()) {
             throw $this->createRequestException($e);
         }
         throw new ServerError(new Status(Status::UNKNOWN, 'No response from server'));
     }
     return $response;
 }