UNPKG

tfl-api-wrapper

Version:

A Node JS wrapper for the Transport for London API

88 lines (87 loc) 6.42 kB
"use strict"; var __extends = (this && this.__extends) || (function () { var extendStatics = function (d, b) { extendStatics = Object.setPrototypeOf || ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; }; return extendStatics(d, b); }; return function (d, b) { if (typeof b !== "function" && b !== null) throw new TypeError("Class extends value " + String(b) + " is not a constructor or null"); extendStatics(d, b); function __() { this.constructor = d; } d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; })(); Object.defineProperty(exports, "__esModule", { value: true }); var tfl_1 = require("./tfl"); var Journey = /** @class */ (function (_super) { __extends(Journey, _super); function Journey(config) { return _super.call(this, config) || this; } /** Get all valid modes */ Journey.prototype.getModes = function () { return this.sendRequest('/Journey/Meta/Modes', {}); }; /** * Perform a Journey Planner search from the parameters provided * @param from Origin of the journey. Can be WGS84 coordinates expressed as "lat,long", a UK postcode, a Naptan (StopPoint) id, an ICS StopId, or a free-text string (will cause disambiguation unless it exactly matches a point of interest name). * @param to Destination of the journey. Can be WGS84 coordinates expressed as "lat,long", a UK postcode, a Naptan (StopPoint) id, an ICS StopId, or a free-text string (will cause disambiguation unless it exactly matches a point of interest name). * @param via Travel through point on the journey. Can be WGS84 coordinates expressed as "lat,long", a UK postcode, a Naptan (StopPoint) id, an ICS StopId, or a free-text string (will cause disambiguation unless it exactly matches a point of interest name). * @param nationalSearch Does the journey cover stops outside London? eg. "nationalSearch=true" * @param date The date must be in yyyyMMdd format * @param time The time must be in HHmm format * @param timeIs Does the time given relate to arrival or leaving time? Possible options: "departing" | "arriving" * @param journeyPreference The journey preference eg possible options: "leastinterchange" | "leasttime" | "leastwalking" * @param mode The mode must be an array of modes. eg possible options: ["public-bus,overground,train,tube,coach,dlr,cablecar,tram,river,walking,cycle"] * @param accessibilityPreference The accessibility preference must be an array eg. ["noSolidStairs", "noEscalators", "noElevators", "stepFreeToVehicle", "stepFreeToPlatform"] * @param fromName An optional name to associate with the origin of the journey in the results. * @param toName An optional name to associate with the destination of the journey in the results. * @param viaName An optional name to associate with the via point of the journey in the results. * @param maxTransferMinutes The max walking time in minutes for transfer eg. "120" * @param maxWalkingMinutes The max walking time in minutes for journeys eg. "120" * @param walkingSpeed The walking speed. eg possible options: "slow" | "average" | "fast". * @param cyclePreference The cycle preference. eg possible options: "allTheWay" | "leaveAtStation" | "takeOnTransport" | "cycleHire" * @param adjustment Time adjustment command. eg possible options: "TripFirst" | "TripLast" * @param bikeProficiency An array of cycling proficiency levels. eg possible options: ["easy,moderate,fast"] * @param alternativeCycle Option to determine whether to return alternative cycling journey * @param alternativeWalking Option to determine whether to return alternative walking journey * @param applyHtmlMarkup Flag to determine whether certain text (e.g. walking instructions) should be output with HTML tags or not. * @param useMultiModalCall A boolean to indicate whether or not to return 3 public transport journeys, a bus journey, a cycle hire journey, a personal cycle journey and a walking journey * @param walkingOptimization A boolean to indicate whether to optimize journeys using walking * @param taxiOnlyTrip A boolean to indicate whether to return one or more taxi journeys. Note, setting this to true will override "useMultiModalCall". * @param routeBetweenEntrances A boolean to indicate whether public transport routes should include directions between platforms and station entrances. */ Journey.prototype.journeyPlannerSearch = function (from, to, via, nationalSearch, date, time, timeIs, journeyPreference, mode, accessibilityPreference, fromName, toName, viaName, maxTransferMinutes, maxWalkingMinutes, walkingSpeed, cyclePreference, adjustment, bikeProficiency, alternativeCycle, alternativeWalking, applyHtmlMarkup, useMultiModalCall, walkingOptimization, taxiOnlyTrip, routeBetweenEntrances) { return this.sendRequest("/Journey/JourneyResults/".concat(from, "/to/").concat(to), { via: via, nationalSearch: nationalSearch, date: date, time: time, timeIs: timeIs, journeyPreference: journeyPreference, mode: tfl_1.default.arrayToCSV(mode), accessibilityPreference: tfl_1.default.arrayToCSV(accessibilityPreference), fromName: fromName, toName: toName, viaName: viaName, maxTransferMinutes: maxTransferMinutes, maxWalkingMinutes: maxWalkingMinutes, walkingSpeed: walkingSpeed, cyclePreference: cyclePreference, adjustment: adjustment, bikeProficiency: tfl_1.default.arrayToCSV(bikeProficiency), alternativeCycle: alternativeCycle, alternativeWalking: alternativeWalking, applyHtmlMarkup: applyHtmlMarkup, useMultiModalCall: useMultiModalCall, walkingOptimization: walkingOptimization, taxiOnlyTrip: taxiOnlyTrip, routeBetweenEntrances: routeBetweenEntrances }); }; return Journey; }(tfl_1.default)); exports.default = Journey;