module Haskmon.Client(
getPokedexById,
getNationalPokedex,
getPokemonById,
getPokemonByName,
getAbilityById,
getMoveById,
getTypeById,
getEggGroupById,
getDescriptionById,
getGameById,
getSpriteById
) where
import Haskmon.Types
import Haskmon.Resource(getResource)
import Data.Aeson(FromJSON)
type ID = Word
getResourceById :: FromJSON a => String -> String -> IO a
getResourceById res dbId = getResource $ "api/v1/" ++ res ++ "/" ++ dbId ++ "/"
getPokedexById :: ID -> IO Pokedex
getPokedexById = getResourceById "pokedex" . show
getNationalPokedex :: IO Pokedex
getNationalPokedex = getPokedexById 1
getPokemonById :: ID -> IO Pokemon
getPokemonById = getResourceById "pokemon" . show
getPokemonByName :: String
-> IO Pokemon
getPokemonByName = getResourceById "pokemon"
getAbilityById :: ID -> IO Ability
getAbilityById = getResourceById "ability" . show
getMoveById :: ID -> IO Move
getMoveById = getResourceById "move" . show
getTypeById :: ID -> IO Type
getTypeById = getResourceById "type" . show
getEggGroupById :: ID -> IO EggGroup
getEggGroupById = getResourceById "egg" . show
getDescriptionById :: ID -> IO Description
getDescriptionById = getResourceById "description" . show
getGameById :: ID -> IO Description
getGameById = getResourceById "game" . show
getSpriteById :: ID -> IO Sprite
getSpriteById = getResourceById "sprite" . show