Skip to content

Commit

Permalink
Add status query option to query for specific stations
Browse files Browse the repository at this point in the history
  • Loading branch information
mpfeil committed Jan 4, 2023
1 parent d1bb2bb commit 7996395
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ Source: https://www.lanuv.nrw.de/luqs/messorte/messorte.php

Optionally accepts an `options` object as first parameter:

- `allStations: true` returns all active and inactive stations.
- `status: aktiv|inaktiv|alle` returns stations with the specified status
- `allStations: true` returns all active and inactive stations. Overrides the `status` option **Deprecated**

### luqs.station(kuerzel)
Returns detailed information about a specific LUQS station
Expand Down
16 changes: 15 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,20 @@ const query = (url, options = {}) => {
const luqs = (options = {}) => {
return new Promise((resolve, reject) => {
let requestOptions
if (options.allStations === true) {
const { status, allStations } = options
if (status) {
requestOptions = {
method: 'POST',
form: {
auswahl_plz: 'alle',
auswahl_status: status,
auswahl_klassifizierung: 'alle'
}
}
}

if (allStations) {
console.info('Option allStations is deprecated and will be removed in a future release!')
requestOptions = {
method: 'POST',
form: {
Expand All @@ -57,6 +70,7 @@ const luqs = (options = {}) => {
}
}
}

query(messorteUrl, requestOptions)
.then($ => {
const stations = []
Expand Down

0 comments on commit 7996395

Please sign in to comment.