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.bean.AlipayUserInfoRequestBean;
import com.hh.arome.bean.AlipayUserInfoResultBean;
import com.hh.arome.bean.DeviceConfigResultBean;
import com.hh.arome.bean.LogcatAddRequestBean;
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 com.hh.arome.utlis.log.AppLogUtils;

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

import static com.hh.arome.common.Constants.Url.USER_INFO_THREE_ELEMENTS;

public class AlipayUserInfoModel extends BaseModel {




    // 默认的
    String urlUserInfoDefault = USER_INFO_THREE_ELEMENTS;


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


//        DeviceConfigResultBean deviceConfigResultBean = ConfigData.getDeviceConfigResultBean();
//        String urlUserInfoNew = "";
//        if (deviceConfigResultBean != null) {
//            // 先获取在线配置的url
//            urlUserInfoNew = deviceConfigResultBean.getServiceAddress();
//            AppLogUtils.e("urlUserInfoNew:"+urlUserInfoNew);
//            if (StringUtils.isNotNull(urlUserInfoNew)) {
//                urlUserInfoDefault = urlUserInfoNew;
//            }
//        }


    }

    public Observable<BaseBean<AlipayUserInfoResultBean>> requestAlipayUserInfo(AlipayUserInfoRequestBean bean) {
        RequestBody requestBody = createRequestBody(bean);

        // 先获取在线配置的url
        String serviceAddress = bean.getServiceAddress();
        if(StringUtils.isNotNull(serviceAddress)){
            urlUserInfoDefault = serviceAddress;
        }

        return mApiService.requestAlipayUserInfo(urlUserInfoDefault,requestBody);
    }


}
