Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Basic endpoints #13

Merged
merged 43 commits into from
Oct 25, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
4b508c4
build(git): add .gitignore
Gianfranco97 Oct 16, 2017
4321ba4
build(test): add mocha and chai for tests
Gianfranco97 Oct 16, 2017
a8560a6
refactor(restclient): change URL API legacy for WHATWG URL API
Gianfranco97 Oct 16, 2017
8ac94d5
docs(initSessionByCredentials): create example code
Gianfranco97 Oct 16, 2017
7b2d42e
test(initSessionByCredentials): create test
Gianfranco97 Oct 16, 2017
f32f488
fix(restclient): to fix login with basic auth
Gianfranco97 Oct 17, 2017
dde935d
refactor(restclient): add the status code of the response
Gianfranco97 Oct 17, 2017
2158fa8
refactor(restclient): change the request get function to a generic
Gianfranco97 Oct 17, 2017
21f3c7e
refactor(initSessionByCredentials): add App-Token as a functional par…
Gianfranco97 Oct 17, 2017
519099f
feat(restclient): add initSessionByUserToken function
Gianfranco97 Oct 17, 2017
4a1189d
test(initSessionByCredentials): successful login
Gianfranco97 Oct 17, 2017
bbc8419
test(initSessionByUserToken): successful login
Gianfranco97 Oct 17, 2017
960550e
refactor(restclient): change type of data returned by promises
Gianfranco97 Oct 17, 2017
eac65b0
ci(circle): run test with npm
Gianfranco97 Oct 17, 2017
02bb2df
ci(circle): create script that generates a configuration file
Gianfranco97 Oct 18, 2017
9718398
feat(sessionToken): add the session Token when login
Gianfranco97 Oct 18, 2017
6cb962a
docs(examples): add code example of killSession
Gianfranco97 Oct 18, 2017
2ab1791
refactor(killSession): validate user initialized
Gianfranco97 Oct 18, 2017
2e0c232
test(killSession): log out successfully
Gianfranco97 Oct 18, 2017
5e73c1a
refactor(killSession): change to a promise
Gianfranco97 Oct 18, 2017
41a9083
feat(restclient): add getMyProfiles function
Gianfranco97 Oct 18, 2017
5dda8cd
docs(examples): add code example of getMyProfiles
Gianfranco97 Oct 18, 2017
9b06596
test(getMyProfiles): get my profiles successfully
Gianfranco97 Oct 18, 2017
8dfd731
feat(restclient): add getActiveProfile function
Gianfranco97 Oct 18, 2017
deb49ca
docs(examples): add code example of getActiveProfile
Gianfranco97 Oct 18, 2017
43e94ef
test(getActiveProfile): get active profile successfully
Gianfranco97 Oct 18, 2017
4c1ef1e
refactor(restclient): improve the request data of the class
Gianfranco97 Oct 18, 2017
ea55d33
fix(restclient): pass missing data on functions and validate options
Gianfranco97 Oct 18, 2017
e74ef0b
feat(restclient): add getMyEntities function
Gianfranco97 Oct 18, 2017
0edfbd8
docs(examples): add code example of getMyEntities
Gianfranco97 Oct 18, 2017
873f8c6
test(getMyEntities): get my entities successfully
Gianfranco97 Oct 18, 2017
34a7b54
feat(restclient): add getActiveEntities function
Gianfranco97 Oct 18, 2017
cffa17f
docs(examples): add code example of getActiveEntities
Gianfranco97 Oct 18, 2017
6f61477
test(getActiveEntities): get active entities successfully
Gianfranco97 Oct 18, 2017
f69c34a
feat(restclient): add getFullSession function
Gianfranco97 Oct 18, 2017
a209f57
docs(examples): add code example of getFullSession
Gianfranco97 Oct 18, 2017
d10f3f1
test(getFullSession): get full session successfully
Gianfranco97 Oct 18, 2017
9b9c540
feat(restclient): add getGlpiConfig function
Gianfranco97 Oct 18, 2017
084b647
docs(examples): add code example of getGlpiConfig
Gianfranco97 Oct 18, 2017
1cb08d8
test(getGlpiConfig): get gpli configuration successfully
Gianfranco97 Oct 18, 2017
15f6a14
feat(restclient): add getAllItems function
Gianfranco97 Oct 19, 2017
126746a
docs(examples): add code example of getAllItems
Gianfranco97 Oct 19, 2017
30a25bd
test(getAllItems): get all items of a type successfully
Gianfranco97 Oct 19, 2017
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
version: 2
jobs:
build:
working_directory: ~/node-module-glpi
docker:
- image: circleci/node:8.5
steps:
- checkout
- restore_cache:
key: dependency-cache-{{ checksum "package.json" }}
- run:
name: install-npm-wee
command: npm install
- save_cache:
key: dependency-cache-{{ checksum "package.json" }}
paths:
- ./node_modules
- run:
name: generate a configuration file
command: ci/create-config-file.sh
- run:
name: test
command: npm test
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
node_modules/
.DS_Store
config.json
6 changes: 6 additions & 0 deletions ci/create-config-file.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
mv ./{config.example,config}.json
sed -i -e "s|http://example.com/glpi/apirest.php|${APIREST_URL}|g" config.json
sed -i -e "s|exampleName|${USER_NAME}|g" config.json
sed -i -e "s|examplePassword|${USER_PASSWORD}|g" config.json
sed -i -e "s|exampleUserToken|${USER_TOKEN}|g" config.json
sed -i -e "s|exampleAppToken|${APP_TOKEN}|g" config.json
9 changes: 9 additions & 0 deletions config.example.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"apirest": "http://example.com/glpi/apirest.php",
"user": {
"name": "exampleName",
"password": "examplePassword",
"userToken": "exampleUserToken"
},
"appToken": "exampleAppToken"
}
19 changes: 0 additions & 19 deletions example/example-001.js

