UNPKG

@spasea/uz-booking-client

Version:
43 lines (42 loc) 1.93 kB
"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()); }); }; Object.defineProperty(exports, "__esModule", { value: true }); const requestable_1 = require("../lib/requestable"); class Wagon extends requestable_1.default { /** * Construct wagon 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); } /** * List wagons by type * @param {number} tripId * @param {string} wagonType - wagon type * @param {Function} [callback] - callback function * @returns {Promise} - the promise for the http request */ list(tripId, wagonType, // tslint:disable-next-line callback) { return __awaiter(this, void 0, void 0, function* () { const response = yield this.request('GET', `/api/v2/trips/${tripId}/wagons-by-class/${wagonType}`, null, 'json', false, callback); return response.data; }); } } exports.default = Wagon;