diff --git a/etl/hubspot/hubspotClient.py b/etl/hubspot/hubspotClient.py index 6fd11bed..8bbe8a63 100644 --- a/etl/hubspot/hubspotClient.py +++ b/etl/hubspot/hubspotClient.py @@ -25,7 +25,7 @@ from hubspot.crm.associations.v4.models import ( # type: ignore[reportMissingTy ForwardPaging as AssociationsPaging, NextPage as AssociationsPagingNext, ) -from etl.hubspot.hubspotDataTodB import CompanyData +from etl.hubspot.hubspotDataTodB import CompanyData, HubspotDataToDb from backend.app.config import get_settings @@ -217,8 +217,15 @@ class HubspotClient: def get_deal_info_for_db( self, deal_id: str ) -> tuple[dict[str, str], Optional[str], Optional[dict[str, str]]]: + deal: dict[str, str] = self.from_deal_id_get_info(deal_id) company: Optional[str] = self.from_deal_id_get_associated_company_id(deal_id) + + if company: + company_data: CompanyData = self.get_company_information(company) + dbloader: HubspotDataToDb = HubspotDataToDb() + dbloader.upsert_company(company_data) + listing: Optional[dict[str, str]] = self.from_deal_id_get_associated_listing( deal_id ) diff --git a/etl/hubspot/hubspotDataTodB.py b/etl/hubspot/hubspotDataTodB.py index fb88422c..58da4036 100644 --- a/etl/hubspot/hubspotDataTodB.py +++ b/etl/hubspot/hubspotDataTodB.py @@ -90,7 +90,7 @@ class HubspotDataToDb: sha256.update(chunk) return sha256.hexdigest() - def update_deal(self, deal_in_db, hubspot_client): + def update_deal(self, deal_in_db, hubspot_client) -> bool: """ Checks if a deal needs updating and syncs it with HubSpot. Also handles major_condition_issue_photos file upload to S3 with integrity check. diff --git a/etl/hubspot/scripts/onboarding/new_organisation.py b/etl/hubspot/scripts/onboarding/new_organisation.py index f2ff8bda..f8c6ba7a 100644 --- a/etl/hubspot/scripts/onboarding/new_organisation.py +++ b/etl/hubspot/scripts/onboarding/new_organisation.py @@ -1,3 +1,13 @@ +""" +README.md + +This is a simple script to showcase how a new organisation can be +added to AraDb. + +This has been made reduntant due to doing this process when ever +hubspot has a webhook +""" + from etl.hubspot.hubspotClient import HubspotClient, Companies from etl.hubspot.hubspotDataTodB import HubspotDataToDb, CompanyData diff --git a/etl/hubspot/scripts/scraper/main.py b/etl/hubspot/scripts/scraper/main.py index f862948b..aa9a9502 100644 --- a/etl/hubspot/scripts/scraper/main.py +++ b/etl/hubspot/scripts/scraper/main.py @@ -29,8 +29,8 @@ def handler(body: dict[str, Any], context: Any, local: bool = False) -> None: "Missing Hubspot Deal ID in SQS body request, 'hubspot_deal_id'" ) - hubspot = HubspotClient() - dbloader = HubspotDataToDb() + hubspot: HubspotClient = HubspotClient() + dbloader: HubspotDataToDb = HubspotDataToDb() deal = dbloader.find_deal_with_deal_id(hubspot_deal_id)