def validate(event, user_id) -> Dict[str, str]: HomeHelper.validate_grid_request(event, "Item Clear API (GRID SLOT)") if event[RequestField.Home.GRID] == Constants.Home.MATCH_GRID_SLOT: end("Cannot clear reserved home grid slot.") user_data = UserUtils.get(user_id, UserAttr.CURRENT_HOME) if not user_data: end("Unable to retrieve current home for user.") return user_data
def validate(event, user_id) -> Dict[str, str]: HomeHelper.validate_grid_request( target=event, message="Item Update API (GRID SLOT)" ) validate_meta( target=event, field=RequestField.Item.META, max_size=Config.GRID_META_LIMIT, message="Item Update API (META)", ) user_data = UserUtils.get(user_id, UserAttr.CURRENT_HOME) if not user_data: end("Unable to retrieve current home for user.") return user_data
def run(event, user_id, valid_data) -> bool: new_id = HomeHelper.new() if not new_id: end("Unable to create new home.") # TODO: delete home if add_home fails if not UserHelper.add_home( user_id, new_id, event[RequestField.Home.NAME], event[RequestField.Home.BIODOME], ): if not HomeHelper.delete(new_id): end("Unable to add home to user, and failed clean-up.") end("Unable to add home to user.") return True
def run(event, user_id, valid_data) -> bool: home_id = valid_data[UserAttr.CURRENT_HOME] grid_slot = event[RequestField.Home.GRID] item_meta = event[RequestField.Item.META] if not HomeHelper.update(home_id, grid_slot, item_meta): end("Unable to update meta for grid slot.") return True
def run(event, user_id, valid_data) -> bool: if not HomeHelper.set_slot( home_id=valid_data[UserAttr.CURRENT_HOME], grid_slot=str(event[RequestField.Home.GRID]), item=event[RequestField.User.ITEM], meta=event[RequestField.Item.META], ): end("Unable to update selected grid slot.") return True
def run(event, user_id, valid_data) -> bool: home_index = event[RequestField.User.HOME] - 1 home_id = valid_data[UserAttr.HOMES][home_index] if not HomeHelper.delete(home_id): end("Unable to delete requested home.") # todo: do we need an extra if :value in #name condition here to catch misuse? if not UserUtils.update(user_id, UserAttr.HOMES, home_index, "REMOVE #name :value"): end("Unable to remove deleted home from user.") return True
def validate(event, user_id) -> Dict[str, Union[int, str]]: HomeHelper.validate_grid_request(event, "Item Place API (GRID SLOT)") if event[RequestField.Home.GRID] == Constants.Home.MATCH_GRID_SLOT: end("Cannot place reserved home grid slot.") validate_meta( target=event, field=RequestField.Item.META, max_size=Config.GRID_META_LIMIT, message="Item Place API (META)", ) user_data = UserUtils.get( user_id, f"{UserAttr.INVENTORY_COUNT}, {UserAttr.CURRENT_HOME}", ) if not user_data: end("Unable to retrieve inventory and current home for user.") validate_choice( target=event, field=RequestField.User.ITEM, max=user_data[UserAttr.INVENTORY_COUNT], message="Item Place API (ITEM CHOICE)", ) return user_data
def run(event, user_id, valid_data) -> bool: home_id = valid_data[UserAttr.CURRENT_HOME] grid_slot = event[RequestField.Home.GRID] if not HomeHelper.clear_slot(home_id, grid_slot): end("Unable to clear grid slot.") return True