Skip to content

Commit

Permalink
[pre-commit.ci] auto fixes from pre-commit.com hooks
Browse files Browse the repository at this point in the history
for more information, see https://pre-commit.ci
  • Loading branch information
pre-commit-ci[bot] committed Oct 25, 2024
1 parent 639ccfe commit c8df91b
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 13 deletions.
1 change: 0 additions & 1 deletion tap_linkedin_ads/streams/ad_analytics/ad_analytics_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,4 +54,3 @@ def merge_dicts(self, *dict_args: dict) -> dict:
for dictionary in dict_args:
result.update(dictionary)
return result

Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion tap_linkedin_ads/streams/base_stream.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
24 changes: 14 additions & 10 deletions tap_linkedin_ads/streams/streams.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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")
)
Expand All @@ -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
Expand Down Expand Up @@ -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."""

Expand Down Expand Up @@ -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."""

Expand Down Expand Up @@ -785,8 +794,3 @@ def get_url_params(
"owner": context["owner_urn"],
**super().get_url_params(context, next_page_token),
}





0 comments on commit c8df91b

Please sign in to comment.