From 40b559f80d8b0123a2bf57f84f7fed6f8964f19b Mon Sep 17 00:00:00 2001 From: Jannis R Date: Fri, 16 Mar 2018 17:28:20 +0100 Subject: [PATCH 1/3] =?UTF-8?q?radar(n,=20w,=20s,=20e)=20->=20radar({n,=20?= =?UTF-8?q?w,=20s,=20e})=20:boom:,=20adapt=20tests=20=E2=9C=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- index.js | 2 +- test/insa.js | 2 +- test/oebb.js | 7 ++++++- test/vbb.js | 7 ++++++- 4 files changed, 14 insertions(+), 4 deletions(-) diff --git a/index.js b/index.js index 158d0151..5a4d3be1 100644 --- a/index.js +++ b/index.js @@ -289,7 +289,7 @@ const createClient = (profile, request = _request) => { }) } - const radar = (north, west, south, east, opt) => { + const radar = ({north, west, south, east, opt}) => { if ('number' !== typeof north) throw new Error('north must be a number.') if ('number' !== typeof west) throw new Error('west must be a number.') if ('number' !== typeof south) throw new Error('south must be a number.') diff --git a/test/insa.js b/test/insa.js index 28679120..61df17fd 100644 --- a/test/insa.js +++ b/test/insa.js @@ -341,7 +341,7 @@ test('radar', co(function* (t) { const west = 11.600826 const south = 52.108486 const east = 11.651451 - const vehicles = yield client.radar(north, west, south, east, { + const vehicles = yield client.radar({north, west, south, east}, { duration: 5 * 60, when, results: 10 }) diff --git a/test/oebb.js b/test/oebb.js index 7427b6db..80e1d92e 100644 --- a/test/oebb.js +++ b/test/oebb.js @@ -450,7 +450,12 @@ test('location', co(function* (t) { })) test('radar Salzburg', co(function* (t) { - const vehicles = yield client.radar(47.827203, 13.001261, 47.773278, 13.07562, { + const vehicles = yield client.radar({ + north: 47.827203, + west: 13.001261, + south: 47.773278, + east: 13.07562 + }, { duration: 5 * 60, when }) diff --git a/test/vbb.js b/test/vbb.js index 778c432b..f2fedf6a 100644 --- a/test/vbb.js +++ b/test/vbb.js @@ -456,7 +456,12 @@ test('location', co(function* (t) { test('radar', co(function* (t) { - const vehicles = yield client.radar(52.52411, 13.41002, 52.51942, 13.41709, { + const vehicles = yield client.radar({ + north: 52.52411, + west: 13.41002, + south: 52.51942, + east: 13.41709 + }, { duration: 5 * 60, when }) From 89060afc8d25aedcecf708260124a3f40d6e2680 Mon Sep 17 00:00:00 2001 From: Jannis R Date: Fri, 16 Mar 2018 17:28:48 +0100 Subject: [PATCH 2/3] adapt docs and examples to 40b559f :memo: --- docs/radar.md | 9 +++++++-- p/insa/example.js | 7 ++++++- p/oebb/example.js | 7 ++++++- p/vbb/example.js | 7 ++++++- readme.md | 2 +- 5 files changed, 26 insertions(+), 6 deletions(-) diff --git a/docs/radar.md b/docs/radar.md index 281b2f77..0090b577 100644 --- a/docs/radar.md +++ b/docs/radar.md @@ -1,4 +1,4 @@ -# `radar(north, west, south, east, [opt])` +# `radar({north, west, south, east}, [opt])` Use this method to find all vehicles currently in an area. Note that it is not supported by every profile/endpoint. @@ -26,7 +26,12 @@ const vbbProfile = require('hafas-client/p/vbb') const client = createClient(vbbProfile) -client.radar(52.52411, 13.41002, 52.51942, 13.41709, {results: 5}) +client.radar({ + north: 52.52411, + west: 13.41002, + south: 52.51942, + east: 13.41709 +}, {results: 5}) .then(console.log) .catch(console.error) ``` diff --git a/p/insa/example.js b/p/insa/example.js index 054ae1f3..8cbe8679 100644 --- a/p/insa/example.js +++ b/p/insa/example.js @@ -16,7 +16,12 @@ client.journeys('008010226', '008013456', {results: 1}) // latitude: 52.148842, // longitude: 11.641705 // }, {distance: 200}) -// client.radar(52.148364, 11.600826, 52.108486, 11.651451, {results: 10}) +// client.radar({ +// north: 52.148364, +// west: 11.600826, +// south: 52.108486, +// east: 11.651451 +// }, {results: 10}) // .then(([journey]) => { // const leg = journey.legs[0] diff --git a/p/oebb/example.js b/p/oebb/example.js index 6a04412c..2dcccf39 100644 --- a/p/oebb/example.js +++ b/p/oebb/example.js @@ -11,7 +11,12 @@ client.journeys('1291501', '8100002', {results: 1}) // client.locations('Salzburg', {results: 2}) // client.location('8100173') // Graz Hbf // client.nearby(47.812851, 13.045604, {distance: 60}) -// client.radar(47.827203, 13.001261, 47.773278, 13.07562, {results: 10}) +// client.radar({ +// north: 47.827203, +// west: 13.001261, +// south: 47.773278, +// east: 13.07562 +// }, {results: 10}) .then((data) => { console.log(require('util').inspect(data, {depth: null})) diff --git a/p/vbb/example.js b/p/vbb/example.js index 079f85c3..335d83ff 100644 --- a/p/vbb/example.js +++ b/p/vbb/example.js @@ -11,7 +11,12 @@ client.journeys('900000003201', '900000024101', {results: 1}) // client.locations('Alexanderplatz', {results: 2}) // client.location('900000042101') // Spichernstr // client.nearby(52.5137344, 13.4744798, {distance: 60}) -// client.radar(52.52411, 13.41002, 52.51942, 13.41709, {results: 10}) +// client.radar({ +// north: 52.52411, +// west: 13.41002, +// south: 52.51942, +// east: 13.41709 +// }, {results: 10}) .then((data) => { console.log(require('util').inspect(data, {depth: null})) diff --git a/readme.md b/readme.md index d627004a..e5082ccb 100644 --- a/readme.md +++ b/readme.md @@ -38,7 +38,7 @@ npm install hafas-client - [`locations(query, [opt])`](docs/locations.md) – find stations, POIs and addresses - [`location(id)`](docs/location.md) – get details about a location - [`nearby(location, [opt])`](docs/nearby.md) – show stations & POIs around -- [`radar(north, west, south, east, [opt])`](docs/radar.md) – find all vehicles currently in a certain area +- [`radar({north, west, south, east}, [opt])`](docs/radar.md) – find all vehicles currently in a certain area ## Usage From 83cae914a47c859ccb71e54bf1fd2d6f48748b0e Mon Sep 17 00:00:00 2001 From: Jannis R Date: Sat, 17 Mar 2018 20:58:03 +0100 Subject: [PATCH 3/3] fix radar signature :bug: --- index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.js b/index.js index 5a4d3be1..76578b6f 100644 --- a/index.js +++ b/index.js @@ -289,7 +289,7 @@ const createClient = (profile, request = _request) => { }) } - const radar = ({north, west, south, east, opt}) => { + const radar = ({north, west, south, east}, opt) => { if ('number' !== typeof north) throw new Error('north must be a number.') if ('number' !== typeof west) throw new Error('west must be a number.') if ('number' !== typeof south) throw new Error('south must be a number.')