getActiveProfile method Null safety
Return the current active profile for the current user as a Map
Reference: https://github.com/glpi-project/glpi/blob/master/apirest.md#get-active-profile
Implementation
Future<Map<String, dynamic>> getActiveProfile() 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/getActiveProfile'),
headers: headers);
if (_response.statusCode != 200) {
throw Exception('${_response.statusCode} ${_response.body}');
}
return json.decode(_response.body);
}