Skip to content

Commit d8bfbc6

Browse files
committed
modify flask to add new view endpoint and return 202s
1 parent 344cf81 commit d8bfbc6

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

src/allocation/entrypoints/flask_app.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
from datetime import datetime
2-
from flask import Flask, request
2+
from flask import Flask, jsonify, request
33

44
from allocation.domain import commands
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 {"message": str(e)}, 400
3738

38-
return {"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)