ch.viascom.hipchat.api.interceptors.BadRequestCodeInterceptor Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of hipchat-api Show documentation
Show all versions of hipchat-api Show documentation
A HipChat v2 API full implementation for Java
package ch.viascom.hipchat.api.interceptors;
import ch.viascom.groundwork.foxhttp.interceptor.response.FoxHttpResponseInterceptor;
import ch.viascom.groundwork.foxhttp.interceptor.response.context.FoxHttpResponseInterceptorContext;
import ch.viascom.hipchat.api.exception.HipChatAPIException;
import lombok.Getter;
import lombok.Setter;
import java.util.function.Consumer;
/**
* @author [email protected]
*/
public class BadRequestCodeInterceptor implements FoxHttpResponseInterceptor {
@Getter
@Setter
private int weight = 100;
private Consumer unauthorizedCodeCallback;
public BadRequestCodeInterceptor(Consumer unauthorizedCodeCallback) {
this.unauthorizedCodeCallback = unauthorizedCodeCallback;
}
@Override
public void onIntercept(FoxHttpResponseInterceptorContext context) throws HipChatAPIException {
if (context.getResponseCode() == 400) {
unauthorizedCodeCallback.accept(context);
}
}
}