From 50a2231174b27178c1e17001af5b59f9c403caa3 Mon Sep 17 00:00:00 2001 From: Adam Goldsmith Date: Sat, 2 Apr 2022 19:01:08 -0400 Subject: [PATCH] Move calendar event ID encoding to method --- octoprint_reservations/google_calendar.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/octoprint_reservations/google_calendar.py b/octoprint_reservations/google_calendar.py index 2ae403e..a4c434f 100644 --- a/octoprint_reservations/google_calendar.py +++ b/octoprint_reservations/google_calendar.py @@ -22,6 +22,10 @@ class CalendarService: creds = self._authenticate() self.service = build("calendar", "v3", credentials=creds) + @staticmethod + def encode_event_id(id): + return b16encode(id.encode("ascii")).decode("ascii").lower().rstrip("=") + def _authenticate(self) -> Credentials: creds = None # The file token.json stores the user's access and refresh tokens, and is @@ -47,8 +51,7 @@ class CalendarService: def insert_or_update_event( self, calendar_id: str, id: str, title: str, start: datetime, end: datetime ): - event_id = b16encode(id.encode("ascii")).decode("ascii").lower().rstrip("=") - print(event_id) + event_id = self.encode_event_id(id) event = { "id": event_id, "summary": title,