tallgrass/game/pokedex
Types
pub type Pokedex {
Pokedex(
id: Int,
name: String,
is_main_series: Bool,
descriptions: List(Description),
names: List(Name),
pokemon_entries: List(PokemonEntry),
region: Resource,
version_groups: List(Resource),
)
}
Constructors
-
Pokedex( id: Int, name: String, is_main_series: Bool, descriptions: List(Description), names: List(Name), pokemon_entries: List(PokemonEntry), region: Resource, version_groups: List(Resource), )
pub type PokemonEntry {
PokemonEntry(entry: Int, species: Resource)
}
Constructors
-
PokemonEntry(entry: Int, species: Resource)
Functions
pub fn fetch(client: Client) -> Result(PaginatedResource, Error)
Fetches a paginated list of pokedex resources.
Example
let result = pokedex.new() |> pokedex.fetch()
pub fn fetch_by_id(
client: Client,
id: Int,
) -> Result(Pokedex, Error)
Fetches a pokedex given the pokedex ID.
Example
let result = pokedex.new() |> pokedex.fetch_by_id(1)
pub fn fetch_by_name(
client: Client,
name: String,
) -> Result(Pokedex, Error)
Fetches a pokedex given the pokedex name.
Example
let result = pokedex.new() |> pokedex.fetch_by_name("kanto")
pub fn fetch_resource(
client: Client,
resource: Resource,
) -> Result(Pokedex, Error)
Fetches a pokedex given a pokedex resource.
Example
let client = pokedex.new()
use res <- result.try(client |> pokedex.fetch())
let assert Ok(first) = res.results |> list.first
client |> pokedex.fetch_resource(first)