import 'package:dio/dio.dart'; import '../../core/exceptions.dart'; import 'api_client.dart'; class AuthApi { final Dio _dio; const AuthApi(this._dio); Future login(String username, String password) async { try { await _dio.post('/api/auth/login', data: { 'username': username, 'password': password, }); } on DioException catch (e) { if (e.response?.statusCode == 401) { throw const AuthException('Invalid username or password.'); } throw dioToApp(e); } } Future logout() async { try { await _dio.post('/api/auth/logout'); } on DioException catch (e) { throw dioToApp(e); } } Future verify() async { try { await _dio.get('/api/auth/me'); return true; } on DioException catch (e) { if (e.response?.statusCode == 401) return false; throw dioToApp(e); } } Future> getStatus() async { try { final response = await _dio.get('/api/auth/status'); return response.data as Map; } on DioException catch (e) { throw dioToApp(e); } } }