/** * Execute an API call using a certain method * * @param ApiCallInterface $call The API call * * @return string The parsed response of the API call */ public function call(ApiCallInterface $call) { if ($call instanceof CurlCall) { if ($this->freshConnect || $this->engine == null || !$this->engine instanceof Curl) { $this->engine = new Curl(); } } else { if ($this->freshConnect || $this->engine == null || !$this->engine instanceof \SoapClient) { $this->engine = new \SoapClient($call->getUrl()); } } if ($this->logger) { $this->logger->startCall($call); } $this->lastCall = $call; $result = $call->execute($this->options, $this->engine, $this->freshConnect); if ($this->logger) { $this->logger->stopCall($call); } if ($call instanceof CurlCall) { if ($this->freshConnect) { $this->engine->close(); } } return $result; }
/** * {@inheritdoc} */ public function startCall(ApiCallInterface $call) { $this->start = microtime(true); $this->calls[++$this->currentCall] = array('type' => $call->getName(), 'url' => $call->getUrl(), 'requestData' => $call->getRequestData(), 'requestObject' => $call->getRequestObjectRepresentation()); }