/** * @param Request $Request * @throws \Productsup\Exceptions\ServerException * @return Response */ public function executeRequest(Request $Request) { if ($this->verbose) { $Request->allowCompression = false; // disable gzip for easier debugging $Request->verboseOutput(); } $this->prepareRequest($Request); if (!($curl_response = curl_exec($this->curl))) { throw new ServerException(curl_error($this->curl), curl_errno($this->curl)); } list($responseHeaders, $responseBody) = $this->parseHttpResponse($curl_response); $statusCode = curl_getinfo($this->curl, CURLINFO_HTTP_CODE); $responseObject = new Response($statusCode, $responseHeaders, $responseBody); if ($this->verbose) { $responseObject->verboseOutput(); } return $responseObject; }
/** * convert api response to a log message * @param Response $response */ private function logResponse(Response $response) { $data = $response->getData(); foreach ($data as $key => $val) { if ($key == 'success') { continue; } // we know it was a success, otherwise it would have failed before $this->_submitLog[] = date('Y-m-d H:i:s') . ' added ' . $val['count'] . ' product(s) ' . ' for ' . $key . ' to batch ' . $this->_batchId; } }