n8n-nodes-tripadvisor
Version:
Tripadvisor custom node for n8n
95 lines • 3 kB
JavaScript
;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.locationReviewsFields = exports.getLocationReviews = void 0;
const https_1 = __importDefault(require("https"));
async function getLocationReviews(locationId, apiKey, language, limit, offset) {
let url = `https://api.content.tripadvisor.com/api/v1/location/${locationId}/reviews?key=${apiKey}`;
if (language) {
url += `&language=${language}`;
}
if (limit) {
url += `&limit=${limit}`;
}
if (offset) {
url += `&offset=${offset}`;
}
return new Promise((resolve, reject) => {
const options = {
method: 'GET',
headers: {
Accept: 'application/json',
},
};
const req = https_1.default.request(url, options, (response) => {
let data = '';
response.on('data', (chunk) => {
data += chunk;
});
response.on('end', () => {
resolve(JSON.parse(data));
});
});
req.on('error', (error) => {
reject(error);
});
req.end();
});
}
exports.getLocationReviews = getLocationReviews;
exports.locationReviewsFields = [
{
displayName: 'Location ID',
name: 'locationId',
type: 'string',
default: '',
required: true,
description: 'A unique identifier for a location on Tripadvisor. The location ID can be obtained using the Location Search.',
displayOptions: {
show: {
resource: ['locationReviews'],
},
},
},
{
displayName: 'Additional Fields',
name: 'additionalFields',
type: 'collection',
placeholder: 'Add Field',
default: {},
displayOptions: {
show: {
resource: ['locationReviews'],
},
},
options: [
{
displayName: 'Language',
name: 'language',
type: 'string',
default: '',
description: 'The language in which to return results (e.g. "en" for English or "es" for Spanish) from the list of our Supported Languages',
},
{
displayName: 'Limit',
name: 'limit',
type: 'number',
typeOptions: {
minValue: 1,
},
default: 50,
description: 'Max number of results to return',
},
{
displayName: 'Offset',
name: 'offset',
type: 'number',
default: '',
description: 'The index of the first result',
},
],
},
];
//# sourceMappingURL=locationReviews.js.map