liteapi-node-sdk
Advanced tools
Comparing version 4.1.0 to 4.2.0
{ | ||
"name": "liteapi-node-sdk", | ||
"version": "4.1.0", | ||
"version": "4.2.0", | ||
"description": "Start building travel apps with liteAPI. Instantly access millions of hotels to build new or existing apps and platforms.", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -6,3 +6,11 @@ const expect = require('expect.js'); | ||
this.timeout(20000); | ||
// Function to generate or retrieve the voucher code dynamically | ||
function getVoucherCode() { | ||
return 'VOUCHER_' + Math.random().toString(36).substr(2, 9).toUpperCase(); | ||
} | ||
let latestVoucherId; | ||
let bookingId; | ||
let offer; | ||
it('should retrieve full rates', async function() { | ||
@@ -23,2 +31,5 @@ const data = { | ||
expect(result.data).to.be.an('object'); | ||
if (result.data.data && result.data.data.length > 0 && result.data.data[0].roomTypes && result.data.data[0].roomTypes.length > 0) { | ||
offer = result.data.data[0].roomTypes[0].offerId; | ||
} | ||
}); | ||
@@ -28,3 +39,3 @@ | ||
const data = { | ||
offerId: 'GE5ESNBSIZKVMQ2QJJNEERSPKIZEMR2OIRKVOVCTKNFVMRCWKNLUWVKKGVDVMRKWGJEEWRSOIVEVCS2PJRFEUVKPK5JVKSKSI5LFKVKTLBFFMSKWKVJEGQSKKZHEMRKSGJFEYRSDIU3FIS2LJRBEIVSLJUZEKSSOJBDEKVSTJBGEUSSWJFJEWTSJJJGFKT2TJJKESUSGKU2FKU2WJE2UKVSTKJBUQSSWIZDEOURSIJDU4S2FI5KFGMSLLJCFMU2NKNKUUVSIIVKVMMSOJNLE4RKJKFFU6S2KJJKU6V2KKNFVER2VGRJEEVKJGVBVMRKWINDEUVSCIZDVEMSSJRDEWRKLKRFTES2GJFDEGV2TIVEUMR2WIVLEWSCJKZHEKSKSGJHEUUJSIUZFMU2ZJFMTGRSNKMZFKS2CJJCVOVSTJBDTKQSWJVJTET2JJZCUMU2UJNKESSSEKVCVCU2ZJRDEOVSFKUZESSKGJZDFCV2LK5FEUSSVK5LVGTSKIJBVIT2RKNJUSNBSIZKVEQ2SJJNEMRSPKNBUMR2OINCU6VCTJNFTKRCVJNLUWVSLGRNFKR2XKNGEURSKIZEVIS2OJNFE4RKPKZFVGS2SI5KTEVKTKVEVUS2UI5JEGRSKGVDEMTKVINJUUSSDKUZFMQ2VI5JEIVKTK5FUKSKWJBCUKVKTJBFEMTSFJFJTETSLJJEVKT2RJNNEUQSNKUZFIQSVJJDEQRCNKJJUMSSWIZDEWURSJJGEMTKGKNKFGQ2LJJCFKS2NKNCUWRSFKRCVKMSLI5JEURSNKJFVGS2OJBKUWVCLGJEVEQKVGJKVGVSJLJFVMU2WINDEUUSGIZDVEMSWJNDEGRKLKRFUGR2KIRKUGV2LIJIFCMSEI5HFET2HIUZUQWKNKJIUOSJSIMZE2SSTIZKVURCLJFBFGR2BGVCECTKCGJDUCWKILFKVGUD4GYZDSNL4GJ6GY4BRHA4TO7BSFV6FKU2EPRKVG7BSGAZDILJRGIWTGMD4GIYDENBNGEZC2MZRPR6DMLRQGA', // Replace with actual offerId | ||
offerId: offer, | ||
}; | ||
@@ -64,2 +75,3 @@ | ||
expect(result.data).to.be.an('object'); | ||
bookingId = result.data.bookingId; | ||
}); | ||
@@ -82,3 +94,3 @@ | ||
it('should cancel a booking', async function() { | ||
const result = await liteApi.cancelBooking('2iurjZrDN'); | ||
const result = await liteApi.cancelBooking(bookingId); | ||
expect(result).to.have.property('status', 'success'); | ||
@@ -179,6 +191,13 @@ expect(result).to.have.property('data'); | ||
expect(result.data.vouchers).to.be.an('array'); | ||
if (result.data.vouchers.length > 0) { | ||
const latestVoucher = result.data.vouchers.reduce((latest, voucher) => { | ||
return new Date(voucher.created_at) > new Date(latest.created_at) ? voucher : latest; | ||
}); | ||
latestVoucherId = latestVoucher.id; | ||
} | ||
}); | ||
it('should retrieve a specific voucher by ID', async function() { | ||
const result = await liteApi.getVoucherById(80); | ||
const result = await liteApi.getVoucherById(latestVoucherId); | ||
expect(result).to.have.property('status', 'success'); | ||
@@ -191,3 +210,3 @@ expect(result).to.have.property('data'); | ||
const data = { | ||
voucher_code: 'em4z7z7l', | ||
voucher_code: getVoucherCode(), | ||
discount_type: 'percentage', | ||
@@ -212,3 +231,3 @@ discount_value: 12, | ||
const data = { | ||
voucher_code: 'em8kyd7l', | ||
voucher_code: getVoucherCode(), | ||
discount_type: 'percentage', | ||
@@ -225,3 +244,3 @@ discount_value: 12, | ||
const result = await liteApi.updateVoucher(80, data); | ||
const result = await liteApi.updateVoucher(latestVoucherId, data); | ||
expect(result).to.have.property('status', 'success'); | ||
@@ -233,3 +252,3 @@ expect(result).to.have.property('data'); | ||
it('should update the status of a voucher', async function() { | ||
const result = await liteApi.updateVoucherStatus(80, { status: 'inactive' }); | ||
const result = await liteApi.updateVoucherStatus(latestVoucherId, { status: 'inactive' }); | ||
expect(result).to.have.property('status', 'success'); | ||
@@ -276,3 +295,3 @@ expect(result).to.have.property('data'); | ||
const result = await liteApi.retrieveAnalyticsReport({ from: '2024-01-01', to: '2024-01-07' }); | ||
expect(result).to.have.property('status', 'success'); | ||
@@ -282,5 +301,5 @@ expect(result).to.have.property('data'); | ||
expect(result.data.totalRevenue).to.be.a('number'); | ||
expect(result.data).to.have.property('salesRevenue').that.is.an('array'); | ||
expect(result.data).to.have.property('salesRevenue'); | ||
expect(result.data.salesRevenue).to.not.be.empty; | ||
}); | ||
}); | ||
@@ -287,0 +306,0 @@ it('should retrieve market analytics', async function() { |
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
1209
0
175587