You are here

public function ApiClient::__construct in Rocket.Chat 8

Same name and namespace in other branches
  1. 8.2 modules/rocket_chat_api/src/RocketChat/ApiClient.php \Drupal\rocket_chat_api\RocketChat\ApiClient::__construct()

ApiClient constructor.

Loads in the configuration from the Drupal Variables and preparers the Client with some defaults and base values for ease of use.

Parameters

\Drupal\rocket_chat_api\RocketChat\RocketChatConfigInterface $config: class that holds the glue between the implementation's of this Code.

bool $login: When true the stored login tokens will not be used. when false the stored login tokens will be used. This is to facilitate login and non-auth calls. Or in other words, is this a login call.

File

modules/rocket_chat_api/src/RocketChat/ApiClient.php, line 84

Class

ApiClient
Class ApiClient.

Namespace

Drupal\rocket_chat_api\RocketChat

Code

public function __construct(RocketChatConfigInterface $config, $login = FALSE) {
  $this->config = $config;
  if (!empty($config)) {
    $this->client = $this
      ->createClient($login);
    $userToken = $this->config
      ->getElement("rocket_chat_uit");
    if (empty($userToken)) {
      $this->loggedIn = FALSE;
    }
    else {
      $this->loggedIn = TRUE;
    }
  }
  else {
    $this->config = NULL;
  }
}