UNPKG

tfl-api-wrapper

Version:

A Node JS wrapper for the Transport for London API

87 lines (86 loc) 3.44 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 Road = /** @class */ (function (_super) { __extends(Road, _super); function Road(config) { return _super.call(this, config) || this; } /** * Get all roads managed by TfL */ Road.prototype.getAll = function () { return this.sendRequest('/Road', {}); }; /** * Get the road with the specified ID (Eg. A1) * @param ids ID(s) of the road(s) */ Road.prototype.getByID = function (ids) { return this.sendRequest("/Road/".concat(tfl_1.default.arrayToCSV(ids)), {}); }; /** * Gets the specified roads with the status aggregated over the date range specified, or now until the end of today if no dates are passed * @param ids * @param startDate * @param endDate */ Road.prototype.getStatusByID = function (ids, startDate, endDate) { return this.sendRequest("/Road/".concat(tfl_1.default.arrayToCSV(ids), "/Status"), { startDate: tfl_1.default.convertDate(startDate), endDate: tfl_1.default.convertDate(endDate) }, 'GET'); }; /** * Gets a list of disrupted streets * @param startDate * @param endDate */ Road.prototype.getAllStreetDisruption = function (startDate, endDate) { return this.sendRequest("/Road/all/Street/Disruption", { startDate: tfl_1.default.convertDate(startDate), endDate: tfl_1.default.convertDate(endDate) }, 'GET'); }; /** * Gets a list of active disruptions filtered by disruption Ids. * @param ids * @param stripContent When true, removes every property/node * except for id, point, severity, severityDescription, * startDate, endDate, corridor details, location and comments. */ Road.prototype.getAllDisruptionsByID = function (ids, stripContent) { return this.sendRequest("/Road/all/Disruption/".concat(tfl_1.default.arrayToCSV(ids)), { stripContent: stripContent }, 'GET'); }; /** * Gets a list of valid RoadDisruption categories */ Road.prototype.getCategories = function () { return this.sendRequest('/Road/Meta/Categories', {}); }; /** * Gets a list of valid RoadDisruption severity codes */ Road.prototype.getSeverities = function () { return this.sendRequest('/Road/Meta/Severities', {}); }; return Road; }(tfl_1.default)); exports.default = Road;