Line data Source code
1 : import 'package:memories_app/network/network_manager.dart'; 2 : import 'package:memories_app/routes/home/model/response/stories_response_model.dart'; 3 : import 'package:memories_app/util/api_endpoints.dart'; 4 : 5 : abstract class HomeRepository { 6 : Future<StoriesResponseModel> getUserStories( 7 : {required int page, required int size}); 8 : 9 : Future<StoriesResponseModel> getAllStoriesWithOwnUrl( 10 : {required int page, required int size}); 11 : } 12 : 13 : class HomeRepositoryImp extends HomeRepository { 14 : final NetworkManager _networkManager; 15 : 16 1 : HomeRepositoryImp({NetworkManager? networkManager}) : _networkManager = networkManager ?? NetworkManager(); 17 : 18 1 : @override 19 : Future<StoriesResponseModel> getUserStories( 20 : {required int page, required int size}) async { 21 : final Result result = 22 3 : await _networkManager.get(ApiEndpoints.buildUserStoriesUrl(page, size)); 23 2 : return StoriesResponseModel.fromJson(result.json); 24 : } 25 : 26 1 : @override 27 : Future<StoriesResponseModel> getAllStoriesWithOwnUrl( 28 : {required int page, required int size}) async { 29 1 : final Result result = await _networkManager 30 2 : .get(ApiEndpoints.buildAllStoriesWithOwnUrl(page, size)); 31 2 : return StoriesResponseModel.fromJson(result.json); 32 : } 33 : }