From cf1dd026eb26bfb10fdfcb97523cbc91d14fe549 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Magalh=C3=A3es?= Date: Tue, 16 Apr 2024 10:56:04 +0100 Subject: [PATCH] chore: more validation to Seeplus payload --- CHANGELOG.md | 2 +- src/budy/controllers/api/seeplus.py | 9 +++++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d139a00..9d82aae 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,7 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Added -* +* Additional validation to status changed in order for Seeplus, more pedantic ### Changed diff --git a/src/budy/controllers/api/seeplus.py b/src/budy/controllers/api/seeplus.py index a731fd3..114ec8a 100644 --- a/src/budy/controllers/api/seeplus.py +++ b/src/budy/controllers/api/seeplus.py @@ -56,8 +56,13 @@ def update(self): return dict(result=result) def _status_change_s(self, data): - reference = data["code"] - status = data["status"] + for key in ("code", "status"): + appier.verify( + key in data, + message="Missing '%s' in Seeplus data payload (OrderManagement.StatusChanged)" % key, + code=400, + ) + reference, status = data["code"], data["status"] order = budy.Order.get(reference=reference) seeplus_status = order.meta.get("seeplus_status", None) seeplus_timestamp = order.meta.get("seeplus_timestamp", None)