/// <summary> /// Returns a single pokemon data using Id. /// </summary> /// <param name="id">The Id of the pokemon</param> public async Task <PokemonResponse> GetPokemon(int id) { try { HttpResponseMessage resp = await Client.GetAsync($"pokemon/{id}"); if (resp.IsSuccessStatusCode) { string data = await resp.Content.ReadAsStringAsync(); PokemonResponse pr = JsonConvert.DeserializeObject <PokemonResponse>(data); return(pr); } else { return(null); } } catch (Exception e) { #if DEBUG Console.WriteLine(e.GetType().ToString()); #endif return(null); } }
/// <summary> /// Returns a single pokemon data using name. /// </summary> /// <param name="name">The name of the pokemon</param> public async Task <PokemonResponse> GetPokemon(string name) { HttpResponseMessage resp = await Client.GetAsync($"pokemon/{name}"); if (resp.IsSuccessStatusCode) { string data = await resp.Content.ReadAsStringAsync(); PokemonResponse pr = JsonConvert.DeserializeObject <PokemonResponse>(data); return(pr); } else { return(null); } }