Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
…-ads into rebuild
  • Loading branch information
pnadolny13 committed Oct 25, 2024
2 parents 38cd018 + c8df91b commit 57cb869
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 12 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 @@ -56,4 +56,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
18 changes: 9 additions & 9 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 Down Expand Up @@ -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")
)
Expand All @@ -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)
Expand Down Expand Up @@ -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."""

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

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





0 comments on commit 57cb869

Please sign in to comment.