package com.gh.gamecenter.retrofit;

import android.content.Context;

import com.gh.common.constant.Config;
import com.gh.gamecenter.common.retrofit.BaseRetrofitManager;
import com.gh.gamecenter.retrofit.service.ApiService;
import com.gh.gamecenter.retrofit.service.VApiService;
import com.halo.assistant.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 final VApiService mVApiService;

    private RetrofitManager() {
        Context context = HaloApp.getInstance().getApplicationContext();
        OkHttpClient okHttpNormalConfig = getOkHttpConfig(context, 0, 2);
        mApiService = provideService(okHttpNormalConfig, Config.API_HOST, ApiService.class);
        mNewApiService = provideService(okHttpNormalConfig, Config.NEW_API_HOST, ApiService.class);
        mUploadApiService = provideService(getOkHttpConfig(context, UPLOAD_CALL_TIME_OUT, 1), Config.API_HOST, ApiService.class);
        mVApiService = provideService(okHttpNormalConfig, Config.VAPI_HOST, VApiService.class);
    }

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

    public ApiService getApi() {
        return mApiService;
    }

    public ApiService getNewApi() {
        return mNewApiService;
    }

    public ApiService getUploadApi() {
        return mUploadApiService;
    }

    public VApiService getVApi() {
        return mVApiService;
    }

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