/** * @param Response $response * @return array|boolean */ public function verifyResponse(Response $response) { $responseBody = (string) $response->getBody(); if (empty($responseBody)) { return true; } $json = json_decode($responseBody, true); if (is_null($json)) { throw new InvalidResponseFormatException("Invalid json in Response Body", $responseBody); } switch ($response->getStatusCode()) { case 400: throw new InvalidInputException($json['ExceptionDescription'], Error::createArrayFromJson($json['Errors'])); case 401: throw new AuthErrorException($json['ExceptionDescription']); case 500: throw new UnknownErrorException($json['ExceptionDescription']); } return $json; }
/** * {@inheritdoc} */ public function jsonInstantiationDataProvider() { return array(array('Grow\\Client\\Model\\Error', array("ErrorItem" => 'item', "ErrorMessage" => 'message'), Error::createNew()->setErrorItem('item')->setErrorMessage('message'))); }