diff --git a/dags/fivetran_acoustic.py b/dags/fivetran_acoustic.py index ea36a829d..a6439357e 100644 --- a/dags/fivetran_acoustic.py +++ b/dags/fivetran_acoustic.py @@ -101,6 +101,16 @@ def _generate_acoustic_report( "Last Modified Date", ] +SUPPRESSION_COLUMNS = [ + "Email", + "Opt In Date", + "Opted Out", + "Opt In Details", + "Email Type", + "Opted Out Date", + "Opt Out Details", +] + REPORTS_CONFIG = { "raw_recipient_export": { "request_template": """ @@ -156,6 +166,39 @@ def _generate_acoustic_report( ), }, }, + "suppression_export": { + "request_template": """ + + + + + + {list_id} + {export_type} + {export_format} + + + {columns} + + {date_start} + {date_end} + {visibility} + + + + """, + "request_params": { + "list_id": "{{ var.value.fivetran_acoustic_suppression_export_list_id }}", # list_name: "MAIN SUPPRESSION LIST - All" + "export_type": "ALL", + "export_format": "CSV", + "visibility": 1, # 0 (Private) or 1 (Shared) + "date_start": EXEC_START, + "date_end": EXEC_END, + "columns": "\n".join( + [f"{column}" for column in SUPPRESSION_COLUMNS] + ), + }, + }, } diff --git a/utils/acoustic/acoustic_client.py b/utils/acoustic/acoustic_client.py index eec18517c..5ec00b294 100644 --- a/utils/acoustic/acoustic_client.py +++ b/utils/acoustic/acoustic_client.py @@ -153,6 +153,7 @@ def generate_report( supported_report_types = ( "raw_recipient_export", "contact_export", + "suppression_export", ) if report_type not in supported_report_types: err_msg = f"{report_type} is not a valid option, supported types are: {supported_report_types}" @@ -183,6 +184,9 @@ def generate_report( report_loc = data["Envelope"]["Body"]["RESULT"]["FILE_PATH"] elif report_type == "raw_recipient_export": job_id, report_loc = data["Envelope"]["Body"]["RESULT"]["MAILING"].values() + elif report_type == "suppression_export": + job_id = data["Envelope"]["Body"]["RESULT"]["JOB_ID"] + report_loc = data["Envelope"]["Body"]["RESULT"]["FILE_PATH"] while not self._is_job_complete(job_id=job_id, extra_info=report_type): sleep(sleep_delay)