@@ -165,10 +165,13 @@ class SnapchatMarketingStream(HttpStream, ABC):
165
165
primary_key = "id"
166
166
raise_on_http_errors = True
167
167
168
- def __init__ (self , start_date , end_date , ** kwargs ):
168
+ def __init__ (self , start_date , end_date , action_report_time , swipe_up_attribution_window , view_attribution_window , ** kwargs ):
169
169
super ().__init__ (** kwargs )
170
170
self .start_date = start_date
171
171
self .end_date = end_date
172
+ self .action_report_time = action_report_time
173
+ self .swipe_up_attribution_window = swipe_up_attribution_window
174
+ self .view_attribution_window = view_attribution_window
172
175
173
176
def next_page_token (self , response : requests .Response ) -> Optional [Mapping [str , Any ]]:
174
177
next_page_cursor = response .json ().get ("paging" , False )
@@ -246,7 +249,14 @@ def stream_slices(self, **kwargs) -> Iterable[Optional[Mapping[str, Any]]]:
246
249
self .initial_state = stream_state .get (self .cursor_field ) if stream_state else self .start_date
247
250
self .max_state = self .initial_state
248
251
249
- parent_stream = self .parent (authenticator = self .authenticator , start_date = self .start_date , end_date = self .end_date )
252
+ parent_stream = self .parent (
253
+ authenticator = self .authenticator ,
254
+ start_date = self .start_date ,
255
+ end_date = self .end_date ,
256
+ action_report_time = self .action_report_time ,
257
+ swipe_up_attribution_window = self .swipe_up_attribution_window ,
258
+ view_attribution_window = self .view_attribution_window ,
259
+ )
250
260
stream_slices = get_parent_ids (parent_stream )
251
261
252
262
if stream_slices :
@@ -368,7 +378,14 @@ def parent(self) -> SnapchatMarketingStream:
368
378
def stream_slices (self , ** kwargs ) -> Iterable [Optional [Mapping [str , Any ]]]:
369
379
"""Each stream slice represents each entity id from parent stream"""
370
380
371
- parent_stream = self .parent (authenticator = self .authenticator , start_date = self .start_date , end_date = self .end_date )
381
+ parent_stream = self .parent (
382
+ authenticator = self .authenticator ,
383
+ start_date = self .start_date ,
384
+ end_date = self .end_date ,
385
+ action_report_time = self .action_report_time ,
386
+ swipe_up_attribution_window = self .swipe_up_attribution_window ,
387
+ view_attribution_window = self .view_attribution_window ,
388
+ )
372
389
self .parent_name = parent_stream .name
373
390
stream_slices = get_parent_ids (parent_stream )
374
391
@@ -388,6 +405,9 @@ def request_params(
388
405
389
406
params = super ().request_params (stream_state = stream_state , stream_slice = stream_slice , next_page_token = next_page_token )
390
407
params ["granularity" ] = self .granularity .value
408
+ params ["action_report_time" ] = self .action_report_time
409
+ params ["swipe_up_attribution_window" ] = self .swipe_up_attribution_window
410
+ params ["view_attribution_window" ] = self .view_attribution_window
391
411
if self .metrics :
392
412
params ["fields" ] = "," .join (self .metrics )
393
413
@@ -808,6 +828,9 @@ def streams(self, config: Mapping[str, Any]) -> List[Stream]:
808
828
),
809
829
"start_date" : config ["start_date" ],
810
830
"end_date" : config .get ("end_date" , default_end_date ),
831
+ "action_report_time" : config .get ("action_report_time" , "conversion" ),
832
+ "swipe_up_attribution_window" : config .get ("swipe_up_attribution_window" , "28_DAY" ),
833
+ "view_attribution_window" : config .get ("view_attribution_window" , "1_DAY" ),
811
834
}
812
835
813
836
return [
0 commit comments