From 30159399f09896397b99e3b5a00b0231d10d4c7e Mon Sep 17 00:00:00 2001 From: Sergi Delgado Segura Date: Thu, 7 Nov 2019 13:30:23 +0000 Subject: [PATCH] Adds serialize method After adding the triggered flag we can not just use to_json to serialize since the two data blobs won't match. This also sets ground towards having a generalized serialization function. --- pisa/appointment.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/pisa/appointment.py b/pisa/appointment.py index 9cf7b5f..a342ac4 100644 --- a/pisa/appointment.py +++ b/pisa/appointment.py @@ -48,3 +48,8 @@ class Appointment: def to_json(self): return json.dumps(self.to_dict(), sort_keys=True, separators=(',', ':')) + + def serialize(self): + data = self.to_dict() + data.pop("triggered") + return json.dumps(data, sort_keys=True, separators=(',', ':')).encode("utf-8")