18 lines
488 B
Dart
18 lines
488 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);
|
||
|
}
|
||
|
}
|