package com.ysnows.base.net;

import android.os.Build;

import com.tencent.mmkv.MMKV;
import com.ysnows.base.base.BApp;

import java.io.IOException;

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

public class BHeaderInterceptor implements Interceptor {
    @Override
    public Response intercept(Chain chain) throws IOException {

        Request request = chain.request().newBuilder()
                .addHeader("User-Agent", "type/android;app_version_code/" +  BApp.instance().config().getVersionCode() + ";app_version_name/" +  BApp.instance().config().getVersionName() + ";phone_brand/" + Build.BRAND + ";phone_model/" + Build.MODEL + ";system_version_code/" + Build.VERSION.SDK_INT + ";system_version_name/" + Build.VERSION.RELEASE)
                .addHeader("Content-Type", "application/json")
                .addHeader("authorization", MMKV.defaultMMKV().decodeString("token", ""))
                .build();

        return chain.proceed(request);
    }
}
