tallgrass/pokemon/habitat

Types

pub type Habitat {
  Habitat(
    id: Int,
    name: String,
    names: List(Name),
    pokemon_species: List(Resource),
  )
}

Constructors

  • Habitat(
      id: Int,
      name: String,
      names: List(Name),
      pokemon_species: List(Resource),
    )

Functions

pub fn fetch(client: Client) -> Result(PaginatedResource, Error)

Fetches a paginated list of pokemon habitat resources.

Example

let result = habitat.new() |> habitat.fetch()
pub fn fetch_by_id(
  client: Client,
  id: Int,
) -> Result(Habitat, Error)

Fetches a pokemon habitat given the pokemon habitat ID.

Example

let result = habitat.new() |> habitat.fetch_by_id(1)
pub fn fetch_by_name(
  client: Client,
  name: String,
) -> Result(Habitat, Error)

Fetches a pokemon habitat given the pokemon habitat name.

Example

let result = habitat.new() |> habitat.fetch_by_name("cave")
pub fn fetch_resource(
  client: Client,
  resource: Resource,
) -> Result(Habitat, Error)

Fetches a pokemon habitat given a pokemon habitat resource.

Example

let client = habitat.new()
use res <- result.try(client |> habitat.fetch())
let assert Ok(first) = res.results |> list.first
client |> habitat.fetch_resource(first)
pub fn new() -> Client

Creates a new Client. This is a re-export of client.new, for the sake of convenience.

Search Document