From 0c88aa8fcf07ed392734dd3b94ccc4bc7e9fa41e Mon Sep 17 00:00:00 2001 From: Arc <33088785+arcbtc@users.noreply.github.com> Date: Wed, 22 Apr 2020 19:47:30 +0100 Subject: [PATCH] Update views_api.py --- lnbits/extensions/diagonalley/views_api.py | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/lnbits/extensions/diagonalley/views_api.py b/lnbits/extensions/diagonalley/views_api.py index 7a59cd5..5e43a6d 100644 --- a/lnbits/extensions/diagonalley/views_api.py +++ b/lnbits/extensions/diagonalley/views_api.py @@ -191,14 +191,21 @@ def api_diagonalleys_order_shipped(order_id): return jsonify([order._asdict() for order in get_diagonalleys_orders(order["wallet"])]), Status.OK -###List products based on wallet +###List products based on indexer id -@diagonalley_ext.route("/api/v1/diagonalley/stall/products/", methods=["GET"]) -def api_diagonalleys_stall_products(wallet_id): +@diagonalley_ext.route("/api/v1/diagonalley/stall/products/", methods=["GET"]) +def api_diagonalleys_stall_products(indexer_id): with open_ext_db("diagonalley") as db: - rows = db.fetchall("SELECT * FROM products WHERE WALLET = ?", (wallet_id,)) + rows = db.fetchone("SELECT * FROM indexers WHERE id = ?", (indexer_id,)) + print(rows[1]) + if not rows: + return jsonify({"message": "Indexer does not exist."}), Status.NOT_FOUND - return jsonify([products._asdict() for products in get_diagonalleys_products(wallet_id)]), Status.OK + products = db.fetchone("SELECT * FROM products WHERE wallet = ?", (rows[1],)) + if not products: + return jsonify({"message": "No products"}), Status.NOT_FOUND + + return jsonify([products._asdict() for products in get_diagonalleys_products(rows[1])]), Status.OK ###Check a product has been shipped