Skip to content

Commit 7ac1cf4

Browse files
committed
modify flask to add new view endpoint and return 202s
1 parent 40148af commit 7ac1cf4

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

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()
@@ -35,4 +36,13 @@ def allocate_endpoint():
3536
except InvalidSku as e:
3637
return jsonify({'message': str(e)}), 400
3738

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

0 commit comments

Comments
 (0)