private function ApiClient::createClient in Rocket.Chat 8
Same name and namespace in other branches
- 8.2 modules/rocket_chat_api/src/RocketChat/ApiClient.php \Drupal\rocket_chat_api\RocketChat\ApiClient::createClient()
Create a Guzzle client Object.
Parameters
bool $login: Filter out the login credentials.
Return value
GuzzleClient New HTTP Client.
3 calls to ApiClient::createClient()
- ApiClient::login in modules/
rocket_chat_api/ src/ RocketChat/ ApiClient.php - Do a Login on the Rocket Chat REST API.
- ApiClient::sudo in modules/
rocket_chat_api/ src/ RocketChat/ ApiClient.php - Execute as different user.
- ApiClient::__construct in modules/
rocket_chat_api/ src/ RocketChat/ ApiClient.php - ApiClient constructor.
File
- modules/
rocket_chat_api/ src/ RocketChat/ ApiClient.php, line 111
Class
- ApiClient
- Class ApiClient.
Namespace
Drupal\rocket_chat_api\RocketChatCode
private function createClient($login = FALSE) {
$userId = $this->config
->getElement("rocket_chat_uid");
$userToken = $this->config
->getElement("rocket_chat_uit");
$guzzleConfig = [
'base_uri' => $this->config
->getElement('rocket_chat_url', "http://localhost:3000") . '/api/v1/',
'allow_redirects' => FALSE,
'timeout' => 60,
'debug' => $this->config
->isDebug(),
'headers' => [
'X-Auth-Token' => $userToken,
'X-User-Id' => $userId,
],
];
if ($login) {
//Doing a fresh 'login' run.
unset($guzzleConfig['headers']);
}
$guzzleConfig['headers']['Content-Type'] = 'application/json';
return new GuzzleClient($guzzleConfig);
}