com.cosmicpush.gateway.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.gateway.push;
import com.cosmicpush.gateway.CosmicPushGateway;
import com.cosmicpush.gateway.common.*;
import com.cosmicpush.gateway.internal.*;
import com.fasterxml.jackson.annotation.JsonIgnore;
public class ImPush implements Push {
private String recipient;
private String message;
private ImType imType;
private PushType pushType = PushType.im;
private ImPush() {
}
public ImPush(ImType imType, String recipient, String message) {
this.recipient = recipient;
this.message = message;
this.imType = imType;
}
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 CosmicPushGateway.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) {
return new ImPush(ImType.googleTalk, recipient, message);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy