Skip to content

Commit

Permalink
feat: add report parameters
Browse files Browse the repository at this point in the history
  • Loading branch information
Abuton committed Sep 19, 2023
1 parent de0a392 commit a509bef
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,5 @@ COPY source_snapchat_marketing ./source_snapchat_marketing
ENV AIRBYTE_ENTRYPOINT "python /airbyte/integration_code/main.py"
ENTRYPOINT ["python", "/airbyte/integration_code/main.py"]

LABEL io.airbyte.version=0.3.0
LABEL io.airbyte.version=0.3.1
LABEL io.airbyte.name=airbyte/source-snapchat-marketing
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ data:
connectorSubtype: api
connectorType: source
definitionId: 200330b2-ea62-4d11-ac6d-cfe3e3f8ab2b
dockerImageTag: 0.3.0
dockerImageTag: 0.3.1
dockerRepository: airbyte/source-snapchat-marketing
githubIssueLabel: source-snapchat-marketing
icon: snapchat.svg
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -165,10 +165,13 @@ class SnapchatMarketingStream(HttpStream, ABC):
primary_key = "id"
raise_on_http_errors = True

def __init__(self, start_date, end_date, **kwargs):
def __init__(self, start_date, end_date, action_report_time, swipe_up_attribution_window, view_attribution_window, **kwargs):
super().__init__(**kwargs)
self.start_date = start_date
self.end_date = end_date
self.action_report_time = action_report_time
self.swipe_up_attribution_window = swipe_up_attribution_window
self.view_attribution_window = view_attribution_window

def next_page_token(self, response: requests.Response) -> Optional[Mapping[str, Any]]:
next_page_cursor = response.json().get("paging", False)
Expand Down Expand Up @@ -246,7 +249,7 @@ def stream_slices(self, **kwargs) -> Iterable[Optional[Mapping[str, Any]]]:
self.initial_state = stream_state.get(self.cursor_field) if stream_state else self.start_date
self.max_state = self.initial_state

parent_stream = self.parent(authenticator=self.authenticator, start_date=self.start_date, end_date=self.end_date)
parent_stream = self.parent(authenticator=self.authenticator, start_date=self.start_date, end_date=self.end_date, action_report_time=self.action_report_time, swipe_up_attribution_window=self.swipe_up_attribution_window, view_attribution_window=self.view_attribution_window)
stream_slices = get_parent_ids(parent_stream)

if stream_slices:
Expand Down Expand Up @@ -368,7 +371,7 @@ def parent(self) -> SnapchatMarketingStream:
def stream_slices(self, **kwargs) -> Iterable[Optional[Mapping[str, Any]]]:
"""Each stream slice represents each entity id from parent stream"""

parent_stream = self.parent(authenticator=self.authenticator, start_date=self.start_date, end_date=self.end_date)
parent_stream = self.parent(authenticator=self.authenticator, start_date=self.start_date, end_date=self.end_date, action_report_time=self.action_report_time, swipe_up_attribution_window=self.swipe_up_attribution_window, view_attribution_window=self.view_attribution_window)
self.parent_name = parent_stream.name
stream_slices = get_parent_ids(parent_stream)

Expand Down Expand Up @@ -808,6 +811,9 @@ def streams(self, config: Mapping[str, Any]) -> List[Stream]:
),
"start_date": config["start_date"],
"end_date": config.get("end_date", default_end_date),
"action_report_time": config.get("action_report_time", "impression"),
"swipe_up_attribution_window": config.get("swipe_up_attribution_window", "28_DAY"),
"view_attribution_window": config.get("view_attribution_window", "7_DAY"),
}

return [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,30 @@
"examples": ["2022-01-30"],
"order": 4,
"format": "date"
},
"action_report_time": {
"type": "string",
"title": "Action Report Time",
"description": "Specifies the principle for conversion reporting",
"examples": ["conversion", "impression"],
"default": "conversion",
"order": 5
},
"swipe_up_attribution_window": {
"type": "string",
"title": "Swipe Up_ Attribution Window",
"description": "Attribution window for swipe ups",
"examples": ["1_DAY", "7_DAY", "28_DAY"],
"default": "28_DAY",
"order": 6
},
"view_attribution_window": {
"type": "string",
"title": "View Attribution Window",
"description": "Attribution window for views",
"examples": ["1_HOUR", "3_HOUR", "6_HOUR", "1_DAY", "7_DAY"],
"default": "1_DAY",
"order": 7
}
}
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@
"authenticator": NoAuth(),
"start_date": "2000-01-01",
"end_date": "2000-02-10",
"action_report_time": "impression",
"swipe_up_attribution_window": "7_DAY",
"view_attribution_window": "1_DAY",
}
stats_stream = AdaccountsStatsDaily(**config_mock)

Expand Down

0 comments on commit a509bef

Please sign in to comment.