hsl-city-bikes
Version:
NPM package for fetching data about city bike station in Helsinki.
50 lines (49 loc) • 2.15 kB
TypeScript
export interface IBikeRentalStation {
stationId: string;
name: string;
bikesAvailable: number;
spacesAvailable: number;
lat: number;
lon: number;
allowDropoff: boolean;
}
interface IBikeRentalStationNode {
place: IBikeRentalStation;
distance: number;
}
/**
* Change the GraphQL API URL from the default one.
*
* @param {string} url The new API URL.
*/
export declare const graphqlApiUrl_set: (url: string) => string;
/**
* Get the current API URL that is being used by the package.
*/
export declare const graphqlApiUrl_get: () => string;
/**
* Fetch information about all HSL bike rental stations.
*
* @returns A Promise for an Array of bike rental stations.
*/
export declare function fetchBikeRentalStations(): Promise<IBikeRentalStation[]>;
/**
* Fetch information about all HSL bike rental stations.
*
* @param {string} stationId The station number as a string. Note that stations with number below 100 has a leading 0 in their ids.
*
* @returns A Promise for a bike rental station. Resolves if a station is found, rejects otherwise.
*/
export declare function fetchBikeRentalStations(stationId: string): Promise<IBikeRentalStation>;
/**
* Fetch the nearest bike rental stations.
*
* @param {number} latitude The latitudal position from where to measure the distance.
* @param {number} longitude The longitudal position from where to measure the distance.
* @param {number | undefined} maxResults The maximum amount of result to get. Note that this is only a maximum, and that the API usually do not give more than around 15 results.
* @param {number | undefined} maxDistance Serach for stations within a certain radius. The distance unit is meters.
*
* @returns An Array of nodes. A node contains a bike rental station and its distances to the specified location. The nodes are ordered according to the distance, with the closest being the first element.
*/
export declare function fetchNearestBikeRentalStations(lat: number, lon: number, maxResults?: number, maxDistance?: number): Promise<IBikeRentalStationNode[]>;
export {};