@ohm-vision/kiwi-tequila-api
Version:
Unofficial wrapper for Kiwi (tequila) API
30 lines (29 loc) • 1.23 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.KiwiPartialApi = exports.KiwiApi = void 0;
const apis_1 = require("./apis");
const utils_1 = require("./utils");
class KiwiApi {
constructor(options) {
const baseConfig = (0, utils_1.buildConfig)(options);
this.locations = new apis_1.LocationsApi(baseConfig);
const config = (0, utils_1.mergeConfig)(baseConfig, "v2");
this.booking = new apis_1.BookingApi(config);
this.search = new apis_1.SearchApi(config);
}
}
exports.KiwiApi = KiwiApi;
KiwiApi.partial = (options, type) => new KiwiPartialApi(options, type);
KiwiApi.singlecity = (options) => new KiwiPartialApi(options, "singlecity");
KiwiApi.multicity = (options) => new KiwiPartialApi(options, "multicity");
KiwiApi.nomad = (options) => new KiwiPartialApi(options, "nomad");
class KiwiPartialApi {
constructor(options, type) {
const api = new KiwiApi(options);
this.locations = api.locations;
this.booking = api.booking;
// bind is required here to ensure the obj methods can access the obj props
this.search = api.search[type].bind(api.search);
}
}
exports.KiwiPartialApi = KiwiPartialApi;