tallgrass/pokemon

Types

pub type Pokemon {
  Pokemon(
    id: Int,
    name: String,
    base_experience: Int,
    cries: PokemonCries,
    height: Int,
    is_default: Bool,
    order: Int,
    weight: Int,
    abilities: List(PokemonAbility),
    forms: List(Resource),
    game_indices: List(VersionGameIndex),
    held_items: List(PokemonHeldItem),
    location_area_encounters: String,
    moves: List(PokemonMove),
    species: Resource,
    stats: List(PokemonStat),
    types: List(PokemonType),
  )
}

Constructors

  • Pokemon(
      id: Int,
      name: String,
      base_experience: Int,
      cries: PokemonCries,
      height: Int,
      is_default: Bool,
      order: Int,
      weight: Int,
      abilities: List(PokemonAbility),
      forms: List(Resource),
      game_indices: List(VersionGameIndex),
      held_items: List(PokemonHeldItem),
      location_area_encounters: String,
      moves: List(PokemonMove),
      species: Resource,
      stats: List(PokemonStat),
      types: List(PokemonType),
    )
pub type PokemonAbility {
  PokemonAbility(ability: Resource, is_hidden: Bool, slot: Int)
}

Constructors

  • PokemonAbility(ability: Resource, is_hidden: Bool, slot: Int)
pub type PokemonCries {
  PokemonCries(latest: String, legacy: String)
}

Constructors

  • PokemonCries(latest: String, legacy: String)
pub type PokemonHeldItem {
  PokemonHeldItem(
    item: Resource,
    version_details: List(PokemonHeldItemVersion),
  )
}

Constructors

  • PokemonHeldItem(
      item: Resource,
      version_details: List(PokemonHeldItemVersion),
    )
pub type PokemonHeldItemVersion {
  PokemonHeldItemVersion(rarity: Int, version: Resource)
}

Constructors

  • PokemonHeldItemVersion(rarity: Int, version: Resource)
pub type PokemonMove {
  PokemonMove(
    move: Resource,
    version_details: List(PokemonMoveVersion),
  )
}

Constructors

  • PokemonMove(
      move: Resource,
      version_details: List(PokemonMoveVersion),
    )
pub type PokemonMoveVersion {
  PokemonMoveVersion(
    learn_level: Int,
    learn_method: Resource,
    version_group: Resource,
  )
}

Constructors

  • PokemonMoveVersion(
      learn_level: Int,
      learn_method: Resource,
      version_group: Resource,
    )
pub type PokemonSprites {
  PokemonSprites(
    back_default: String,
    back_female: Option(String),
    back_shiny: String,
    back_shiny_female: Option(String),
    front_default: String,
    front_female: Option(String),
    front_shiny: String,
    front_shiny_female: Option(String),
  )
}

Constructors

  • PokemonSprites(
      back_default: String,
      back_female: Option(String),
      back_shiny: String,
      back_shiny_female: Option(String),
      front_default: String,
      front_female: Option(String),
      front_shiny: String,
      front_shiny_female: Option(String),
    )
pub type PokemonStat {
  PokemonStat(stat: Resource, base_stat: Int, effort: Int)
}

Constructors

  • PokemonStat(stat: Resource, base_stat: Int, effort: Int)

Functions

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

Fetches a paginated list of pokemon resources.

Example

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

Fetches a pokemon given the pokemon ID.

Example

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

Fetches a pokemon given the pokemon name.

Example

let result = pokemon.new() |> pokemon.fetch_by_name("ditto")
pub fn fetch_resource(
  client: Client,
  resource: Resource,
) -> Result(Pokemon, Error)

Fetches a pokemon given a pokemon resource.

Example

let client = pokemon.new()
use res <- result.try(client |> pokemon.fetch())
let assert Ok(first) = res.results |> list.first
client |> pokemon.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