some_random_api/endpoints/
pokemon.rs1use crate::{Pokedex, PokemonAbility, PokemonItem, PokemonMove, Requester};
2use anyhow::Result;
3
4pub struct PokemonEndpoint(pub(crate) Requester);
14
15impl PokemonEndpoint {
16 pub async fn abilities<T: ToString>(&self, ability: T) -> Result<PokemonAbility> {
18 self.0
19 .request(
20 "pokemon/abilities",
21 Some(&[("ability", ability.to_string())]),
22 )
23 .await
24 }
25
26 pub async fn items<T: ToString>(&self, item: T) -> Result<PokemonItem> {
28 self.0
29 .request("pokemon/items", Some(&[("item", item.to_string())]))
30 .await
31 }
32
33 pub async fn moves<T: ToString>(&self, pokemon_move: T) -> Result<PokemonMove> {
35 self.0
36 .request("pokemon/moves", Some(&[("move", pokemon_move.to_string())]))
37 .await
38 }
39
40 pub async fn pokedex<T: ToString>(&self, pokemon: T) -> Result<Pokedex> {
42 self.0
43 .request("pokemon/pokedex", Some(&[("pokemon", pokemon.to_string())]))
44 .await
45 }
46}