public Models.Pokemon.Pokemon Transform(PokemonResponseModel pokemonResponseModel) { Models.Pokemon.Pokemon pokemon = TransformApiPokemonToPokeServerEvolutionlessPokemon(pokemonResponseModel); var species = _restServiceSpecies.Request(_envConfig.Value.PokeApi.SpeciesAPI.APIUriFormatter(pokemon.Name), "GET"); pokemon.Description = species.flavor_text_entries.FirstOrDefault(f => f.language.name == CultureInfo.CurrentCulture.TwoLetterISOLanguageName.ToLower())?.flavor_text; pokemon.Evolutions = ExtractEvolutions(pokemon, species).ToArray(); return(pokemon); }
private PokemonResponseModel GetSamplePokemon(string pokemonName) { var pokemonId = 25; var pokemon = new PokemonResponseModel { id = pokemonId, name = pokemonName, species = new NamedAPIResource(pokemonName, string.Format("https://pokeapi.co/api/v2/pokemon-species/{0}/", pokemonId)) }; return(pokemon); }
private Models.Pokemon.Pokemon TransformApiPokemonToPokeServerEvolutionlessPokemon(PokemonResponseModel pokemonResponseModel) { return(new Models.Pokemon.Pokemon() { Abilities = pokemonResponseModel.abilities.Select(a => a.ability.name).ToArray(), BaseExperience = pokemonResponseModel.base_experience, Height = pokemonResponseModel.height * 0.1, Identifier = pokemonResponseModel.id, Image = new Uri(pokemonResponseModel.sprites.front_default), Moves = pokemonResponseModel.moves.Select(m => new Models.Pokemon.Move() { Name = m.move.name, LearningMethod = string.Join(',', m.version_group_details.Select(vgd => vgd.move_learn_method.name)) }).ToArray(), Name = pokemonResponseModel.name, PokemonTypes = pokemonResponseModel.types.Select(t => Enum.Parse <PokemonType>(t.type.name.ToLower()).ToString()).ToArray(), Stats = pokemonResponseModel.stats.Select(s => new Models.Pokemon.Stat() { }).ToArray(), Weight = pokemonResponseModel.weight * 0.1, }); }