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 {
  await authenticator.checkAuthentication();

  final url = Uri.parse('${options.environment.url}/api/users/me');
  final response =
      await _client.get(url, headers: _createHeadersWithDefaults(headers));
  if (response.statusCode >= 400) {
    throw response;
  }
  return User.fromJson(json.decode(response.body));
}