<?php
/**
* --------------------------------------------------------------------
*
* LICENSE
* This file is part of the GLPI API Client Library for PHP,
* a subproject of GLPI. GLPI is a free IT Asset Management.
* GLPI is free software: you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 3
* of the License, or (at your option) any later version.
* GLPI is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* @author Domingo Oropeza - <doropeza@teclib.com>
* @copyright (C) 2017 Teclib' and contributors.
* @license GPLv3 https://www.gnu.org/licenses/gpl-3.0.html
* @link https://github.com/glpi-project/php-library-glpi
* @link http://www.glpi-project.org/
*/
namespace Glpi\Api\Rest;
* Class EndPointHandler
* @package Glpi\Api\Rest
class EndPointHandler {
* @var Client
protected $client;
* EndPointHandler constructor.
* @param Client $client
public function __construct(Client $client) {100%
$this->client = $client;
}
* @return Client
public function getClient() {0%
return $this->client;
* Return all the profiles associated to logged user.
* @return array
public function getMyProfiles() {100%
$response = $this->client->request('get', 'getMyProfiles');
return [
'statusCode' => $response->getStatusCode(),
'body' => $response->getBody()->getContents(),
];
* Return the current active profile.
public function getActiveProfile() {100%
$response = $this->client->request('get', 'getActiveProfile');
* Change active profile to the profiles_id one.
* @see getMyProfiles endpoint for possible profiles.
* @param integer $profiles_id
public function changeActiveProfile($profiles_id) {100%
$options['body'] = json_encode(['profiles_id' => $profiles_id]);
$response = $this->client->request('post', 'changeActiveProfile', $options);
* Return all the possible entities of the current logged user (and for current active profile).
* @param array $queryString
public function getMyEntities(array $queryString = []) {100%
$options['query'] = $queryString;
$response = $this->client->request('get', 'getMyEntities', $options);
* Return active entities of current logged user.
public function getActiveEntities() {100%
$response = $this->client->request('get', 'getActiveEntities');
* Change active entity to the entities_id one.
* @see getMyEntities endpoint for possible entities.
* @param array $parameters
public function changeActiveEntities(array $parameters = []) {100%
$options = [];
if ($parameters) {
$options['body'] = json_encode($parameters);
$response = $this->client->request('post', 'changeActiveEntities', $options);