예제 #1
0
 def get(self, id: int):
     """Get a store by its id"""
     store = StoreModel.fetch_by_id(id)
     if store:
         return store_schema.dump(store), 200
     else:
         return {"message": STORE_NOT_FOUND}, 404
예제 #2
0
 def delete(self, id: int):
     """DElete a store by id"""
     store = StoreModel.fetch_by_id(id)
     if store:
         store.delete_from_db()
         return {"message": OPERATION_SUCCESSFUL.format("Delete")}
     else:
         return {"message": STORE_NOT_FOUND}, 404
예제 #3
0
 def put(self, id: int):
     """edit a store based on its id"""
     data = api.payload
     store = StoreModel.fetch_by_id(id)
     if store:
         if u"name" in data["name"]:
             store.name = name
         return {"message": OPERATION_SUCCESSFUL.format("update")}, 201
     else:
         return {"message": STORE_NOT_FOUND}, 404