/**
  * @param string $request
  * @param array $params
  * @param string $data
  */
 protected function buildDialogue($request, array $params, $data = '')
 {
     $this->client->expects($this->once())->method('get')->with($this->getUrl($request, $params))->will($this->returnValue($this->request));
     $this->request->expects($this->once())->method('setHeader')->with('User-Agent', $this->app_code)->will($this->returnValue($this->request));
     $this->request->expects($this->once())->method('send')->will($this->returnValue($this->response));
     $this->response->expects($this->once())->method('isError')->will($this->returnValue(!$data));
     if ($data) {
         $this->response->expects($this->once())->method('getBody')->with(true)->will($this->returnValue(gzencode($data)));
         $this->response_repair->expects($this->once())->method('repair')->with($data)->will($this->returnValue($data));
     } else {
         $this->response->expects($this->never())->method('getBody');
         $this->response_repair->expects($this->never())->method('repair');
     }
 }
 /**
  * @param string $request
  * @param array $params
  * @param bool $force
  *
  * @return string
  */
 public function getContent($request, array $params = [], $force = false)
 {
     $path = $this->api_prefix . '&request=' . $request . ($params ? '&' . http_build_query($params) : '');
     // try get response from cache
     if ($force || !$this->cache instanceof CacheResponse || !($response = $this->cache->get($path))) {
         $response = $this->client->get($path)->setHeader('User-Agent', $this->app_code)->send();
         if ($response->isError()) {
             throw new \RuntimeException("Failed execute request '{$request}' to the server '" . $this->getApiHost() . "'");
         }
         $response = gzdecode($response->getBody(true));
         $response = $this->response_repair->repair($response);
         // repair
         // cache response
         if ($this->cache instanceof CacheResponse) {
             $this->cache->set($request, $path, $response);
         }
     }
     return $response;
 }
 /**
  * @dataProvider getResponses
  *
  * @param string $expected
  * @param string $actual
  */
 public function testRepair($expected, $actual)
 {
     $repair = new ResponseRepair();
     $this->assertEquals($expected, $repair->repair($actual));
 }