From d250b8f4f4f70cfcb1091f9f3e2cc525c18e7280 Mon Sep 17 00:00:00 2001 From: Jun-te Kim Date: Mon, 10 Nov 2025 14:22:26 +0000 Subject: [PATCH] added line items pulling --- etl/hubSpotClient/hubspotClient.py | 36 +++++++++++++++++++ .../scripts/hubspot_update_script.py | 4 +-- 2 files changed, 38 insertions(+), 2 deletions(-) diff --git a/etl/hubSpotClient/hubspotClient.py b/etl/hubSpotClient/hubspotClient.py index adbec50..e8cdd87 100644 --- a/etl/hubSpotClient/hubspotClient.py +++ b/etl/hubSpotClient/hubspotClient.py @@ -130,6 +130,42 @@ class HubSpotClient(): ) return deal.properties + + def from_deal_get_line_items(self, deal_id): + """ + Fetches all line items associated with a given deal from HubSpot. + Returns a list of line item property dictionaries. + """ + # Get all line item associations for the deal + associations = self.client.crm.associations.v4.basic_api.get_page( + object_type="deals", + object_id=deal_id, + to_object_type="line_items", + limit=100 + ) + + if not associations.results: + return [] + + line_items = [] + for assoc in associations.results: + line_item_id = assoc.to_object_id + line_item = self.client.crm.line_items.basic_api.get_by_id( + line_item_id, + properties=[ + "name", + "quantity", + "price", + "hs_product_id", + "amount", + "description", + ], + ) + line_items.append(line_item.properties) + + return line_items + + def get_deal_info_for_db(self, deal_id): deal = self.from_deal_get_info(deal_id) diff --git a/etl/hubSpotClient/scripts/hubspot_update_script.py b/etl/hubSpotClient/scripts/hubspot_update_script.py index 5705c23..491ee02 100644 --- a/etl/hubSpotClient/scripts/hubspot_update_script.py +++ b/etl/hubSpotClient/scripts/hubspot_update_script.py @@ -8,8 +8,8 @@ db = HubspotTodb() companies = [ Companies.ABRI, - Companies.LIVEWEST, - Companies.SOUTHERN_HOUSING_GROUP, + # Companies.LIVEWEST, + # Companies.SOUTHERN_HOUSING_GROUP, ] # Global trackers