forked from eatvio/eatvio_app
67 lines
2.1 KiB
Dart
67 lines
2.1 KiB
Dart
import 'package:eatvio_app/features/profile/models/profile_model.dart';
|
|
import 'package:eatvio_app/features/settings/models/oauth_account_model.dart';
|
|
import 'package:eatvio_app/features/settings/models/oauth_attach_request.dart';
|
|
import 'package:eatvio_app/features/settings/models/profile_settings_model.dart';
|
|
import 'package:eatvio_app/features/settings/services/settings_service.dart';
|
|
import 'package:sentry_flutter/sentry_flutter.dart';
|
|
|
|
class SettingsRepository {
|
|
final SettingsService settingsService;
|
|
|
|
const SettingsRepository({required this.settingsService});
|
|
|
|
Future<ProfileSettingsModel> getProfileSettings() async {
|
|
try {
|
|
return await settingsService.getProfileSettings();
|
|
} catch (e, s) {
|
|
await Sentry.captureException(e, stackTrace: s);
|
|
rethrow;
|
|
}
|
|
}
|
|
|
|
Future<ProfileSettingsModel> updateProfileSettings({required ProfileSettingsModel profileSettingsModel}) async {
|
|
try {
|
|
return await settingsService.updateProfileSettings(data: profileSettingsModel.toJson());
|
|
} catch (e, s) {
|
|
await Sentry.captureException(e, stackTrace: s);
|
|
rethrow;
|
|
}
|
|
}
|
|
|
|
Future<ProfileDetailsModel> updateProfileDetails({required ProfileDetailsModel profileDetailsModel}) async {
|
|
try {
|
|
return await settingsService.updateProfileDetails(data: profileDetailsModel.toJson());
|
|
} catch (e, s) {
|
|
await Sentry.captureException(e, stackTrace: s);
|
|
rethrow;
|
|
}
|
|
}
|
|
|
|
Future<OAuthAccountsResponseModel> getOAuthAccounts() async {
|
|
try {
|
|
return await settingsService.getOAuthAccounts();
|
|
} catch (e, s) {
|
|
await Sentry.captureException(e, stackTrace: s);
|
|
rethrow;
|
|
}
|
|
}
|
|
|
|
Future<void> linkOAuthAccount({required OAuthAttachRequest request}) async {
|
|
try {
|
|
return await settingsService.linkOAuthAccount(request);
|
|
} catch (e, s) {
|
|
await Sentry.captureException(e, stackTrace: s);
|
|
rethrow;
|
|
}
|
|
}
|
|
|
|
Future<void> unlinkOAuthAccount({required String provider}) async {
|
|
try {
|
|
return await settingsService.unlinkOAuthAccount(provider);
|
|
} catch (e, s) {
|
|
await Sentry.captureException(e, stackTrace: s);
|
|
rethrow;
|
|
}
|
|
}
|
|
}
|