This repository has been archived by the owner on Jul 12, 2021. It is now read-only.
forked from MiroslavMerinsky/Balikobot
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
David Alexa
committed
Apr 17, 2019
1 parent
e704e99
commit 54614c6
Showing
1 changed file
with
16 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,13 +2,16 @@ | |
|
||
namespace ThreeSixtyEu\Balikobot; | ||
|
||
use Monolog\Logger; | ||
use Navigator\Application\Utils\Debugger; | ||
|
||
/** | ||
* @author Miroslav Merinsky <[email protected]> | ||
* @version 1.0 | ||
*/ | ||
class Balikobot | ||
{ | ||
|
||
const LOGGER_CHANNEL = 'balikobot'; | ||
/** | ||
* Requests | ||
*/ | ||
|
@@ -450,6 +453,11 @@ class Balikobot | |
/** @var int */ | ||
private $activeApiBranch; | ||
|
||
/** | ||
* @var Logger | ||
*/ | ||
private $logger; | ||
|
||
/** @var string */ | ||
private $apiUrl = 'https://api.balikobot.cz'; | ||
|
||
|
@@ -482,6 +490,7 @@ public function __construct($apiBranches) | |
} | ||
|
||
$this->apiBranches = $apiBranches; | ||
$this->logger = Debugger::getLogger(self::LOGGER_CHANNEL, Debugger::HANDLERS_AUX|Debugger::HANDLERS_DEFAULT); | ||
} | ||
|
||
/** | ||
|
@@ -1552,8 +1561,11 @@ private function call($request, $shipper, array $data = [], $url = null) | |
throw new \InvalidArgumentException('Invalid argument has been entered.'); | ||
} | ||
|
||
$targetUrl = $url ? "$this->apiUrl/$shipper/$request/$url" : "$this->apiUrl/$shipper/$request"; | ||
$this->logger->info('Sending request to URL ' . $targetUrl, $data); | ||
|
||
$r = curl_init(); | ||
curl_setopt($r, CURLOPT_URL, $url ? "$this->apiUrl/$shipper/$request/$url" : "$this->apiUrl/$shipper/$request"); | ||
curl_setopt($r, CURLOPT_URL, $targetUrl); | ||
curl_setopt($r, CURLOPT_RETURNTRANSFER, true); | ||
curl_setopt($r, CURLOPT_HEADER, false); | ||
if (!empty($data)) { | ||
|
@@ -1571,6 +1583,8 @@ private function call($request, $shipper, array $data = [], $url = null) | |
$response = curl_exec($r); | ||
curl_close($r); | ||
|
||
$this->logger->info('Result of ' . $targetUrl, json_decode($response, true)); | ||
|
||
return json_decode($response, true); | ||
} | ||
|
||
|