package com.gh.gamecenter.minigame

import com.gh.gamecenter.feature.entity.GameEntity
import com.gh.gamecenter.retrofit.RetrofitManager
import com.gh.gamecenter.retrofit.service.ApiService
import io.reactivex.Single
import okhttp3.ResponseBody

/**
 * 小游戏-最近在玩-数据层
 */
class MiniGameRecentlyPlayRepository(
    private val apiService: ApiService = RetrofitManager.getInstance().newApi
) {

    /**
     * 获取小游戏-最近在玩游戏列表
     * @param gameType 游戏类型（qq/wechat）
     */
    fun getRecentPlayedMiniGameList(gameType: String): Single<List<GameEntity>> {
        return apiService.getRecentPlayedMiniGameList(gameType)
    }

    /**
     * 提交微信小游戏秒玩记录
     * @param wechatAppId 微信游戏ID
     * @param gid 设备ID
     */
    fun postRecentPlayedWGame(wechatAppId: String, gid: String): Single<ResponseBody> {
        return apiService.postWGamePlay(wechatAppId, gid)
    }

    /**
     * 提交QQ小游戏秒玩记录
     * @param qqAppId QQ游戏ID
     * @param userId 用户ID
     */
    fun postRecentPlayedQGame(qqAppId: String, userId: String): Single<ResponseBody> {
        return apiService.postQGamePlay(qqAppId, userId)
    }
}