mirror of
https://github.com/Hestia-Homes/survey-extraction.git
synced 2026-06-08 11:17:29 +00:00
moved dfependecny
This commit is contained in:
parent
b54c4220f5
commit
06a7b02ca2
3 changed files with 44 additions and 6 deletions
0
etl/hubSpotClient/__init__.py
Normal file
0
etl/hubSpotClient/__init__.py
Normal file
36
etl/hubSpotClient/hubspot.py
Normal file
36
etl/hubSpotClient/hubspot.py
Normal 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}") #
|
||||
|
|
@ -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)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue