diff --git a/index.js b/index.js index d649812..9e57896 100644 --- a/index.js +++ b/index.js @@ -405,9 +405,10 @@ class LiteApi { * The minimum required information is the country code in ISO-2 format. The API supports additional search criteria such as city name, geo coordinates, and radius. * This endpoint provides detailed hotel metadata, including names, addresses, ratings, amenities, and images, facilitating robust hotel search and display features within applications. * @param {string} parameters - The search criteria parameters. + * @param {string} language - Language code for the response (optional) * @returns {array} - The result of the operation. */ - async getHotels(parameters) { + async getHotels(parameters, language) { const options = { method: 'GET', headers: { @@ -418,7 +419,8 @@ class LiteApi { }; const query = decodeURIComponent(new URLSearchParams(parameters || {}).toString()); - const response = await fetch(this.serviceURL + '/data/hotels?' + query, options) + const languageQuery = language ? '&language=' + encodeURIComponent(language) : ''; + const response = await fetch(this.serviceURL + '/data/hotels?' + query + languageQuery, options) const data = await response.json(); if (!response.ok) { diff --git a/test/test.js b/test/test.js index 132849a..6de432c 100644 --- a/test/test.js +++ b/test/test.js @@ -129,14 +129,14 @@ describe('LiteAPI SDK Test Suite', function() { }); it('should retrieve hotels by country and city', async function() { - const result = await liteApi.getHotels({ countryCode: 'IT', cityName: 'Rome' }); + const result = await liteApi.getHotels({ countryCode: 'IT', cityName: 'Rome', language: 'fr' }); expect(result).to.have.property('status', 'success'); expect(result).to.have.property('data'); expect(result.data).to.be.an('array'); }); it('should retrieve hotel details by ID', async function() { - const result = await liteApi.getHotelDetails('lp1897'); + const result = await liteApi.getHotelDetails('lp1897', 'fr'); expect(result).to.have.property('status', 'success'); expect(result).to.have.property('data'); expect(result.data).to.be.an('object');