From 06a7b02ca243d41de0d00b5c39d6316765b681eb Mon Sep 17 00:00:00 2001 From: Jun-te Kim Date: Tue, 8 Apr 2025 18:44:28 +0000 Subject: [PATCH] moved dfependecny --- etl/hubSpotClient/__init__.py | 0 etl/hubSpotClient/hubspot.py | 36 +++++++++++++++++++++++++++++ etl/hubspot_to_deemed_calculator.py | 14 ++++++----- 3 files changed, 44 insertions(+), 6 deletions(-) create mode 100644 etl/hubSpotClient/__init__.py create mode 100644 etl/hubSpotClient/hubspot.py diff --git a/etl/hubSpotClient/__init__.py b/etl/hubSpotClient/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/etl/hubSpotClient/hubspot.py b/etl/hubSpotClient/hubspot.py new file mode 100644 index 0000000..ecc84b6 --- /dev/null +++ b/etl/hubSpotClient/hubspot.py @@ -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}") # \ No newline at end of file diff --git a/etl/hubspot_to_deemed_calculator.py b/etl/hubspot_to_deemed_calculator.py index d7d05de..fdbcdc5 100644 --- a/etl/hubspot_to_deemed_calculator.py +++ b/etl/hubspot_to_deemed_calculator.py @@ -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, - ) \ No newline at end of file +from etl.hubSpotClient.hubspot import HubSpotClient, DealStage + +hubSpotClient = HubSpotClient() + + + +deals = hubSpotClient.get_deals_from_deal_stage(DealStage.SURVEYED_COMPLETE_NEEDS_SIGN_OFF) +