import server from "./index";

interface InputData<T> {
  image: File;
}

interface PredictRes<T> {
  code: number;
  response_id: string;
  data: T;
}

interface OcrInput {
  FormData: FormData;
}

interface MagciColorRes {
  image: string;
  cost: number;
}

interface DetectionRes {
  code: number;
  response_id: string;
  data: any;
}

interface OcrRecRes {
  code: number;
  response_id: string;
  data: any;
}

interface TableRecRes {
  code: number;
  response_id: string;
  data: any;
}

export const GetVersion = (
  api: string
): Promise<string> => server.get(api);

export const GetBuildTag = (
  api: string
): Promise<string> => server.get(api);

export const GetModelInfo = (
  api: string
): Promise<string> => server.get(api);

export const IMMagicColor = (
  api: string,
  data: FormData
): Promise<PredictRes<MagciColorRes>> => server.post(api, data);

export const Detection = (api: string, data: FormData): Promise<DetectionRes> =>
  server.post(api, data);

export const OcrRec = (api: string, data: FormData): Promise<OcrRecRes> =>
  server.post(api, data);

export const TableRec = (api: string, data: FormData): Promise<TableRecRes> =>
  server.post(api, data);

export const SubmitBug = (api: string, data: any): Promise<OcrRecRes> =>
  server.get(api, data);

export {};
