Skip to content
This repository has been archived by the owner on Sep 11, 2024. It is now read-only.

Commit

Permalink
refactor(endpoint): update code standards for EndPointHandler
Browse files Browse the repository at this point in the history
  • Loading branch information
DIOHz0r authored and ajsb85 committed Oct 25, 2017
1 parent 0f2a4e2 commit 794d594
Showing 1 changed file with 27 additions and 12 deletions.
39 changes: 27 additions & 12 deletions src/GlpiProject/API/Rest/EndPointHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@
namespace GlpiProject\API\Rest;



use GlpiProject\API\Rest\Exception\InsufficientArgumentsException;

class EndPointHandler
{

Expand All @@ -25,7 +22,10 @@ public function __construct(Client $client) {
*/
public function getMyProfiles() {
$response = $this->client->request('get', 'getMyProfiles');
return ['statusCode' => $response->getStatusCode(), 'body' => json_decode($response->getBody()->getContents())];
return [
'statusCode' => $response->getStatusCode(),
'body' => $response->getBody()->getContents(),
];
}

/**
Expand All @@ -34,7 +34,10 @@ public function getMyProfiles() {
*/
public function getActiveProfile() {
$response = $this->client->request('get', 'getActiveProfile');
return ['statusCode' => $response->getStatusCode(), 'body' => json_decode($response->getBody()->getContents())];
return [
'statusCode' => $response->getStatusCode(),
'body' => $response->getBody()->getContents(),
];
}

/**
Expand All @@ -45,19 +48,25 @@ public function getActiveProfile() {
* @return array
*/
public function changeActiveProfile($profiles_id) {
$options['body'] = json_encode(['profiles_id' => $profiles_id]);
$options['body'] = ['profiles_id' => $profiles_id];
$response = $this->client->request('post', 'changeActiveProfile', $options);
return ['statusCode' => $response->getStatusCode(), 'body' => json_decode($response->getBody()->getContents())];
return [
'statusCode' => $response->getStatusCode(),
'body' => $response->getBody()->getContents(),
];
}

/**
* Return all the possible entities of the current logged user (and for current active profile).
* @param array $options
* @return array
*/
public function getMyEntities(array $options = array()) {
public function getMyEntities(array $options = []) {
$response = $this->client->request('get', 'getMyEntities', $options);
return ['statusCode' => $response->getStatusCode(), 'body' => json_decode($response->getBody()->getContents())];
return [
'statusCode' => $response->getStatusCode(),
'body' => $response->getBody()->getContents(),
];
}

/**
Expand All @@ -66,7 +75,10 @@ public function getMyEntities(array $options = array()) {
*/
public function getActiveEntities() {
$response = $this->client->request('get', 'getActiveEntities');
return ['statusCode' => $response->getStatusCode(), 'body' => json_decode($response->getBody()->getContents())];
return [
'statusCode' => $response->getStatusCode(),
'body' => $response->getBody()->getContents(),
];
}

/**
Expand All @@ -76,9 +88,12 @@ public function getActiveEntities() {
* @param array $options
* @return array
*/
public function changeActiveEntities(array $options = array()) {
public function changeActiveEntities(array $options = []) {
$response = $this->client->request('post', 'changeActiveEntities', $options);
return ['statusCode' => $response->getStatusCode(), 'body' => json_decode($response->getBody()->getContents())];
return [
'statusCode' => $response->getStatusCode(),
'body' => $response->getBody()->getContents(),
];
}


Expand Down

0 comments on commit 794d594

Please sign in to comment.