/**
  * Отправить запрос
  *
  * @param DataContainer $dataContainer
  * @param bool $isBatch
  * @return bool|int|mixed|DataContainerResponse
  * @throws NovaPoshtaException
  */
 protected function _send(DataContainer $dataContainer, $isBatch = false)
 {
     $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;
     }
     $this->logger->toData = $dataContainer;
     $data = $this->serializer->serializeData($dataContainer);
     $this->logger->toOriginalData = $data;
     $response = $this->query($data);
     $this->logger->fromOriginalData = $response;
     if ($response) {
         $response = $this->serializer->unserializeData($response);
     } else {
         $response = new DataContainerResponse();
         $response->success = false;
         $response->errors[] = array('DataSerializerJSON.ERROR_REQUEST');
     }
     $this->logger->fromData = $response;
     $this->setDataLogger();
     return $response;
 }
 private static function getPrintLink($typePrint, MethodParameters $data = null)
 {
     $refs = isset($data->DocumentRefs) ? $data->DocumentRefs : null;
     if (empty($refs)) {
         return '';
     }
     $link = '';
     $link .= Config::getUrlMyNovaPoshta() . '/orders/' . $typePrint;
     foreach ($refs as $ref) {
         if (isset($data->Copies) && $data->Copies == self::PRINT_COPIES_FOURFOLD) {
             $link .= '/orders[]/' . $ref;
         }
         $link .= '/orders[]/' . $ref;
     }
     if (isset($data->Type)) {
         $link .= '/type/' . $data->Type;
     }
     $link .= '/apiKey/' . Config::getApiKey();
     return $link;
 }
Example #3
0
 /**
  * Вызвать метод printScanSheet() - загрузка печатной формы реестра
  *
  * @param MethodParameters $data
  * @return string
  */
 public static function printScanSheet(MethodParameters $data = null)
 {
     $refs = isset($data->DocumentRefs) ? $data->DocumentRefs : null;
     if (empty($refs)) {
         return '';
     }
     $link = '';
     $link .= Config::getUrlMyNovaPoshta() . '/scanSheet/printScanSheet';
     foreach ($refs as $ref) {
         $link .= '/refs[]/' . $ref;
     }
     if (isset($data->Type)) {
         $link .= '/type/' . $data->Type;
     }
     $link .= '/apiKey/' . Config::getApiKey();
     return $link;
 }