getGlpiConfig method Null safety
Return the Glpi instance configuration data inside a Map
.
Reference: https://github.com/glpi-project/glpi/blob/master/apirest.md#get-glpi-config
Implementation
Future<Map<String, dynamic>> getGlpiConfig() async {
if (_sessionToken!.isEmpty) {
throw Exception('No session token, initSession first');
}
final Map<String, String> headers = {
'Session-Token': _sessionToken!,
'Content-Type': 'application/json',
...?appToken != null ? {'App-Token': appToken!} : null,
};
final response =
await http.get(Uri.parse('$baseUrl/getGlpiConfig'), headers: headers);
if (response.statusCode != 200) {
throw GlpiException.fromResponse(
response.statusCode, json.decode(response.body));
}
return json.decode(response.body);
}