From 58dc34029c11abe8605d7fdab8ac703c275ad71e Mon Sep 17 00:00:00 2001 From: Franklin Date: Thu, 29 Oct 2026 03:29:01 +0100 Subject: [PATCH 1/5] Fix: Removed deprecated getCalamities endpoint --- README.md | 19 ------------------- nsapi.js | 17 ----------------- test.js | 20 -------------------- 3 files changed, 56 deletions(-) diff --git a/README.md b/README.md index 4968aca..3b63b7b 100644 --- a/README.md +++ b/README.md @@ -120,25 +120,6 @@ ns.getArrivals( { [API documentation](https://apiportal.ns.nl/docs/services/reisinformatie-api/operations/getArrivals) -### getCalamities -**( [object] ) : array** - -List of all current calamities - -| parameter | type | description | -|:-----------|:---------------|:--------------| -| [lang] | string | Text language | - -```js -ns.getArrivals( { lang: 'en' } ) - .then( console.log ) - .catch( console.error ) -; -``` - -[API documentation](https://apiportal.ns.nl/docs/services/reisinformatie-api/operations/getCalamities) - - ### getDepartures **( object ) : array** diff --git a/nsapi.js b/nsapi.js index 7ce9420..32d4543 100644 --- a/nsapi.js +++ b/nsapi.js @@ -134,23 +134,6 @@ module.exports = class NSAPI { } - /** - * Get calamities - * - * @param {object} [parameters] Request parameters - * @return {Promise} - */ - - async getCalamities ( parameters = {} ) { - const data = await this._request( { - path: '/reisinformatie-api/api/v1/calamities', - parameters, - } ); - - return data.meldingen; - } - - /** * Get a list of departure times * diff --git a/test.js b/test.js index dfc09ff..e17deb5 100644 --- a/test.js +++ b/test.js @@ -27,7 +27,6 @@ dotest.add( 'Module', async test => { .isClass( 'fail', 'exports', app ) .isAsyncFunction( 'fail', '.getAllStations', ns?.getAllStations ) .isAsyncFunction( 'fail', '.getArrivals', ns?.getArrivals ) - .isAsyncFunction( 'fail', '.getCalamities', ns?.getCalamities ) .isAsyncFunction( 'fail', '.getDepartures', ns?.getDepartures ) .isAsyncFunction( 'fail', '.getDisruption', ns?.getDisruption ) .isAsyncFunction( 'fail', '.getDisruptions', ns?.getDisruptions ) @@ -189,25 +188,6 @@ dotest.add( 'Method .getArrivals - String dateTime', async test => { } ); -dotest.add( 'Method .getCalamities', async test => { - let data; - let error; - - try { - data = await ns.getCalamities(); - } - catch ( err ) { - error = err; - } - finally { - test( error ) - .isArray( 'fail', 'data', data ) - .isNotEmpty( 'warn', 'data', data ) - .done() - ; - } -} ); - dotest.add( 'Method .getDepartures - Without dateTime', async test => { let data; From 5aa6e5a9838d12b96a4d42cd1ce9e9b1bd56d31f Mon Sep 17 00:00:00 2001 From: Franklin Date: Thu, 29 Oct 2026 03:36:06 +0100 Subject: [PATCH 2/5] Style: Consistent whitespace --- test.js | 1 - 1 file changed, 1 deletion(-) diff --git a/test.js b/test.js index e17deb5..fa97511 100644 --- a/test.js +++ b/test.js @@ -188,7 +188,6 @@ dotest.add( 'Method .getArrivals - String dateTime', async test => { } ); - dotest.add( 'Method .getDepartures - Without dateTime', async test => { let data; let error; From b577485603c281f57ecb43d986dc5927010fe294 Mon Sep 17 00:00:00 2001 From: Franklin Date: Thu, 29 Oct 2026 04:02:35 +0100 Subject: [PATCH 3/5] Fix: Restore getCalamities as alias --- nsapi.js | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/nsapi.js b/nsapi.js index 32d4543..f0d2f4d 100644 --- a/nsapi.js +++ b/nsapi.js @@ -134,6 +134,19 @@ module.exports = class NSAPI { } + /** + * Get calamities - DEPRECATED + * + * @param {object} [parameters] Request parameters + * @return {Promise} + */ + + async getCalamities ( parameters = {} ) { + console.trace( 'DEPRECATED - getCalamities is deprecated by the API, use getDisruptions' ); + return this.getDisruptions( parameters ); + } + + /** * Get a list of departure times * From a8178f564922de8ef3387843425820e50d77e5b6 Mon Sep 17 00:00:00 2001 From: Franklin Date: Thu, 29 Oct 2026 04:11:23 +0100 Subject: [PATCH 4/5] Test: Restore getCalamities coverage --- test.js | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/test.js b/test.js index fa97511..361a7ae 100644 --- a/test.js +++ b/test.js @@ -27,6 +27,7 @@ dotest.add( 'Module', async test => { .isClass( 'fail', 'exports', app ) .isAsyncFunction( 'fail', '.getAllStations', ns?.getAllStations ) .isAsyncFunction( 'fail', '.getArrivals', ns?.getArrivals ) + .isAsyncFunction( 'fail', '.getCalamities', ns?.getCalamities ) .isAsyncFunction( 'fail', '.getDepartures', ns?.getDepartures ) .isAsyncFunction( 'fail', '.getDisruption', ns?.getDisruption ) .isAsyncFunction( 'fail', '.getDisruptions', ns?.getDisruptions ) @@ -335,6 +336,26 @@ dotest.add( 'Method .getStationDisruption', async test => { } ); +dotest.add( 'Method .getCalamities (alias)', async test => { + let data; + let error; + + try { + data = await ns.getCalamities(); + } + catch ( err ) { + error = err; + } + finally { + test( error ) + .isArray( 'fail', 'data', data ) + .isNotEmpty( 'warn', 'data', data ) + .done() + ; + } +} ); + + dotest.add( 'Method .getTrips - Without dateTime', async test => { let data; let error; From 034ec7f53e7a284314a0a0ed6e2c91fe0444d0df Mon Sep 17 00:00:00 2001 From: Franklin Date: Thu, 29 Oct 2026 04:13:54 +0100 Subject: [PATCH 5/5] Style: Removed trailing whitespace --- test.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test.js b/test.js index 361a7ae..02ad5bd 100644 --- a/test.js +++ b/test.js @@ -27,7 +27,7 @@ dotest.add( 'Module', async test => { .isClass( 'fail', 'exports', app ) .isAsyncFunction( 'fail', '.getAllStations', ns?.getAllStations ) .isAsyncFunction( 'fail', '.getArrivals', ns?.getArrivals ) - .isAsyncFunction( 'fail', '.getCalamities', ns?.getCalamities ) + .isAsyncFunction( 'fail', '.getCalamities', ns?.getCalamities ) .isAsyncFunction( 'fail', '.getDepartures', ns?.getDepartures ) .isAsyncFunction( 'fail', '.getDisruption', ns?.getDisruption ) .isAsyncFunction( 'fail', '.getDisruptions', ns?.getDisruptions ) @@ -349,7 +349,7 @@ dotest.add( 'Method .getCalamities (alias)', async test => { finally { test( error ) .isArray( 'fail', 'data', data ) - .isNotEmpty( 'warn', 'data', data ) + .isNotEmpty( 'warn', 'data', data ) .done() ; }