/**
  * Return a single string to be displayed to the console
  * @param ApiException $apiException
  */
 public static function formatApiExceptionArray(ApiException $apiException)
 {
     $output = $apiException->getMessage();
     if ($apiException->getErrors() && count($apiException->getErrors()) > 0) {
         $errors = $apiException->getErrors();
         foreach ($errors as $error) {
             $output .= "\n[" . $error['property'] . "] " . $error['message'] . " (value = " . print_r($error['value'], TRUE) . ")";
         }
     }
     return $output;
 }
Exemplo n.º 2
0
 /**
  * @param string $url
  * @param array  $params
  *
  * @return array
  *
  * @throws ApiException
  */
 private function doGet($url, $params = null)
 {
     if (empty($this->apiKey)) {
         $exception = new ApiException('Invalid API Key', 401);
         $this->debug($exception->getMessage(), 'ERROR', array('method' => 'GET', 'code' => $exception->getCode(), 'errors' => $exception->getErrors()));
     }
     $this->curl->headers = $this->getDefaultCurlHeaders();
     $this->curl->options = $this->getDefaultCurlOptions();
     $response = $this->curl->get(self::API_URL . $url, $params);
     // Note that doGet doesn't decode here, it returns the actual response
     // body.
     $this->debug('response = ' . $response->body, null, array('method' => 'GET', 'url' => $url, 'params' => $params));
     return array($response->headers['Status-Code'], $response->body);
 }