com.cosmicpush.pub.push.ImPush 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.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonProperty;
import java.io.Serializable;
public class ImPush implements Push, Serializable {
private final String recipient;
private final String message;
private final ImType imType;
private final String callbackUrl;
private final PushType pushType = PushType.im;
public ImPush(@JsonProperty("imType") ImType imType,
@JsonProperty("recipient") String recipient,
@JsonProperty("message") String message,
@JsonProperty("callbackUrl") String callbackUrl) {
this.recipient = recipient;
this.message = message;
this.imType = imType;
this.callbackUrl = callbackUrl;
}
@Override
public String getCallbackUrl() {
return callbackUrl;
}
public ImType getImType() {
return imType;
}
@Override
public PushType getPushType() {
return pushType;
}
public String getRecipient() {
return recipient;
}
public String getMessage() {
return message;
}
@Override
@JsonIgnore
public String getEndPoint() {
return EndPoints.PUSH_IM;
}
@Override
public RequestErrors validate(RequestErrors errors) {
ValidationUtils.requireValue(errors, recipient, "The recipient must be specified.");
ValidationUtils.requireValue(errors, message, "The chat message must be specified.");
ValidationUtils.requireValue(errors, imType, "The IM type must be specified.");
return errors;
}
public static ImPush googleTalk(String recipient, String message, String callbackUrl) {
return new ImPush(ImType.googleTalk, recipient, message, callbackUrl);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy