import invokeApi from '../helpers/apiHelpers';
import apiPath from '../constants/apiPath';
import config from '../config';

export const initialPdfFile = async (token: string): Promise<unknown> =>
  invokeApi({
    path: apiPath.initPdf,
    method: 'GET',
    data: {
      f: token,
    },
  });

export const saveFile = async (
  token: string,
  data: Record<string, unknown>,
): Promise<unknown> =>
  invokeApi({
    path: `${apiPath.saveFile}?f=${token}`,
    method: 'POST',
    data,
  });

export const fetchXfdf = (token: string): Promise<string> =>
  fetch(`${config.API_HOST}${apiPath.getXfdf}?f=${token}`).then((res) =>
    res.text(),
  );

export default {};
