package com.gh.gamecenter.pkg

import android.annotation.SuppressLint
import com.gh.gamecenter.core.provider.IPkgProvider
import com.gh.gamecenter.pkg.retrofit.RetrofitManager
import io.reactivex.android.schedulers.AndroidSchedulers
import io.reactivex.schedulers.Schedulers

@com.therouter.inject.ServiceProvider
class PkgProviderImpl : IPkgProvider {

    @SuppressLint("CheckResult")
    override fun requestPkgConfig(configId: String, onConfigReceived: (config: Any) -> Unit) {
        RetrofitManager.getInstance().api.getPkgConfig(configId)
            .subscribeOn(Schedulers.io())
            .observeOn(AndroidSchedulers.mainThread())
            .subscribe({
                onConfigReceived.invoke(it)
            }, {
                it.printStackTrace()
            })
    }

}