diff --git a/tap_hubspot_beta/client_v3.py b/tap_hubspot_beta/client_v3.py index 71bd9f1..8ed75dd 100644 --- a/tap_hubspot_beta/client_v3.py +++ b/tap_hubspot_beta/client_v3.py @@ -189,6 +189,7 @@ class hubspotV3Stream(hubspotStream): records_jsonpath = "$.results[*]" next_page_token_jsonpath = "$.paging.next.after" + marketing_streams = ["campaigns"] def get_next_page_token( self, response: requests.Response, previous_token: Optional[Any] @@ -206,13 +207,17 @@ def get_url_params( params.update(self.additional_prarams) if self.properties_url: params["properties"] = ",".join(self.selected_properties) + if self.name in self.marketing_streams: + default_properties = ["id", "createdAt", "updatedAt"] + properties = [prop for prop in self.selected_properties if prop not in default_properties] + params["properties"] = ",".join(properties) if next_page_token: params["after"] = next_page_token return params def post_process(self, row: dict, context: Optional[dict]) -> dict: """As needed, append or transform raw data to match expected structure.""" - if self.properties_url: + if self.properties_url or self.name in self.marketing_streams: for name, value in row["properties"].items(): row[name] = value del row["properties"] diff --git a/tap_hubspot_beta/streams.py b/tap_hubspot_beta/streams.py index 5de5170..5d41e3c 100644 --- a/tap_hubspot_beta/streams.py +++ b/tap_hubspot_beta/streams.py @@ -1449,6 +1449,33 @@ class QuotesStream(ObjectSearchV3): properties_url = "properties/v2/quotes/properties" +class CampaignsStream(hubspotV3Stream): + """Campaigns Stream""" + + name = "campaigns" + path = "marketing/v3/campaigns" + + schema = th.PropertiesList( + th.Property("id", th.StringType), + th.Property("hs_name", th.StringType), + th.Property("hs_start_date", th.DateTimeType), + th.Property("hs_end_date", th.DateTimeType), + th.Property("hs_notes", th.StringType), + th.Property("hs_audience", th.StringType), + th.Property("hs_goal", th.StringType), + th.Property("hs_currency_code", th.StringType), + th.Property("hs_campaign_status", th.StringType), + th.Property("hs_owner", th.StringType), + th.Property("hs_color_hex", th.StringType), + th.Property("hs_created_by_user_id", th.StringType), + th.Property("hs_object_id", th.StringType), + th.Property("hs_budget_items_sum_amount", th.StringType), + th.Property("hs_spend_items_sum_amount", th.StringType), + th.Property("createdAt", th.DateTimeType), + th.Property("updatedAt", th.DateTimeType), + ).to_dict() + + class AssociationQuotesDealsStream(AssociationDealsStream): """Association Quotes -> Deals Stream""" @@ -1689,4 +1716,4 @@ class AssociationTasksDealsStream(AssociationTasksStream): """Association Tasks -> Deals Stream""" name = "associations_tasks_deals" - path = "crm/v4/associations/tasks/deals/batch/read" \ No newline at end of file + path = "crm/v4/associations/tasks/deals/batch/read" diff --git a/tap_hubspot_beta/tap.py b/tap_hubspot_beta/tap.py index aca02ee..62bf772 100644 --- a/tap_hubspot_beta/tap.py +++ b/tap_hubspot_beta/tap.py @@ -69,6 +69,7 @@ AssociationTasksCompaniesStream, AssociationTasksContactsStream, AssociationTasksDealsStream, + CampaignsStream ) STREAM_TYPES = [ @@ -135,6 +136,7 @@ AssociationTasksCompaniesStream, AssociationTasksContactsStream, AssociationTasksDealsStream, + CampaignsStream ]