package com.capgemini.reports.emailing.templates;

import lombok.extern.slf4j.Slf4j;

/** Represents a mail to warn the user that his report has failed. */
@Slf4j
public class FailedEmailTemplate extends AbstractEmailTemplate {

    private static final String FAILED_FR = " terminé en erreur";
    private static final String TEMPLATE_LOCATION = "template_email_failed.html";

    /**
     * Represents a mail to warn the user that his report has failed.
     * @param completeReportName the name of the report (e.g. R01 report "BOM Assemblage PU")
     * @param postingTime a String describing he time at which this report was posted in the queues
     * @param startTime a String describing he time at which this report's execution has started
     * @param failureTime a String describing he time at which this report caused an error
     * @param errorMessage the error message to include for the user
     * @param schedulingName
     */
    public FailedEmailTemplate(final String completeReportName, final String postingTime, final String startTime, final String failureTime,
                               final String errorMessage, final String schedulingName) {
        super(completeReportName + " - planification " + schedulingName + FAILED_FR);
        this.setTagValue(EmailTagEnum.POSTING_TIME, postingTime);
        this.setTagValue(EmailTagEnum.REPORT_NAME, completeReportName);
        this.setTagValue(EmailTagEnum.START_TIME, startTime);
        this.setTagValue(EmailTagEnum.END_TIME, failureTime);
        this.setTagValue(EmailTagEnum.ERROR_MESSAGE, errorMessage);
    }

    /**
     * Represents a mail to warn the user that his report has failed.
     * @param completeReportName the name of the report (e.g. R01 report "BOM Assemblage PU")
     * @param postingTime a String describing he time at which this report was posted in the queues
     * @param startTime a String describing he time at which this report's execution has started
     * @param failureTime a String describing he time at which this report caused an error
     * @param errorMessage the error message to include for the user
     */
    public FailedEmailTemplate(final String completeReportName, final String postingTime, final String startTime, final String failureTime,
                               final String errorMessage) {
        super(completeReportName + FAILED_FR);
        this.setTagValue(EmailTagEnum.POSTING_TIME, postingTime);
        this.setTagValue(EmailTagEnum.REPORT_NAME, completeReportName);
        this.setTagValue(EmailTagEnum.START_TIME, startTime);
        this.setTagValue(EmailTagEnum.END_TIME, failureTime);
        this.setTagValue(EmailTagEnum.ERROR_MESSAGE, errorMessage);
    }

    @Override
    protected String getEmailTemplate() {
        return TEMPLATE_LOCATION;
    }

}
