Travelport-Ukraine / uapi-json

Best Travelport Universal API wrapper ever :airplane: :mountain_railway: :hotel:
https://travelport-ukraine.github.io/uapi-json/
MIT License
74 stars 61 forks source link

Error in cancel PNR : Air.js #589

Closed ukeh closed 2 years ago

ukeh commented 2 years ago

There is an error in Air.js file.

function : cancelBooking()

return this.getUniversalRecordByPNR(options) .then((ur) => { const urr = Array.isArray(ur) ? ur[0] : ur; const record = { reservationLocatorCode: urr.uapi_reservation_locator }; return (ignoreTickets ? Promise.resolve([]) : this.getTickets(record).then(checkTickets) ) .then(() => this.getBooking(options)) .then(booking => service.cancelBooking(booking)) .catch( err => Promise.reject(new AirRuntimeError.FailedToCancelPnr(options, err)) ); });

Here this.getTickets(record) actually passing record as a parameter, where record = { reservationLocatorCode };

And the getTickets() is taking pnr from the parameter list which is not present in the "record" object.

async getTickets(options) {
  const { pnr } = options;
  const ur = await this.getUniversalRecordByPNR({ pnr });
  const urData = Array.isArray(ur) ? ur[0] : ur;
  const { uapi_reservation_locator: reservationLocatorCode } = urData;
  try {
    return await service.getTickets({ reservationLocatorCode });
  } catch (err) {
    if (err instanceof AirRuntimeError.NoAgreement) {
      throw err;
    }

    throw new AirRuntimeError.UnableToRetrieveTickets(options, err);
  }
},
ukeh commented 2 years ago

Solution

instead of calling this.getTickets(record), call this.getTickets(options)