mpruvot / python_chess_app

0 stars 0 forks source link

You can create class for this #14

Closed pbrochar closed 6 months ago

pbrochar commented 6 months ago

https://github.com/mpruvot/python_chess_app/blob/9a22b93faca5e7b7fc8a8d75bca898c75c7f34fe/services/strapi_service.py#L23

It's current to create classes to do this kind of jobs:

like

class PlayerFactory:
   @staticmethod
    def from_strapi_response(strapi_response: dict[str, Any]) -> Player:
        player_attributes = strapi_response["attributes"]
        player_id = strapi_response["id"]
        player = Player(**player_attributes)
        player.player_id = player_id
        return player

If tomorrow we want to instantiate players from another data source, it'll be easier.

mpruvot commented 6 months ago

Fixed