@spasea/uz-booking-client
Version:
Unofficial UZ api client
59 lines (58 loc) • 1.97 kB
JavaScript
;
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, true);
}
/**
* 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', 'train_search/', {
data: {
date,
from_code: from,
time_from: time,
time_to: '23:59:59',
to_code: to,
},
tran_id: 'trains',
}, 'form', 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} callback - callback function
* @returns {Promise} - the promise for the http request
*/
findInterchange(from, to, date, time,
// tslint:disable-next-line
callback) {
return this.request('POST', 'train_interchange/', {
date,
from,
time,
to,
}, 'form', false, callback);
}
}
exports.default = Train;