hubspot integation

This commit is contained in:
Jun-te Kim 2025-04-09 15:40:31 +00:00
parent 4452cd4347
commit e77654a6e7
2 changed files with 40 additions and 19 deletions

View file

@ -6,6 +6,7 @@ from etl.hubSpotClient.types import SubmissionInfoFromDeal
class DealStage(Enum):
SURVEYED_COMPLETE_NEEDS_SIGN_OFF = "1617223914"
SURVEYED_NO_ACCESS_NEED_SIGN_OFF = "1617223915"
CUSTOMER_CONTACTED = "888730834"
class HubSpotClient():
def __init__(self):
@ -17,24 +18,36 @@ class HubSpotClient():
def get_deals_from_deal_stage(self, deal_stage: DealStage):
search_request = PublicObjectSearchRequest(
filter_groups=[{
"filters": [{
"propertyName": "dealstage",
"operator": "EQ",
"value": deal_stage.value,
}]
}],
properties=[
"dealname",
"number_of_wet_rooms_needing_ventilation",
"work_type",
"property_needs_trickle_vents",
"domna_survey_post_sap",
"existing_wall_insulation"
],
)
found_deals = self.client.crm.deals.search_api.do_search(search_request)
found_deals = []
after = None
while True:
print("hello world")
search_request = PublicObjectSearchRequest(
filter_groups=[{
"filters": [{
"propertyName": "dealstage",
"operator": "EQ",
"value": deal_stage.value,
}]
}],
properties=[
"dealname",
"number_of_wet_rooms_needing_ventilation",
"work_type",
"property_needs_trickle_vents",
"domna_survey_post_sap",
"existing_wall_insulation"
],
limit=20
after=after
)
response = self.client.crm.deals.search_api.do_search(search_request)
found_deals.extend(response.results)
if not response.paging or not response.paging.next:
break
after = response.paging.next.after
return found_deals
all_deals = []
if hasattr(found_deals, "results"):
for deal in found_deals.results:

View file

@ -12,8 +12,9 @@ os.environ["JJC_SERVICE_SHAREPOINT_ID"] = "7fdd0485-bbf3-4b29-b30f-98c81c2a6284"
hubSpotClient = HubSpotClient()
deals = hubSpotClient.get_deals_from_deal_stage(DealStage.SURVEYED_COMPLETE_NEEDS_SIGN_OFF)
deals = hubSpotClient.get_deals_from_deal_stage(DealStage.CUSTOMER_CONTACTED)
hubSpotClient.print_all_pipeline_ids()
csv_list = []
@ -121,4 +122,11 @@ print("Excel file 'survey_data.xlsx' created successfully!")
# All three installers
# Rate card
# Different installer detection detection
# Sheet for each installer
# Uploaded into sharepoint -> Adminstrators -> different location -> one document per housing association