package com.agilex.healthcare.schedulingmanager.notification.appointmentrequest;

import com.agilex.messaging.core.Message;

import java.io.Serializable;
import java.util.UUID;
import agilex.commons.helper.PropertyHelper;

/**
 * Created with IntelliJ IDEA.
 * User: clarkee
 * Date: 2/22/13
 * Time: 3:27 PM
 * To change this template use File | Settings | File Templates.
 */
@SuppressWarnings("serial")
public class EmailNotificationMessage implements Message, Serializable {


    private String emailAddress;
    private final String messageId;
    private EmailDefaults emailDefaults;
    private String emailBody;

    public EmailNotificationMessage(String emailAddress, EmailDefaults emailDefaults, String emailBody) {
        this.emailDefaults = emailDefaults;
        this.messageId = UUID.randomUUID().toString();
        this.emailAddress = emailAddress;
        this.emailBody = emailBody;
    }

    public String getEmailAddress() {
        return emailAddress;
    }

    @Override
    public String id() {
        return messageId;
    }

    public String getMessageBody() {
        if (emailBody != null && emailBody.trim().length() > 0){
            return emailBody;
        }
        return emailDefaults.getBody();
    }

    public String getFrom() {
        return emailDefaults.getFrom();
    }

    public String getReplyTo() {
        return emailDefaults.getReplyTo();
    }

    public String getSubject() {
        return emailDefaults.getSubject();
    }
}
