package com.getbubblenow.android.api.interceptor;

import java.io.IOException;

import androidx.annotation.NonNull;
import okhttp3.Interceptor;
import okhttp3.Request;
import okhttp3.Response;

public class UserAgentInterceptor implements Interceptor {
    private static final String USER_AGENT_HEADER_KEY = "User-Agent";

    private final String userAgent;

    public UserAgentInterceptor(final String userAgent) {
        this.userAgent = userAgent;
    }

    @NonNull
    @Override
    public Response intercept(final Chain chain) throws IOException {
        final Request original = chain.request();
        final Request.Builder builder = original.newBuilder().header(USER_AGENT_HEADER_KEY, userAgent);
        final Request request = builder.build();
        return chain.proceed(request);
    }
}
