mirror of
https://github.com/public-transport/db-vendo-client.git
synced 2025-02-22 22:59: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
|
||||
if (opt.bike) filters.push(bike)
|
||||
|
||||
if (('age' in opt) && ('ageGroup' in opt))
|
||||
throw new TypeError('opt.age and opt.ageGroup are mutually exclusive.')
|
||||
if (('age' in opt) && ('ageGroup' in opt)) {
|
||||
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
|
||||
|
||||
query.trfReq = {
|
||||
// todo:
|
||||
// todo: what are these?
|
||||
// "directESuiteCall": true,
|
||||
// "rType": "DB-PE",
|
||||
|
||||
|
@ -192,6 +195,7 @@ const transformJourneysQuery = ({opt}, query) => {
|
|||
// todo [breaking]: support multiple travelers
|
||||
tvlrProf: [{
|
||||
type: tvlrAgeGroup || ageGroup.ADULT,
|
||||
...(('age' in opt) ? {age: opt.age} : {}),
|
||||
redtnCard: opt.loyaltyCard
|
||||
? formatLoyaltyCard(opt.loyaltyCard)
|
||||
: null
|
||||
|
|
|
@ -27,6 +27,7 @@ const opt = {
|
|||
products: {},
|
||||
|
||||
firstClass: false,
|
||||
age: 24,
|
||||
loyaltyCard: {
|
||||
type: loyaltyCards.BAHNCARD,
|
||||
discount: 25,
|
||||
|
@ -73,7 +74,8 @@ tap.test('formats a journeys() request correctly (DB)', (t) => {
|
|||
trfReq: {
|
||||
jnyCl: 2,
|
||||
tvlrProf: [{
|
||||
type: 'E', // "adult"
|
||||
type: 'Y', // "young"
|
||||
age: 24,
|
||||
redtnCard: 2, // BahnCard 25
|
||||
}],
|
||||
cType: 'PK',
|
||||
|
|
Loading…
Add table
Reference in a new issue