From 33eb54fd96fe06fcb83f3030f7007a76bda4f4a1 Mon Sep 17 00:00:00 2001 From: Bharat Chauhan Date: Sun, 3 Dec 2023 17:39:06 +0530 Subject: [PATCH] Update code for next version --- async_stripe/api_resources/list_object.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/async_stripe/api_resources/list_object.py b/async_stripe/api_resources/list_object.py index 76c591d..9119a7f 100644 --- a/async_stripe/api_resources/list_object.py +++ b/async_stripe/api_resources/list_object.py @@ -31,7 +31,11 @@ async def next_page_patch( stripe_account=stripe_account, ) - last_id = self.data[-1].id + last_id = getattr(self.data[-1], "id") + if not last_id: + raise ValueError( + "Unexpected: element in .data of list object had no id" + ) params_with_filters = self._retrieve_params.copy() params_with_filters.update({"starting_after": last_id}) @@ -54,7 +58,11 @@ async def previous_page_patch( stripe_account=stripe_account, ) - first_id = self.data[0].id + first_id = getattr(self.data[0], "id") + if not first_id: + raise ValueError( + "Unexpected: element in .data of list object had no id" + ) params_with_filters = self._retrieve_params.copy() params_with_filters.update({"ending_before": first_id})