changeActiveProfile method Null safety
- int profilesId
override
Change the active profile for the current user. Will throw an Exception if the request fails or if the selected id is incorrect. Reference: https://github.com/glpi-project/glpi/blob/master/apirest.md#change-active-profile.
Implementation
@override
Future<bool> changeActiveProfile(int profilesId) 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.post(
Uri.parse('$host/changeActiveProfile'),
headers: headers,
body: json.encode({'profiles_id': profilesId}),
);
if (_response.statusCode != 200) {
throw Exception('${_response.statusCode} ${_response.body}');
}
return true;
}