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

feat: Add org id to hubspot company #3680

Merged
merged 3 commits into from
Mar 27, 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
4 changes: 2 additions & 2 deletions api/integrations/lead_tracking/hubspot/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@ def create_contact(self, user: FFAdminUser, hubspot_company_id: str) -> dict:
)
return response.to_dict()

def create_company(self, name: str) -> dict:
properties = {"name": name}
def create_company(self, name: str, organisation_id: int) -> dict:
properties = {"name": name, "orgid": str(organisation_id)}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor: I'd love to see the hubspot parameters pulled out as constants in e.g. hubspot.constants.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We discussed offline and decided against it for now.

simple_public_object_input_for_create = SimplePublicObjectInputForCreate(
properties=properties,
)
Expand Down
5 changes: 4 additions & 1 deletion api/integrations/lead_tracking/hubspot/lead_tracker.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,10 @@ def get_or_create_organisation_hubspot_id(self, organisation: Organisation) -> s
if getattr(organisation, "hubspot_organisation", None):
return organisation.hubspot_organisation.hubspot_id

response = self.client.create_company(name=organisation.name)
response = self.client.create_company(
name=organisation.name,
organisation_id=organisation.id,
)
# Store the organisation data in the database since we are
# unable to look them up via a unique identifier.
HubspotOrganisation.objects.create(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,9 @@ def test_hubspot_with_new_contact_and_new_organisation(
# Then
organisation.refresh_from_db()
assert organisation.hubspot_organisation.hubspot_id == future_hubspot_id
mock_create_company.assert_called_once_with(name=organisation.name)
mock_create_company.assert_called_once_with(
name=organisation.name, organisation_id=organisation.id
)
mock_create_contact.assert_called_once_with(user, future_hubspot_id)
mock_get_contact.assert_called_once_with(user)

Expand Down