Skip to content

Commit 5c8966f

Browse files
authored
feat: add acoustic supression list export (#1951)
1 parent 7d9927e commit 5c8966f

File tree

2 files changed

+47
-0
lines changed

2 files changed

+47
-0
lines changed

dags/fivetran_acoustic.py

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,16 @@ def _generate_acoustic_report(
101101
"Last Modified Date",
102102
]
103103

104+
SUPPRESSION_COLUMNS = [
105+
"Email",
106+
"Opt In Date",
107+
"Opted Out",
108+
"Opt In Details",
109+
"Email Type",
110+
"Opted Out Date",
111+
"Opt Out Details",
112+
]
113+
104114
REPORTS_CONFIG = {
105115
"raw_recipient_export": {
106116
"request_template": """
@@ -156,6 +166,39 @@ def _generate_acoustic_report(
156166
),
157167
},
158168
},
169+
"suppression_export": {
170+
"request_template": """
171+
<!-- https://developer.goacoustic.com/acoustic-campaign/reference/export-from-a-database -->
172+
<!-- date_format: 07/25/2011 12:12:11 (time is optional) -->
173+
<Envelope>
174+
<Body>
175+
<ExportList>
176+
<LIST_ID>{list_id}</LIST_ID>
177+
<EXPORT_TYPE>{export_type}</EXPORT_TYPE>
178+
<EXPORT_FORMAT>{export_format}</EXPORT_FORMAT>
179+
<INCLUDE_RECIPIENT_ID></INCLUDE_RECIPIENT_ID>
180+
<EXPORT_COLUMNS>
181+
{columns}
182+
</EXPORT_COLUMNS>
183+
<DATE_START>{date_start}</DATE_START>
184+
<DATE_END>{date_end}</DATE_END>
185+
<VISIBILITY>{visibility}</VISIBILITY>
186+
</ExportList>
187+
</Body>
188+
</Envelope>
189+
""",
190+
"request_params": {
191+
"list_id": "{{ var.value.fivetran_acoustic_suppression_export_list_id }}", # list_name: "MAIN SUPPRESSION LIST - All"
192+
"export_type": "ALL",
193+
"export_format": "CSV",
194+
"visibility": 1, # 0 (Private) or 1 (Shared)
195+
"date_start": EXEC_START,
196+
"date_end": EXEC_END,
197+
"columns": "\n".join(
198+
[f"<COLUMN>{column}</COLUMN>" for column in SUPPRESSION_COLUMNS]
199+
),
200+
},
201+
},
159202
}
160203

161204

utils/acoustic/acoustic_client.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,7 @@ def generate_report(
153153
supported_report_types = (
154154
"raw_recipient_export",
155155
"contact_export",
156+
"suppression_export",
156157
)
157158
if report_type not in supported_report_types:
158159
err_msg = f"{report_type} is not a valid option, supported types are: {supported_report_types}"
@@ -183,6 +184,9 @@ def generate_report(
183184
report_loc = data["Envelope"]["Body"]["RESULT"]["FILE_PATH"]
184185
elif report_type == "raw_recipient_export":
185186
job_id, report_loc = data["Envelope"]["Body"]["RESULT"]["MAILING"].values()
187+
elif report_type == "suppression_export":
188+
job_id = data["Envelope"]["Body"]["RESULT"]["JOB_ID"]
189+
report_loc = data["Envelope"]["Body"]["RESULT"]["FILE_PATH"]
186190

187191
while not self._is_job_complete(job_id=job_id, extra_info=report_type):
188192
sleep(sleep_delay)

0 commit comments

Comments
 (0)