feat(blogPost): add recipes

This commit is contained in:
mso7nueh
2024-07-31 17:41:38 +03:00
parent 2f1d6425dc
commit 264b10bd0d
19 changed files with 2531 additions and 512 deletions

View File

@@ -1,5 +1,6 @@
import 'package:dio/dio.dart';
import 'package:eatvio_app/features/feed/models/feed_blog_post_settings_model.dart';
import 'package:eatvio_app/features/feed/models/recipes_pagination_model.dart';
import 'package:retrofit/retrofit.dart';
part 'feed_service.g.dart';
@@ -10,4 +11,7 @@ abstract class FeedService {
@GET('/api/blogPosts/index')
Future<FeedBlogPostSettingsModel> getBlocPostList();
@GET('/api/recipes/index')
Future<RecipesPagination> getRecipes();
}

View File

@@ -45,6 +45,33 @@ class _FeedService implements FeedService {
return _value;
}
@override
Future<RecipesPagination> getRecipes() async {
final _extra = <String, dynamic>{};
final queryParameters = <String, dynamic>{};
final _headers = <String, dynamic>{};
const Map<String, dynamic>? _data = null;
final _result = await _dio
.fetch<Map<String, dynamic>>(_setStreamType<RecipesPagination>(Options(
method: 'GET',
headers: _headers,
extra: _extra,
)
.compose(
_dio.options,
'/api/recipes/index',
queryParameters: queryParameters,
data: _data,
)
.copyWith(
baseUrl: _combineBaseUrls(
_dio.options.baseUrl,
baseUrl,
))));
final _value = RecipesPagination.fromJson(_result.data!);
return _value;
}
RequestOptions _setStreamType<T>(RequestOptions requestOptions) {
if (T != dynamic &&
!(requestOptions.responseType == ResponseType.bytes ||