Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

source-hubspot-native: use v3 of the owners API #2291

Merged
merged 1 commit into from
Jan 23, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 23 additions & 4 deletions source-hubspot-native/source_hubspot_native/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
6 changes: 1 addition & 5 deletions source-hubspot-native/source_hubspot_native/resources.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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),
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
]
Expand Down
Loading