package dev.meloda.fast.data

import okhttp3.Interceptor
import okhttp3.Response

class AccessTokenInterceptor : Interceptor {

    override fun intercept(chain: Interceptor.Chain): Response {
        val request = chain.request()
        val urlBuilder = request.url.newBuilder()

        if (request.url.queryParameter("access_token") == null) {
            urlBuilder.addQueryParameter("access_token", UserConfig.accessToken)
        }

        return chain.proceed(request.newBuilder().url(urlBuilder.build()).build())
    }
}
