package com.filestack.util;

import okhttp3.Interceptor;
import okhttp3.Request;
import okhttp3.Response;

import java.io.IOException;

/**
 * Intercepts requests to add Filestack-specific headers.
 */
public class HeaderInterceptor implements Interceptor {
    public static String HEADER_USER_AGENT = "User-Agent";
    public static String HEADER_FILESTACK_SOURCE = "Filestack-Source";

    public static String USER_AGENT = "filestack-java %s";
    public static String FILESTACK_SOURCE = "Java-%s";

    private String version;

    public HeaderInterceptor() {
        this.version = Util.getVersion();
    }

    @Override
    public Response intercept(Chain chain) throws IOException {
        Request original = chain.request();

        Request modified = original.newBuilder()
                .addHeader(HEADER_USER_AGENT, String.format(USER_AGENT, version))
                .addHeader(HEADER_FILESTACK_SOURCE, String.format(FILESTACK_SOURCE, version))
                .build();

        return chain.proceed(modified);
    }
}

@@ -22,16 +22,44 @@
 .util;%0A%0A
+import java.io.IOException;%0A
 import o
@@ -132,37 +132,8 @@
 e;%0A%0A
-import java.io.IOException;%0A%0A
 /**%0A

Fix linter warnings for HeaderInterceptor