public function request($method, $uri, array $options = []) {
      $apiToken = $this->addTokens();
      try {
         $options['headers']['Content-Type'] = "application/json";
         $sessionHeaders = [];
         if ($apiToken) {
            if (key_exists('Session-Token', $apiToken) && $apiToken['Session-Token']) {
               $sessionHeaders['Session-Token'] = $apiToken['Session-Token'];
            }
            if (key_exists('App-Token', $apiToken) && $apiToken['App-Token']) {
               $sessionHeaders['App-Token'] = $apiToken['App-Token'];
            }
         }
         $options = array_merge_recursive($options, ['headers' => $sessionHeaders]);
         $response = $this->httpClient->request($method, $this->url . $uri, $options);
         return $response;
      } catch (ClientException $e) {
         $response = $e->getResponse();
         /*$body = $response->getBody()->getContents();
         $reasonPhrase = $response->getReasonPhrase() . (($body) ? ' ' . $body : '');*/
         return $response;
      } catch (RequestException $e) {
         $hasResponse = $e->hasResponse();
         $statusCode = ($hasResponse) ? $e->getResponse()->getStatusCode() : '500';
         $contents = ($hasResponse) ? $e->getResponse()->getReasonPhrase() : 'Request Error';
         throw new Exception($contents, $statusCode);
      }
   }
public function request($method, $uri, array $options = []) {
      $apiToken = $this->addTokens();
      try {
         $options['headers']['Content-Type'] = "application/json";
         $sessionHeaders = [];
         if ($apiToken) {
            if (key_exists('Session-Token', $apiToken) && $apiToken['Session-Token']) {
               $sessionHeaders['Session-Token'] = $apiToken['Session-Token'];
            }
            if (key_exists('App-Token', $apiToken) && $apiToken['App-Token']) {
               $sessionHeaders['App-Token'] = $apiToken['App-Token'];
            }
         }
         $options = array_merge_recursive($options, ['headers' => $sessionHeaders]);
         $response = $this->httpClient->request($method, $this->url . $uri, $options);
         return $response;
      } catch (ClientException $e) {
         $response = $e->getResponse();
         /*$body = $response->getBody()->getContents();
         $reasonPhrase = $response->getReasonPhrase() . (($body) ? ' ' . $body : '');*/
         return $response;
      } catch (RequestException $e) {
         $hasResponse = $e->hasResponse();
         $statusCode = ($hasResponse) ? $e->getResponse()->getStatusCode() : '500';
         $contents = ($hasResponse) ? $e->getResponse()->getReasonPhrase() : 'Request Error';
         throw new Exception($contents, $statusCode);
      }
   }
public function request ( $ method , $ uri , array $ options = [ ] ) { $ apiToken = $ this -> addTokens ( ) ; try { $ options [ 'headers' ] [ 'Content-Type' ] = "application/json" ; $ sessionHeaders = [ ] ; if ( $ apiToken ) { if ( key_exists ( 'Session-Token' , $ apiToken ) && $ apiToken [ 'Session-Token' ] ) { $ sessionHeaders [ 'Session-Token' ] = $ apiToken [ 'Session-Token' ] ; } if ( key_exists ( 'App-Token' , $ apiToken ) && $ apiToken [ 'App-Token' ] ) { $ sessionHeaders [ 'App-Token' ] = $ apiToken [ 'App-Token' ] ; } } $ options = array_merge_recursive ( $ options , [ 'headers' => $ sessionHeaders ] ) ; $ response = $ this -> httpClient -> request ( $ method , $ this -> url . $ uri , $ options ) ; return $ response ; } catch ( ClientException $ e ) { $ response = $ e -> getResponse ( ) ; /*$body = $response->getBody()->getContents();
         $reasonPhrase = $response->getReasonPhrase() . (($body) ? ' ' . $body : '');*/ return $ response ; } catch ( RequestException $ e ) { $ hasResponse = $ e -> hasResponse ( ) ; $ statusCode = ( $ hasResponse ) ? $ e -> getResponse ( ) -> getStatusCode ( ) : '500' ; $ contents = ( $ hasResponse ) ? $ e -> getResponse ( ) -> getReasonPhrase ( ) : 'Request Error' ; throw new Exception ( $ contents , $ statusCode ) ; } }
Prepare and send a request to the GLPI Api.

@param $method
@param $uri
@param array $options
@return mixed|null|\Psr\Http\Message\ResponseInterface
@throws Exception
Prepare and send a request to the GLPI Api .