getMyEntities method Null safety
- {bool isRecursive = false}
Return the entities list for the current user.
Setting isRecursive
to true will get the list of all the entities and sub-entities.
Entities are under the key myentities
Reference: https://github.com/glpi-project/glpi/blob/master/apirest.md#get-my-entities
Implementation
Future<Map<String, dynamic>> getMyEntities({bool isRecursive = false}) async {
if (_sessionToken == null) {
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/getMyEntities?is_recursive=$isRecursive'),
headers: headers);
if (_response.statusCode != 200) {
throw Exception('${_response.statusCode} ${_response.body}');
}
return json.decode(_response.body);
}