tallgrass/game/generation
Types
pub type Generation {
Generation(
id: Int,
name: String,
abilities: List(Resource),
main_region: Resource,
moves: List(Resource),
names: List(Name),
pokemon_species: List(Resource),
types: List(Resource),
version_groups: List(Resource),
)
}
Constructors
-
Generation( id: Int, name: String, abilities: List(Resource), main_region: Resource, moves: List(Resource), names: List(Name), pokemon_species: List(Resource), types: List(Resource), version_groups: List(Resource), )
Functions
pub fn fetch(client: Client) -> Result(PaginatedResource, Error)
Fetches a paginated list of generation resources.
Example
let result = generation.new() |> generation.fetch()
pub fn fetch_by_id(
client: Client,
id: Int,
) -> Result(Generation, Error)
Fetches a generation given the generation ID.
Example
let result = generation.new() |> generation.fetch_by_id(1)
pub fn fetch_by_name(
client: Client,
name: String,
) -> Result(Generation, Error)
Fetches a generation given the generation name.
Example
let result = generation.new() |> generation.fetch_by_name("generation-i")
pub fn fetch_resource(
client: Client,
resource: Resource,
) -> Result(Generation, Error)
Fetches a generation given a generation resource.
Example
let client = generation.new()
use res <- result.try(client |> generation.fetch())
let assert Ok(first) = res.results |> list.first
client |> generation.fetch_resource(first)