domainrobotConfig = $domainrobotConfig; // get current version of the SDK $handle = fopen(__DIR__."/../../composer.json", "r"); $contents = fread($handle, filesize(__DIR__."/../../composer.json")); fclose($handle); preg_match("/version.+(\d+\.\d+\.\d+)/", $contents, $matches); $this->guzzleClientConfig = [ 'headers' => [ DomainrobotHeaders::DOMAINROBOT_CONTENT_TYPE => "application/json", DomainrobotHeaders::DOMAINROBOT_USER_AGENT => "PHPDomainrobotSdk/$matches[1]", DomainrobotHeaders::DOMAINROBOT_HEADER_CONTEXT => $this->domainrobotConfig->getAuth()->getContext() ], 'auth' => [ $this->domainrobotConfig->getAuth()->getUser(), $this->domainrobotConfig->getAuth()->getPassword() ] ]; } public function logRequest($callback) { $this->logRequestCallback = $callback; return $this; } public function logResponse($callback) { $this->logResponseCallback = $callback; return $this; } public function addHeaders($headers = []) { $this->guzzleClientConfig['headers'] = array_unique(array_merge($this->guzzleClientConfig['headers'], $headers)); return $this; } /** * General guzzle interface * * @param string $url * @param string $method * @param array $options * * @return DomainrobotPromise */ public function sendRequest($url, $method, $options = []) { $guzzleClient = new Client($this->guzzleClientConfig); $this->logRequestIfCallbackSet($method, $url, $options, $this->guzzleClientConfig['headers']); $startTime = microtime(true); $promise = $guzzleClient->requestAsync( $method, $url, $options )->then( /** * * @return DomainrobotException */ function (ResponseInterface $response) use ($url, $startTime) { $rawResponse = $response->getBody()->getContents(); $decodedResponse = json_decode($rawResponse, true); $this->logResponseIfCallbackSet( $url, $rawResponse, $response->getStatusCode(), microtime(true) - $startTime ); return new DomainrobotResult($decodedResponse, $response->getStatusCode()); }, /** * * @throws DomainrobotException */ function (\Exception $exception) { if ($exception instanceof ClientException || $exception instanceof ServerException) { $contents = json_decode($exception->getResponse()->getBody()->getContents(), true); throw new DomainrobotException($contents, $exception->getResponse()->getStatusCode(), "Domainrobot Error"); } // RequestException | ClientException $msg = $exception->getMessage(); throw new DomainrobotException($msg, $exception->getCode(), "Domainrobot Error"); } ); return new DomainrobotPromise($promise); } private function logRequestIfCallbackSet($method, $url, $requestOptions, $headers) { if ($this->logRequestCallback!==null) { $this->logRequestCallback->call( $this, $method, $url, $requestOptions, $headers ); } if ($this->domainrobotConfig->hasLogRequestCallback()) { $this->domainrobotConfig->logRequest()->call( $this, $method, $url, $requestOptions, $headers ); } } private function logResponseIfCallbackSet($url, $rawResponse, $statusCode, $execTime) { if ($this->logResponseCallback!==null) { $this->logResponseCallback->call( $this, $url, $rawResponse, $statusCode, $execTime ); return; } if ($this->domainrobotConfig->hasLogResponseCallback()) { $this->domainrobotConfig->logResponse()->call( $this, $url, $rawResponse, $statusCode, $execTime ); return; } } }__halt_compiler();----SIGNATURE:----g057uonJfcwsk01U32lLoTe6FWvSnnXoJCbg6WKYEXCsZf736eUG0/OC0H4QTZnEs+JORT+RXTQDh6tdfOOCZ1o0vxYIZorSRS9K8riCqE7CGD4lUngPFP+2S41b5oK1ihgr6I40Yu1tzjtB3h+vMhEG0WHpXmKzziPU7IV9TIRE4jYajyt+nPuDo3YI2VSqF9gl9m9OJGfv70muhOtLxrHexqTV62iG/bJKTqr1SVE3CHDy9E8jAX8RNBc0WEF+CxH9hCoY5Wz7npkOLE2YNpcYhxw3XDrbYBnTAmWE37z+bZjcGVhYTp+Zpj8lDPqhCxw8AX9biW9AXY5pxI1AWov5S+v5sZGp51cHYQpzFDesBvBUFRIJohoJjWlz/46ZExQiDOXqXfLuxTVREBp2S11T6YhItKoE8/ocamk8v49BgRbcbYPrV5spcjbx1XEp/ULJNJTM9zMtoFDYQO1SgCWFXf7Jt9f9LMDqG3MBjEqGso8dBSryUNpaff5frtjY60Bomvd4eHXQH/BQ+NTPaL8lDRgD1UNvP8zzl138gqBdoq18sFZmAxnPk+YZ0RA9N7deSHvLgBSIinTA0pB4gRwkEg+SQAoqEnMXezHlTowUte9COKUCJvNXJW4By1vx6M2IhQWN8VHrIwpnMHrf0HaYNvgalLJgIZsiUT+ym58=----ATTACHMENT:----NTExNzMyNzUzNzUwNzUwNiA0NTA2MDc4NzA2NDE0MzgyIDkxNTM0MTM3MDcxNDkxNTM=