This file was deleted.

18 changes: 18 additions & 0 deletions example/example-getActiveEntities.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
const GlpiRestClient = require('../lib/restclient')
const config = require('../config.json')

const client = new GlpiRestClient(config.apirest)

client.initSessionByCredentials(config.user.name, config.user.password, config.appToken)
.then((res) => {
client.getActiveEntities()
.then((res2) => {
console.log(res2)
})
.catch((err2) => {
console.log(err2)
})
})
.catch((err) => {
console.log(err)
})
18 changes: 18 additions & 0 deletions example/example-getActiveProfile.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
const GlpiRestClient = require('../lib/restclient')
const config = require('../config.json')

const client = new GlpiRestClient(config.apirest)

client.initSessionByCredentials(config.user.name, config.user.password, config.appToken)
.then((res) => {
client.getActiveProfile()
.then((res2) => {
console.log(res2)
})
.catch((err2) => {
console.log(err2)
})
})
.catch((err) => {
console.log(err)
})
19 changes: 19 additions & 0 deletions example/example-getAllItems.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
const GlpiRestClient = require('../lib/restclient')
const config = require('../config.json')
const itemtype = require('../lib/itemtype')

const client = new GlpiRestClient(config.apirest)

client.initSessionByCredentials(config.user.name, config.user.password, config.appToken)
.then((res) => {
client.getAllItems(itemtype.User)
.then((res2) => {
console.log(res2)
})
.catch((err2) => {
console.log(err2)
})
})
.catch((err) => {
console.log(err)
})
18 changes: 18 additions & 0 deletions example/example-getFullSession.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
const GlpiRestClient = require('../lib/restclient')
const config = require('../config.json')

const client = new GlpiRestClient(config.apirest)

client.initSessionByCredentials(config.user.name, config.user.password, config.appToken)
.then((res) => {
client.getFullSession()
.then((res2) => {
console.log(res2)
})
.catch((err2) => {
console.log(err2)
})
})
.catch((err) => {
console.log(err)
})
18 changes: 18 additions & 0 deletions example/example-getGlpiConfig.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
const GlpiRestClient = require('../lib/restclient')
const config = require('../config.json')

const client = new GlpiRestClient(config.apirest)

client.initSessionByCredentials(config.user.name, config.user.password, config.appToken)
.then((res) => {
client.getGlpiConfig()
.then((res2) => {
console.log(res2)
})
.catch((err2) => {
console.log(err2)
})
})
.catch((err) => {
console.log(err)
})
18 changes: 18 additions & 0 deletions example/example-getMyEntities.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
const GlpiRestClient = require('../lib/restclient')
const config = require('../config.json')

const client = new GlpiRestClient(config.apirest)

client.initSessionByCredentials(config.user.name, config.user.password, config.appToken)
.then((res) => {
client.getMyEntities()
.then((res2) => {
console.log(res2)
})
.catch((err2) => {
console.log(err2)
})
})
.catch((err) => {
console.log(err)
})
18 changes: 18 additions & 0 deletions example/example-getMyProfiles.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
const GlpiRestClient = require('../lib/restclient')
const config = require('../config.json')

const client = new GlpiRestClient(config.apirest)

client.initSessionByCredentials(config.user.name, config.user.password, config.appToken)
.then((res) => {
client.getMyProfiles()
.then((res2) => {
console.log(res2)
})
.catch((err2) => {
console.log(err2)
})
})
.catch((err) => {
console.log(err)
})
12 changes: 12 additions & 0 deletions example/example-initSessionByCredentials.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
const GlpiRestClient = require('../lib/restclient')
const config = require('../config.json')

const client = new GlpiRestClient(config.apirest)

client.initSessionByCredentials(config.user.name, config.user.password, config.appToken)
.then((res) => {
console.log(res)
})
.catch((err) => {
console.log(err)
})
12 changes: 12 additions & 0 deletions example/example-initSessionByUserToken.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
const GlpiRestClient = require('../lib/restclient')
const config = require('../config.json')

const client = new GlpiRestClient(config.apirest)

client.initSessionByUserToken(config.user.userToken, config.appToken)
.then((res) => {
console.log(res)
})
.catch((err) => {
console.log(err)
})
18 changes: 18 additions & 0 deletions example/example-killSession.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
const GlpiRestClient = require('../lib/restclient')
const config = require('../config.json')

const client = new GlpiRestClient(config.apirest)

client.initSessionByCredentials(config.user.name, config.user.password, config.appToken)
.then((res) => {
client.killSession()
.then((res2) => {
console.log(res2)
})
.catch((err2) => {
console.log(err2)
})
})
.catch((err) => {
console.log(err)
})
11 changes: 0 additions & 11 deletions lib/item.js

This file was deleted.

Loading