| 1 | import 'package:dio/dio.dart'; |
| 2 | import 'package:openapi/openapi.dart'; |
| 3 | import 'package:aero/constants/main.dart'; |
| 4 | import 'package:aero/services/main.dart'; |
| 5 | import 'package:aero/utils/error.dart'; |
| 6 | |
| 7 | class ProfileService { |
| 8 | final Dio _dio; |
| 9 | final _profileApi = openapi.getProfileApi |
| 10 | |
| 11 | ProfileService() : _dio = Dio |
| 12 | // Add interceptors for logging |
| 13 | _dio.interceptors.add(LogInterceptor |
| 14 | requestBody: true, |
| 15 | responseBody: true, |
| 16 | error: true, |
| 17 | )); |
| 18 | } |
| 19 | |
| 20 | Future<ProfileStatsResponseEntity?> getProfileStats |
| 21 | try { |
| 22 | final response = await _profileApi. |
| 23 | return response.data; |
| 24 | } catch (e) { |
| 25 | if (e is DioException) { |
| 26 | throw ApiException(message: getErrorMessage |
| 27 | } |
| 28 | throw ApiException( |
| 29 | message: 'Failed to fetch profile stats: $e', |
| 30 | ); |
| 31 | } |
| 32 | } |
| 33 | } |
| 34 | |