UNPKG

mobility-toolbox-js

Version:

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

45 lines (44 loc) 1.63 kB
import HttpAPI from './HttpAPI'; /** * This class provides convenience methods to use to the [geOps Stops API](https://developer.geops.io/apis/stops/). * * @example * import { StopsAPI } from 'mobility-toolbox-js/api'; * * const api = new StopsAPI({ * apiKey: [yourApiKey], * // url: 'https://api.geops.io/stops/v1/', * }); * * const stops = await api.search({ q:"Bern" }); * * console.log('Log stops:', JSON.stringify(stops)); * * @public */ class StopsAPI extends HttpAPI { /** * 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/stops/v1/'] Url of the [geOps stops API](https://developer.geops.io/apis/stops/). * @public */ constructor(options = {}) { // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing super(Object.assign(Object.assign({}, options), { url: options.url || 'https://api.geops.io/stops/v1/' })); } /** * Search for stops. * * @param {StopsParameters} params Request parameters. See [Stops API documentation](https://developer.geops.io/apis/stops). * @param {FetchOptions} config Options for the fetch request. * @returns {Promise<StopsResponse>} An GeoJSON feature collection with coordinates in [EPSG:4326](http://epsg.io/4326). See [Stops API documentation](https://developer.geops.io/apis/stops). * @public */ search(params, config) { return this.fetch('', params, config); } } export default StopsAPI;