UNPKG

mobility-toolbox-js

Version:

Toolbox for JavaScript applications in the domains of mobility and logistics.

50 lines (49 loc) 2 kB
import HttpAPI from './HttpAPI'; import type { RealtimeFeedCollection, RealtimeRestOperations, RealtimeTrainsByRouteIdentifierResult, RealtimeTrajectoryCollection } from '../types'; export interface RealtimeRestAPIOptions { apiKey?: string; tenant?: string; url?: string; } /** * This class provides convenience methods to use to the [geOps Realtime REST API](https://developer.geops.io/apis/realtime/). * For the websocket see {@link RealtimeAPI}. * * @example * import { RealtimeRestAPI } from 'mobility-toolbox-js/api'; * * const api = new RealtimeRestAPI({ * apiKey: [yourApiKey], * tenant: 'trenord', * // url: 'https://api.geops.io/tracker-http/v1/', * }); * * const feeds = await api.feeds(); * * console.log('Log feeds:', JSON.stringify(feeds)); * */ declare class RealtimeRestAPI extends HttpAPI { tenant?: string; /** * Constructor * * @param {Object} options Options. * @param {string} options.apiKey Access key for [geOps apis](https://developer.geops.io/). * @param {string} [options.url='https://api.geops.io/tracker-http/v1/'] Url of the [geOps stops API](https://developer.geops.io/apis/realtime/). */ constructor(options?: RealtimeRestAPIOptions); /** * Get list of feeds. */ feeds(params?: Partial<RealtimeRestOperations['feeds_feeds__get']['parameters']['query']>, config?: RequestInit): Promise<RealtimeFeedCollection>; /** * Search for trains by route identifier. */ trainsByRouteIdentifier(params?: RealtimeRestOperations['trains_by_route_identifier_trains_by_route_identifier__feed_name___get']['parameters']['query'], config?: RequestInit): Promise<RealtimeTrainsByRouteIdentifierResult>; /** * Get trajectories for a tenant. */ trajectories(params?: Partial<RealtimeRestOperations['trajectories_trajectories__feed_name___get']['parameters']['query']>, config?: RequestInit): Promise<RealtimeTrajectoryCollection>; } export default RealtimeRestAPI;