-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request entur#236 from entur/feature/mobility.getStationsById
Added new function mobility.getStationsById()
- Loading branch information
Showing
4 changed files
with
140 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import { RequestOptions } from '../../http' | ||
import { getServiceConfig, ArgumentConfig } from '../../config' | ||
import { mobilityQuery } from '../../api' | ||
|
||
import { Station } from '../types' | ||
|
||
import getStationsQuery from './query' | ||
|
||
export interface GetStationsByIdParams { | ||
/** Return only stations with the given IDs. */ | ||
stationIds: string[] | ||
} | ||
|
||
export default function createGetStationsById(argConfig: ArgumentConfig) { | ||
const config = getServiceConfig(argConfig) | ||
|
||
return async function getStationsById( | ||
params: GetStationsByIdParams, | ||
options?: RequestOptions, | ||
): Promise<Station[]> { | ||
const data = await mobilityQuery<{ stationsById: Station[] }>( | ||
getStationsQuery, | ||
params, | ||
config, | ||
options, | ||
) | ||
|
||
return data?.stationsById || [] | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,105 @@ | ||
export default ` | ||
query ($stationIds: [String]!) { | ||
stationsById( | ||
ids: $stationIds | ||
) { | ||
id | ||
name { | ||
translation { | ||
language | ||
value | ||
} | ||
} | ||
lat | ||
lon | ||
address | ||
capacity | ||
rentalUris { | ||
android | ||
ios | ||
web | ||
} | ||
numBikesAvailable | ||
numDocksAvailable | ||
isInstalled | ||
isRenting | ||
isReturning | ||
lastReported | ||
system { | ||
id | ||
language | ||
name { | ||
translation { | ||
language | ||
value | ||
} | ||
} | ||
shortName { | ||
translation { | ||
language | ||
value | ||
} | ||
} | ||
operator { | ||
id | ||
name { | ||
translation { | ||
language | ||
value | ||
} | ||
} | ||
} | ||
url | ||
purchaseUrl | ||
startDate | ||
phoneNumber | ||
feedContactEmail | ||
timezone | ||
licenseUrl | ||
rentalApps { | ||
ios { | ||
storeUri | ||
discoveryUri | ||
} | ||
android { | ||
storeUri | ||
discoveryUri | ||
} | ||
} | ||
} | ||
pricingPlans { | ||
id | ||
url | ||
name { | ||
translation { | ||
language | ||
value | ||
} | ||
} | ||
currency | ||
price | ||
isTaxable | ||
description { | ||
translation { | ||
language | ||
value | ||
} | ||
} | ||
perKmPricing { | ||
start | ||
rate | ||
interval | ||
end | ||
} | ||
perMinPricing { | ||
start | ||
rate | ||
interval | ||
end | ||
} | ||
surgePricing | ||
} | ||
} | ||
} | ||
` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,22 @@ | ||
import { ArgumentConfig } from '../config' | ||
|
||
import { default as createGetStations } from './getStations' | ||
import { default as createGetStationsById } from './getStationsById' | ||
import { default as createGetVehicles } from './getVehicles' | ||
import { default as createGetOperators } from './getOperators' | ||
|
||
export interface MobilityClient { | ||
getOperators: ReturnType<typeof createGetOperators> | ||
getStations: ReturnType<typeof createGetStations> | ||
getStationsById: ReturnType<typeof createGetStationsById> | ||
getVehicles: ReturnType<typeof createGetVehicles> | ||
} | ||
|
||
export default function createClient(config: ArgumentConfig): MobilityClient { | ||
return { | ||
getOperators: createGetOperators(config), | ||
getStations: createGetStations(config), | ||
getStationsById: createGetStationsById(config), | ||
getVehicles: createGetVehicles(config), | ||
} | ||
} |