@@ -0,0 +1,1993 @@
+package ch.viascom.hipchat.api.interceptors;%0A%0Aimport ch.viascom.groundwork.foxhttp.exception.FoxHttpException;%0Aimport ch.viascom.groundwork.foxhttp.header.FoxHttpHeader;%0Aimport ch.viascom.groundwork.foxhttp.interceptor.response.FoxHttpResponseInterceptor;%0Aimport ch.viascom.groundwork.foxhttp.interceptor.response.context.FoxHttpResponseInterceptorContext;%0Aimport lombok.Getter;%0Aimport lombok.Setter;%0A%0Aimport java.util.ArrayList;%0Aimport java.util.function.BiConsumer;%0A%0A/**%0A * @author patrick.boesch@viascom.ch%0A */%0Apublic class RateLimitsInterceptor implements FoxHttpResponseInterceptor %7B%0A%0A    @Getter%0A    @Setter%0A    private int weight;%0A%0A    private BiConsumer%3CFoxHttpResponseInterceptorContext, FoxHttpHeader%3E rateLimitCallback;%0A%0A    @Getter%0A    private ArrayList%3CString%3E rateLimitHeaderNames = new ArrayList%3C%3E();%0A%0A%0A    public RateLimitsInterceptor(BiConsumer%3CFoxHttpResponseInterceptorContext, FoxHttpHeader%3E rateLimitCallback) %7B%0A        this.rateLimitCallback = rateLimitCallback;%0A%0A        //Set headers from API rate limits%0A        rateLimitHeaderNames.add(%22X-Ratelimit-Limit%22);%0A        rateLimitHeaderNames.add(%22X-Ratelimit-Remaining%22);%0A        rateLimitHeaderNames.add(%22X-Ratelimit-Reset%22);%0A        rateLimitHeaderNames.add(%22X-FloodControl-Limit%22);%0A        rateLimitHeaderNames.add(%22X-FloodControl-Remaining%22);%0A        rateLimitHeaderNames.add(%22X-FloodControl-Reset%22);%0A%0A    %7D%0A%0A    @Override%0A    public void onIntercept(FoxHttpResponseInterceptorContext context) throws FoxHttpException %7B%0A        if (context.getResponseCode() == 429) %7B%0A%0A            FoxHttpHeader limitHeaders = new FoxHttpHeader();%0A%0A            context.getFoxHttpResponse().getResponseHeaders().getHeaderEntries()%0A                    .stream()%0A                    .filter(headerEntry -%3E rateLimitHeaderNames.contains(headerEntry.getValue()))%0A                    .forEach(headerEntry -%3E limitHeaders.getHeaderEntries().add(headerEntry));%0A%0A            rateLimitCallback.accept(context, limitHeaders);%0A        %7D%0A%0A%0A    %7D%0A%7D%0A

Add RateLimitsInterceptor