import 'dart:convert'; 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 getProfileBySlug(String slug) async { try { return await profileService.getProfileBySlug(slug: slug); } catch (e) { rethrow; } } Future getProfileDetailsBySlug(String slug) async { try { return await profileService.getProfileDetailsBySlug(slug: slug); } catch (e) { rethrow; } } Future getMyProfile() async { try { return await profileService.getMyProfile(); } catch (e) { rethrow; } } Future getMyProfileDetails() async { try { return await profileService.getMyProfileDetails(); } catch (e) { rethrow; } } Future 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 addWeight({ required double weight, }) async { try { return (await profileService.addWeight(weight: weight)); } catch (e) { rethrow; } } Future> getBlogPostsByAuthorSlug({ required String slug, }) async { try { return (await profileService.getBlogPostByAuthorSlug( slug: slug, )); } catch (e) { rethrow; } } Future> 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> 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> getSubscribersBySlug(String slug, [String? query]) async { try { return (await profileService.getSubscribers(slug: slug, query: query)).data; } catch (e) { rethrow; } } Future> getSubscriptionsBySlug(String slug, [String? query]) async { try { return (await profileService.getSubscriptions(slug: slug, query: query)).data; } catch (e) { rethrow; } } Future subscribe(String slug) async { try { return await profileService.subscribe(slug: slug); } catch (e) { rethrow; } } Future unsubscribe(String slug) async { try { return await profileService.unsubscribe(slug: slug); } catch (e) { rethrow; } } Future uploadPhoto(File file) async { try { return await profileService.uploadPhoto(photo: file); } catch (e) { rethrow; } } Future deletePhoto() async { try { return await profileService.deletePhoto(); } catch (e) { rethrow; } } Future> getChosenDiets() async { try { return (await profileService.getChosenDiets()).diets; } catch (e) { rethrow; } } Future getPassKey(String phone) async { return (jsonDecode( (await profileService.getPassKey(json: '{"route_name": "user_detailz.change-phone-verify", "route_params": {"phone": "$phone"}}'))))['key_is']!; } Future getMyPhone() async { return (jsonDecode(await profileService.getMyPhone())['phone']); } Future sendEmailCode() async { return await profileService.sendEmailCode(); } Future tryVerifyEmailByCode(String code) async { try { await profileService.tryVerifyEmailByCode(code: "{\"code\": \"$code\"}"); return true; } catch (e) { return false; } } }