getNameChangeInfo function

Future<ProfileNameChangeInfo> getNameChangeInfo(
  1. String accessToken
)

Implementation

Future<ProfileNameChangeInfo> getNameChangeInfo(String accessToken) async {
  final headers = {
    'authorization': 'Bearer $accessToken',
  };
  final response = await request(
      http.get, _minecraftServicesApi, '/minecraft/profile/namechange',
      headers: headers);

  if (response.statusCode == 401) {
    throw AuthException(AuthException.invalidCredentialsMessage);
  }
  final map = parseResponseMap(response);
  return ProfileNameChangeInfo(DateTime.parse(map['changedAt']),
      DateTime.parse(map['createdAt']), map['nameChangeAllowed']);
}