Update the Planet model with similar refactors presented in the Hello Books API:
In the Planet model:
- Create an instance method
to_dict - Create a class method
from_dict
In a new file:
- Create a function that handles generalized id validation for models.
In the planet_routes file:
- Update routes that fetch planet data to use the new instance method
to_dictwhen creating a dictionary representation of a planet - Update the create planet route to use the new
from_dictclass method to create new planet instances. - Update any routes that need to validate a model's id to use the new generalized id validation helper function
The behavior of our routes should stay the same through these refactors. We should not see any changes to the capabilities our routes had previously.