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

Commit 5351b4b

Browse files
committed
feat: First endpoints
1 parent 0491005 commit 5351b4b

File tree

8 files changed

+716
-43
lines changed

8 files changed

+716
-43
lines changed

README.md

+20-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
#
1+
# Warning
2+
3+
This library is WIP, created to develop Flyve MDM.
24

35
# How to install
46

@@ -12,4 +14,20 @@ composer require glpi-project/rest-api-client
1214
use GlpiProject\API\Rest\Client;
1315
use GuzzleHttp\Client as HttpClient;
1416

15-
$client = new Client.php(new HttpClient(['base_uri' => "http://localhost/glpi/apirest.php/"]));
17+
// Instanciate the API client
18+
$client = new Client(new HttpClient(), 'http://localhost/glpi/apirest.php/');
19+
20+
// Authenticate
21+
if (!$client->initSessionByCredentials('glpi', 'glpi')) {
22+
die('failed to authenticate');
23+
}
24+
25+
// The client handles the session token for you (app token not yet supported)
26+
27+
// do something
28+
try {
29+
$response = $client->computer('post', ['name' => 'computer 0001']);
30+
} catch (\Exception $e) {
31+
// Handle here HTTP >= 400
32+
}
33+
```

composer.json

+29-28
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,32 @@
11
{
2-
"name" : "glpi-project/rest-api-client",
3-
"type" : "library",
4-
"description" : "Client for GLPI rest API",
5-
"keywords" : [
6-
"GLPI",
7-
"rest",
2+
"name" : "glpi-project/rest-api-client",
3+
"type" : "library",
4+
"description" : "Client for GLPI rest API",
5+
"keywords" : [
6+
"GLPI",
7+
"rest",
88
"api",
99
"client"
10-
],
11-
"homepage" : "https://github.com/glpi-project/rest-api-client",
12-
"license" : "GPL-3.0+",
13-
"authors" : [{
14-
"name" : "Thierry Bugier",
15-
"email" : "tbugier@teclib.com",
16-
"role" : "Developer"
17-
}
18-
],
19-
"require" : {
20-
"php" : ">=5.6.0",
21-
"guzzlehttp/guzzle": "^6.3"
22-
},
23-
"require-dev" : {
24-
"atoum/atoum" : "^3.1"
25-
},
26-
"autoload" : {
27-
"psr-4" : {
28-
"GlpiProject\\API\\Rest\\" : "src/GlpiProject/API/Rest/"
29-
}
30-
}
31-
}
10+
],
11+
"homepage" : "https://github.com/glpi-project/rest-api-client",
12+
"license" : "GPL-3.0+",
13+
"authors" : [{
14+
"name" : "Thierry Bugier",
15+
"email" : "tbugier@teclib.com",
16+
"role" : "Developer"
17+
}
18+
],
19+
"require" : {
20+
"php" : ">=5.6.0",
21+
"guzzlehttp/guzzle" : "^6.3"
22+
},
23+
"require-dev" : {
24+
"atoum/atoum" : "^3.1"
25+
},
26+
"autoload" : {
27+
"psr-4" : {
28+
"GlpiProject\\API\\Rest\\" : "src/GlpiProject/API/Rest/",
29+
"GlpiProject\\API\\Rest\\Exception\\" : "src/GlpiProject/API/Rest/Exception/"
30+
}
31+
}
32+
}

0 commit comments

Comments
 (0)