forked from eatvio/eatvio_app
124 lines
4.2 KiB
Dart
124 lines
4.2 KiB
Dart
import 'package:eatvio_app/features/feed/models/comment_model.dart';
|
|
import 'package:eatvio_app/features/feed/models/diets_pagination_model.dart';
|
|
import 'package:eatvio_app/features/feed/models/feed_blog_post_model.dart';
|
|
import 'package:eatvio_app/features/feed/models/feed_consultant_model.dart';
|
|
import 'package:eatvio_app/features/feed/models/plan_pagination_model.dart';
|
|
import 'package:eatvio_app/features/feed/models/post_feed_mapper.dart';
|
|
import 'package:eatvio_app/features/feed/models/recipes_model.dart';
|
|
import 'package:eatvio_app/features/feed/models/view_model.dart';
|
|
import 'package:eatvio_app/features/feed/services/feed_service.dart';
|
|
|
|
class FeedRepository {
|
|
final FeedService feedService;
|
|
|
|
FeedRepository({required this.feedService});
|
|
|
|
Future<({List<FeedBlogPostModel> posts, String? nextCursor})> getFeed({String? search, String? cursor, int? currentUserId}) async {
|
|
final response = await feedService.getFeed(search: search, cursor: cursor);
|
|
return (
|
|
posts: response.data.map((item) => PostFeedMapper.fromPostFeedItem(item, currentUserId: currentUserId)).toList(),
|
|
nextCursor: response.meta.nextCursor,
|
|
);
|
|
}
|
|
|
|
Future<FeedBlogPostModel> getBlogPost({required int id}) async {
|
|
return await feedService.getBlogPost(postId: id);
|
|
|
|
}
|
|
|
|
Future<List<Recipe>> getRecipes({String? query, List<int>? tags, int page = 1}) async {
|
|
return (await feedService.getRecipes(query: query, tags: tags, page: page)).recipesList;
|
|
|
|
}
|
|
|
|
Future<DietsPagination> getDiets({int page = 1, String? query, String? types, int? duration, String? sorting}) async {
|
|
return (await feedService.getDiets(page: page, query: query, types: types, duration: duration, sorting: sorting));
|
|
|
|
}
|
|
|
|
Future<PlanPaginationModel> getPlans({int page = 1, String? query, String? types, int? duration, int? minPrice, int? maxPrice}) async {
|
|
return (await feedService.getPlans(page: page, query: query, types: types, duration: duration, minPrice: minPrice, maxPrice: maxPrice));
|
|
|
|
}
|
|
|
|
Future<CommentModel> getBlogPostComments({required String id}) async {
|
|
return (await feedService.getBlogPostComments(id: id));
|
|
|
|
}
|
|
|
|
Future<void> sendBlogPostComment({required String id, required String commentText, int? parentCommentId}) async {
|
|
await feedService.sendBlogPostComment(id: id, body: commentText, parentCommentId: parentCommentId);
|
|
|
|
}
|
|
|
|
Future<CommentModel> getDietsComments({required String id}) async {
|
|
return (await feedService.getDietsComments(id: id));
|
|
|
|
}
|
|
|
|
Future<void> sendDietsComment({required String id, required String commentText, int? parentCommentId}) async {
|
|
await feedService.sendDietsComment(id: id, body: commentText, parentCommentId: parentCommentId);
|
|
|
|
}
|
|
|
|
Future<CommentModel> getRecipesComments({required String id}) async {
|
|
return (await feedService.getRecipesComments(id: id));
|
|
|
|
}
|
|
|
|
Future<void> sendRecipesComment({required String id, required String commentText, int? parentCommentId}) async {
|
|
await feedService.sendRecipesComment(id: id, body: commentText, parentCommentId: parentCommentId);
|
|
|
|
}
|
|
|
|
Future<CommentModel> getPlansComments({required String slug}) async {
|
|
return (await feedService.getPlansComments(slug: slug));
|
|
|
|
}
|
|
|
|
Future<void> sendPlansComment({required String slug, required String commentText, int? parentCommentId}) async {
|
|
await feedService.sendPlansComment(slug: slug, body: commentText, parentCommentId: parentCommentId);
|
|
|
|
}
|
|
|
|
Future<void> likeBlogPost({required int id}) async {
|
|
await feedService.likeBlogPost(id: id);
|
|
|
|
}
|
|
|
|
Future<void> unlikedBlogPost({required int id}) async {
|
|
await feedService.unlikedBlogPost(id: id);
|
|
|
|
}
|
|
|
|
Future<List<FeedConsultantModel>> getConsultants([String? name]) async {
|
|
return (await feedService.getConsultants(name: name)).data;
|
|
|
|
}
|
|
|
|
Future<void> viewPost(int id) async {
|
|
return (await feedService.viewPost(id: id));
|
|
|
|
}
|
|
|
|
Future<void> viewRecipe(String slug) async {
|
|
return (await feedService.viewRecipe(slug: slug));
|
|
|
|
}
|
|
|
|
Future<void> viewDiet(int id) async {
|
|
return (await feedService.viewDiet(id: id));
|
|
|
|
}
|
|
|
|
Future<void> viewPlan(String slug) async {
|
|
return (await feedService.viewPlan(slug: slug));
|
|
|
|
}
|
|
|
|
Future<void> viewContent({required ViewModel viewModel}) async {
|
|
await feedService.viewContent(viewModel: viewModel);
|
|
|
|
}
|
|
}
|