pmu/lib/data/repositories/hero_repository.dart
2024-12-18 10:10:10 +04:00

20 lines
508 B
Dart

import '../dtos/hero_dto.dart';
import '../../services/api_service.dart';
import '../mappers/hero_mapper.dart';
class HeroRepository {
final ApiService apiService;
HeroRepository({required this.apiService});
Future<List<HeroDto>> getHeroes() async {
final heroes = await apiService.fetchHeroes();
return HeroMapper.fromJsonList(heroes);
}
Future<HeroDto> getHeroDetails(int id) async {
final hero = await apiService.fetchHeroDetails(id);
return HeroMapper.fromJson(hero);
}
}