UNPKG

@spasea/uz-booking-client

Version:
63 lines (62 loc) 2.09 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const requestable_1 = require("../lib/requestable"); class Train extends requestable_1.default { /** * Construct station class. * @param {string} [lang] - language * @param {auth} [auth] - the credentials to authenticate to UzBoojking. If auth is * not provided requests will be made unauthenticated * @param {string} [apiBase] - the base UzBooking API URL */ constructor(lang, auth, apiBase) { super(lang, auth, apiBase); } /** * Find train * @param {number} from - departure station id * @param {number} to - target station id * @param {string} date - departure date * @param {string} time - departure time * @param {Function} callback - callback function * @returns {Promise} - the promise for the http request */ find(from, to, date, time, // tslint:disable-next-line callback) { return this.request('POST', '', { data: { date, from_code: from, time_from: time, time_to: '23:59:59', to_code: to, }, tran_id: 'trains', }, 'json', false, callback); } /** * Find train with interchanges * @param {number} from - departure station id * @param {number} to - target station id * @param {string} date - departure date * @param {string} time - departure time * @param {Function} cb - callback function * @returns {Promise} - the promise for the http request */ findInterchange(from, to, date, time, // tslint:disable-next-line callback) { return this.request('POST', '', { data: { date, from_code: from, time_from: time, time_to: '23:59:59', to_code: to, }, tran_id: 'trains_transfer', }, 'json', false, callback); } } exports.default = Train;