From b189f5b6d2af40cf879b6a401d06c921c89243f2 Mon Sep 17 00:00:00 2001 From: Gianfranco Manganiello Date: Mon, 15 Jan 2018 17:00:46 -0400 Subject: [PATCH] feat(GlpiRestClient): create function of initSessionByCredentials --- src/restclient.js | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/src/restclient.js b/src/restclient.js index 72df08d..b1b86b4 100644 --- a/src/restclient.js +++ b/src/restclient.js @@ -45,6 +45,32 @@ class GlpiRestClient { }) } + initSessionByCredentials (userName, userPassword) { + return new Promise((resolve, reject) => { + try { + const data = { + function: 'initSessionByCredentials', + endpoint: 'initSession', + method: 'GET', + url: this._url, + appToken: this._appToken, + userName, + userPassword + } + + const myRequest = prepareRequest(data) + + this._makeRequest(myRequest, (response) => { + resolve ( + response + ) + }) + } + catch (err) { + reject(err) + } + }) + } } export default GlpiRestClient