From 80c09363f969515a2087ca1ae53c9e7d97d85b69 Mon Sep 17 00:00:00 2001 From: Derek Homeier Date: Fri, 31 May 2024 23:45:33 +0200 Subject: [PATCH] Raise exception on non-existing event; update full event --- spond/spond.py | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/spond/spond.py b/spond/spond.py index 8dbf0b5..eb923bb 100644 --- a/spond/spond.py +++ b/spond/spond.py @@ -358,7 +358,6 @@ async def update_event(self, uid: str, updates: dict): "autoAccept": False, "payment": {}, "attachments": [], - "id": None, "tasks": { "openTasks": [], "assignedTasks": [ @@ -374,10 +373,19 @@ async def update_event(self, uid: str, updates: dict): }, } + if not self.events: + await self.get_events() + for event in self.events: + if event["id"] == uid: + base_event.update(event) + url = f"{self.API_BASE_URL}sponds/{uid}" + break + else: + errmsg = f"No event with id='{uid}' existing" + raise ValueError(errmsg) + for key in base_event: - if event.get(key) is not None and not updates.get(key): - base_event[key] = event[key] - elif updates.get(key) is not None: + if updates.get(key) is not None: base_event[key] = updates[key] data = dict(base_event)