From 7996395f231925e37af3eb4eb597833050cf2904 Mon Sep 17 00:00:00 2001 From: Matthias Pfeil Date: Wed, 4 Jan 2023 10:41:31 +0100 Subject: [PATCH] Add status query option to query for specific stations --- README.md | 3 ++- index.js | 16 +++++++++++++++- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 2b7908c..743c77a 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/index.js b/index.js index 257c47b..24348cb 100644 --- a/index.js +++ b/index.js @@ -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: { @@ -57,6 +70,7 @@ const luqs = (options = {}) => { } } } + query(messorteUrl, requestOptions) .then($ => { const stations = []