package com.dahe.gldriver.net

import com.dahe.gldriver.utils.BaseSingNoParam
import com.dahe.mylibrary.CommonBaseLibrary
import com.dahe.mylibrary.net.JsonInterceptor
import okhttp3.OkHttpClient
import java.util.concurrent.TimeUnit

/**
 * @ClassName DataManager3
 * @Author 用户
 * @Date 2023/12/29 10:09
 * @Description TODO
 */
class DataManager private constructor(){

    //伴生对象实现BaseSingleton抽象类
    companion object : BaseSingNoParam<Api>() {
        //重写方法并给出具体实现
        override fun creator(): Api {
            return  CommonBaseLibrary.getRetrofit().newBuilder()
                .client(OkHttpClient.Builder()
                    .connectTimeout(30, TimeUnit.SECONDS)
                    .readTimeout(30, TimeUnit.SECONDS)
                    .writeTimeout(30, TimeUnit.SECONDS)
                    .addInterceptor(JsonInterceptor())
                    .addInterceptor(RequestHeadInterceptor())
                    .build()) //                .addNetworkInterceptor(new TokenInterceptor())
                .build().create(Api::class.java)
        }
    }

}