import { showerFetch, ResponseDataEntity } from './index';

export enum OperationMode {
  beanFirst = 1,
  aimiFirst = 2,
  onlyAimi = 3,
}

type ShowerParams = {
  deviceCode: string;
  customerId: string;
  campusId: number;
};
export type DeviceInfoResponse = {
  code: string;
  isOnlyBluetooth: number;
  operationMode: OperationMode;
  position: string;
};
/**
 * 通过设备码获取设备信息
 */
export const fetchShowerInfo = (
  params: ShowerParams,
): Promise<ResponseDataEntity<DeviceInfoResponse>> =>
  showerFetch({
    url: `/dcxy/api/shower/devices/${params.deviceCode}`,
    data: params,
  });

type UsingParams = {
  customerId: number;
};
/**
 * 通过用户查询在使用的设备信息
 */
export const fetchUsingShowerInfo = (params: UsingParams) =>
  showerFetch({
    url: '/dcxy/api/shower/devices/inuseByCurrentUser',
    data: params,
  });

type StartParams = {
  deviceCode: string;
  customerId: string;
  customerName: string;
  customerPhone: string;
};
/**
 * 开启设备使用
 */
export const startShowerEquipment = (params: StartParams) =>
  showerFetch({
    url: `/dcxy/api/shower/devices/${params.deviceCode}/beginning`,
    method: 'POST',
    data: params,
  });
type ControllerParams = {
  customerId: number;
  campusId: number;
};
type ControllerResponse = {
  beanAmount: number;
  money: number;
  thresholdPrompt: string;
  thresholdValue: number;
};

export const getShowerController = (
  params: ControllerParams,
): Promise<ResponseDataEntity<ControllerResponse>> =>
  showerFetch({
    url: '/dcxy/api/shower/controllerConfigs',
    data: params,
  });
