package com.swago.baseswago.http

import com.swago.baseswago.util.SwagoInfo
import com.swago.baseswago.util.UserInfo.getLoginModel
import okhttp3.Interceptor
import okhttp3.Request
import okhttp3.Response

/**
 * @date 2021/8/14 14:10
 * description:
 */
class SwagoInterceptor : Interceptor {
    override fun intercept(chain: Interceptor.Chain): Response {

        val request: Request = chain.request()
            .newBuilder()
            .addHeader("apiToken", getLoginModel()?.token?:"")
            .addHeader("languageCode",SwagoInfo.getLanguageCode())
            .addHeader("app-client-version",SwagoInfo.getVersionCode())
            .addHeader("app-client",SwagoInfo.getAppClient())
            .addHeader("app-client-device",SwagoInfo.getDeviceInfo())
            .addHeader("app-client-channel",SwagoInfo.getChannel())
            .build()
        return chain.proceed(request)
    }
}