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

Commit 200a7eb

Browse files
DIOHz0rajsb85
authored andcommittedOct 25, 2017
fix(item): updated getMultipleItems end point
1 parent 66b5bee commit 200a7eb

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed
 

‎src/Glpi/Api/Rest/ItemHandler.php

+11-3
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@
3131
namespace Glpi\Api\Rest;
3232

3333

34+
use Glpi\Api\Rest\Exception\InsufficientArgumentsException;
35+
3436
class ItemHandler {
3537
/**
3638
* @var Client
@@ -105,15 +107,21 @@ public function getSubItems($itemType, $id, $subItem, array $queryString = []) {
105107

106108
/**
107109
* Virtually call Get an item for each line in input. So, you can have a ticket, an user in the same query.
110+
* @param array $items
108111
* @param array $queryString
109112
* @return array
110113
*/
111-
public function getMultipleItems(array $queryString){
112-
$options['query'] = $queryString;
114+
public function getMultipleItems(array $items, array $queryString = []){
115+
foreach($items as $item){
116+
if (!key_exists('itemtype', $item) || !key_exists('items_id', $item)) {
117+
throw new InsufficientArgumentsException("'itemtype' and 'items_id' are mandatory");
118+
}
119+
}
120+
$options['query'] = array_merge($queryString, ['items' => $items]);
113121
$response = $this->client->request('get', 'getMultipleItems', $options);
114122
return [
115123
'statusCode' => $response->getStatusCode(),
116-
'body' => $response->getBody()->getContents()
124+
'body' => $response->getBody()->getContents(),
117125
];
118126
}
119127

0 commit comments

Comments
 (0)