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

fix: For Hubspot make the switch to unique org id #3863

Merged
merged 3 commits into from
May 1, 2024
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
12 changes: 3 additions & 9 deletions api/integrations/lead_tracking/hubspot/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,20 +103,14 @@ def create_company(
organisation_id: int = None,
domain: str | None = None,
) -> dict:
properties = {
"name": name,
"active_subscription": active_subscription,
"orgid": str(organisation_id),
}
properties = {"name": name}

if domain:
properties["domain"] = domain
if active_subscription:
properties["active_subscription"] = active_subscription

# hubspot doesn't allow null values for numeric fields, so we
# set this to -1 for auto generated organisations.
properties["orgid"] = organisation_id or -1
if organisation_id:
properties["orgid_unique"] = organisation_id

simple_public_object_input_for_create = SimplePublicObjectInputForCreate(
properties=properties,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ def generate_get_company_by_domain_response_no_results() -> FakeHubspotResponse:


def generate_create_company_response(
name: str, domain: str | None = None, organisation_id: int = -1
name: str, domain: str | None = None, organisation_id: None | int = None
) -> FakeHubspotResponse:
"""
Generate a sample response given by the Hubspot API when creating a company.
Expand All @@ -81,25 +81,29 @@ def generate_create_company_response(
properties dynamically.
"""

properties = {
"active_subscription": None,
"createdate": "2024-04-23T17:36:50.158Z",
"domain": domain,
"hs_lastmodifieddate": "2024-04-23T17:36:50.158Z",
"hs_object_id": "11349198823",
"hs_object_source": "INTEGRATION",
"hs_object_source_id": "2902325",
"hs_object_source_label": "INTEGRATION",
"name": name,
"website": domain,
}

if organisation_id:
properties["orgid_unique"] = organisation_id

return FakeHubspotResponse(
data={
"archived": False,
"archived_at": None,
"created_at": datetime(2024, 4, 23, 17, 36, 50, 158000, tzinfo=tzlocal()),
"id": "11349198823",
"properties": {
"active_subscription": None,
"createdate": "2024-04-23T17:36:50.158Z",
"domain": domain,
"hs_lastmodifieddate": "2024-04-23T17:36:50.158Z",
"hs_object_id": "11349198823",
"hs_object_source": "INTEGRATION",
"hs_object_source_id": "2902325",
"hs_object_source_label": "INTEGRATION",
"name": name,
"orgid": organisation_id,
"website": domain,
},
"properties": properties,
"properties_with_history": None,
"updated_at": datetime(2024, 4, 23, 17, 36, 50, 158000, tzinfo=tzlocal()),
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,6 @@ def test_create_company_without_organisation_information(
hubspot_client.client.crm.companies.basic_api.create.assert_called_once()
call_args = hubspot_client.client.crm.companies.basic_api.create.call_args
assert call_args.kwargs["simple_public_object_input_for_create"].properties == {
"active_subscription": None,
"domain": domain,
"name": name,
"orgid": -1,
}