Example #1
0
    def post(self, name):
        if StoreModel.find(name):
            return {"message": "Store '{}' already exists".format(name)}, 400

        store = StoreModel(name)
        try:
            store.save()
        except:
            return {
                "message": "An error occurred while creating the store"
            }, 500

        return store.json(), 200
Example #2
0
    def delete(self, name):
        store = StoreModel.find(name)
        if store:
            store.delete()

        return {"message": "Store deleted"}
Example #3
0
    def get(self, name):
        store = StoreModel.find(name)
        if store:
            return store.json()

        return {"message": "Store not found"}, 404