// const xml2js = require("xml2js");

// const parser = new xml2js.Parser({
//   explicitArray: false,
//   ignoreAttrs: false,
// });

// module.exports = async (soapXml) => {
//   const parsed = await parser.parseStringPromise(soapXml);

//   const body =
//     parsed["SOAP:Envelope"]?.["SOAP:Body"] ||
//     parsed["soapenv:Envelope"]?.["soapenv:Body"];

//   if (!body) throw new Error("Invalid SOAP response");

//   if (body["SOAP:Fault"]) {
//     return {
//       success: false,
//       fault: body["SOAP:Fault"],
//     };
//   }

//   const rsp = body["air:AirPriceRsp"];
//   if (!rsp) throw new Error("AirPriceRsp not found");

//   const results = rsp["air:AirPriceResult"];
//   const pricingSolution =
//     Array.isArray(results)
//       ? results[0]?.["air:AirPricingSolution"]
//       : results?.["air:AirPricingSolution"];

//   if (!pricingSolution)
//     throw new Error("AirPricingSolution not found");

//   const info = pricingSolution["air:AirPricingInfo"];

//   return {
//     success: true,
//     pricing: {
//       totalPrice: info.$.TotalPrice,
//       basePrice: info.$.BasePrice,
//       taxes: info.$.Taxes,
//       refundable: info.$.Refundable === "true",
//       pricingMethod: info.$.PricingMethod,
//       provider: info.$.ProviderCode,
//     },
//     fareInfos: pricingSolution["air:FareInfo"] || [],
//     brand: pricingSolution["air:Brand"] || null,
//   };
// };
