diff --git a/source-hubspot-native/source_hubspot_native/api.py b/source-hubspot-native/source_hubspot_native/api.py index 3b287a654b..a49ccec078 100644 --- a/source-hubspot-native/source_hubspot_native/api.py +++ b/source-hubspot-native/source_hubspot_native/api.py @@ -79,11 +79,30 @@ async def fetch_deal_pipelines( async def fetch_owners( - log: Logger, http: HTTPSession -) -> list[Owner]: - url = f"{HUB}/owners/v2/owners/" + http: HTTPSession, log: Logger, +) -> AsyncGenerator[Owner, None]: + url = f"{HUB}/crm/v3/owners" + after: str | None = None + + input: dict[str, Any] = { + "limit": 500, + } + + while True: + if after: + input["after"] = after + + result = PageResult[Owner].model_validate_json( + await http.request(log, url, method="GET", params=input) + ) + + for owner in result.results: + yield owner + + if not result.paging: + break - return TypeAdapter(list[Owner]).validate_json(await http.request(log, url)) + after = result.paging.next.after async def fetch_page_with_associations( diff --git a/source-hubspot-native/source_hubspot_native/resources.py b/source-hubspot-native/source_hubspot_native/resources.py index e392e82afb..cf1e7a177e 100644 --- a/source-hubspot-native/source_hubspot_native/resources.py +++ b/source-hubspot-native/source_hubspot_native/resources.py @@ -250,10 +250,6 @@ def open( def owners(http: HTTPSession) -> Resource: - async def snapshot(log: Logger) -> AsyncGenerator[Owner, None]: - for item in await fetch_owners(log, http): - yield item - def open( binding: CaptureBinding[ResourceConfig], binding_index: int, @@ -266,7 +262,7 @@ def open( binding_index, state, task, - fetch_snapshot=snapshot, + fetch_snapshot=functools.partial(fetch_owners, http), tombstone=Owner(_meta=Owner.Meta(op="d"), createdAt=None, updatedAt=None), ) diff --git a/source-hubspot-native/tests/snapshots/snapshots__capture__stdout.json b/source-hubspot-native/tests/snapshots/snapshots__capture__stdout.json index 3981143ae7..96d5627a8a 100644 --- a/source-hubspot-native/tests/snapshots/snapshots__capture__stdout.json +++ b/source-hubspot-native/tests/snapshots/snapshots__capture__stdout.json @@ -5736,28 +5736,15 @@ "row_id": 0, "uuid": "DocUUIDPlaceholder-329Bb50aa48EAa9ef" }, - "activeSalesforceId": null, - "activeUserId": 63843671, + "archived": false, "createdAt": "2024-02-08T02:34:06.654000Z", "email": "johnny@estuary.dev", "firstName": "Johnny", - "hasContactsAccess": false, - "isActive": true, + "id": "722900407", "lastName": "Graettinger", - "ownerId": 722900407, - "portalId": 45192106, - "remoteList": [ - { - "active": true, - "id": 579527292, - "ownerId": 722900407, - "portalId": 45192106, - "remoteId": "63843671", - "remoteType": "HUBSPOT" - } - ], "type": "PERSON", "updatedAt": "2024-02-08T04:35:51.909000Z", + "userId": 63843671, "userIdIncludingInactive": 63843671 } ]