@spasea/uz-booking-client
Version:
Unofficial UZ api client
46 lines (45 loc) • 2.06 kB
JavaScript
;
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());
});
};
Object.defineProperty(exports, "__esModule", { value: true });
const requestable_1 = require("../lib/requestable");
class Train extends requestable_1.default {
/**
* Construct station class.
* @constructor
* @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
* @param userId
*/
constructor(lang, auth, apiBase, userId) {
super(lang, auth, apiBase, false, userId);
}
/**
* Find train
* @param {number} stationFromId - departure station id
* @param {number} stationToId - target station id
* @param {string} date - departure date
* @param {Function} [callback] - callback function
* @returns {Promise} - the promise for the http request
*/
find(stationFromId, stationToId, date, callback) {
return __awaiter(this, void 0, void 0, function* () {
const response = yield this.request('GET', '/api/trips', {
station_from_id: stationFromId,
station_to_id: stationToId,
date,
}, 'json', false, callback);
return response.data;
});
}
}
exports.default = Train;