import axios from "axios";

export const useVNINVerification = (token:string, uniqueId: string) => {
  return new Promise(async (resolve, reject) => {
    try {
      const response = await axios.post(
        `${process.env.NEXT_PUBLIC_VNIN_API_ENDPOINT}/partner/thirdpartyverification`,
        {
          AccessLevel: "4",
          UniqueId: uniqueId,
          EmailAddress: "walenewera@yahoo.com",
          InstitutionCode: "VNimc",
          Code: "VNimc",
          InstitutionName: "VNimc",
          ServiceCode: "SV0052",
          ServiceName: "Virtual NIN",
        },
        {
          headers: {
            Authorization: `Bearer ${token}`,
            "Content-Type": "application/json",
          },
        }
      );
      resolve({resp: response.data, status: response.status });
    } catch (error) {
        console.error('Error fetching VNIN Number verification token:', error);
        reject({resp: "VNIN Number verification token failed", status: 400 });
    }
  })
}