mirror of
https://github.com/Hestia-Homes/survey-extraction.git
synced 2026-06-08 11:17:29 +00:00
added line items pulling
This commit is contained in:
parent
eb95dad5fe
commit
d250b8f4f4
2 changed files with 38 additions and 2 deletions
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -8,8 +8,8 @@ db = HubspotTodb()
|
|||
|
||||
companies = [
|
||||
Companies.ABRI,
|
||||
Companies.LIVEWEST,
|
||||
Companies.SOUTHERN_HOUSING_GROUP,
|
||||
# Companies.LIVEWEST,
|
||||
# Companies.SOUTHERN_HOUSING_GROUP,
|
||||
]
|
||||
|
||||
# Global trackers
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue