getMyProfiles method Null safety

  1. @override
Future<Map<String, dynamic>> getMyProfiles()
override

Return a Map of all the profile for the current user Profiles are under the key myprofiles Reference: https://github.com/glpi-project/glpi/blob/master/apirest.md#get-my-profiles.

Implementation

@override
Future<Map<String, dynamic>> getMyProfiles() 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/getMyProfiles'),
      headers: headers);

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

  return json.decode(_response.body);
}