get method

Gets the current session.

Returns an AuthResponse containing the current Session.

Example:

final response = await authClient.session.get();
if (response.isSuccess) {
  print('Session expires: ${response.data!.expiresAt}');
}

Implementation

Future<AuthResponse<Session>> get() async {
  try {
    final response = await _dio.get(ApiEndpoints.getSession);
    final session = Session.fromJson(response.data['session'] ?? response.data);
    return AuthResponse.success(session);
  } on DioException catch (e) {
    return AuthResponse.error(AuthError.fromDio(e));
  }
}