def get(self) -> Response: """ GET response method for all documents in product collection. JSON Web Token is required. :return: JSON object """ output = Products.objects() return jsonify({'result': output})
def put(self, product_id: str) -> Response: """ PUT response method for updating a product. JSON Web Token is required. Authorization is required: Access(admin=true) :return: JSON object """ data = request.get_json() put_user = Products.objects(id=product_id).update(**data) return jsonify({'result': put_user})
def delete(self, user_id: str) -> Response: """ DELETE response method for deleting single product. JSON Web Token is required. Authorization is required: Access(admin=true) :return: JSON object """ #authorized: bool = Products.objects.get(id=get_jwt_identity()).access.admin if True: output = Products.objects(id=user_id).delete() return jsonify({'result': output}) else: return forbidden()
def get_detail(id): docs = Products.objects(id=id) return jsonify(docs), 200
def get_list(): docs = Products.objects() return jsonify(docs), 200