feat: add acoustic supression list export (#1951)

This commit is contained in:
kik-kik 2024-03-15 16:53:09 +01:00 коммит произвёл GitHub
Родитель 7d9927edc7
Коммит 5c8966f646
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: B5690EEEBB952194
2 изменённых файлов: 47 добавлений и 0 удалений

Просмотреть файл

@ -101,6 +101,16 @@ CONTACT_COLUMNS = [
"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 @@ REPORTS_CONFIG = {
),
},
},
"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]
),
},
},
}

Просмотреть файл

@ -153,6 +153,7 @@ class AcousticClient:
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 @@ class AcousticClient:
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)