19 lines
489 B
Dart
19 lines
489 B
Dart
import '../dtos/hero_dto.dart';
|
|
import '../../services/api_service.dart';
|
|
|
|
class HeroRepository {
|
|
final ApiService apiService;
|
|
|
|
HeroRepository({required this.apiService});
|
|
|
|
Future<List<HeroDto>> getHeroes() async {
|
|
final heroes = await apiService.fetchHeroes();
|
|
return heroes.map((hero) => HeroDto.fromJson(hero)).toList();
|
|
}
|
|
|
|
Future<HeroDto> getHeroDetails(int id) async {
|
|
final hero = await apiService.fetchHeroDetails(id);
|
|
return HeroDto.fromJson(hero);
|
|
}
|
|
}
|