package com.hh.arome.mvp.model;

import com.common.lib_base.common.http.bean.BaseBean;
import com.common.lib_base.utils.StringUtils;
import com.hh.arome.BuildConfig;
import com.hh.arome.bean.DeviceConfigRequestBean;
import com.hh.arome.bean.DeviceConfigResultBean;
import com.hh.arome.bean.HeartBeatRequestBean;
import com.hh.arome.bean.SimpleResultBean;
import com.hh.arome.common.ConfigData;
import com.hh.arome.http.ApiService;
import com.hh.arome.mvp.model.base.BaseModel;

import io.reactivex.Observable;
import okhttp3.RequestBody;

public class HeartbeatModel extends BaseModel {


    String urlHeartbeatDefault = BuildConfig.BASE_URL_OMC + "middle-management/api/v1/device/heart/tracking";

    public String getUrlHeartbeatDefault() {
        return urlHeartbeatDefault;
    }


    public HeartbeatModel(ApiService mApiService) {
        super(mApiService);

        // 先获取在线配置的心跳
        DeviceConfigResultBean deviceConfigResultBean = ConfigData.getDeviceConfigResultBean();
        String urlHeartbeatNew = "";
        if (deviceConfigResultBean != null) {
            urlHeartbeatNew = deviceConfigResultBean.getHeartTrackingUrl();
            if (StringUtils.isNotNull(urlHeartbeatNew)) {
                urlHeartbeatDefault = urlHeartbeatNew;
            }
        }

    }





    public Observable<BaseBean<SimpleResultBean>> requestHeartBeat(HeartBeatRequestBean bean) {
        RequestBody requestBody = createRequestBody(bean);

        return mApiService.requestHeartBeat(urlHeartbeatDefault,
                requestBody);
    }






}
