diff --git a/lib/data/dtos/pokemon_dto.dart b/lib/data/dtos/pokemon_dto.dart index 8b58d94..8f9f72e 100644 --- a/lib/data/dtos/pokemon_dto.dart +++ b/lib/data/dtos/pokemon_dto.dart @@ -27,6 +27,7 @@ class PokemonDataDto { final int? height; final int? weight; final List? abilities; + // final PokemonAttributesDataDto? attributes; const PokemonDataDto({ this.name, @@ -35,11 +36,31 @@ class PokemonDataDto { this.height, this.weight, this.abilities, + // this.attributes, }); factory PokemonDataDto.fromJson(Map json) => _$PokemonDataDtoFromJson(json); } +// @JsonSerializable(createToJson: false) +// class PokemonAttributesDataDto { +// final String? imageUrl; +// final int? height; +// final int? weight; +// final List? abilities; +// final PokemonSpritesDto? sprites; +// +// const PokemonAttributesDataDto({ +// this.imageUrl, +// this.height, +// this.weight, +// this.abilities, +// this.sprites, +// }); +// +// factory PokemonAttributesDataDto.fromJson(Map json) => _$PokemonAttributesDataDtoFromJson(json); +// } + @JsonSerializable(createToJson: false) class AbilityDto { final AbilityDetailDto? ability; @@ -56,4 +77,15 @@ class AbilityDetailDto { const AbilityDetailDto({this.name}); factory AbilityDetailDto.fromJson(Map json) => _$AbilityDetailDtoFromJson(json); -} \ No newline at end of file +} + +// @JsonSerializable(createToJson: false) +// class PokemonSpritesDto { +// final String front_default; +// +// const PokemonSpritesDto({ +// required this.front_default, +// }); +// +// factory PokemonSpritesDto.fromJson(Map json) => _$PokemonSpritesDtoFromJson(json); +// } diff --git a/lib/data/mappers/pokemon_mapper.dart b/lib/data/mappers/pokemon_mapper.dart index 21f1312..ddaf1de 100644 --- a/lib/data/mappers/pokemon_mapper.dart +++ b/lib/data/mappers/pokemon_mapper.dart @@ -17,6 +17,8 @@ extension PokemonDataDtoToModel on PokemonDataDto { name ?? 'UNKNOWN', imageUrl: imageUrl ?? _imagePlaceholder, descriptionText: 'Height: ${height ?? 'UNKNOWN'} cm, Weight: ${weight ?? 'UNKNOWN'} g, Abilities: ${abilities?.map((ability) => ability.ability?.name ?? 'UNKNOWN').join(', ') ?? 'UNKNOWN'}', + // imageUrl: attributes?.sprites?.front_default ?? _imagePlaceholder, + // descriptionText: 'Height: ${attributes?.height ?? 'UNKNOWN'} cm, Weight: ${attributes?.weight ?? 'UNKNOWN'} g, Abilities: ${attributes?.abilities?.map((ability) => ability.ability?.name ?? 'UNKNOWN').join(', ') ?? 'UNKNOWN'}', id: url?.split('/')[6] ?? 'UNKNOWN', ); } \ No newline at end of file diff --git a/lib/data/repositories/pokemon_repository.dart b/lib/data/repositories/pokemon_repository.dart index 0d1b912..6da993d 100644 --- a/lib/data/repositories/pokemon_repository.dart +++ b/lib/data/repositories/pokemon_repository.dart @@ -29,19 +29,21 @@ class PokeRepository extends ApiInterface { 'limit': pageSize, }; - if (q != null && q.isNotEmpty) { - url = '$_baseUrl/pokemon/$q'; - queryParameters = { - 'offset': page, - 'limit': pageSize, - }; - } + // if (q != null && q.isNotEmpty) { + // url = '$_baseUrl/pokemon/$q'; + // queryParameters = { + // 'offset': page, + // 'limit': pageSize, + // }; + // } final Response response = await _dio.get>( url, queryParameters: queryParameters, ); + // final PokemonDto dto = PokemonDto.fromJson(response.data as Map); + // final HomeData data = dto.toDomain(); final PokemonDto dto = PokemonDto.fromJson(response.data as Map); final List pokemonDataList = dto.results ?? [];