
com.cosmicpush.pub.push.EmailPush Maven / Gradle / Ivy
/*
* Copyright (c) 2014 Jacob D. Parr
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.cosmicpush.pub.push;
import com.cosmicpush.pub.common.*;
import com.cosmicpush.pub.internal.*;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonIgnore;
import java.io.Serializable;
import com.fasterxml.jackson.annotation.JsonProperty;
import org.crazyyak.dev.common.StringUtils;
public class EmailPush implements Push, Serializable {
private final String fromAddress;
private final String toAddress;
private final String emailSubject;
private final String htmlContent;
private final String callbackUrl;
private final PushType pushType = PushType.email;
@JsonCreator
public EmailPush(@JsonProperty("toAddress") String toAddress,
@JsonProperty("fromAddress") String fromAddress,
@JsonProperty("emailSubject") String emailSubject,
@JsonProperty("htmlContent") String htmlContent,
@JsonProperty("callbackUrl") String callbackUrl) {
this.toAddress = toAddress;
this.fromAddress = fromAddress;
this.emailSubject = emailSubject;
this.htmlContent = htmlContent;
this.callbackUrl = callbackUrl;
}
@Override
public PushType getPushType() {
return pushType;
}
public String getFromAddress() {
return fromAddress;
}
public String getToAddress() {
return toAddress;
}
public String getEmailSubject() {
return emailSubject;
}
public String getHtmlContent() {
return htmlContent;
}
@Override
public String getCallbackUrl() {
return callbackUrl;
}
@Override
@JsonIgnore
public String getEndPoint() {
return EndPoints.PUSH_EMAIL;
}
@Override
public RequestErrors validate(RequestErrors errors) {
ValidationUtils.requireValue(errors, toAddress, "The \"to\" address must be specified.");
ValidationUtils.requireValue(errors, fromAddress, "The \"from\" address must be specified.");
if (StringUtils.isBlank(emailSubject) && StringUtils.isBlank(htmlContent)) {
errors.add("At least the subject and/or the HTML content must be specified.");
}
return errors;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy