/** * Отправить запрос * * @param DataContainer $dataContainer * @param bool $isBatch * @return bool|int|mixed|DataContainerResponse * @throws NovaPoshtaException */ protected function _send(DataContainer $dataContainer, $isBatch = false) { $logger = new DataLogger(); $dataContainer->apiKey = Config::getApiKey(); $dataContainer->language = Config::getLanguage(); $dataContainer->id = $this->getIdBatch(); if ($isBatch) { if (!$this->serializer instanceof SerializerBatchInterface) { throw new NovaPoshtaException('NovaPoshta\\Core\\Serializer\\SendData_NO_BATCH'); } $this->dataBatch[$dataContainer->id] = $dataContainer; return $dataContainer->id; } $logger->toData = $dataContainer; $data = $this->serializer->serializeData($dataContainer); $logger->toOriginalData = $data; $response = $this->query($data); $logger->fromOriginalData = $response; if ($response) { $response = $this->serializer->unserializeData($response); } else { $response = new DataContainerResponse(); $response->success = false; $response->errors[] = array('DataSerializerJSON.ERROR_REQUEST'); } $logger->fromData = $response; BaseLogger::setDataLogger($logger); return $response; }
protected function setDataLogger() { BaseLogger::setDataLogger($this->logger); }