Skip to content

Commit

Permalink
feat: add acoustic supression list export (#1951)
Browse files Browse the repository at this point in the history
  • Loading branch information
kik-kik authored Mar 15, 2024
1 parent 7d9927e commit 5c8966f
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 0 deletions.
43 changes: 43 additions & 0 deletions dags/fivetran_acoustic.py
Original file line number Diff line number Diff line change
Expand Up @@ -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": """
Expand Down Expand Up @@ -156,6 +166,39 @@ def _generate_acoustic_report(
),
},
},
"suppression_export": {
"request_template": """
<!-- https://developer.goacoustic.com/acoustic-campaign/reference/export-from-a-database -->
<!-- date_format: 07/25/2011 12:12:11 (time is optional) -->
<Envelope>
<Body>
<ExportList>
<LIST_ID>{list_id}</LIST_ID>
<EXPORT_TYPE>{export_type}</EXPORT_TYPE>
<EXPORT_FORMAT>{export_format}</EXPORT_FORMAT>
<INCLUDE_RECIPIENT_ID></INCLUDE_RECIPIENT_ID>
<EXPORT_COLUMNS>
{columns}
</EXPORT_COLUMNS>
<DATE_START>{date_start}</DATE_START>
<DATE_END>{date_end}</DATE_END>
<VISIBILITY>{visibility}</VISIBILITY>
</ExportList>
</Body>
</Envelope>
""",
"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>{column}</COLUMN>" for column in SUPPRESSION_COLUMNS]
),
},
},
}


Expand Down
4 changes: 4 additions & 0 deletions utils/acoustic/acoustic_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -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}"
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 5c8966f

Please sign in to comment.