def delete_address(id): address = Address.find(id) if address is None: return jsonify(message="Error deleting address, not found"), 404 success = address.delete() if success: return jsonify(message="Successfully deleted address"), 204 else: return jsonify(message="Error deleting address"), 400
def update_address(id): first_name = request.json['first_name'] last_name = request.json['last_name'] phone = request.json['phone'] email = request.json['email'] street = request.json['street'] city = request.json['city'] state = request.json['state'] zip = request.json['zip'] favorite = request.json['favorite'] address = Address.find(id) if address is None: return jsonify(message="Error updating address, not found"), 404 updated_address = address.update(first_name, last_name, phone, email, street, city, state, zip, favorite) return address_schema.jsonify(updated_address), 200
def find_address(id): address = Address.find(id) if address is None: return jsonify(message="Address not found"), 404 else: return address_schema.jsonify(address), 200