Compare commits

...

3 Commits

2 changed files with 13 additions and 3 deletions

View File

@ -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,
@ -76,3 +79,10 @@ class CalendarService:
else:
raise
def delete_event(self, calendar_id: str, id: str):
event_id = self.encode_event_id(id)
try:
self.service.events().delete(calendar_id, event_id)
except HttpError as error:
print("Got error when deleting event: ", error)

View File

@ -1,6 +1,6 @@
[project]
name = "octoprint_reservations"
version = "0.1.0"
version = "0.1.1"
description = ""
authors = [{ name = "Adam Goldsmith", email = "adam@adamgoldsmith.name" }]
license-expression = "MIT"