mirror of
https://github.com/Hestia-Homes/survey-extraction.git
synced 2026-06-30 13:10:56 +00:00
added types for better pydantic things
This commit is contained in:
parent
00383038e0
commit
a42ea8670a
3 changed files with 30 additions and 1 deletions
|
|
@ -4,6 +4,7 @@ from hubspot.crm.deals import PublicObjectSearchRequest
|
|||
|
||||
class DealStage(Enum):
|
||||
SURVEYED_COMPLETE_NEEDS_SIGN_OFF = "1617223914"
|
||||
SURVEYED_NO_ACCESS_NEED_SIGN_OFF = "1617223915"
|
||||
|
||||
class HubSpotClient():
|
||||
def __init__(self):
|
||||
|
|
@ -25,7 +26,11 @@ class HubSpotClient():
|
|||
}],
|
||||
properties=["dealname"],
|
||||
)
|
||||
return self.client.crm.deals.search_api.do_search(search_request)
|
||||
found_deals = self.client.crm.deals.search_api.do_search(search_request)
|
||||
if hasattr(found_deals, "results"):
|
||||
return found_deals.results
|
||||
else:
|
||||
return None
|
||||
|
||||
def print_all_pipeline_ids(self):
|
||||
pipelines = self.client.crm.pipelines.pipelines_api.get_all(object_type="deals")
|
||||
|
|
|
|||
15
etl/hubSpotClient/types.py
Normal file
15
etl/hubSpotClient/types.py
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
from sqlmodel import Field, SQLModel
|
||||
from sqlalchemy import Column
|
||||
from sqlalchemy.dialects.postgresql import UUID
|
||||
import uuid
|
||||
|
||||
class BaseModel(SQLModel):
|
||||
id: uuid.UUID = Field(
|
||||
default_factory=uuid.uuid4,
|
||||
sa_column=Column(UUID(as_uuid=True), primary_key=True)
|
||||
)
|
||||
|
||||
|
||||
class Deal(BaseModel):
|
||||
id: str
|
||||
name: str
|
||||
|
|
@ -1,4 +1,5 @@
|
|||
from etl.hubSpotClient.hubspot import HubSpotClient, DealStage
|
||||
from etl.hubSpotClient.types import Deal
|
||||
|
||||
hubSpotClient = HubSpotClient()
|
||||
|
||||
|
|
@ -6,3 +7,11 @@ hubSpotClient = HubSpotClient()
|
|||
|
||||
deals = hubSpotClient.get_deals_from_deal_stage(DealStage.SURVEYED_COMPLETE_NEEDS_SIGN_OFF)
|
||||
|
||||
all_deals = []
|
||||
|
||||
if deals:
|
||||
for deal in deals:
|
||||
all_deals.append(Deal(
|
||||
id= deal.properties["hs_object_id"],
|
||||
name=deal.properties["dealname"]
|
||||
))
|
||||
Loading…
Add table
Reference in a new issue