import { get, post } from "./http";

const prefix = 'devicesApi/user/';

export default user = {
  login: (param) => {
    return post(prefix + 'login', param);
  },
  register: (param) => {
    return post(prefix + 'register', param);
  },
  registerDriver: (param) => {
    return post(prefix + 'upgradeDriver', param);
  },
  getConmpany: () => {
    return get(prefix + 'getFleetCompanyList');
  },
  getProfile: () => {
    return get(prefix + 'getUserDetail', {});
  },
  setProfile: (params) => {
    return post(prefix + 'update', params);
  },
  setNotifySwitch: (params) => {
    return post(prefix + 'updateUserNotifySwitch', params);
  },
  setNotifyToken: (token) => {
    return post(prefix + 'registerGoogleToken', token);
  },
  getCountryCode: () => {
    return get(prefix + 'getCountryCode', {});
  },
  rateCharge: (params) => {
    return post(prefix + 'rating', params);
  },
  feedback: (params) => {
    return post(prefix + 'feedback', params);
  },
  getTypeOfFeedback: () => {
    return get(prefix + 'getTypeOfFeedback', {});
  },
  getVehicles: () => {
    return get(prefix + 'getVehicles', {});
  },
  getVehicleById: (params) => {
    return get(prefix + 'getVehicleById', params);
  },
  addVehicle: (params) => {
    return post(prefix + 'addVehicle', params);
  },
  updateVehicle: (params) => {
    return post(prefix + 'updateVehicle', params);
  },
  deleteVehicle: (params) => {
    return get(prefix + 'delVehicleById', params);
  },
  getConnectorType: () => {
    return get(prefix + 'getConnectorType', {});
  },
  /**
   * 重置密码时发送邮箱验证码接口
   * @param {String} email 邮箱地址
   * @returns Promise(Response)
   */
  sendVerificationCode: (email) => {
    return get(prefix + 'sendVerificationCode', {email: email, type: "reset"});
  },
  /**
   * 注册和重置密码时发送邮箱验证码接口
   * @param {Object} params {email, type}
   * @returns Promise(Response)
   */
  sendVerificationCodeV2: (params) => {
    return get(prefix + 'sendVerificationCode', params);
  },
  updatePassword: (params) => {
    return post(prefix + 'updatePassword', params);
  },
  getCountryList: () => {
    return get('devicesApi/base/getCountries')
  },
  deleteAccount: () => {
    return get(prefix + 'delUser')
  }
}