module.exports = function buildUniversalRecordXML(locatorCode, targetBranch) {
  if (!locatorCode || typeof locatorCode !== "string") {
    throw new Error("Invalid locatorCode passed to XML builder");
  }

  if (!targetBranch) {
    throw new Error("targetBranch missing in XML builder");
  }

  return `
<soapenv:Envelope
  xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
  xmlns:universal="http://www.travelport.com/schema/universal_v52_0"
  xmlns:common="http://www.travelport.com/schema/common_v52_0">

  <soapenv:Header/>

  <soapenv:Body>

    <universal:UniversalRecordRetrieveReq
      TraceId="URR_${Date.now()}"
      AuthorizedBy="Travelport"
      TargetBranch="${targetBranch}">

      <common:BillingPointOfSaleInfo OriginApplication="uAPI"/>

      <universal:UniversalRecordLocatorCode>${locatorCode}</universal:UniversalRecordLocatorCode>

    </universal:UniversalRecordRetrieveReq>

  </soapenv:Body>
</soapenv:Envelope>
`.trim();
};
