liteapi-node-sdk
Advanced tools
Comparing version 3.1.0 to 3.2.0
38
index.js
@@ -273,2 +273,34 @@ class LiteApi { | ||
/** | ||
* Look up for a list of places and areas, given a search query. Places can be used to search for hotels within a location and restrict the list to results within the boundaries of a selected place. | ||
* @param {string} textQuery - Search query. e.g. 'Manhattan' | ||
* * @param {string} type - Restricts the results to places matching the specified type. e.g. 'hotel' | ||
* * @param {string} language - The language code, indicating in which language the results should be returned. e.g. 'en' | ||
* @returns {array} - The result of the operation. | ||
*/ | ||
async getPlaces(textQuery, type, language) { | ||
const options = { | ||
method: 'GET', | ||
headers: { | ||
accept: 'application/json', | ||
'content-type': 'application/json', | ||
'X-API-Key': this.apiKey | ||
}, | ||
}; | ||
const response = await fetch(this.serviceURL + '/data/places?textQuery=' + encodeURIComponent(textQuery) + '&type=' + (type ? encodeURIComponent(type) : '') + '&language=' + (language || 'en'), options); | ||
const data = await response.json(); | ||
if (!response.ok) { | ||
return { | ||
"status": "failed", | ||
"error": data.error | ||
} | ||
} | ||
return { | ||
"status": "success", | ||
"data": data.data | ||
} | ||
} | ||
/** | ||
* The API returns all available currency codes along with its name and the list of supported countries that the currency applies to. | ||
@@ -638,6 +670,6 @@ * @returns {array} - The result of the operation. | ||
}; | ||
const response = await fetch(`${this.serviceURL}/loyalties/`, options); | ||
const result = await response.json(); | ||
if (!response.ok) { | ||
@@ -649,3 +681,3 @@ return { | ||
} | ||
return { | ||
@@ -652,0 +684,0 @@ "status": "success", |
{ | ||
"name": "liteapi-node-sdk", | ||
"version": "3.1.0", | ||
"version": "3.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", |
@@ -9,2 +9,3 @@ <h1 style="font-weight: 500;">liteAPI SDK</h1> | ||
- [Static data](#static-data) | ||
- [Suggest a list of places](#autosuggest-a-list-of-places) | ||
- [List of cities](#list-of-cities) | ||
@@ -85,2 +86,28 @@ - [List of Countries](#list-of-countries) | ||
## Suggest a list of places | ||
The `getPlaces` function look up for a list of places and areas, given a search query. Places can be used to search for hotels within a location and restrict the list to results within the boundaries of a selected place. | ||
* <h4 style="color:#9155fd; font-weight: 800;"> Example :</h4> | ||
```js | ||
const result = await liteApi.getPlaces('Manhattan'); | ||
``` | ||
* <h4 style="color:#9155fd; font-weight: 800;"> Parameters :</h4> | ||
Name | Type | Description | Notes | ||
------------- | ------------- | ------------- | ------------- | ||
**textQuery** | **string**| Search query. e.g. 'Manhattan' | [required] | ||
**type** | **string**| Restricts the results to places matching the specified type. e.g. 'hotel' | [optional] | ||
**language** | **string**| The language code, indicating in which language the results should be returned. e.g. 'en' | [optional] | ||
* <h4 style="color:#9155fd; font-weight: 800;"> Return type :</h4> | ||
An array of city objects containing the following properties: | ||
Field | Type | Description | ||
------|------|------------ | ||
**data** | **object** | An array of the suggested places. | ||
<br> | ||
## List of cities | ||
@@ -87,0 +114,0 @@ |
656
750
136293