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

// instructions
export const downloadPdf = async ({ body }) => {
 var url=`${BULK_PDF_DOWNLOAD}isForceGenerate=${true}&isMotorProductQuotePdf=${true}`
 console.log("PDF DownLoad service ",url);
  UserExperior.startTimer(url);
  try {
    const res = await fetch(url, {
        headers:{
        'Authorization':"Basic 1 eyJhbGciOiJIUzI1NiJ9.eyJzdWIiOiJ1c2Vycy9Uek1Vb2NNRjRwIiwiZXhwIjoxNjA5MzUzMDAwLCJuYW1lIjoiRElHSVQiLCJwYXNzd29yZCI6IkBkbWluVXNlcjEiLCJzY29wZSI6InNlbGYsZ3JvdXBzL2FkbWlucyJ9.dDo9OsFkXq3zrRtvnEgLfn9115uW1h4daHLWV4x4SpI",
        "Content-Type":"application/json; charset=utf8"
        },
      method: "POST",
      body:JSON.stringify(body)
    });
    let data = await res.json();
    if (res.status !== 200) {
      throw new Error(data?.error);
    }
    UserExperior.endTimer(url);
    return data;
  } catch (err) {
    errorRecord(err);
    console.log(err);
  }
};
