diff --git a/index.js b/index.js index ca120390..0658e35e 100644 --- a/index.js +++ b/index.js @@ -36,7 +36,7 @@ const createClient = (profile, request = _request) => { const products = profile.formatProductsFilter(opt.products || {}) const dir = opt.direction ? profile.formatStation(opt.direction) : null - return request(profile, { + return request(profile, opt, { meth: 'StationBoard', req: { type: 'DEP', @@ -159,7 +159,7 @@ const createClient = (profile, request = _request) => { } if (profile.journeysNumF) query.numF = opt.results - return request(profile, { + return request(profile, opt, { cfg: {polyEnc: 'GPA'}, meth: 'TripSearch', req: profile.transformJourneysQuery(query, opt) @@ -210,7 +210,7 @@ const createClient = (profile, request = _request) => { }, opt) const f = profile.formatLocationFilter(opt.stations, opt.addresses, opt.poi) - return request(profile, { + return request(profile, opt, { cfg: {polyEnc: 'GPA'}, meth: 'LocMatch', req: {input: { @@ -234,7 +234,7 @@ const createClient = (profile, request = _request) => { else if ('string' === typeof station) station = profile.formatStation(station) else throw new Error('station must be an object or a string.') - return request(profile, { + return request(profile, opt, { meth: 'LocDetails', req: { locL: [station] @@ -267,7 +267,7 @@ const createClient = (profile, request = _request) => { stations: true, // return stations? }, opt) - return request(profile, { + return request(profile, opt, { cfg: {polyEnc: 'GPA'}, meth: 'LocGeoPos', req: { @@ -305,7 +305,7 @@ const createClient = (profile, request = _request) => { opt.when = new Date(opt.when || Date.now()) if (Number.isNaN(+opt.when)) throw new Error('opt.when is invalid') - return request(profile, { + return request(profile, opt, { cfg: {polyEnc: 'GPA'}, meth: 'JourneyDetails', req: { @@ -353,7 +353,7 @@ const createClient = (profile, request = _request) => { if (Number.isNaN(+opt.when)) throw new Error('opt.when is invalid') const durationPerStep = opt.duration / Math.max(opt.frames, 1) * 1000 - return request(profile, { + return request(profile, opt, { meth: 'JourneyGeoPos', req: { maxJny: opt.results, diff --git a/lib/request.js b/lib/request.js index b02d43fb..fe56efc4 100644 --- a/lib/request.js +++ b/lib/request.js @@ -11,7 +11,7 @@ const {fetch} = require('fetch-ponyfill')({Promise}) const md5 = input => createHash('md5').update(input).digest() -const request = (profile, data) => { +const request = (profile, opt, data) => { const body = profile.transformReqBody({lang: 'en', svcReqL: [data]}) const req = profile.transformReq({ method: 'post',