Skip to content

Commit

Permalink
fix(item): updated getMultipleItems end point
Browse files Browse the repository at this point in the history
  • Loading branch information
DIOHz0r authored and ajsb85 committed Oct 25, 2017
1 parent 66b5bee commit 200a7eb
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions src/Glpi/Api/Rest/ItemHandler.php
Expand Up @@ -31,6 +31,8 @@
namespace Glpi\Api\Rest;


use Glpi\Api\Rest\Exception\InsufficientArgumentsException;

class ItemHandler {
/**
* @var Client
Expand Down Expand Up @@ -105,15 +107,21 @@ public function getSubItems($itemType, $id, $subItem, array $queryString = []) {

/**
* Virtually call Get an item for each line in input. So, you can have a ticket, an user in the same query.
* @param array $items
* @param array $queryString
* @return array
*/
public function getMultipleItems(array $queryString){
$options['query'] = $queryString;
public function getMultipleItems(array $items, array $queryString = []){
foreach($items as $item){
if (!key_exists('itemtype', $item) || !key_exists('items_id', $item)) {
throw new InsufficientArgumentsException("'itemtype' and 'items_id' are mandatory");
}
}
$options['query'] = array_merge($queryString, ['items' => $items]);
$response = $this->client->request('get', 'getMultipleItems', $options);
return [
'statusCode' => $response->getStatusCode(),
'body' => $response->getBody()->getContents()
'body' => $response->getBody()->getContents(),
];
}

Expand Down

0 comments on commit 200a7eb

Please sign in to comment.