package fi.bitrite.android.ws.api.interceptors;

import android.os.Build;
import android.text.TextUtils;

import com.u.securekeys.SecureEnvironment;
import com.u.securekeys.annotation.SecureKey;
import com.u.securekeys.annotation.SecureKeys;

import java.io.IOException;

import javax.inject.Inject;

import fi.bitrite.android.ws.BuildConfig;
import fi.bitrite.android.ws.di.AppScope;
import okhttp3.Credentials;
import okhttp3.Interceptor;
import okhttp3.Request;
import okhttp3.Response;

@AppScope
public class DefaultInterceptor implements Interceptor {

    private static final String USER_AGENT = String.format("WSAndroid %s %s %s Android v%s",
            BuildConfig.VERSION_NAME, Build.MANUFACTURER, Build.MODEL, Build.VERSION.RELEASE);

    @Inject
    public DefaultInterceptor() {
    }

    @Override
    @SecureKeys({
        @SecureKey(key = "ws_api_userId", value = BuildConfig.WS_API_USER_ID),
        @SecureKey(key = "ws_api_key", value = BuildConfig.WS_API_KEY)
    })
    public Response intercept(Chain chain) throws IOException {
        Request original = chain.request();

        Request.Builder requestBuilder = original.newBuilder()
                .header("User-Agent", USER_AGENT)
                .header("Accept", "application/json");

        // Construct the API key credential.
        final String apiUserId = SecureEnvironment.getString("ws_api_userId");
        final String apiKey = SecureEnvironment.getString("ws_api_key");
        if (!TextUtils.isEmpty(apiUserId)) {
            // The apiUserId is unset in case the dev proxy server is used.
            requestBuilder.header("Authorization", Credentials.basic(apiUserId,apiKey));
        }

        return chain.proceed(requestBuilder.build());
    }
}

@@ -46,33 +46,8 @@
 s;%0A%0A
-import android.os.Build;%0A
 impo
@@ -576,149 +576,24 @@
 T = 
-String.format(%22WSAndroid %25s %25s %25s Android v%25s%22,%0A            BuildConfig.VERSION_NAME, Build.MANUFACTURER, Build.MODEL, Build.VERSION.RELEASE)
+%22WarmshowersApp%22
 ;%0A%0A 

Use "WarmshowersApp" as the value for User-Agent