def delete(cls, name: str): store = StoreModel.find_by_name(name) if store: store.delete_from_db() return {"message": STORE_DELETED}, 200 return {"message": STORE_NOT_FOUND}, 404
def post(cls, name: str): if StoreModel.find_by_name(name): return {"message": NAME_ALREADY_EXISTS.format(name)}, 400 store = StoreModel(name=name) try: store.save_to_db() except: return {"message": ERROR_INSERTING}, 500 return store_schema.dump(store), 201
def post(cls, name): if StoreModel.find_by_name(name): return ( { "message": NAME_ALREADY_EXISTS.format(name) }, 400, ) store = StoreModel(name) try: store.save_to_db() except: return {"message": ERROR_CREATING}, 500 return store.json(), 201
def delete(cls, name): store = StoreModel.find_by_name(name) if store: store.delete_from_db() return {"message": STORE_DELETED}
def get(cls, name): store = StoreModel.find_by_name(name) if store: return store.json() return {"message": STORE_NOT_FOUND}, 404
def get(cls, name: str): store = StoreModel.find_by_name(name) if store: return store_schema.dump(store), 200 return {"message": STORE_NOT_FOUND}, 404