moved dfependecny

This commit is contained in:
Jun-te Kim 2025-04-08 18:44:28 +00:00
parent b54c4220f5
commit 06a7b02ca2
3 changed files with 44 additions and 6 deletions

View file

View file

@ -0,0 +1,36 @@
import hubspot
from enum import Enum
from hubspot.crm.contacts import PublicObjectSearchRequest
class DealStage(Enum):
SURVEYED_COMPLETE_NEEDS_SIGN_OFF = "1617223914"
class HubSpotClient():
def __init__(self):
self.access_token = "pat-eu1-064f7f5c-a7d8-4d93-a9b2-b604da6164a6"
self.client = hubspot.Client.create(access_token=self.access_token)
def get_all_deals(self):
return self.client.crm.deals.get_all()
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"],
)
return self.client.crm.deals.search_api.do_search(search_request)
def print_all_pipeline_ids(self):
pipelines = self.client.crm.pipelines.pipelines_api.get_all(object_type="deals")
for pipeline in pipelines.results:
print(f"Pipeline: {pipeline.label}")
for stage in pipeline.stages:
print(f" - Label: {stage.label}")
print(f" ID: {stage.id}") #

View file

@ -1,6 +1,8 @@
import hubspot
HUBSPOT_ACCESS_TOKEN = "pat-eu1-064f7f5c-a7d8-4d93-a9b2-b604da6164a6"
client = hubspot.Client.create(access_token=HUBSPOT_ACCESS_TOKEN)
deals = client.crm.deals.get_all(
limit=50,
)
from etl.hubSpotClient.hubspot import HubSpotClient, DealStage
hubSpotClient = HubSpotClient()
deals = hubSpotClient.get_deals_from_deal_stage(DealStage.SURVEYED_COMPLETE_NEEDS_SIGN_OFF)