class UserInsertService(Resource): def __init__(self, **kwargs): self.user_handler = UserDataHandler(kwargs['database_connector']) self.translator = UserTranslator() def put(self): user_json = request.json user = self.translator.translate_json_to_user(user_json) print(user) self.user_handler.register_user(user)
class UserModifyService(Resource): def __init__(self, **kwargs): self.user_handler = UserDataHandler(kwargs['database_connector']) self.translator = UserTranslator() def post(self): user_json = request.json user = self.translator.translate_json_to_user(user_json) return self.user_handler.update_user(user)
class UserListService(Resource): def __init__(self, **kwargs): self.user_handler = UserDataHandler(kwargs['database_connector']) self.translator = UserTranslator() def get(self, user_id): jsonsList = json.dumps(self.user_handler.retrieve(user_id), default=self.translator.object_dict) return json.loads(jsonsList)
def __init__(self, **kwargs): self.user_handler = UserDataHandler(kwargs['database_connector'])
class UserDeleteService(Resource): def __init__(self, **kwargs): self.user_handler = UserDataHandler(kwargs['database_connector']) def delete(self, user_id): return self.user_handler.delete(user_id)