32 private $guzzle_client;
41 $this->guzzle_client =
new Client([
42 'base_uri' =>
"http://{$host}:{$port}",
58 $allHeaders = $headers;
59 $authTokenVal = $this->getAuthToken();
60 $authToken = [
'Authorization' =>
'Bearer ' . $authTokenVal];
61 $allHeaders = array_merge($allHeaders, $authToken);
63 return $this->submitAPIRequest($apiMethod, $requestURI, $jsonBody, $allHeaders);
71 private function getAuthToken()
73 $jsonArray = json_encode([
'username' =>
'admin',
'password' =>
'admin123']);
77 self::INTEGRATION_ADMIN_TOKEN_URI,
79 self::APPLICATION_JSON_HEADER
83 throwException(
$response->getReasonPhrase() .
' Could not get admin token from service, please check logs.');
86 $authToken = str_replace(
'"',
"",
$response->getBody()->getContents());
99 private function submitAPIRequest($apiMethod, $requestURI, $jsonBody, $headers)
101 $response = $this->guzzle_client->request(
105 'headers' => $headers,
const APPLICATION_JSON_HEADER
const INTEGRATION_ADMIN_TOKEN_URI
submitAuthAPIRequest($apiMethod, $requestURI, $jsonBody, $headers)
__construct($host, $port)