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.DeviceConfigResultBean;
import com.hh.arome.bean.HeartBeatRequestBean;
import com.hh.arome.bean.LogcatAddRequestBean;
import com.hh.arome.bean.SimpleResultBean;
import com.hh.arome.common.ConfigData;
import com.hh.arome.common.Constants;
import com.hh.arome.http.ApiService;
import com.hh.arome.mvp.model.base.BaseModel;
import com.hh.arome.utlis.log.AppLogUtils;

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

import static com.hh.arome.common.Constants.Url.API_LOGCAT_ADD;
import static com.hh.arome.common.Constants.Url.BASE_API_URL;
import static com.hh.arome.common.Constants.Url.BASE_URL;
import static com.hh.arome.common.Constants.Url.LOG_URL_DEFAULT;

public class LogcatAddModel extends BaseModel {



    String urlLogDefault = LOG_URL_DEFAULT;

    public LogcatAddModel(ApiService mApiService) {
        super(mApiService);
    }

    public Observable<BaseBean<SimpleResultBean>> requestLogcatAdd(LogcatAddRequestBean bean) {
        RequestBody requestBody = createRequestBody(bean);

        // 先获取在线配置的url
        DeviceConfigResultBean deviceConfigResultBean = ConfigData.getDeviceConfigResultBean();
        if(deviceConfigResultBean!=null){
            String logPushUrl = deviceConfigResultBean.getLogPushUrl();
            if(StringUtils.isNotNull(logPushUrl)){
                urlLogDefault = logPushUrl;
            }
        }

        return mApiService.requestLogcatAdd(urlLogDefault,requestBody);
    }





}
