getUserProfilePicture method Null safety
- int id
override
Get a user's profile picture.
id
must be the id of the user to get the picture.
Reference: https://github.com/glpi-project/glpi/blob/master/apirest.md#get-a-users-profile-picture
Implementation
@override
Future<String> getUserProfilePicture(int id) 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('$host/User/$id/Picture');
final response = await _innerClient.get(uri, headers: headers);
if (response.statusCode != 200 && response.statusCode != 207) {
throw GlpiException.fromResponse(
response.statusCode, json.decode(response.body));
}
return Future.value(response.body);
}