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

type RiskTakerParams = {
  uid : string,
}

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

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

export default {};
