Skip to content
This repository has been archived by the owner on Jul 12, 2021. It is now read-only.

Commit

Permalink
pridana podpora pro trackPackage vyuziva track_v3 refs #8336
Browse files Browse the repository at this point in the history
  • Loading branch information
Dukecz committed Mar 18, 2021
1 parent 8761205 commit 0395395
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions src/Balikobot/Balikobot.php
Original file line number Diff line number Diff line change
Expand Up @@ -1071,7 +1071,7 @@ public function trackPackage($shipper, $carrierId)
throw new \InvalidArgumentException('Invalid argument has been entered.');
}

$response = $this->call(self::REQUEST_TRACK, $shipper, ['id' => $carrierId]);
$response = $this->call(self::REQUEST_TRACK, $shipper, ['id' => $carrierId], null, 3);

if (isset($response['status']) && ($response['status'] != 200)) {
throw new \UnexpectedValueException(
Expand Down Expand Up @@ -1553,15 +1553,23 @@ private function getEid($shipper = null, $orderId = null)
* @param string $shipper
* @param array $data
* @param string $url
* @param int $version
*
* @return array
*/
private function call($request, $shipper, array $data = [], $url = null)
private function call($request, $shipper, array $data = [], $url = null, int $version = 1)
{
if (empty($request) || empty ($shipper)) {
throw new \InvalidArgumentException('Invalid argument has been entered.');
}

$targetUrl = $url ? "$this->apiUrl/$shipper/$request/$url" : "$this->apiUrl/$shipper/$request";
if ($version > 1) {
$versionString = sprintf('v%d/', $version);
} else {
$versionString = '';
}

$targetUrl = $url ? "$this->apiUrl/$versionString$shipper/$request/$url" : "$this->apiUrl/$versionString$shipper/$request";
$this->logger->info('Sending request to URL ' . $targetUrl, $data);

$r = curl_init();
Expand Down

0 comments on commit 0395395

Please sign in to comment.