mirror of
https://github.com/LukeHagar/pokemonAPI-Amari.git
synced 2025-12-10 04:21:09 +00:00
Adding clean install to repo with project files
This commit is contained in:
17
poke_sdk/PokeAPI.py
Normal file
17
poke_sdk/PokeAPI.py
Normal file
@@ -0,0 +1,17 @@
|
||||
from .api_client import APIClient
|
||||
from .models import Pokemon, Generation
|
||||
|
||||
|
||||
class PokeAPI:
|
||||
def __init__(self):
|
||||
self.client = APIClient()
|
||||
|
||||
def get_pokemon(self, identifier: str) -> Pokemon:
|
||||
"""Fetches a Pokémon by its name or ID."""
|
||||
data = self.client.get(f"pokemon/{identifier}")
|
||||
return Pokemon(name=data['name'], id=data['id'], types=[t['type']['name'] for t in data['types']])
|
||||
|
||||
def get_generation(self, identifier: str) -> Generation:
|
||||
"""Fetches a generation by its ID or name."""
|
||||
data = self.client.get(f"generation/{identifier}")
|
||||
return Generation(id=data['id'], name=data['name'], pokemon_species=[ps['name'] for ps in data['pokemon_species']])
|
||||
Reference in New Issue
Block a user