package com.quyunshuo.module.home.service

import com.module.pay.service.HomeApiService
import com.quyunshuo.androidbaseframemvvm.base.mvvm.m.BaseRepository
import com.quyunshuo.androidbaseframemvvm.common.constant.Heartbeat
import javax.inject.Inject

/**
 * 首页M层
 *
 * @author Qu Yunshuo
 * @since 5/25/21 5:42 PM
 */

class GlobalServiceRepository @Inject constructor() : BaseRepository() {
    private  val TAG = "GlobalServiceRepository"
    @Inject
    lateinit var mApi: HomeApiService


    //广告规则读取
    suspend fun getVideoRule(id: String)= request<String> {
        val lid = id.toLong()
        val params = HashMap<String, Long>()
        params["id"] = lid
        mApi.getVideoRule(params).run {
            emit(this)
        }
    }

    //广告视频信息读取
    suspend fun getVideoInfo(id: String)= request<String> {
        val params = HashMap<String, String>()
        params["id"] = id
        mApi.getVideoInfo(params).run {
            emit(this)
        }
    }

    //闹钟信息读取
    suspend fun getAlarmClock(type:String)= request<String> {
        //开机//关机//开休眠//关休眠
        val params = HashMap<String, String>()
        params["clientId"] = Heartbeat.deviceId!!
        params["type"] = type
        mApi.getClock(params).run {
            emit(this)
        }
    }


}