mirror of
https://github.com/public-transport/db-vendo-client.git
synced 2025-02-23 07:09:35 +02:00
DB journeys(): pass along opt.age if defined ✅
This commit is contained in:
parent
a8401f36e1
commit
0bc6ba3650
2 changed files with 10 additions and 4 deletions
|
@ -178,13 +178,16 @@ const transformJourneysQuery = ({opt}, query) => {
|
||||||
const filters = query.jnyFltrL
|
const filters = query.jnyFltrL
|
||||||
if (opt.bike) filters.push(bike)
|
if (opt.bike) filters.push(bike)
|
||||||
|
|
||||||
if (('age' in opt) && ('ageGroup' in opt))
|
if (('age' in opt) && ('ageGroup' in opt)) {
|
||||||
throw new TypeError('opt.age and opt.ageGroup are mutually exclusive.')
|
throw new TypeError(`\
|
||||||
|
opt.age and opt.ageGroup are mutually exclusive.
|
||||||
|
Pass in just opt.age, and the age group will calculated automatically.`)
|
||||||
|
}
|
||||||
|
|
||||||
const tvlrAgeGroup = ('age' in opt) ? ageGroupFromAge(opt.age) : opt.ageGroup
|
const tvlrAgeGroup = ('age' in opt) ? ageGroupFromAge(opt.age) : opt.ageGroup
|
||||||
|
|
||||||
query.trfReq = {
|
query.trfReq = {
|
||||||
// todo:
|
// todo: what are these?
|
||||||
// "directESuiteCall": true,
|
// "directESuiteCall": true,
|
||||||
// "rType": "DB-PE",
|
// "rType": "DB-PE",
|
||||||
|
|
||||||
|
@ -192,6 +195,7 @@ const transformJourneysQuery = ({opt}, query) => {
|
||||||
// todo [breaking]: support multiple travelers
|
// todo [breaking]: support multiple travelers
|
||||||
tvlrProf: [{
|
tvlrProf: [{
|
||||||
type: tvlrAgeGroup || ageGroup.ADULT,
|
type: tvlrAgeGroup || ageGroup.ADULT,
|
||||||
|
...(('age' in opt) ? {age: opt.age} : {}),
|
||||||
redtnCard: opt.loyaltyCard
|
redtnCard: opt.loyaltyCard
|
||||||
? formatLoyaltyCard(opt.loyaltyCard)
|
? formatLoyaltyCard(opt.loyaltyCard)
|
||||||
: null
|
: null
|
||||||
|
|
|
@ -27,6 +27,7 @@ const opt = {
|
||||||
products: {},
|
products: {},
|
||||||
|
|
||||||
firstClass: false,
|
firstClass: false,
|
||||||
|
age: 24,
|
||||||
loyaltyCard: {
|
loyaltyCard: {
|
||||||
type: loyaltyCards.BAHNCARD,
|
type: loyaltyCards.BAHNCARD,
|
||||||
discount: 25,
|
discount: 25,
|
||||||
|
@ -73,7 +74,8 @@ tap.test('formats a journeys() request correctly (DB)', (t) => {
|
||||||
trfReq: {
|
trfReq: {
|
||||||
jnyCl: 2,
|
jnyCl: 2,
|
||||||
tvlrProf: [{
|
tvlrProf: [{
|
||||||
type: 'E', // "adult"
|
type: 'Y', // "young"
|
||||||
|
age: 24,
|
||||||
redtnCard: 2, // BahnCard 25
|
redtnCard: 2, // BahnCard 25
|
||||||
}],
|
}],
|
||||||
cType: 'PK',
|
cType: 'PK',
|
||||||
|
|
Loading…
Add table
Reference in a new issue