Skip to content

Commit 0d96e5b

Browse files
committed
modify flask to add new view endpoint and return 202s
1 parent 149c5e1 commit 0d96e5b

1 file changed

Lines changed: 11 additions & 1 deletion

File tree

‎src/allocation/entrypoints/flask_app.py‎

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
from allocation.adapters import orm
66
from allocation.service_layer import messagebus, unit_of_work
77
from allocation.service_layer.handlers import InvalidSku
8+
from allocation import views
89

910
app = Flask(__name__)
1011
orm.start_mappers()
@@ -34,4 +35,13 @@ def allocate_endpoint():
3435
except InvalidSku as e:
3536
return jsonify({'message': str(e)}), 400
3637

37-
return jsonify({'batchref': batchref}), 201
38+
return 'OK', 202
39+
40+
41+
@app.route("/allocations/<orderid>", methods=['GET'])
42+
def allocations_view_endpoint(orderid):
43+
uow = unit_of_work.SqlAlchemyUnitOfWork()
44+
result = views.allocations(orderid, uow)
45+
if not result:
46+
return 'not found', 404
47+
return jsonify(result), 200

0 commit comments

Comments
 (0)