protected function checkResponse(Response $response) { if (!$response->isSuccess()) { $msg = 'Bad response. ' . $response->getApiCode() . ': ' . $response->getApiCodeDescription(); throw new \Exception($msg . print_r($response->getUserMessages())); } }