protected function requestToString(RequestException $e)
 {
     if ($e->getResponse() === null) {
         return '-';
     }
     $request = $e->getResponse()->getRequest();
     return sprintf("%s %s\n%s", $request->getMethod(), $request->getUrl(), "    " . str_replace("\n", "\n    ", json_encode($request->getFileParams()->getArrayCopy() + $request->getBodyParams()->getArrayCopy(), JSON_PRETTY_PRINT)));
 }
 /**
  * @param array $data
  * @param string $expected_class
  * @dataProvider createConcreteProvider
  */
 public function testCreateConcrete($data, $expected_class)
 {
     $response = new Response();
     $response->setBody(json_encode(array('error' => $data)));
     $response->setStatusCode(400);
     $e = RequestException::create($response);
     $fqn = '\\FacebookAds\\Http\\Exception\\' . $expected_class;
     $this->assertTrue(is_a($e, $fqn));
 }
 /**
  * @param array $data
  * @param string $expected_class
  * @dataProvider createConcreteProvider
  */
 public function testCreateConcrete($data, $expected_class)
 {
     $e = RequestException::create(array('error' => $data), 400);
     $fqn = '\\FacebookAds\\Http\\Exception\\' . $expected_class;
     $this->assertTrue(is_a($e, $fqn));
 }
 /**
  * @param ResponseInterface $response
  */
 public function __construct(ResponseInterface $response)
 {
     $content = array('error' => array('message' => 'Empty Response'));
     $response->setBody(json_encode($content));
     parent::__construct($response);
 }
 /**
  * @param RequestInterface $request
  * @return ResponseInterface
  * @throws RequestException
  */
 public function sendRequest(RequestInterface $request)
 {
     $response = $this->getAdapter()->sendRequest($request);
     $response->setRequest($request);
     $response_content = $response->getContent();
     if ($response_content === null) {
         throw new EmptyResponseException($response->getStatusCode());
     }
     if (is_array($response_content) && array_key_exists('error', $response_content)) {
         throw RequestException::create($response->getContent(), $response->getStatusCode());
     }
     return $response;
 }