/** * Override API call to enable retry with servers' clock auto sync method. * * @param string $path * @param string $method * @param array $params * @param bool $retry Is in retry or first call attempt. * * @return array|mixed|string|void */ private function _call($path, $method = 'GET', $params = array(), $retry = false) { $this->_logger->entrance(); $result = $this->_api->Api($path, $method, $params); if (null !== $result && isset($result->error) && 'request_expired' === $result->error->code) { if (!$retry) { // Try to sync clock diff. if (false !== $this->_sync_clock_diff()) { return $this->_call($path, $method, $params, true); } } } if (null !== $result && isset($result->error)) { // Log API errors. $this->_logger->error($result->error->message); } return $result; }
/** * Override API call to enable retry with servers' clock auto sync method. * * @param string $path * @param string $method * @param array $params * @param bool $retry Is in retry or first call attempt. * * @return array|mixed|string|void */ private function _call($path, $method = 'GET', $params = array(), $retry = false) { $this->_logger->entrance($method . ':' . $path); if (self::is_temporary_down()) { $result = $this->get_temporary_unavailable_error(); } else { $result = $this->_api->Api($path, $method, $params); if (null !== $result && isset($result->error) && isset($result->error->code) && 'request_expired' === $result->error->code) { if (!$retry) { $diff = isset($result->error->timestamp) ? time() - strtotime($result->error->timestamp) : false; // Try to sync clock diff. if (false !== $this->_sync_clock_diff($diff)) { // Retry call with new synced clock. return $this->_call($path, $method, $params, true); } } } } if (null !== $result && isset($result->error) && isset($result->error->message)) { // Log API errors. $this->_logger->error($result->error->message); } return $result; }