diff --git a/tap_linkedin_ads/streams/ad_analytics/ad_analytics_base.py b/tap_linkedin_ads/streams/ad_analytics/ad_analytics_base.py index 8e2cbf9..03b45a4 100644 --- a/tap_linkedin_ads/streams/ad_analytics/ad_analytics_base.py +++ b/tap_linkedin_ads/streams/ad_analytics/ad_analytics_base.py @@ -56,4 +56,3 @@ def merge_dicts(self, *dict_args: dict) -> dict: for dictionary in dict_args: result.update(dictionary) return result - diff --git a/tap_linkedin_ads/streams/ad_analytics/ad_analytics_by_creative.py b/tap_linkedin_ads/streams/ad_analytics/ad_analytics_by_creative.py index 114670d..40e3e76 100644 --- a/tap_linkedin_ads/streams/ad_analytics/ad_analytics_by_creative.py +++ b/tap_linkedin_ads/streams/ad_analytics/ad_analytics_by_creative.py @@ -3,7 +3,7 @@ from __future__ import annotations import typing as t -from datetime import datetime, timezone +from datetime import timezone from importlib import resources import pendulum diff --git a/tap_linkedin_ads/streams/base_stream.py b/tap_linkedin_ads/streams/base_stream.py index f0437fd..bdd650d 100644 --- a/tap_linkedin_ads/streams/base_stream.py +++ b/tap_linkedin_ads/streams/base_stream.py @@ -3,7 +3,6 @@ from __future__ import annotations import typing as t -from datetime import datetime, timezone from functools import cached_property from singer_sdk import metrics diff --git a/tap_linkedin_ads/streams/streams.py b/tap_linkedin_ads/streams/streams.py index e8f0548..866626d 100644 --- a/tap_linkedin_ads/streams/streams.py +++ b/tap_linkedin_ads/streams/streams.py @@ -6,7 +6,6 @@ from datetime import datetime, timezone from importlib import resources -import pendulum from singer_sdk.helpers.types import Context from singer_sdk.typing import ( ArrayType, @@ -34,7 +33,9 @@ def post_process(self, row: dict, context: dict | None = None) -> dict | None: # This function extracts day, month, and year from date range column # These values are parse with datetime function and the date is added to the day column if "changeAuditStamps" in row: - created_time = row.get("changeAuditStamps", {}).get("created", {}).get("time") + created_time = ( + row.get("changeAuditStamps", {}).get("created", {}).get("time") + ) last_modified_time = ( row.get("changeAuditStamps", {}).get("lastModified", {}).get("time") ) @@ -56,10 +57,12 @@ def post_process(self, row: dict, context: dict | None = None) -> dict | None: tz=UTC, ).isoformat() else: - raise Exception("No changeAuditStamps or createdAt/lastModifiedAt fields found") + raise Exception( + "No changeAuditStamps or createdAt/lastModifiedAt fields found" + ) # Manual date filtering date = datetime.fromisoformat(row["last_modified_time"]) - start_date = datetime.fromisoformat(self.get_starting_timestamp(context)).replace(tzinfo=timezone.utc) + start_date = self.get_starting_timestamp(context) end_date = datetime.fromisoformat(self.config["end_date"]).replace(tzinfo=timezone.utc) if date >= start_date and date <= end_date: return super().post_process(row, context) @@ -538,6 +541,7 @@ def post_process(self, row: dict, context: dict | None = None) -> dict | None: row["campaign_group_id"] = int(row["campaignGroup"].split(":")[3]) return super().post_process(row, context) + class CampaignGroupsStream(LinkedInAdsStream): """https://docs.microsoft.com/en-us/linkedin/marketing/integrations/ads/account-structure/create-and-manage-campaign-groups#search-for-campaign-groups.""" @@ -644,6 +648,7 @@ def post_process(self, row: dict, context: dict | None = None) -> dict | None: ).isoformat() return super().post_process(row, context) + class CreativesStream(LinkedInAdsStream): """https://learn.microsoft.com/en-us/linkedin/marketing/integrations/ads/account-structure/create-and-manage-creatives?view=li-lms-2023-05&tabs=http%2Chttp-update-a-creative#search-for-creatives.""" @@ -789,8 +794,3 @@ def get_url_params( "owner": context["owner_urn"], **super().get_url_params(context, next_page_token), } - - - - -