31 lines
920 B
Dart
31 lines
920 B
Dart
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
|
import '../../../core/api/api_client.dart';
|
|
import '../../../core/api/guarded_api_call.dart';
|
|
import '../../../core/api/api_exception.dart';
|
|
import '../../auth/data/auth_providers.dart';
|
|
|
|
final profileRepositoryProvider = Provider<ProfileRepository>((ref) {
|
|
final apiClient = ref.read(apiClientProvider);
|
|
return ProfileRepository(apiClient, ref);
|
|
});
|
|
|
|
class ProfileRepository {
|
|
final ApiClient _apiClient;
|
|
final Ref _ref;
|
|
|
|
ProfileRepository(this._apiClient, this._ref);
|
|
|
|
Future<Map<String, dynamic>> getProfile() async {
|
|
return guardedApiCall(
|
|
_ref,
|
|
() => _apiClient.getJson('/api/profile'),
|
|
);
|
|
}
|
|
|
|
Future<Map<String, dynamic>> updateProfile(Map<String, dynamic> profileData) async {
|
|
return guardedApiCall(
|
|
_ref,
|
|
() => _apiClient.patchJson('/api/profile', profileData),
|
|
);
|
|
}
|
|
} |