listSearchOptions method Null safety
- GlpiItemType itemType
Return all the searchOptions usable in searchItems criteria for a given GlpiItemType.
Implementation
Future<Map<String, dynamic>> listSearchOptions(GlpiItemType itemType) 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 uri = Uri.parse(
'$baseUrl/listSearchOptions/${itemType.toString().split('.').last}');
final response = await http.get(uri, headers: headers);
if (response.statusCode != 200 && response.statusCode != 206) {
throw GlpiException.fromResponse(
response.statusCode, json.decode(response.body));
}
return Future.value(json.decode(response.body));
}