forked from eatvio/eatvio_app
74 lines
1.7 KiB
Dart
74 lines
1.7 KiB
Dart
import 'package:eatvio_app/features/profile/models/profile_model.dart';
|
|
import 'package:eatvio_app/features/settings/models/profile_settings_model.dart';
|
|
import 'package:eatvio_app/features/settings/services/settings_service.dart';
|
|
|
|
class SettingsRepository {
|
|
final SettingsService settingsService;
|
|
|
|
const SettingsRepository({required this.settingsService});
|
|
|
|
Future<ProfileSettingsModel> getProfileSettings() async {
|
|
try {
|
|
return await settingsService.getProfileSettings();
|
|
} catch (e) {
|
|
rethrow;
|
|
}
|
|
}
|
|
|
|
Future<ProfileSettingsModel> updateProfileSettings({
|
|
required ProfileSettingsModel profileSettingsModel,
|
|
}) async {
|
|
try {
|
|
return await settingsService.updateProfileSettings(
|
|
data: profileSettingsModel.toJson(),
|
|
);
|
|
} catch (e) {
|
|
rethrow;
|
|
}
|
|
}
|
|
|
|
Future<ProfileDetailsModel> updateProfileDetails({
|
|
required ProfileDetailsModel profileDetailsModel,
|
|
}) async {
|
|
try {
|
|
return await settingsService.updateProfileDetails(
|
|
data: profileDetailsModel.toJson(),
|
|
);
|
|
} catch (e) {
|
|
rethrow;
|
|
}
|
|
}
|
|
|
|
Future<void> sendEmailCodeForPasswordChange(String email) async {
|
|
try {
|
|
return await settingsService.sendEmailCodeForPasswordChange(
|
|
data: {
|
|
'email': email,
|
|
},
|
|
);
|
|
} catch (e) {
|
|
rethrow;
|
|
}
|
|
}
|
|
|
|
Future<void> confirmPasswordChange(
|
|
String code,
|
|
String password,
|
|
String passwordConfirmation,
|
|
String email,
|
|
) async {
|
|
try {
|
|
return await settingsService.confirmPasswordChange(
|
|
data: {
|
|
'code': code,
|
|
'password': password,
|
|
'password_confirmation': passwordConfirmation,
|
|
'email': email,
|
|
},
|
|
);
|
|
} catch (e) {
|
|
rethrow;
|
|
}
|
|
}
|
|
}
|