/** * Sends the request to Vend, and reutrns the decoded JSON data from the response. * * @param CurlHttpRequest $request The request to send. * * @param $requestType * * @return array * @throws EntityNotFoundException * @throws CommunicationException */ protected function sendRequest(CurlHttpRequest $request, $requestType) { $result = $request->send(); if (!$result->getError() && 404 == $result->getResponseCode()) { throw new EntityNotFoundException('The specified entity can not be found', 404, null, $result); } if (!$result->isRequestSuccessful()) { $exceptionClass = $this->getCommunicationExceptionClass(); throw new $exceptionClass($requestType, $result, 0, null, $result); } $resultData = json_decode($result->getResponseBody(), true); if (empty($resultData)) { $exceptionClass = $this->getCommunicationExceptionClass(); throw new $exceptionClass($requestType, $result, 0, null, $result); } return $resultData; }