Skip to content

Commit

Permalink
Merge pull request #84 from HubSpot/feature/objects-get-all
Browse files Browse the repository at this point in the history
Get all with an object type
  • Loading branch information
plaurynovich-hubspot authored Nov 18, 2021
2 parents 0f23466 + a702b46 commit 219b2d7
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
4.0.3
4.0.4
19 changes: 16 additions & 3 deletions hubspot/discovery/crm/objects/discovery.py
Original file line number Diff line number Diff line change
@@ -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

Expand Down Expand Up @@ -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

0 comments on commit 219b2d7

Please sign in to comment.