<?xml version="1.0" encoding="UTF-8"?>
<config xmlns="http://web-harvest.sourceforge.net/schema/1.0/config" scriptlang="groovy">
    <!--
     Generic report.

     Input parameters:
       ftl_template_s3_link - S3 link to FTL template. Full URL.
       s3_bucket - S3 bucket name, where to generate temporary HTML report and where to put final PDF report.
       s3_folder - S3 folder, where to generate temporary HTML report and where to put final PDF report.
      _sys_transaction_id - ID of the report transaction created in previous step.
     -->

    <robotics-flow>
        <robot driver="universal" close-on-completion="true">
            <script><![CDATA[
                import com.workfusion.odf.impl.processor.TransactionReportProcessor;
                import com.workfusion.odf.core.Intake;

                def params = [
                    "ftl_template_s3_link": ftl_template_s3_link.toString(),
                    "s3_bucket": s3_bucket.toString(),
                    "s3_folder": s3_folder.toString()
                ];

                def intake = Intake.init(binding).params(params).get();
                processedTransaction = intake.processTransaction(TransactionReportProcessor.class, _sys_transaction_id.toString());
                pdfReportLink = processedTransaction.getAttribute(TransactionReportProcessor.PARAM_PDF_REPORT_S3_LINK);
            ]]></script>
        </robot>
    </robotics-flow>

    <export include-original-data="true">
        <single-column name="_sys_transaction_pdf_report_link" value="${pdfReportLink}"/>
    </export>
</config>
