getMyEntities method Null safety

  1. @override
Future<Map<String, dynamic>> getMyEntities(
  1. {bool isRecursive = false}
)
override

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

@override
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 _innerClient.get(
      Uri.parse('$host/getMyEntities?is_recursive=$isRecursive'),
      headers: headers);

  if (_response.statusCode != 200) {
    throw Exception('${_response.statusCode} ${_response.body}');
  }

  return json.decode(_response.body);
}