getMe method

Future<User> getMe({
  1. Map<String, String> headers = const {},
})

Get the User that is authenticated

headers will be added in addition to ApptiveGridClient.defaultHeaders

Requires Authorization throws Response if the request fails

Implementation

Future<User> getMe({
  Map<String, String> headers = const {},
}) async {
  // Always check for authentication here
  // as there is no way of loading the currently logged in user without being logged in
  await authenticator.checkAuthentication();

  final url = Uri.parse('${options.environment.url}/api/users/me');
  return (await performApptiveLink<User>(
    link: ApptiveLink(uri: url, method: 'get'),
    headers: headers,
    parseResponse: (response) async =>
        User.fromJson(json.decode(response.body)),
  ))!;
}