package com.capgemini.reports.emailing.templates;

import com.capgemini.reports.exceptions.InvalidInputException;

/**
 * Represents a mail to warn the destinator that the report has some invalid parameters and will not be executed.<br>
 */
public class BadParamEmailTemplate extends AbstractEmailTemplate {

    private static final String SUCCESSFUL_FR = " terminé avec succès";
    private static final String TEMPLATE_LOCATION = "template_email_bad_parameters.html";

    /**
     * Represents a mail to warn the destinator that the report has some invalid parameters and will not be executed.<br>
     *
     * @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 failed
     * @param iie                the specific Exception that contains the explanation
     */
    public BadParamEmailTemplate(final String completeReportName, final String postingTime, final String startTime, final String failureTime,
                                 final InvalidInputException iie) {
        super(completeReportName + SUCCESSFUL_FR);

        // Assign parameters
        this.setTagValue(EmailTagEnum.REPORT_NAME, completeReportName);
        this.setTagValue(EmailTagEnum.POSTING_TIME, postingTime);
        this.setTagValue(EmailTagEnum.START_TIME, startTime);
        this.setTagValue(EmailTagEnum.END_TIME, failureTime);
        this.setTagValue(EmailTagEnum.ERROR_MESSAGE, iie.getErrorMessageForUser());
    }

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

}
