import { defHttp } from '/@/utils/http/axios';
import { PageParams, RentListGetResultModel,InvoiceListResul, addCameraParams, updateParams,getItemParams } from './model';
import { Result,UploadFileParams } from '/#/axios';
import { ContentTypeEnum } from '/@/enums/httpEnum';

enum Api {
  cameraVersionList = '/service/manage/cameraVersion/list',
  upload = '/service/manage/common/upload/files',
  spaceSdkList = '/service/manage/spaceSdk/list',
  spaceSdkUpdate = '/service/manage/spaceSdk/update',
  spaceSdkOnline = '/service/manage/spaceSdk/online',
  spaceSdkTop = '/service/manage/spaceSdk/top',
  spaceSdkDel = '/service/manage/spaceSdk/delete',
  addAndUpload = '/service/manage/cameraVersion/addAndUpload',
  editAndUpload = '/service/manage/cameraVersion/update',
  delAndUpload = '/service/manage/cameraVersion/delete',
  appFileAgentList = '/service/manage/appFile/agentList',
  spaceSdkUpload = '/service/manage/spaceSdk/upload',
  appFileAdd = '/service/manage/appFile/add',
  appFileUpload = '/service/manage/appFile/upload',
  spaceSdkDelete = '/service/manage/spaceSdk/delete',
  appFileList = '/service/manage/appFile/list',
  appFileDelete = '/service/manage/appFile/delete'
}

/**
 * @description: Get sample list value
 */

export const CameraList = (params: PageParams) =>
  defHttp.post<Result>({
    url: Api.cameraVersionList,
    params: params,
    // data: params,
    headers: {
      // @ts-ignore
      ignoreCancelToken: true,
    },
  });

/**
 * @description: 新增固件
 */
export const AddAndUpload = (params: PageParams) =>{
  return defHttp.uploadFile<Result>(
    {
      url: Api.addAndUpload,
    },
    params
  );
}
/**
 * @description: 编辑固件
 */

export const EditAndUpload = (params: PageParams) =>
defHttp.post<Result>({
  url: Api.editAndUpload,
  params,
  // data: params,
  headers: {
    // @ts-ignore
    ignoreCancelToken: true,
  },
});


/**
 * @description: 删除固件
 */
 export const DelAndUpload = (params: PageParams) =>
 defHttp.post<Result>({
   url: Api.delAndUpload,
   params,
   // data: params,
   headers: {
     // @ts-ignore
     ignoreCancelToken: true,
   },
 });

export const SpaceSdkOnline = (params: PageParams) =>
  defHttp.post<Result>({
    url: Api.spaceSdkOnline,
    params: params,
    // data: params,
    headers: {
      // @ts-ignore
      ignoreCancelToken: true,
    },
  });

export const SpaceSdkUpdate = (params: PageParams) =>
  defHttp.post<Result>({
    url: Api.spaceSdkUpdate,
    params: params,
    // data: params,
    headers: {
      // @ts-ignore
      ignoreCancelToken: true,
    },
  });

/**
 * @description: SDK list
 */
 export const SpaceSdkList = (params: PageParams) =>
 defHttp.post<Result>({
   url: Api.spaceSdkList,
   params,
   // data: params,
   headers: {
     // @ts-ignore
     ignoreCancelToken: true,
   },
 });

export const SpaceSdkTop = (params: addCameraParams) =>
 defHttp.post<RentListGetResultModel>({
   url: Api.spaceSdkTop,
   params,
   headers: {
     // @ts-ignore
     ignoreCancelToken: true,
   },
 });

export const SpaceSdkDelete = (params: updateParams) =>
 defHttp.post<Result>({
   url: Api.spaceSdkDelete,
   params,
   headers: {
     // @ts-ignore
     ignoreCancelToken: true,
   },
 });
//app 管理
export const AppFileAdd = (params: updateParams) =>
 defHttp.post<Result>({
   url: Api.appFileAdd,
   params,
   headers: {
     // @ts-ignore
     ignoreCancelToken: true,
   },
 });

 export const AppFileAgentList = (params: updateParams) =>
 defHttp.get<Result>({
   url: Api.appFileAgentList,
   params,
   headers: {
     // @ts-ignore
     ignoreCancelToken: true,
   },
 });

export const AppFileList = (params: updateParams) =>
 defHttp.post<Result>({
   url: Api.appFileList,
   params,
   headers: {
     // @ts-ignore
     ignoreCancelToken: true,
   },
 });
 
export const AppFileDelete = (params: updateParams) =>
defHttp.post<Result>({
  url: Api.appFileDelete,
  params,
  headers: {
    // @ts-ignore
    ignoreCancelToken: true,
  },
});
//上传文件
export function SpaceSdkUpload(
  params: UploadFileParams,
  onUploadProgress: (progressEvent: ProgressEvent) => void,
) {
  return defHttp.uploadFile<Result>(
    {
      url: Api.spaceSdkUpload,
      onUploadProgress,
    },
    params,
  );
 }
export function uploadApi(
  params: UploadFileParams,
  onUploadProgress: (progressEvent: ProgressEvent) => void,
) {
  return defHttp.uploadFile<Result>(
    {
      url: Api.upload,
      onUploadProgress,
    },
    params,
  );
 }
 
export function AppFileUpload(
  params: UploadFileParams,
  onUploadProgress: (progressEvent: ProgressEvent) => void,
) {
  return defHttp.uploadFile<Result>(
    {
      url: Api.appFileUpload,
      onUploadProgress,
    },
    params,
  );
 }