From f72d09d09d267375eb9fe8dbb39875384338a366 Mon Sep 17 00:00:00 2001 From: bnznamco Date: Tue, 16 Jan 2024 18:43:55 +0100 Subject: [PATCH] fix: fix _download_all_pages handler --- mailupy/client.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/mailupy/client.py b/mailupy/client.py index 8b2ef55..12a5584 100644 --- a/mailupy/client.py +++ b/mailupy/client.py @@ -55,9 +55,9 @@ def _download_all_pages(self, url): f'{url}{spacer}pageNumber={current}', headers=self._default_headers() ).json() - total = math.ceil(data['TotalElementsCount'] / data['PageSize']) - is_paginated = data['IsPaginated'] - for item in data['Items']: + total = math.ceil(data.get('TotalElementsCount', 0) / data.get('PageSize', 0)) + is_paginated = data.get('IsPaginated', False) + for item in data.get('Items', []): yield item current = current + 1