Skip to content

Commit

Permalink
merge custom audiences classes and remove rule to fix bug (#149)
Browse files Browse the repository at this point in the history
  • Loading branch information
pnadolny13 authored Jan 24, 2024
1 parent dc35211 commit 46dfbdc
Showing 1 changed file with 8 additions and 34 deletions.
42 changes: 8 additions & 34 deletions tap_facebook/streams/custom_audiences.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

import typing as t

from singer_sdk.streams.core import REPLICATION_INCREMENTAL
from singer_sdk.typing import (
BooleanType,
IntegerType,
Expand All @@ -18,7 +17,7 @@
from tap_facebook.client import FacebookStream


class CustomAudiencesInternal(FacebookStream):
class CustomAudiences(FacebookStream):
"""https://developers.facebook.com/docs/marketing-api/reference/custom-audience/."""

"""
Expand All @@ -30,6 +29,13 @@ class CustomAudiencesInternal(FacebookStream):
tap_stream_id = stream id
"""

name = "customaudiences"
primary_keys = ["id"] # noqa: RUF012

@property
def path(self) -> str:
return f"/customaudiences?fields={self.columns}"

@property
def columns(self) -> list[str]:
return [
Expand All @@ -55,12 +61,6 @@ def columns(self) -> list[str]:
"name",
]

name = "customaudiencesinternal"
tap_stream_id = "customaudiencesinternal"
primary_keys = ["id"] # noqa: RUF012
replication_method = REPLICATION_INCREMENTAL
replication_key = "time_updated"

schema = PropertiesList(
Property("account_id", StringType),
Property("id", StringType),
Expand Down Expand Up @@ -91,38 +91,12 @@ def columns(self) -> list[str]:
Property("permission_for_actions", ObjectType()),
Property("pixel_id", StringType),
Property("retention_days", IntegerType),
Property("rule", StringType),
Property("subtype", StringType),
Property("rule_aggregation", StringType),
Property("opt_out_link", StringType),
Property("name", StringType),
).to_dict()

@property
def path(self) -> str:
return f"/customaudiences?fields={self.columns}"


class CustomAudiences(CustomAudiencesInternal):
"""https://developers.facebook.com/docs/marketing-api/reference/custom-audience/."""

"""
columns: columns which will be added to fields parameter in api
name: stream name
account_id: facebook account
path: path which will be added to api url in client.py
schema: instream schema
tap_stream_id = stream id
"""

# Add rule column
@property
def columns(self) -> list[str]:
return [*super().columns, "rule"]

name = "customaudiences"
tap_stream_id = "customaudiences"

def get_url_params(
self,
context: dict | None, # noqa: ARG002
Expand Down

0 comments on commit 46dfbdc

Please sign in to comment.