import { DOCUMENT_LAST } from "react-native-digitcamera/src/Api/ApiUrls";
import status from "../Status";
import { errorRecord } from "../../common/libEventLog/libCrashlytics/libCrashlyticsEvent";
var UserExperior = require("react-native-userexperior");

export const getDocumentLast = async ({ body }) => {
  try {
    UserExperior.startTimer(DOCUMENT_LAST);
    console.log("Service", DOCUMENT_LAST);
    const res = await fetch(DOCUMENT_LAST, {
      method: "POST",
      body: JSON.stringify(body),
    });
    const checkd = status.checkStatus(res);
    const json = await checkd.json();
    if (res.status !== 200) {
      throw new Error(data?.error);
    }
    UserExperior.endTimer(DOCUMENT_LAST);
    return json;
  } catch (err) {
    errorRecord(err);
    console.log("Document Last Error", err);
    throw new Error(err.message);
  }
};
