getUserProfile method

Future<UAEPASSUserProfile?> getUserProfile(
  1. String token
)

Get profile information

token: The authorization token obtained during the authentication process.

Returns a UAEPASSUserProfile representing the profile info.

Implementation

Future<UAEPASSUserProfile?> getUserProfile(String token) async {
  try {
    const String url = "/idshub/userinfo";

    final response = await http.get(
      Uri.parse(Const.baseUrl(_isProduction) + url),
      headers: <String, String>{
        'Content-Type': 'application/x-www-form-urlencoded',
        'Authorization': 'Bearer $token'
      },
    );

    if (response.statusCode == 200) {
      return UAEPASSUserProfile.fromJson(jsonDecode(response.body));
    } else {
      return null;
    }
  } catch (e, s) {
    if (kDebugMode) {
      print(e);
      print(s);
    }
  }
  return null;
}