From 6311a469b720b811656efc15125ac1951ab9609d Mon Sep 17 00:00:00 2001 From: Mel <97147377+MelissaAutumn@users.noreply.github.com> Date: Mon, 11 Dec 2023 07:52:07 -0800 Subject: [PATCH] Build and return all pages and not just the last one. (Fixes #205) (#211) --- .../src/appointment/controller/apis/google_client.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/backend/src/appointment/controller/apis/google_client.py b/backend/src/appointment/controller/apis/google_client.py index dffcab0d8..efdc4c00f 100644 --- a/backend/src/appointment/controller/apis/google_client.py +++ b/backend/src/appointment/controller/apis/google_client.py @@ -86,20 +86,24 @@ def get_email(self, token): def list_calendars(self, token): response = {} + items = [] with build("calendar", "v3", credentials=token) as service: request = service.calendarList().list() while request is not None: try: response = request.execute() + + items += response.get('items', []) except HttpError as e: logging.warning(f"[google_client.list_calendars] Request Error: {e.status_code}/{e.error_details}") request = service.calendarList().list_next(request, response) - return response.get("items", []) + return items def list_events(self, calendar_id, time_min, time_max, token): response = {} + items = [] # Limit the fields we request fields = ','.join( @@ -123,12 +127,14 @@ def list_events(self, calendar_id, time_min, time_max, token): while request is not None: try: response = request.execute() + + items += response.get('items', []) except HttpError as e: logging.warning(f"[google_client.list_events] Request Error: {e.status_code}/{e.error_details}") request = service.events().list_next(request, response) - return response.get("items", []) + return items def create_event(self, calendar_id, body, token): response = None