package com.gh.gamecenter.common.retrofit;

import android.content.Context;

import com.gh.gamecenter.common.utils.EnvHelper;
import com.gh.gamecenter.core.HaloApp;

import okhttp3.OkHttpClient;

/**
 * Created by LGT on 2016/11/7.
 * Retrofit 管理工具
 */
public class RetrofitManager extends BaseRetrofitManager {

    private final ApiService mApiService;
    private final ApiService mNewApiService;
    private final ApiService mUploadApiService;

    private RetrofitManager() {
        Context context = HaloApp.getInstance().getApplicationContext();
        OkHttpClient okHttpNormalConfig = getOkHttpConfig(context, 0, 2);
        mApiService = provideService(okHttpNormalConfig, EnvHelper.getHost(), ApiService.class);
        mNewApiService = provideService(okHttpNormalConfig, EnvHelper.getNewHost(), ApiService.class);
        mUploadApiService = provideService(getOkHttpConfig(context, UPLOAD_CALL_TIME_OUT, 1), EnvHelper.getHost(), ApiService.class);
    }

    public static RetrofitManager getInstance() {
        return SingletonHolder.INSTANCE;
    }

    public ApiService getApi() {
        return mApiService;
    }

    public ApiService getNewApi() {
        return mNewApiService;
    }

    public ApiService getUploadApi() {
        return mUploadApiService;
    }

    private static class SingletonHolder {
        private static final RetrofitManager INSTANCE = new RetrofitManager();
    }
}
