/**@flow
 * Created by shiyunjie on 2018/8/29.
 */
import _ from 'lodash';
import { fetchCoreAPI } from '../../utils/api/BasicAPIRequest';

type RiskTakerParams = {
  uid : string,
}

export async function queryInsuranceListByUidAPI(params : RiskTakerParams) {
  console.log('queryInsuranceListByUidAPI', params);
  const body = await fetchCoreAPI('001001', params);
  console.log('queryInsuranceListByUidAPI_body:', body);
  if (_.get(body, 'code') === '0000' && _.get(body, 'data')) {
    return _.get(body, 'data');
  }
  return [];
}

export async function queryInsuranceProductsAPI(params) {
  console.log('queryInsuranceProductsAPI', params);
  const body = await fetchCoreAPI('001002', params);
  console.log('queryInsuranceProductsAPI_body:', body);
  if (_.get(body, 'code') === '0000' && _.get(body, 'data')) {
    return _.get(body, 'data');
  }
  return [];
}

export async function trailPolicyAPI(params) {
  console.log('trailPolicyAPI', params);
  const body = await fetchCoreAPI('001003', {params:params});
  console.log('trailPolicyAPI_body:', body);
  if (_.get(body, 'code') === '0000' && _.get(body, 'data')) {
    return _.get(body, 'data');
  }
  return [];
}

export default {};
