From a702b4688c59bb67a98bcbf5d58b42b9ee30c00b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9F=D0=B0=D0=B2=D0=B5=D0=BB=20=D0=9B=D0=B0=D0=B2=D1=80?= =?UTF-8?q?=D0=B8=D0=BD=D0=BE=D0=B2=D0=B8=D1=87?= Date: Wed, 17 Nov 2021 17:29:50 +0300 Subject: [PATCH] Get all with an object type --- VERSION | 2 +- hubspot/discovery/crm/objects/discovery.py | 19 ++++++++++++++++--- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/VERSION b/VERSION index c4e41f94..c5106e6d 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -4.0.3 +4.0.4 diff --git a/hubspot/discovery/crm/objects/discovery.py b/hubspot/discovery/crm/objects/discovery.py index cb51bcda..d07cb759 100644 --- a/hubspot/discovery/crm/objects/discovery.py +++ b/hubspot/discovery/crm/objects/discovery.py @@ -1,5 +1,4 @@ import hubspot.crm.objects as api_client -from hubspot.utils.objects import fetch_all from ...discovery_base import DiscoveryBase from .feedback_submissions.discovery import Discovery as FeedbackSubmissionsDiscovery @@ -29,5 +28,19 @@ def gdpr_api(self) -> api_client.GDPRApi: def feedback_submissions(self): return FeedbackSubmissionsDiscovery(self.config) - def get_all(self, **kwargs): - return fetch_all(self.basic_api, **kwargs) + def get_all(self, object_type, **kwargs): + return self.fetch_all(object_type, **kwargs) + + def fetch_all(self, object_type, **kwargs): + results = [] + after = None + PAGE_MAX_SIZE = 100 + + while True: + page = self.basic_api.get_page(object_type, after=after, limit=PAGE_MAX_SIZE, **kwargs) + results.extend(page.results) + if page.paging is None: + break + after = page.paging.next.after + + return results