request fn: opt param 💥

This commit is contained in:
Jannis R 2018-06-13 19:30:58 +02:00
parent 8881d8a1a4
commit a45d640272
No known key found for this signature in database
GPG key ID: 0FE83946296A88A5
2 changed files with 8 additions and 8 deletions

View file

@ -36,7 +36,7 @@ const createClient = (profile, request = _request) => {
const products = profile.formatProductsFilter(opt.products || {}) const products = profile.formatProductsFilter(opt.products || {})
const dir = opt.direction ? profile.formatStation(opt.direction) : null const dir = opt.direction ? profile.formatStation(opt.direction) : null
return request(profile, { return request(profile, opt, {
meth: 'StationBoard', meth: 'StationBoard',
req: { req: {
type: 'DEP', type: 'DEP',
@ -159,7 +159,7 @@ const createClient = (profile, request = _request) => {
} }
if (profile.journeysNumF) query.numF = opt.results if (profile.journeysNumF) query.numF = opt.results
return request(profile, { return request(profile, opt, {
cfg: {polyEnc: 'GPA'}, cfg: {polyEnc: 'GPA'},
meth: 'TripSearch', meth: 'TripSearch',
req: profile.transformJourneysQuery(query, opt) req: profile.transformJourneysQuery(query, opt)
@ -210,7 +210,7 @@ const createClient = (profile, request = _request) => {
}, opt) }, opt)
const f = profile.formatLocationFilter(opt.stations, opt.addresses, opt.poi) const f = profile.formatLocationFilter(opt.stations, opt.addresses, opt.poi)
return request(profile, { return request(profile, opt, {
cfg: {polyEnc: 'GPA'}, cfg: {polyEnc: 'GPA'},
meth: 'LocMatch', meth: 'LocMatch',
req: {input: { req: {input: {
@ -234,7 +234,7 @@ const createClient = (profile, request = _request) => {
else if ('string' === typeof station) station = profile.formatStation(station) else if ('string' === typeof station) station = profile.formatStation(station)
else throw new Error('station must be an object or a string.') else throw new Error('station must be an object or a string.')
return request(profile, { return request(profile, opt, {
meth: 'LocDetails', meth: 'LocDetails',
req: { req: {
locL: [station] locL: [station]
@ -267,7 +267,7 @@ const createClient = (profile, request = _request) => {
stations: true, // return stations? stations: true, // return stations?
}, opt) }, opt)
return request(profile, { return request(profile, opt, {
cfg: {polyEnc: 'GPA'}, cfg: {polyEnc: 'GPA'},
meth: 'LocGeoPos', meth: 'LocGeoPos',
req: { req: {
@ -305,7 +305,7 @@ const createClient = (profile, request = _request) => {
opt.when = new Date(opt.when || Date.now()) opt.when = new Date(opt.when || Date.now())
if (Number.isNaN(+opt.when)) throw new Error('opt.when is invalid') if (Number.isNaN(+opt.when)) throw new Error('opt.when is invalid')
return request(profile, { return request(profile, opt, {
cfg: {polyEnc: 'GPA'}, cfg: {polyEnc: 'GPA'},
meth: 'JourneyDetails', meth: 'JourneyDetails',
req: { req: {
@ -353,7 +353,7 @@ const createClient = (profile, request = _request) => {
if (Number.isNaN(+opt.when)) throw new Error('opt.when is invalid') if (Number.isNaN(+opt.when)) throw new Error('opt.when is invalid')
const durationPerStep = opt.duration / Math.max(opt.frames, 1) * 1000 const durationPerStep = opt.duration / Math.max(opt.frames, 1) * 1000
return request(profile, { return request(profile, opt, {
meth: 'JourneyGeoPos', meth: 'JourneyGeoPos',
req: { req: {
maxJny: opt.results, maxJny: opt.results,

View file

@ -11,7 +11,7 @@ const {fetch} = require('fetch-ponyfill')({Promise})
const md5 = input => createHash('md5').update(input).digest() 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 body = profile.transformReqBody({lang: 'en', svcReqL: [data]})
const req = profile.transformReq({ const req = profile.transformReq({
method: 'post', method: 'post',