All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.cosmicpush.gateway.push.EmailToSmsPush 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.gateway.push;

import com.cosmicpush.gateway.CosmicPushGateway;
import com.cosmicpush.gateway.common.*;
import com.cosmicpush.gateway.internal.*;
import com.fasterxml.jackson.annotation.*;
import org.crazyyak.dev.net.email.EmailAddress;

@JsonIgnoreProperties(ignoreUnknown = true)
public class EmailToSmsPush implements Push {

  private String fromAddress;
  private String toAddress;

  private String message;

  private PushType pushType = PushType.emailToSms;

  private EmailToSmsPush() {
  }

  public EmailToSmsPush(EmailAddress fromAddress, EmailAddress toAddress, String message) {
    this.message = message;
    this.toAddress =   (toAddress == null) ? null : toAddress.getValue();
    this.fromAddress = (fromAddress == null) ? null : fromAddress.getValue();
  }

  @Override
  public PushType getPushType() {
    return pushType;
  }

  public String getFromAddress() {
    return fromAddress;
  }

  public String getMessage() {
    return message;
  }

  public String getToAddress() {
    return toAddress;
  }

  @Override
  @JsonIgnore
  public String getEndPoint() {
    return CosmicPushGateway.PUSH_EMAIL_TO_SMS;
  }

  @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.");
    ValidationUtils.requireValue(errors, message, "The SMS message must be specified.");
    return errors;
  }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy