mirror of
https://github.com/retailcrm/opencart-module.git
synced 2024-11-22 21:26:08 +03:00
c724392c36
Plugin's deliveries ICML export Order export
45 lines
1.2 KiB
PHP
45 lines
1.2 KiB
PHP
<?php
|
|
|
|
/**
|
|
* Class RequestProxy
|
|
* @package RetailCrm\Component
|
|
*/
|
|
class RetailcrmProxy
|
|
{
|
|
|
|
private $api;
|
|
private $log;
|
|
|
|
public function __construct($url, $key, $log)
|
|
{
|
|
$this->api = new RetailcrmApiClient($url, $key);
|
|
$this->log = $log;
|
|
}
|
|
|
|
public function __call($method, $arguments)
|
|
{
|
|
try {
|
|
$response = call_user_func_array(array($this->api, $method), $arguments);
|
|
$date = date('[Y-m-d H:i:s]');
|
|
|
|
if (!$response->isSuccessful()) {
|
|
error_log($date . " [$method] " . $response->getErrorMsg() . "\n", 3, $this->log);
|
|
if (isset($response['errors'])) {
|
|
$error = implode("\n", $response['errors']);
|
|
error_log($date .' '. $error . "\n", 3, $this->log);
|
|
}
|
|
$response = false;
|
|
}
|
|
|
|
return $response;
|
|
} catch (CurlException $e) {
|
|
error_log($date . " [$method] " . $e->getMessage() . "\n", 3, $this->log);
|
|
return false;
|
|
} catch (InvalidJsonException $e) {
|
|
error_log($date . " [$method] " . $e->getMessage() . "\n", 3, $this->log);
|
|
return false;
|
|
}
|
|
}
|
|
|
|
}
|