Skip to content

Commit

Permalink
fix: For Hubspot make the switch to unique org id (#3863)
Browse files Browse the repository at this point in the history
  • Loading branch information
zachaysan authored May 1, 2024
1 parent 57313ca commit 54c2603
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 25 deletions.
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,
}

0 comments on commit 54c2603

Please sign in to comment.