@ohm-vision/kiwi-tequila-api
Version:
Unofficial wrapper for Kiwi (tequila) API
176 lines (175 loc) • 6.58 kB
JavaScript
"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.LocationsApi = void 0;
const axios_1 = __importDefault(require("axios"));
const utils_1 = require("../utils");
class LocationsApi {
constructor(baseConfig) {
this.config = (0, utils_1.mergeConfig)(baseConfig, "locations");
}
/**
* Search by query
*
* Type of request used mainly for suggestions (based on incomplete names)
* @param params
* @returns
*/
searchByQuery(params) {
return __awaiter(this, void 0, void 0, function* () {
const { data } = yield axios_1.default.get((0, utils_1.buildUrl)("query", params), this.config);
return data;
});
}
/**
* Search by radius
*
* This type of request supports either specification of location by coordinates (lat, lon)
* or by identifier (slug or id of location - term)
* @param params
* @returns
*/
searchByRadius(params) {
return __awaiter(this, void 0, void 0, function* () {
const { data } = yield axios_1.default.get((0, utils_1.buildUrl)("radius", params), this.config);
return data;
});
}
/**
* Search by box
*
* Get all locations within the specified box.
* @param params
* @returns
*/
searchByBox(params) {
return __awaiter(this, void 0, void 0, function* () {
const { data } = yield axios_1.default.get((0, utils_1.buildUrl)("box", params), this.config);
return data;
});
}
/**
* Search by subentity
*
* Get all locations that are below (in hierarchy) the one specified by id - e.g. for
* ?type=subentity&term=london_gb all locations in London are returned (as London is city,
* airports, stations and bus_stations are returned).
* @param params
* @returns
*/
getBySubentity(params) {
return __awaiter(this, void 0, void 0, function* () {
const { data } = yield axios_1.default.get((0, utils_1.buildUrl)("subentity", params), this.config);
return data;
});
}
/**
* Get by id
*
* Get location specified by its id.
* @param params
* @returns
*/
getById(params) {
return __awaiter(this, void 0, void 0, function* () {
const { data } = yield axios_1.default.get((0, utils_1.buildUrl)("id", params), this.config);
return data;
});
}
/**
* Get by anything
*
* Get locations specified by any of the following fields for example - id, int_id, code, icao, name, slug, etc.
* @param params
* @returns
*/
getByAnything(params) {
return __awaiter(this, void 0, void 0, function* () {
const { data } = yield axios_1.default.get((0, utils_1.buildUrl)("anything", params), this.config);
return data;
});
}
/**
* Get dump
*
* Get dump of locations data in specified language. When retrieving large amounts of locations (using type=dump),
* it is more efficient to use paginated response. This can be done using parameter search_after. In addition,
* when retrieving paginated data it is advised to use "sort=id", so the returned results are consistent.
* @param params
* @returns
*/
getDump(params) {
return __awaiter(this, void 0, void 0, function* () {
const { data } = yield axios_1.default.get((0, utils_1.buildUrl)("dump", params), this.config);
return data;
});
}
/**
* Search top destinations
*
* This type of request returns a list of destinations most searched / clicked on / booked from the starting point
* term. The limit is used to limit the range of results.
* @param params
* @returns
*/
searchTopDestinations(params) {
return __awaiter(this, void 0, void 0, function* () {
const { data } = yield axios_1.default.get((0, utils_1.buildUrl)("tophashtags", params), this.config);
return data;
});
}
/**
* Search by hashtags
*
* This type of request returns a list of destinations most searched / clicked on / booked from the starting point term.
* The limit is used to limit the range of results.
* @param params
* @returns
*/
searchByHashtags(params) {
return __awaiter(this, void 0, void 0, function* () {
const { data } = yield axios_1.default.get((0, utils_1.buildUrl)("hashtag", params), this.config);
return data;
});
}
/**
* Top destinations' hashtags lookup
*
* This type of request returns a list of destinations' hashtags most searched / clicked on / booked from the starting
* point term. In other words it can be understood as following: What are the most popular activies at the places that
* customers tend to search for / click / book when flying from term ? The limit is used to limit the range of results.
*
* @param params
* @returns
*/
topDestinationsHashtagsLookup(params) {
return __awaiter(this, void 0, void 0, function* () {
const { data } = yield axios_1.default.get((0, utils_1.buildUrl)("tophashtags", params), this.config);
return data;
});
}
/**
* Search by seo url
*
* @param params
* @returns
*/
searchBySeoUrl(params) {
return __awaiter(this, void 0, void 0, function* () {
const { data } = yield axios_1.default.get((0, utils_1.buildUrl)("slug", params), this.config);
return data;
});
}
}
exports.LocationsApi = LocationsApi;