PokeAPI / pokebase

Python 3 wrapper for Pokéapi v2
BSD 3-Clause "New" or "Revised" License
286 stars 53 forks source link

Root endpoint support #24

Closed C-Garza closed 2 years ago

C-Garza commented 3 years ago

I noticed root endpoints don't work for endpoints that don't have name properties for their objects, such as /machine. I talk about this in this issue at pokepy, but I'll state it again. The /machine endpoint returns this:

results: [
  0: {
    url: "https://pokeapi.co/api/v2/machine/1/"
  },
  ...
]

while the /pokemon endpoint returns this:

results: [
  0: {
    name: "bulbasaur",
    url: "https://pokeapi.co/api/v2/pokemon/1/"
  },
  ...
]

Because there's no name property, it returns None for the name here in the APIResource class.

I think I managed to fix the issue by adding this conditional after those lines:

if name == None:
  self.__dict__.update({'name': id_})

Should I open a pull request for this then?

Davidy22 commented 3 years ago

I got a fix for this merged, does latest work for you now?

GregHilmes commented 2 years ago

Closed due to no response.