Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 0 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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**

Expand Down
10 changes: 3 additions & 7 deletions nsapi.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
* @return {Promise<object>}
*/

async _request ( { path, parameters } ) {

Check warning on line 43 in nsapi.js

View workflow job for this annotation

GitHub Actions / Node (24)

Async method '_request' has a complexity of 11. Maximum allowed is 8

Check warning on line 43 in nsapi.js

View workflow job for this annotation

GitHub Actions / Node (22)

Async method '_request' has a complexity of 11. Maximum allowed is 8

Check warning on line 43 in nsapi.js

View workflow job for this annotation

GitHub Actions / Node (26)

Async method '_request' has a complexity of 11. Maximum allowed is 8

Check warning on line 43 in nsapi.js

View workflow job for this annotation

GitHub Actions / Node (22)

Async method '_request' has a complexity of 11. Maximum allowed is 8

Check warning on line 43 in nsapi.js

View workflow job for this annotation

GitHub Actions / Node (24)

Async method '_request' has a complexity of 11. Maximum allowed is 8

Check warning on line 43 in nsapi.js

View workflow job for this annotation

GitHub Actions / Node (26)

Async method '_request' has a complexity of 11. Maximum allowed is 8
let url = `https://gateway.apiportal.ns.nl${path}`;
const params = new URLSearchParams( parameters );

Expand Down Expand Up @@ -135,19 +135,15 @@


/**
* Get calamities
* Get calamities - DEPRECATED
*
* @param {object} [parameters] Request parameters
* @return {Promise<array>}
*/

async getCalamities ( parameters = {} ) {
const data = await this._request( {
path: '/reisinformatie-api/api/v1/calamities',
parameters,
} );

return data.meldingen;
console.trace( 'DEPRECATED - getCalamities is deprecated by the API, use getDisruptions' );
return this.getDisruptions( parameters );
}


Expand Down
40 changes: 20 additions & 20 deletions test.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@


// ! Basic tests
dotest.add( 'Module', async test => {

Check warning on line 25 in test.js

View workflow job for this annotation

GitHub Actions / Node (24)

Async arrow function has a complexity of 15. Maximum allowed is 8

Check warning on line 25 in test.js

View workflow job for this annotation

GitHub Actions / Node (22)

Async arrow function has a complexity of 15. Maximum allowed is 8

Check warning on line 25 in test.js

View workflow job for this annotation

GitHub Actions / Node (26)

Async arrow function has a complexity of 15. Maximum allowed is 8

Check warning on line 25 in test.js

View workflow job for this annotation

GitHub Actions / Node (22)

Async arrow function has a complexity of 15. Maximum allowed is 8

Check warning on line 25 in test.js

View workflow job for this annotation

GitHub Actions / Node (24)

Async arrow function has a complexity of 15. Maximum allowed is 8

Check warning on line 25 in test.js

View workflow job for this annotation

GitHub Actions / Node (26)

Async arrow function has a complexity of 15. Maximum allowed is 8
test()
.isClass( 'fail', 'exports', app )
.isAsyncFunction( 'fail', '.getAllStations', ns?.getAllStations )
Expand Down Expand Up @@ -189,26 +189,6 @@
} );


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;
let error;
Expand Down Expand Up @@ -356,6 +336,26 @@
} );


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;
Expand Down
Loading