Quando tentei desenvolver o desafio, pedi o acesso à API que buscava os CEPs, então decidi procurar outra para realizar. Encontrei a API de Pokémon, e decidi fazer meu projeto/desafio com essa base de dados.
Segue como fiz a classe de objetos do tipo "Pokemon":
public class Pokemon {
private String name;
private Sprites sprites;
private int id;
private int weight;
public Pokemon(PokeAPI pokeAPI){
this.name = pokeAPI.name();
this.sprites = pokeAPI.sprites();
this.id = pokeAPI.id();
this.weight = pokeAPI.weight();
}
Sendo PokeAPI o record do objeto Pokemon. Após fazer a classe da requisição da API:
public static void main(String[] args) throws IOException, InterruptedException {
PokemonGetter searchPokemon = new PokemonGetter();
Pokemon myPokemon = searchPokemon.searchPokemon("Aipom");
System.out.println(myPokemon.getWeight());
}