diff --git a/src/prepareRequest.js b/src/prepareRequest.js index c1c52e8..00e7e15 100644 --- a/src/prepareRequest.js +++ b/src/prepareRequest.js @@ -150,7 +150,6 @@ function prepareRequest (data) { break case 'getMultipleItems': - queryString = `?${createQueryString(data.items)}${createQueryString(data.options)}` url = `${url}/getMultipleItems${queryString}` @@ -158,6 +157,14 @@ function prepareRequest (data) { myInit = { method: 'GET' } break + case 'searchItems': + queryString = `?${createQueryString(data.criteria)}${createQueryString(data.metacriteria)}${createQueryString(data.options)}` + + url = `${url}/search/${data.itemtype}/${queryString}` + + myInit = { method: 'GET' } + break + default: break } diff --git a/src/restclient.js b/src/restclient.js index 4f9ba99..91b5ee4 100644 --- a/src/restclient.js +++ b/src/restclient.js @@ -476,6 +476,31 @@ class GlpiRestClient { }) } + searchItems (itemtype, criteria, metacriteria, options) { + return new Promise((resolve, reject) => { + try { + const data = { + function: 'searchItems', + itemtype, + criteria, + metacriteria, + options + } + + this._makeRequest( prepareRequest(data), 'searchItems', (response, isOk) => { + if (isOk) { + resolve ( response ) + } else { + reject (response) + } + }) + } + catch (err) { + reject(err) + } + }) + } + registerUser (userToken, userData) { return new Promise(async (resolve, reject) => { try {