package org.linlinjava.jz.core.insurance;

import com.alibaba.fastjson.JSON;
import org.linlinjava.jz.core.insurance.config.InsuranceProperties;
import org.linlinjava.jz.core.insurance.vo.InsureExternalVo;
import org.linlinjava.jz.core.util.HttpUtil;
import org.linlinjava.jz.core.util.ResponseUtil;
import org.linlinjava.jz.core.util.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * 保姆安心包投保服务
 * 2020-12-9
 */

@Service
public class InsuranceService {

    @Autowired
    private InsuranceProperties properties;

    /**
     * post请求接口
     *
     * @return
     */
    public Object Post(InsureExternalVo vo) throws Exception {

        if (vo == null || StringUtils.isEmpty(vo.getCustomerName()) || StringUtils.isEmpty(vo.getCustomerTel()) || StringUtils.isEmpty(vo.getCustomerIdCard()))
            return ResponseUtil.badArgument();

        return ResponseUtil.ok(HttpUtil.sendPost(properties.getUrl(), JSON.toJSONString(vo)));

    }

}
