Files
eatvio_app/lib/features/profile/repositories/profile_repository.dart
Username1548 4242265830 new test cases
2025-01-29 14:47:27 +07:00

184 lines
4.2 KiB
Dart

import 'dart:io';
import 'package:eatvio_app/features/feed/models/feed_blog_post_model.dart';
import 'package:eatvio_app/features/profile/models/chosen_diets_pagination_model.dart';
import 'package:eatvio_app/features/profile/models/circumference_model.dart';
import 'package:eatvio_app/features/profile/models/profile_model.dart';
import 'package:eatvio_app/features/profile/models/sub_model.dart';
import 'package:eatvio_app/features/profile/models/weight_model.dart';
import 'package:eatvio_app/features/profile/services/profile_service.dart';
class ProfileRepository {
final ProfileService profileService;
ProfileRepository({
required this.profileService,
});
Future<ProfileModel> getProfileBySlug(String slug) async {
try {
return await profileService.getProfileBySlug(slug: slug);
} catch (e) {
rethrow;
}
}
Future<ProfileDetailsModel> getProfileDetailsBySlug(String slug) async {
try {
return await profileService.getProfileDetailsBySlug(slug: slug);
} catch (e) {
rethrow;
}
}
Future<ProfileModel> getMyProfile() async {
try {
return await profileService.getMyProfile();
} catch (e) {
rethrow;
}
}
Future<ProfileDetailsModel> getMyProfileDetails() async {
try {
return await profileService.getMyProfileDetails();
} catch (e) {
rethrow;
}
}
Future<void> addCircumference({
required int chestCircumference,
required int waistCircumference,
required int hipCircumference,
}) async {
try {
return (await profileService.addCircumference(
chestCircumference: chestCircumference,
waistCircumference: waistCircumference,
hipCircumference: hipCircumference,
));
} catch (e) {
rethrow;
}
}
Future<void> addWeight({
required double weight,
}) async {
try {
return (await profileService.addWeight(weight: weight));
} catch (e) {
rethrow;
}
}
Future<List<FeedBlogPostModel>> getBlogPostsByAuthorSlug({
required String slug,
}) async {
try {
return (await profileService.getBlogPostByAuthorSlug(
slug: slug,
));
} catch (e) {
rethrow;
}
}
Future<List<WeightModel>> getWeight({
required String period,
String? slug,
}) async {
try {
if (slug != null) {
return (await profileService.getWeightBySlug(
period: period,
slug: slug,
));
} else {
return (await profileService.getWeight(
period: period,
));
}
} catch (e) {
rethrow;
}
}
Future<List<CircumferenceModel>> getCircumferences({
required String period,
String? slug,
}) async {
try {
if (slug != null) {
return (await profileService.getCircumferencesBySlug(
period: period,
slug: slug,
));
} else {
return (await profileService.getCircumferences(
period: period,
));
}
} catch (e) {
rethrow;
}
}
Future<List<SubModel>> getSubscribersBySlug(String slug, [String? query]) async {
try {
return (await profileService.getSubscribers(slug: slug, query: query)).data;
} catch (e) {
rethrow;
}
}
Future<List<SubModel>> getSubscriptionsBySlug(String slug, [String? query]) async {
try {
return (await profileService.getSubscriptions(slug: slug, query: query)).data;
} catch (e) {
rethrow;
}
}
Future<void> subscribe(String slug) async {
try {
return await profileService.subscribe(slug: slug);
} catch (e) {
rethrow;
}
}
Future<void> unsubscribe(String slug) async {
try {
return await profileService.unsubscribe(slug: slug);
} catch (e) {
rethrow;
}
}
Future<void> uploadPhoto(File file) async {
try {
return await profileService.uploadPhoto(photo: file);
} catch (e) {
rethrow;
}
}
Future<void> deletePhoto() async {
try {
return await profileService.deletePhoto();
} catch (e) {
rethrow;
}
}
Future<List<ChosenDietModel>> getChosenDiets() async {
try {
return (await profileService.getChosenDiets()).diets;
} catch (e) {
rethrow;
}
}
}