From c8df91ba0602a9bce148a1f1e5b36f2b6826137c Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Fri, 25 Oct 2024 20:07:49 +0000 Subject: [PATCH] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- .../streams/ad_analytics/ad_analytics_base.py | 1 - .../ad_analytics/ad_analytics_by_creative.py | 2 +- tap_linkedin_ads/streams/base_stream.py | 1 - tap_linkedin_ads/streams/streams.py | 24 +++++++++++-------- 4 files changed, 15 insertions(+), 13 deletions(-) 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 ecd761f..57c01e2 100644 --- a/tap_linkedin_ads/streams/ad_analytics/ad_analytics_base.py +++ b/tap_linkedin_ads/streams/ad_analytics/ad_analytics_base.py @@ -54,4 +54,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 5d768b9..0e80a85 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, @@ -30,7 +29,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") ) @@ -52,11 +53,17 @@ 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.config["start_date"]).replace(tzinfo=timezone.utc) - end_date = datetime.fromisoformat(self.config["end_date"]).replace(tzinfo=timezone.utc) + start_date = datetime.fromisoformat(self.config["start_date"]).replace( + tzinfo=timezone.utc + ) + 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) return None @@ -534,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.""" @@ -640,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.""" @@ -785,8 +794,3 @@ def get_url_params( "owner": context["owner_urn"], **super().get_url_params(context, next_page_token), } - - - - -